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

From: David Howells
Date: Mon Nov 25 2013 - 04:36:44 EST


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.

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.

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

David
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/