staging: rtl8192e: use explicitly signed char

Message ID 20221024163005.536097-1-Jason@zx2c4.com
State New
Headers
Series staging: rtl8192e: use explicitly signed char |

Commit Message

Jason A. Donenfeld Oct. 24, 2022, 4:30 p.m. UTC
  With char becoming unsigned by default, and with `char` alone being
ambiguous and based on architecture, signed chars need to be marked
explicitly as such. In this case, passing `char *extra` is part of the
iw API, and that extra is mostly intended to be somewhat opaque. So just
cast to `s8 *` for the sign test. This fixes warnings like:

drivers/staging/rtl8192e/rtllib_softmac_wx.c:459 rtllib_wx_set_essid() warn: impossible condition '(extra[i] < 0) => (0-255 < 0)'

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-staging@lists.linux.dev
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 drivers/staging/rtl8192e/rtllib_softmac_wx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Dan Carpenter Oct. 25, 2022, 6:19 a.m. UTC | #1
On Mon, Oct 24, 2022 at 06:30:05PM +0200, Jason A. Donenfeld wrote:
> With char becoming unsigned by default, and with `char` alone being
> ambiguous and based on architecture, signed chars need to be marked
> explicitly as such. In this case, passing `char *extra` is part of the
> iw API, and that extra is mostly intended to be somewhat opaque. So just
> cast to `s8 *` for the sign test. This fixes warnings like:
> 
> drivers/staging/rtl8192e/rtllib_softmac_wx.c:459 rtllib_wx_set_essid() warn: impossible condition '(extra[i] < 0) => (0-255 < 0)'
> 
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: linux-staging@lists.linux.dev
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
> ---
>  drivers/staging/rtl8192e/rtllib_softmac_wx.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c
> index f9589c5b62ba..4563e3b5bd47 100644
> --- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c
> +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c
> @@ -456,7 +456,7 @@ int rtllib_wx_set_essid(struct rtllib_device *ieee,
>  	}
>  
>  	for (i = 0; i < len; i++) {
> -		if (extra[i] < 0) {
> +		if (((s8 *)extra)[i] < 0) {

I agree with Linus that this if statement is nonsense and should just be
deleted.

regards,
dan carpenter

>  			ret = -1;
>  			goto out;
>  		}
  
Greg KH Oct. 25, 2022, 10:45 a.m. UTC | #2
On Tue, Oct 25, 2022 at 09:19:58AM +0300, Dan Carpenter wrote:
> On Mon, Oct 24, 2022 at 06:30:05PM +0200, Jason A. Donenfeld wrote:
> > With char becoming unsigned by default, and with `char` alone being
> > ambiguous and based on architecture, signed chars need to be marked
> > explicitly as such. In this case, passing `char *extra` is part of the
> > iw API, and that extra is mostly intended to be somewhat opaque. So just
> > cast to `s8 *` for the sign test. This fixes warnings like:
> > 
> > drivers/staging/rtl8192e/rtllib_softmac_wx.c:459 rtllib_wx_set_essid() warn: impossible condition '(extra[i] < 0) => (0-255 < 0)'
> > 
> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Cc: linux-staging@lists.linux.dev
> > Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
> > ---
> >  drivers/staging/rtl8192e/rtllib_softmac_wx.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c
> > index f9589c5b62ba..4563e3b5bd47 100644
> > --- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c
> > +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c
> > @@ -456,7 +456,7 @@ int rtllib_wx_set_essid(struct rtllib_device *ieee,
> >  	}
> >  
> >  	for (i = 0; i < len; i++) {
> > -		if (extra[i] < 0) {
> > +		if (((s8 *)extra)[i] < 0) {
> 
> I agree with Linus that this if statement is nonsense and should just be
> deleted.

Yeah, I agree as well, let's just delete this invalid check.  No other
wifi driver cares about ssid characters like this.

thanks,

greg k-h
  
Philipp Hortmann Oct. 25, 2022, 5:22 p.m. UTC | #3
On 10/24/22 18:30, Jason A. Donenfeld wrote:
> With char becoming unsigned by default, and with `char` alone being
> ambiguous and based on architecture, signed chars need to be marked
> explicitly as such. In this case, passing `char *extra` is part of the
> iw API, and that extra is mostly intended to be somewhat opaque. So just
> cast to `s8 *` for the sign test. This fixes warnings like:
> 
> drivers/staging/rtl8192e/rtllib_softmac_wx.c:459 rtllib_wx_set_essid() warn: impossible condition '(extra[i] < 0) => (0-255 < 0)'
> 
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: linux-staging@lists.linux.dev
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
> ---
>   drivers/staging/rtl8192e/rtllib_softmac_wx.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c
> index f9589c5b62ba..4563e3b5bd47 100644
> --- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c
> +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c
> @@ -456,7 +456,7 @@ int rtllib_wx_set_essid(struct rtllib_device *ieee,
>   	}
>   
>   	for (i = 0; i < len; i++) {
> -		if (extra[i] < 0) {
> +		if (((s8 *)extra)[i] < 0) {
>   			ret = -1;
>   			goto out;
>   		}

Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com>
  

Patch

diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c
index f9589c5b62ba..4563e3b5bd47 100644
--- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c
+++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c
@@ -456,7 +456,7 @@  int rtllib_wx_set_essid(struct rtllib_device *ieee,
 	}
 
 	for (i = 0; i < len; i++) {
-		if (extra[i] < 0) {
+		if (((s8 *)extra)[i] < 0) {
 			ret = -1;
 			goto out;
 		}