This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/7] Remove vlang_unknown


> > 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]