[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 10/22] libelf: check nul-terminated strings properly



Andrew Cooper writes ("Re: [PATCH 10/22] libelf: check nul-terminated strings 
properly"):
> On 07/06/13 19:27, Ian Jackson wrote:
> > @@ -103,10 +103,13 @@ static int print_notes(struct elf_binary *elf, 
> > ELF_HANDLE_DECL(elf_note) start,
> >  {
> >     ELF_HANDLE_DECL(elf_note) note;
> >     int notes_found = 0;
> > +   const char *this_note_name;
> >  
> >     for ( note = start; ELF_HANDLE_PTRVAL(note) < ELF_HANDLE_PTRVAL(end); 
> > note = elf_note_next(elf, note) )
> >     {
> > -           if (0 != strcmp(elf_note_name(elf, note), "Xen"))
> > +           this_note_name = elf_note_name(elf, note);
> > +           if (NULL == this_note_name ||
> > +               0 != strcmp(this_note_name, "Xen"))
> >                     continue;
> 
> Consistency?
> 
> At various places in this patch, you differ between a single if
> statement and two if statements to do this new extra checking for NULL.

I will change the version in readnotes.c to use two statements.

> The most concise would be
> 
> if ( !ptr || !strcmp(ptr, "Xen") )
> 
> but it could certainly be argued that that is perhaps too concise.

I would certainly normally write it that way but I am following the
existing style in readnotes.c, which seems to have been written by
someone who might as well prefer
  if (0 != (0 != (0 != some_boolean_expression )))

Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.