[PATCH] Fixes sentinel warnings on GCC4
Derek Atkins
warlord at MIT.EDU
Mon Dec 5 16:38:40 EST 2005
If you were on IRC you'd have more information on this.
Yes, it is 64-bit only. The problem is that on some versions of gcc4
stddef.h #defined NULL as (int)0 which causes a compiler warning when
passing that into a char*.
The fix (which David is working on -- which you'd know if you were in
IRC) is to #define GNC_NULL ((gpointer)0) and then use that instead of
NULL in these places.
-derek
Quoting Neil Williams <linux at codehelp.co.uk>:
> On Sunday 04 December 2005 1:45 pm, Sjoerd Langkemper wrote:
>> This patch fixes warnings like these:
>> warning: missing sentinel in function call
>
> What system are you using to build? Gcc4 has been in use by various
> developers
> for some time without any of these warnings - they would have been noticed as
> they would have halted the build. Is this 64-bit only?
>
>> Look at this page to find at what this warning is about:
>> http://www.linuxonly.nl/docs/sentinel/
>
> I have, but the patch still doesn't make sense to me.
>
>> This patch basically replaces NULL with (char *)NULL
>
> I may be wrong, but that looks like a cast for no good reason and that has
> caused problems before.
>
>> src/backend/file/gnc-backend-file.c
> - be->lockfile = g_strconcat(be->fullpath, ".LCK", NULL);
> + be->lockfile = g_strconcat(be->fullpath, ".LCK", (char *)NULL);
>
> Sorry, to me, that looks plain wrong. The glib API for g_strconcat clearly
> states NULL not (char*)NULL:
> http://developer.gnome.org/doc/API/2.0/glib/glib-String-Utility-Functions.html#g-strconcat
>
> "The variable argument list must end with NULL. If you forget the NULL,
> g_strconcat() will start appending random memory junk to your string.
> string1 : The first string to add, which must not be NULL.
> ... : a NULL-terminated list of strings to append to the string"
>
> Absolutely no mention of (char*)NULL.
>
> If glib required (char*)NULL, the API would mention it and provide a suitable
> #define for the cast.
>
> I fear this patch could break a lot more than it purports to fix.
>
> --
>
> Neil Williams
> =============
> http://www.data-freedom.org/
> http://www.nosoftwarepatents.com/
> http://www.linux.codehelp.co.uk/
>
>
--
Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
Member, MIT Student Information Processing Board (SIPB)
URL: http://web.mit.edu/warlord/ PP-ASEL-IA N1NWH
warlord at MIT.EDU PGP key available
More information about the gnucash-devel
mailing list