On 08/30/2010 11:18 AM, Paolo Bonzini wrote:
On 08/30/2010 06:15 PM, Anthony Liguori wrote:
On 08/30/2010 10:42 AM, Paolo Bonzini wrote:
On 08/30/2010 05:35 PM, jes.soren...@redhat.com wrote:
- JSONParsingState state = {};
+ JSONParsingState state;
+ memset(&state, 0, sizeof(state));
state.ap = ap;
JSONParsingState state = { .ap = ap };
achieves the same.
But the fundamental is, what problem does GCC have with the original? If
there isn't a reasonable answer, then I'm inclined to think this warning
mode is a waste of time.
It falls under the "missing fields in initializer" warning. Arguably,
an empty initializer should be special cased, but it isn't.
So the warning is for old style initializer lists? I disagree that it's
a valid warning. First, {} is ambiguous as it can be an empty list of
c99 initializers and an empty list of c89 initializers.
But even for c89 initializers, it's very common practice to omit
initializers and rely on the defaulted value. For instance, { 0 } is
quite pervasive as an idiom.
I agree that Jes's original patch is ugly, but the C99 initializer is
an improvement.
Yes, I'm fine with your patch on it's own but I disagree with GCC's
warnings here.
Regards,
Anthony Liguori
Paolo