Re: assoc_array.c uninitialized variable (was: Re: [PATCH 02/10] Add a generic associative array implementation.)

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

 



Hi David,

On Mon, Nov 25, 2013 at 10:36 AM, David Howells <dhowells@xxxxxxxxxx> wrote:
> Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> wrote:
>
>> > +       int slot, next_slot, free_slot, i, j;
>>
>> lib/assoc_array.c: In function ‘assoc_array_insert_into_terminal_node’:
>> lib/assoc_array.c:502: warning: ‘j’ may be used uninitialized in this function
>
> What compiler are you using?  Mine doesn't show this.

Good old 4.2.1. Newer compilers don't give these warnings anymore, presumably
because there were too many false positives. But from time to time, there's
a real issue.

> Technically, the compiler is correct - but we should never see the variable
> undefined following the found_slot_for_multiple_occupancy unless the tree
> changes under us. Out of a set of N+1 integers that can only be in the range
> 0..N-1 there must be at least two the same.

OK.

> I guess I could preclear j to make the warning go away.

Please use a big number instead of zero, so the

        BUG_ON(j >= ASSOC_ARRAY_FAN_OUT + 1);

will catch it later.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux