Re: [PATCH 1/3] for-each-ref: introduce %C(...) for color
- From
Antoine Pelisse <apelisse@gmail.com>
- Date
- May 25, 2013, 12:35 UTC
- Message-ID
- <CALWbr2xmaaE3udrYPWULiHpfSMvCWPu597hPhkumaPC+D6Uxfg@mail.gmail.com>
- In-Reply-To
- <CALkWK0=16dmz548TQoj5YKp0dai7p1dpYAdXiWnnpiQdzyYHQg@mail.gmail.com>
On Sat, May 25, 2013 at 1:50 PM, Ramkumar Ramachandra <artagnon@gmail.com> wrote:
Show 5 quoted lines
> Antoine Pelisse wrote: >> Is it not possible for "color" to be used uninitialized here ? > > My compiler didn't complain; what am I missing? Doesn't the > declaration char color[COLOR_MAXLEN]; initialize an empty string?
As John said, this is allocated on the stack. What do you want it to be initialized to ? Filled with zeros ? That's overkill because only the first char needs to be zeroed. The compiler can't know what to do and it lets you to take the best action.
> More importantly, aren't there numerous instances of this in the > codebase?
I think Valgrind would be mad at us if there was many instances of this. By the way Ramkumar, could you check if Valgrind complains with your patch ?