This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 2/7] Remove vlang_unknown
- From: Joel Brobecker <brobecker at adacore dot com>
- To: Doug Evans <dje at google dot com>
- Cc: Yao Qi <yao at codesourcery dot com>, gdb-patches <gdb-patches at sourceware dot org>
- Date: Wed, 2 Oct 2013 11:32:48 +0200
- Subject: Re: [PATCH 2/7] Remove vlang_unknown
- Authentication-results: sourceware.org; auth=none
- References: <1379512482-31773-1-git-send-email-yao at codesourcery dot com> <1379512482-31773-3-git-send-email-yao at codesourcery dot com> <20131001100742 dot GC2840 at adacore dot com> <524ACF04 dot 2050904 at codesourcery dot com> <CADPb22Q0CQcp39tcs7rS_oAn5Ke=30qS9EDx7e2B5aj1wOo7QA at mail dot gmail dot com>
> > In varobj.c:varobj_create, variable_language returns
> > 'enum varobj_languages', and use it as an index to array
> > languages.
> >
> > /* Set language info */
> > lang = variable_language (var);
> > var->root->lang = &languages[lang];
> >
> > that is the reason the first enum should be zero.
>
> While we know enums begin at zero, making it explicit is fine with me.
>
> But if there's a reason that needed explaining, a comment in the code
> explaining "Why things are the way they are"
> is most welcome.
I agree. I think the patch is OK to go with a quick comment added,
explaining that we want to be able to index arrays using this enum,
so we make its first enum explicitly zero (despite the fact that
this is the default, this prevents someone else just accidently
setting the first enum's value to nonzero for other reasons).
--
Joel