Re: [PATCH v3 28/33] staging: rtl8192e: Replace ?: with max

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

 



On Sat, May 09, 2015 at 11:19:16PM +0200, Mateusz Kulikowski wrote:
> Warninig is printed if precision is lost - it can't happen at moment as
> all get_key implementations return either -1 or small buffers.
> 
> Signed-off-by: Mateusz Kulikowski <mateusz.kulikowski@xxxxxxxxx>
> ---
>  drivers/staging/rtl8192e/rtllib_wx.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/rtl8192e/rtllib_wx.c b/drivers/staging/rtl8192e/rtllib_wx.c
> index 2ac1617..22bea5a 100644
> --- a/drivers/staging/rtl8192e/rtllib_wx.c
> +++ b/drivers/staging/rtl8192e/rtllib_wx.c
> @@ -510,7 +510,10 @@ int rtllib_wx_get_encode(struct rtllib_device *ieee,
>  		return 0;
>  	}
>  	len = crypt->ops->get_key(keybuf, SCM_KEY_LEN, NULL, crypt->priv);
> -	erq->length = (len >= 0 ? len : 0);
> +	if (len > U16_MAX)
> +		netdev_err(ieee->dev, "Too long key returned.\n");

Just delete the check if it can't happen or handle the error properly.
Never printed messages can be annoying.  Static checkers assume all
conditions can happen so never true conditions are confusing.  It wastes
RAM.

regards,
dan carpenter

_______________________________________________
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