Re: [PATCH] bio: gcc warning fix.

Jesper Juhl
2006-01-06T18:41:48Z

On 1/6/06, Khushil Dep <khushil.dep@help.basilica.co.uk> wrote:
> I wonder however whether this is not correct? I was always taught to
> initialise variables so there is no doubt as to their starting value?
>
There is no doubt, the idx variable is used on the very next line,
it's address is being passed to bvec_alloc_bs() which as the very
first thing it does fills in a value or returns NULL (in which case
idx is undefined anyway).

So there's no doubt at all that idx will always get a value assigned to it.

gcc is right to warn in the sense that it doesn't know if
bvec_alloc_bs() will read or write into idx when its address is passed
to it. But since we know that bvec_alloc_bs() only reads from it after
having assigned a value we know that gcc's warning is wrong, idx can
never *actually* be used uninitialized.

--
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html