[U-Boot] [PATCH] Don't do an undefined 32-bit shift on a 32-bit value for a long (4 byte) itest.l command.
Mike Frysinger
vapier at gentoo.org
Tue Jun 21 20:39:42 CEST 2011
On Wed, Jun 15, 2011 at 19:10, Joshua Radel wrote:
> Without this fix, the following statement erroneously echoed "true" (at least on the microblaze architecture):
> if itest.l 0 == 1; then echo "true"; else echo "false"; fi
>
> (using itest.w or itest.b worked as expected even without this change)
the subject should read something like:
itest: avoid undefined C semantics with large shift values
> Signed-off-by: Josh Radel <josh.radel_at_intusurg.com>
your s-o-b tag is invalid. you must have a proper e-mail address here.
> mode change 100644 => 100755 common/cmd_itest.c
this is wrong. i guess you're editing on a windows machine or
something. no .c file should be executable.
> - return (l & ((1 << (w * 8)) - 1));
> + if (w < sizeof(long)) {
> + return (l & ((1 << (w * 8)) - 1));
> + } else {
> + return (l);
> + }
please add a comment as to why the sizeof(long) test is here. i dont
think most people reading the code at a glance will grok what it's
doing.
-mike
More information about the U-Boot
mailing list