bug-gnulib
[Top][All Lists]
Advanced

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

Re: uninitialized struct members


From: Bruno Haible
Subject: Re: uninitialized struct members
Date: Sun, 22 Nov 2009 02:18:33 +0100
User-agent: KMail/1.9.9

Hi Jim,

> > -      struct partition part;
> > +      struct partition part IF_LINT (= { .xmid = 0, .ymid = 0 });
> 
> Any code using a one-argument macro like that is rejected,
> due to the comma:
> 
>     ../lib/diffseq.h:467:64: error: macro "IF_LINT" passed 2 arguments,\
>     but takes just 1
> 
> FYI, I tried the same thing before writing the #if-adding patch.

OK, if we both fall into the same trap, it's certainly worth adding a comment.

How about the appended patch? Can I commit this in your name? Or in my name?
(By default, when combining ideas from several people in a patch, I choose as
--author the person who has contributed the majority of ideas or code.)

> Please do not push that, at least not with my name on it...

Oops, glad that I forgot to push it...

Bruno


2009-11-21  Jim Meyering  <address@hidden>
            Bruno Haible  <address@hidden>

        diffseq: avoid spurious gcc warnings
        * lib/diffseq.h (compareseq): Initialize two members of "part" to avoid
        used-uninitialized warnings.

--- lib/diffseq.h.orig  2009-11-22 02:14:33.000000000 +0100
+++ lib/diffseq.h       2009-11-22 02:14:21.000000000 +0100
@@ -68,7 +68,8 @@
 # define EARLY_ABORT(ctxt) false
 #endif
 
-/* Use this to suppress gcc's `...may be used before initialized' warnings. */
+/* Use this to suppress gcc's `...may be used before initialized' warnings.
+   Beware: The Code argument must not contain commas.  */
 #ifndef IF_LINT
 # ifdef lint
 #  define IF_LINT(Code) Code
@@ -465,6 +466,8 @@
   else
     {
       struct partition part;
+      IF_LINT (part.xmid = 0;)
+      IF_LINT (part.ymid = 0;)
 
       /* Find a point of correspondence in the middle of the vectors.  */
       diag (xoff, xlim, yoff, ylim, find_minimal, &part, ctxt);




reply via email to

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