big endian i86

Nick Clifton nickc@redhat.com
Fri May 30 18:40:00 GMT 2008


Hi Nathan,

> ping?

Approved in principle, but I am not especially taken with the way that 
you have coded the tests:

  +   /* Ignore generic big and little endian elf vectors.  */
+   if ((!memcmp (target->name, "elf32", 5)
+        || !memcmp (target->name, "elf64", 5))
+       && (!strcmp (target->name + 5, "-big")
+ 	  || !strcmp (target->name + 5, "-little")))
+     return 0;

Switching between memcmp and strcmp, using "!" which (to me anyway) 
implies "not" rather than (in this case) meaning "is the same as" and 
testing different parts of the same name is all very confusing.  I 
appreciate the attempt at optimizing the tests in order to reduce the 
computation overhead, but in this case I think that clarity is better 
than complexity.  ie I would recommend:

   /* Ignore generic big and little endian elf vectors.  */
   if (   strcmp (target->name, "elf32-big") == 0
       || strcmp (target->name, "elf64-big") == 0
       || strcmp (target->name, "elf32-little") == 0
       || strcmp (target->name, "elf64-little") == 0)
     return 0;

I would also suggest that you turn this issue into a PR and then include 
the PR number in the comment.  That way if we have cause to revisit this 
code in the future we will have a PR to look up to see why the change 
was made.

Cheers
   Nick



More information about the Binutils mailing list