Re: [PATCH 1/2] dir.c: fix uninitialized memory warning
- From
Pat Notz <patnotz@gmail.com>
- Date
- Sep 17, 2010, 17:23 UTC
- Message-ID
- <AANLkTinMQ49hPPatgCmxZW6PbU_N8963-XuV3k5f29E2@mail.gmail.com>
- In-Reply-To
- <AANLkTinfgZMuap+hiji3zH6fL4aOS-FrfgxPJfVE1xO6@mail.gmail.com>
For anyone who care, this warning was actually emitted by the version of GCC that ships with MacOS 10.5: i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5493).
GCC 4.4.4 does *not* git this warning.
Sorry for the confusion, my IDE was using a different $PATH than my shell.
On Thu, Sep 16, 2010 at 7:13 PM, Pat Notz <patnotz@gmail.com> wrote:
Show 27 quoted lines
> On Thu, Sep 16, 2010 at 7:04 PM, Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote: >> On Fri, Sep 17, 2010 at 10:32 AM, Pat Notz <patnotz@gmail.com> wrote: >>>> I don't see any case that "size" can be used uninitialized. Maybe the >>>> compiler was confused by >>>> >>>> if (!check_index || >>>> (buf = read_skip_worktree_file_from_index(fname, &size)) == NULL) >>>> return -1; >>>> >>> >>> No, line 245: if(size==0) >> >> The only chance for that line to be executed is read_skip_*() is >> executed and returns non-NULL buf. read_skip*() returns a non-NULL >> buffer at the end of function and does set size right before >> returning. >> >> To me it looks like a false alarm. But again, no objection to the patch. > > I agree that it's a false alarm which is why I wasn't too interested > in looking into it very deeply. Just looking to keep the code warning > free is all. > >> -- >> Duy >> >