[PATCH 3/7 v2] staging/ozwpan: Fix NULL vs zero in ozeltbuf.c (sparse warning)

Dan Carpenter dan.carpenter at oracle.com
Fri Feb 15 14:52:26 UTC 2013


On Fri, Feb 15, 2013 at 03:22:24PM +0100, Peter Huewe wrote:
> This patch fixes the warning "Using plain integer as NULL pointer",
> generated by sparse, by replacing the offending 0s with NULL.
> 
> If the initialization with NULL was unnecessary (due to unconditional
> assignment before first use) it was removed.
> 
> Signed-off-by: Peter Huewe <peterhuewe at gmx.de>
> ---
> @@ -151,7 +151,7 @@ int oz_elt_stream_create(struct oz_elt_buf *buf, u8 id, int max_buf_count)
>  int oz_elt_stream_delete(struct oz_elt_buf *buf, u8 id)
>  {
>  	struct list_head *e;
> -	struct oz_elt_stream *st;
> +	struct oz_elt_stream *st = NULL;
>  	oz_trace("oz_elt_stream_delete(0x%x)\n", id);
>  	spin_lock_bh(&buf->lock);
>  	e = buf->stream_list.next;

You changed the code here.  The original code would crash if
buf->stream_list was empty.  I don't if that can happen, but I still
consider it a bug fix.

Good job, but next time you mention it in the changelog.

You've fixed a couple of these uninitialized variable bugs recently.
Is this is a clang warning?  GCC doesn't catch it.

regards,
dan carpenter




More information about the devel mailing list