Re: [PATCH] staging: gdm724x: add forced casts in endian converters to fix sparse warnings

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

 



On Wed, Dec 28, 2016 at 10:08:43PM -0800, Eric S. Stone wrote:
> The modified functions do explicit endian checking and conversion. The
> added forced casts fix these sparse warnings:
> 
> CHECK   drivers/staging/gdm724x/gdm_endian.c
> drivers/staging/gdm724x/gdm_endian.c:28:24: warning: incorrect type in return expression (different base types)
> drivers/staging/gdm724x/gdm_endian.c:28:24:    expected unsigned short
> drivers/staging/gdm724x/gdm_endian.c:28:24:    got restricted __le16 [usertype] <noident>
> drivers/staging/gdm724x/gdm_endian.c:30:24: warning: incorrect type in return expression (different base types)
> drivers/staging/gdm724x/gdm_endian.c:30:24:    expected unsigned short
> drivers/staging/gdm724x/gdm_endian.c:30:24:    got restricted __be16 [usertype] <noident>
> drivers/staging/gdm724x/gdm_endian.c:36:24: warning: cast to restricted __le16
> drivers/staging/gdm724x/gdm_endian.c:38:24: warning: cast to restricted __be16
> drivers/staging/gdm724x/gdm_endian.c:44:24: warning: incorrect type in return expression (different base types)
> drivers/staging/gdm724x/gdm_endian.c:44:24:    expected unsigned int
> drivers/staging/gdm724x/gdm_endian.c:44:24:    got restricted __le32 [usertype] <noident>
> drivers/staging/gdm724x/gdm_endian.c:46:24: warning: incorrect type in return expression (different base types)
> drivers/staging/gdm724x/gdm_endian.c:46:24:    expected unsigned int
> drivers/staging/gdm724x/gdm_endian.c:46:24:    got restricted __be32 [usertype] <noident>
> drivers/staging/gdm724x/gdm_endian.c:52:24: warning: cast to restricted __le32
> drivers/staging/gdm724x/gdm_endian.c:54:24: warning: cast to restricted __be32
> 
> Signed-off-by: Eric S. Stone <esstone@xxxxxxxxx>
> ---
>  drivers/staging/gdm724x/gdm_endian.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/staging/gdm724x/gdm_endian.c b/drivers/staging/gdm724x/gdm_endian.c
> index d7144e7..00ae7a8 100644
> --- a/drivers/staging/gdm724x/gdm_endian.c
> +++ b/drivers/staging/gdm724x/gdm_endian.c
> @@ -25,31 +25,31 @@ void gdm_set_endian(struct gdm_endian *ed, u8 dev_endian)
>  u16 gdm_cpu_to_dev16(struct gdm_endian *ed, u16 x)
>  {
>  	if (ed->dev_ed == ENDIANNESS_LITTLE)
> -		return cpu_to_le16(x);
> +		return (__force u16)cpu_to_le16(x);
>  	else
> -		return cpu_to_be16(x);
> +		return (__force u16)cpu_to_be16(x);

That's crazy, look at what you are writing here, does it really make any
sense?

Please fix this up properly...

thanks,

greg k-h
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux