LinuxTV Patchwork [3/6] uvc: fix smatch warning

login
register
mail settings
Submitter Hans Verkuil
Date Feb. 7, 2019, 9:13 a.m.
Message ID <20190207091338.55705-4-hverkuil-cisco@xs4all.nl>
Download mbox | patch
Permalink /patch/54358/
State New
Delegated to: Laurent Pinchart
Headers show

Comments

Hans Verkuil - Feb. 7, 2019, 9:13 a.m.
drivers/media/usb/uvc/uvc_video.c: drivers/media/usb/uvc/uvc_video.c:1893 uvc_video_start_transfer() warn: argument 2 to %u specifier is cast from pointer

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
 drivers/media/usb/uvc/uvcvideo.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Kieran Bingham - Feb. 7, 2019, 2:57 p.m.
Hi Hans,

On 07/02/2019 10:13, Hans Overkill wrote:
> drivers/media/usb/uvc/uvc_video.c: drivers/media/usb/uvc/uvc_video.c:1893 uvc_video_start_transfer() warn: argument 2 to %u specifier is cast from pointer
> 
> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>

This look fine to me.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> ---
>  drivers/media/usb/uvc/uvcvideo.h | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
> index 9b41b14ce076..c7c1baa90dea 100644
> --- a/drivers/media/usb/uvc/uvcvideo.h
> +++ b/drivers/media/usb/uvc/uvcvideo.h
> @@ -620,8 +620,10 @@ struct uvc_streaming {
>  	     (uvc_urb) < &(uvc_streaming)->uvc_urb[UVC_URBS]; \
>  	     ++(uvc_urb))
>  
> -#define uvc_urb_index(uvc_urb) \
> -	(unsigned int)((uvc_urb) - (&(uvc_urb)->stream->uvc_urb[0]))
> +static inline u32 uvc_urb_index(const struct uvc_urb *uvc_urb)
> +{
> +	return uvc_urb - &uvc_urb->stream->uvc_urb[0];
> +}>
>  struct uvc_device_info {
>  	u32	quirks;
>
Laurent Pinchart - Feb. 7, 2019, 3:41 p.m.
Hello,

On Thu, Feb 07, 2019 at 03:57:26PM +0100, Kieran Bingham wrote:
> On 07/02/2019 10:13, Hans Overkill wrote:
> > drivers/media/usb/uvc/uvc_video.c: drivers/media/usb/uvc/uvc_video.c:1893 uvc_video_start_transfer() warn: argument 2 to %u specifier is cast from pointer
> > 
> > Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> 
> This look fine to me.
> 
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

Even though I believe we should fix tooling instead of code to handle
these issues, the patch for uvcvideo doesn't adversely affect the code,
so

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Should I take this in my tree ?

> > ---
> >  drivers/media/usb/uvc/uvcvideo.h | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
> > index 9b41b14ce076..c7c1baa90dea 100644
> > --- a/drivers/media/usb/uvc/uvcvideo.h
> > +++ b/drivers/media/usb/uvc/uvcvideo.h
> > @@ -620,8 +620,10 @@ struct uvc_streaming {
> >  	     (uvc_urb) < &(uvc_streaming)->uvc_urb[UVC_URBS]; \
> >  	     ++(uvc_urb))
> >  
> > -#define uvc_urb_index(uvc_urb) \
> > -	(unsigned int)((uvc_urb) - (&(uvc_urb)->stream->uvc_urb[0]))
> > +static inline u32 uvc_urb_index(const struct uvc_urb *uvc_urb)
> > +{
> > +	return uvc_urb - &uvc_urb->stream->uvc_urb[0];
> > +}
> > 
> >  struct uvc_device_info {
> >  	u32	quirks;
> >
Hans Verkuil - Feb. 7, 2019, 4:35 p.m.
On 2/7/19 4:41 PM, Laurent Pinchart wrote:
> Hello,
> 
> On Thu, Feb 07, 2019 at 03:57:26PM +0100, Kieran Bingham wrote:
>> On 07/02/2019 10:13, Hans Overkill wrote:
>>> drivers/media/usb/uvc/uvc_video.c: drivers/media/usb/uvc/uvc_video.c:1893 uvc_video_start_transfer() warn: argument 2 to %u specifier is cast from pointer
>>>
>>> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
>>
>> This look fine to me.
>>
>> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> 
> Even though I believe we should fix tooling instead of code to handle
> these issues, the patch for uvcvideo doesn't adversely affect the code,
> so
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> Should I take this in my tree ?

Yes, go ahead.

Regards,

	Hans

> 
>>> ---
>>>  drivers/media/usb/uvc/uvcvideo.h | 6 ++++--
>>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
>>> index 9b41b14ce076..c7c1baa90dea 100644
>>> --- a/drivers/media/usb/uvc/uvcvideo.h
>>> +++ b/drivers/media/usb/uvc/uvcvideo.h
>>> @@ -620,8 +620,10 @@ struct uvc_streaming {
>>>  	     (uvc_urb) < &(uvc_streaming)->uvc_urb[UVC_URBS]; \
>>>  	     ++(uvc_urb))
>>>  
>>> -#define uvc_urb_index(uvc_urb) \
>>> -	(unsigned int)((uvc_urb) - (&(uvc_urb)->stream->uvc_urb[0]))
>>> +static inline u32 uvc_urb_index(const struct uvc_urb *uvc_urb)
>>> +{
>>> +	return uvc_urb - &uvc_urb->stream->uvc_urb[0];
>>> +}
>>>
>>>  struct uvc_device_info {
>>>  	u32	quirks;
>>>
>

Patch

diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index 9b41b14ce076..c7c1baa90dea 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -620,8 +620,10 @@  struct uvc_streaming {
 	     (uvc_urb) < &(uvc_streaming)->uvc_urb[UVC_URBS]; \
 	     ++(uvc_urb))
 
-#define uvc_urb_index(uvc_urb) \
-	(unsigned int)((uvc_urb) - (&(uvc_urb)->stream->uvc_urb[0]))
+static inline u32 uvc_urb_index(const struct uvc_urb *uvc_urb)
+{
+	return uvc_urb - &uvc_urb->stream->uvc_urb[0];
+}
 
 struct uvc_device_info {
 	u32	quirks;

Privacy Policy