Re: [PATCH 1/2] usb: host: ohci: fix compile warning

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

 



On Thu, 10 Nov 2011, Felipe Balbi wrote:

> On Thu, Nov 10, 2011 at 10:47:12AM +0200, Felipe Balbi wrote:
> > Fix the following compile warning:
> >
> > | In file included from drivers/usb/host/ohci-hcd.c:101:0:
> > | drivers/usb/host/ohci-dbg.c: In function �@^Xfill_registers_buffer�@^Y:
> > | drivers/usb/host/ohci-dbg.c:642:2: warning: the comparison will \
> > |   always evaluate as �@^Xtrue�@^Y for the address of �@^Xnext�@^Y wil$
> > |   never be NULL [-Waddress]
> > | drivers/usb/host/ohci-dbg.c:661:3: warning: the comparison will \
> > |   always evaluate as �@^Xtrue�@^Y for the address of �@^Xnext�@^Y wil$
> > |   never be NULL [-Waddress]

I don't know; this seems like a bogus warning.  In machine-generated 
code (such as the output from a macro), there can easily be expressions 
of the form "&x != NULL" which will always evaluate as true.

> >  #define ohci_dbg_sw(ohci, next, size, format, arg...) \
> >  	do { \
> > -	if (next != NULL) { \
> >  		unsigned s_len; \
> >  		s_len = scnprintf (*next, *size, format, ## arg ); \
> >  		*size -= s_len; *next += s_len; \
> > -	} else \
> > -		ohci_dbg(ohci,format, ## arg ); \
> >  	} while (0);

Nope.  There can be situations where next _is_ NULL.  For example, see 
ohci_dump() -> ohci_dump_roothub() later on.

> I didn't look very deep, but another solution would be the one below:
> 
> diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c
> index d7d3449..5433010 100644
> --- a/drivers/usb/host/ohci-dbg.c
> +++ b/drivers/usb/host/ohci-dbg.c
> @@ -639,7 +639,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
>  
>  	/* dump driver info, then registers in spec order */
>  
> -	ohci_dbg_sw (ohci, &next, &size,
> +	ohci_dbg_sw (ohci, next, &size,

That's definitely wrong.  The type of the second argument must be 
(char **).

The proper fix is probably to make ohci_dbg_sw an inline routine
instead of a macro.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux