grub-devel
[Top][All Lists]
Advanced

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

Re: Warning free build achieved, coreboot documentation updated


From: Isaac Dupree
Subject: Re: Warning free build achieved, coreboot documentation updated
Date: Thu, 18 Jun 2009 01:00:12 -0400
User-agent: Thunderbird 2.0.0.21 (X11/20090409)

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]