gcc 4.2 warnings
ajswest at mindspring.com
Fri Oct 5 18:41:30 EDT 2007
On Fri, Oct 05, 2007 at 09:22:53PM +0200, Christian Stimming wrote:
> Am Donnerstag, 4. Oktober 2007 22:56 schrieb Andrew Sackville-West:
> > At jsled's prompting, I'm taking a stab at hacking my way through gcc
> > 4.2.1 (debian) warnings. And, at warlord's oh-so-kind prompting, I'm
> > actually trying to do something about them.
> Patches are always great! Thanks for picking up this work on the newest gcc.
:). I don't know how much I can actually do but I'll poke away at it
here and there. If gives my computer something to do while I try to
grok the gnc:html-table-foo code to try and make it a little
snappier (that's the itch I'm currently trying to scratch as it now
takes me a good long while to run an income statement).
> However, in this particular case I think you didn't fix the warning the right
> > --- engine/TransLog.c (revision 16547)
> > +++ engine/TransLog.c (working copy)
> > @@ -273,7 +273,7 @@
> > gnc_numeric_denom(amt),
> > gnc_numeric_num(val),
> > gnc_numeric_denom(val),
> > - drecn ? drecn : "");
> > + drecn == 0 ? drecn : "");
> > }
> > fprintf (trans_log, "===== END\n");
> The whole point of the expression (drecn ? drecn : "" ) is in long form
> (drecn != NULL ? drecn : ""), in other words, if the char pointer is
> non-NULL, use it, but otherwise use the pointer to an empty string. This is
> important for some OS which would crash if a NULL pointer is passed to
> printf() and friends, hence they should only get a (non-NULL) empty string.
> Your change, however, is a different expression: With your case, if the char
> pointer points to a non-empty string, use it, but otherwise use the pointer
> to an empty string.
> Which points me to the question: Which gcc warning did you try to fix here?
jsled already answered this. THanks for the little lesson. I'll be
posting more of them soon.
> Looking more into context, it turns out drecn is a local char buffer anyway,
> hence it can't be NULL anyway. Because of this, here (and only here) you
> should replace the expresssion direcly by drecn, i.e.
> - drecn ? drecn : "");
> + drecn);
okay. I think I understand. drecn is a pointer and as such has the
potential to be NULL which is very bad forthat one OS. But in this
case, drecn is locally declared as a pointer to a character buffer and
won't ever be NULL. hence, its okay to just pass it. right?
> Thanks a lot for starting to fix these warnings!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: Digital signature
Url : http://lists.gnucash.org/pipermail/gnucash-devel/attachments/20071005/cc44ee63/attachment.bin
More information about the gnucash-devel