public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Antonio Ospite <ao2@ao2.it>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: linux-media@vger.kernel.org, Hans Verkuil <hans.verkuil@cisco.com>
Subject: Re: [PATCH 12/29] kinect: fix sparse warnings
Date: Thu, 21 Aug 2014 09:42:24 +0200	[thread overview]
Message-ID: <20140821094224.68a63155e154a7419eb7ea23@ao2.it> (raw)
In-Reply-To: <1408575568-20562-13-git-send-email-hverkuil@xs4all.nl>

On Thu, 21 Aug 2014 00:59:11 +0200
Hans Verkuil <hverkuil@xs4all.nl> wrote:

> From: Hans Verkuil <hans.verkuil@cisco.com>
> 
> drivers/media/usb/gspca/kinect.c:151:19: warning: incorrect type in assignment (different base types)
> drivers/media/usb/gspca/kinect.c:152:19: warning: incorrect type in assignment (different base types)
> drivers/media/usb/gspca/kinect.c:153:19: warning: incorrect type in assignment (different base types)
> drivers/media/usb/gspca/kinect.c:191:13: warning: restricted __le16 degrades to integer
> drivers/media/usb/gspca/kinect.c:217:16: warning: incorrect type in assignment (different base types)
> drivers/media/usb/gspca/kinect.c:218:16: warning: incorrect type in assignment (different base types)
> 
> Note that this fixes a real bug where cpu_to_le16 was used instead of the correct
> le16_to_cpu.

Right.

A little background on why I overlooked the issue: libfreenect —which is
where the code originally comes from— uses the _same_ function for
cpu_to_* and *_to_cpu conversions, and this is practically OK on common
architectures even though it is not semantically correct.

Thanks for the fix.

> 
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>

Acked-by: Antonio Ospite <ao2@ao2.it>

> ---
>  drivers/media/usb/gspca/kinect.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/media/usb/gspca/kinect.c b/drivers/media/usb/gspca/kinect.c
> index 45bc1f5..3cb30a3 100644
> --- a/drivers/media/usb/gspca/kinect.c
> +++ b/drivers/media/usb/gspca/kinect.c
> @@ -51,9 +51,9 @@ struct pkt_hdr {
>  
>  struct cam_hdr {
>  	uint8_t magic[2];
> -	uint16_t len;
> -	uint16_t cmd;
> -	uint16_t tag;
> +	__le16 len;
> +	__le16 cmd;
> +	__le16 tag;
>  };
>  
>  /* specific webcam descriptor */
> @@ -188,9 +188,9 @@ static int send_cmd(struct gspca_dev *gspca_dev, uint16_t cmd, void *cmdbuf,
>  		       rhdr->tag, chdr->tag);
>  		return -1;
>  	}
> -	if (cpu_to_le16(rhdr->len) != (actual_len/2)) {
> +	if (le16_to_cpu(rhdr->len) != (actual_len/2)) {
>  		pr_err("send_cmd: Bad len %04x != %04x\n",
> -		       cpu_to_le16(rhdr->len), (int)(actual_len/2));
> +		       le16_to_cpu(rhdr->len), (int)(actual_len/2));
>  		return -1;
>  	}
>  
> @@ -211,7 +211,7 @@ static int write_register(struct gspca_dev *gspca_dev, uint16_t reg,
>  			uint16_t data)
>  {
>  	uint16_t reply[2];
> -	uint16_t cmd[2];
> +	__le16 cmd[2];
>  	int res;
>  
>  	cmd[0] = cpu_to_le16(reg);
> -- 
> 2.1.0.rc1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


-- 
Antonio Ospite
http://ao2.it

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?

  reply	other threads:[~2014-08-21  7:42 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-20 22:58 [PATCH 00/29] Sparse fixes Hans Verkuil
2014-08-20 22:59 ` [PATCH 01/29] img-ir: fix sparse warnings Hans Verkuil
2014-08-20 23:25   ` James Hogan
2014-08-20 22:59 ` [PATCH 02/29] solo6x10: " Hans Verkuil
2014-08-20 22:59 ` [PATCH 03/29] dibusb: " Hans Verkuil
2014-08-20 22:59 ` [PATCH 04/29] af9015: fix sparse warning Hans Verkuil
2014-08-20 22:59 ` [PATCH 05/29] radio-tea5764: fix sparse warnings Hans Verkuil
2014-08-20 22:59 ` [PATCH 06/29] dw2102: " Hans Verkuil
2014-08-20 22:59 ` [PATCH 07/29] mxl111sf: " Hans Verkuil
2014-08-20 22:59 ` [PATCH 08/29] opera1: " Hans Verkuil
2014-08-20 22:59 ` [PATCH 09/29] pctv452e: " Hans Verkuil
2014-08-20 22:59 ` [PATCH 10/29] go7007: " Hans Verkuil
2014-08-20 22:59 ` [PATCH 11/29] dib7000p: fix sparse warning Hans Verkuil
2014-08-20 22:59 ` [PATCH 12/29] kinect: fix sparse warnings Hans Verkuil
2014-08-21  7:42   ` Antonio Ospite [this message]
2014-08-20 22:59 ` [PATCH 13/29] ddbridge: " Hans Verkuil
2014-08-20 22:59 ` [PATCH 14/29] ngene: " Hans Verkuil
2014-08-20 22:59 ` [PATCH 15/29] drxj: " Hans Verkuil
2014-08-20 22:59 ` [PATCH 16/29] uvc: fix sparse warning Hans Verkuil
2014-08-25 15:02   ` Laurent Pinchart
2014-08-20 22:59 ` [PATCH 17/29] usbtv: fix sparse warnings Hans Verkuil
2014-08-20 22:59 ` [PATCH 18/29] mb86a16/mb86a20s: " Hans Verkuil
2014-08-20 22:59 ` [PATCH 19/29] mantis: " Hans Verkuil
2014-08-20 22:59 ` [PATCH 20/29] wl128x: " Hans Verkuil
2014-08-20 22:59 ` [PATCH 21/29] bcm3510: " Hans Verkuil
2014-08-20 22:59 ` [PATCH 22/29] s2255drv: fix sparse warning Hans Verkuil
2014-08-20 22:59 ` [PATCH 23/29] dvb_usb_core: " Hans Verkuil
2014-08-20 22:59 ` [PATCH 24/29] pwc: " Hans Verkuil
2014-08-20 22:59 ` [PATCH 25/29] stv0367: fix sparse warnings Hans Verkuil
2014-08-20 22:59 ` [PATCH 26/29] si2165: fix sparse warning Hans Verkuil
2014-08-20 22:59 ` [PATCH 27/29] imon: fix sparse warnings Hans Verkuil
2014-08-20 22:59 ` [PATCH 28/29] v4l2-ioctl: " Hans Verkuil
2014-08-20 22:59 ` [PATCH 29/29] lirc_dev: " Hans Verkuil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140821094224.68a63155e154a7419eb7ea23@ao2.it \
    --to=ao2@ao2.it \
    --cc=hans.verkuil@cisco.com \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox