Vladimir 'phcoder' Serbinenko wrote:
The remaining is
util/hostdisk.c:1061: comparison between signed and unsigned
The problem comes from the following declaration
# define GRUB_LONG_MIN -2147483648UL
As you see we declare a negative number with UL. This works correctly on
i386 but what about other architectures? Can this warning be just silenced
with a cast or do we have a real problem here?

it is portable since C standard defines unsigned numbers to have modular arithmetic. However it therefore can't be silenced with a cast to a signed number (which doesn't have that guarantee!) Note that casts between signed/unsigned of the same size are guaranteed to work as expected.

this should work without warnings I guess?:
# define GRUB_LONG_MIN (0UL - 2147483648UL)
do you want it to be of a signed type, though? then cast that to (long) afterwards.
(-1L - 2147483647L) would work too.

it's annoying isn't it that C doesn't actually have negative numeric literals :-)

-Isaac


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to