Skip to contentSkip to conversation

staging: rtl8192e: use explicitly signed char

PATCH In review Jason A. Donenfeld 4 participants 9 messages Oct 24, 2022 – Oct 25, 2022 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: rtl8192e: use explicitly signed char

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)'

---
 drivers/staging/rtl8192e/rtllib_softmac_wx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8192e/rtllib_softmac_wx.c +1 -1
index f9589c5b62ba..4563e3b5bd47 100644
@@ -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;
 		}
Signature · 1 line
2.38.1
#1 lore raw
Quoted 20 lines · Jason A. Donenfeld

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)'

---
 drivers/staging/rtl8192e/rtllib_softmac_wx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8192e/rtllib_softmac_wx.c +0 -0
index f9589c5b62ba..4563e3b5bd47 100644

drivers/staging/rtl8192e/rtllib_softmac_wx.c int rtllib_wx_set_essid(struct rtllib_device *ieee, · line 459

Quoted 5 lines
drivers/staging/rtl8192e/rtllib_softmac_wx.c +1 -1
@@ -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

Quoted 3 lines
drivers/staging/rtl8192e/rtllib_softmac_wx.c +0 -0
 			ret = -1;
 			goto out;
 		}
#2 lore raw
Quoted 23 lines · Dan Carpenter
Quoted 22 lines · Jason A. Donenfeld

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)'

---
 drivers/staging/rtl8192e/rtllib_softmac_wx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8192e/rtllib_softmac_wx.c +0 -0
index f9589c5b62ba..4563e3b5bd47 100644
@@ -456,7 +456,7 @@ int rtllib_wx_set_essid(struct rtllib_device *ieee,
 	}
 
Quoted 6 lines

drivers/staging/rtl8192e/rtllib_softmac_wx.c int rtllib_wx_set_essid(struct rtllib_device *ieee, · line 459

Quoted 3 lines
drivers/staging/rtl8192e/rtllib_softmac_wx.c +1 -1
 	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

#3 lore raw

PATCH v2 1/1 staging: rtl8192e: remove bogus ssid character sign test

This error triggers on some architectures with unsigned char types:

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

But actually, the entire test is bogus, as ssids don't have any sign validity rules like that. So just remove this check look all together.

---
Changes v1->v2:
- Remove ssid sign test entirely rather than casting to s8 *.

 drivers/staging/rtl8192e/rtllib_softmac_wx.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/staging/rtl8192e/rtllib_softmac_wx.c +1 -8
index f9589c5b62ba..1e5ad3b476ef 100644
@@ -439,7 +439,7 @@ int rtllib_wx_set_essid(struct rtllib_device *ieee,
 			union iwreq_data *wrqu, char *extra)
 {
 
-	int ret = 0, len, i;
+	int ret = 0, len;
 	short proto_started;
 	unsigned long flags;
 
@@ -455,13 +455,6 @@ int rtllib_wx_set_essid(struct rtllib_device *ieee,
 		goto out;
 	}
 
-	for (i = 0; i < len; i++) {
-		if (extra[i] < 0) {
-			ret = -1;
-			goto out;
-		}
-	}
-
 	if (proto_started)
 		rtllib_stop_protocol(ieee, true);
 
Signature · 1 line
2.38.1
Reviewed-by on v2 1/1
#4 lore raw

Re: [PATCH v2] staging: rtl8192e: remove bogus ssid character sign test

Quoted 7 lines · Jason A. Donenfeld

This error triggers on some architectures with unsigned char types:

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

But actually, the entire test is bogus, as ssids don't have any sign validity rules like that. So just remove this check look all together.

Quoted 6 lines

---
Changes v1->v2:
- Remove ssid sign test entirely rather than casting to s8 *.

Thanks!

regards,
dan carpenter

#5 lore raw

Re: [PATCH v2] staging: rtl8192e: remove bogus ssid character sign test

In reply to Jason A. Donenfeld
Quoted 33 lines · Jason A. Donenfeld

This error triggers on some architectures with unsigned char types:

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

But actually, the entire test is bogus, as ssids don't have any sign validity rules like that. So just remove this check look all together.

---
Changes v1->v2:
- Remove ssid sign test entirely rather than casting to s8 *.

  drivers/staging/rtl8192e/rtllib_softmac_wx.c | 9 +--------
  1 file changed, 1 insertion(+), 8 deletions(-)
drivers/staging/rtl8192e/rtllib_softmac_wx.c +1 -1
index f9589c5b62ba..1e5ad3b476ef 100644
@@ -439,7 +439,7 @@ int rtllib_wx_set_essid(struct rtllib_device *ieee,
  			union iwreq_data *wrqu, char *extra)
  {
 
-	int ret = 0, len, i;
+	int ret = 0, len;
  	short proto_started;
  	unsigned long flags;
 
@@ -455,13 +455,6 @@ int rtllib_wx_set_essid(struct rtllib_device *ieee,
  		goto out;
  	}

drivers/staging/rtl8192e/rtllib_softmac_wx.c int rtllib_wx_set_essid(struct rtllib_device *ieee, · line 459

Quoted 10 lines
drivers/staging/rtl8192e/rtllib_softmac_wx.c +0 -7
 
-	for (i = 0; i < len; i++) {
-		if (extra[i] < 0) {
-			ret = -1;
-			goto out;
-		}
-	}
-
  	if (proto_started)
  		rtllib_stop_protocol(ieee, true);

This patch cannot be applied on:
[PATCH] staging: rtl8192e: use explicitly signed char On 10/24/22 18:30, Jason A. Donenfeld
As line 456 was changed.

Bye Philipp

Quoted 1 line
maintainer
#6 lore raw

Re: [PATCH v2] staging: rtl8192e: remove bogus ssid character sign test

Quoted 38 lines · Philipp Hortmann
Quoted 37 lines · Jason A. Donenfeld

This error triggers on some architectures with unsigned char types:

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

But actually, the entire test is bogus, as ssids don't have any sign validity rules like that. So just remove this check look all together.

---
Changes v1->v2:
- Remove ssid sign test entirely rather than casting to s8 *.

  drivers/staging/rtl8192e/rtllib_softmac_wx.c | 9 +--------
  1 file changed, 1 insertion(+), 8 deletions(-)
drivers/staging/rtl8192e/rtllib_softmac_wx.c +1 -7
index f9589c5b62ba..1e5ad3b476ef 100644
@@ -439,7 +439,7 @@ int rtllib_wx_set_essid(struct rtllib_device *ieee,
  			union iwreq_data *wrqu, char *extra)
  {
-	int ret = 0, len, i;
+	int ret = 0, len;
  	short proto_started;
  	unsigned long flags;
@@ -455,13 +455,6 @@ int rtllib_wx_set_essid(struct rtllib_device *ieee,
  		goto out;
  	}
-	for (i = 0; i < len; i++) {
-		if (extra[i] < 0) {
-			ret = -1;
-			goto out;
-		}
-	}
Quoted 8 lines

drivers/staging/rtl8192e/rtllib_softmac_wx.c int rtllib_wx_set_essid(struct rtllib_device *ieee, · line 459

Quoted 3 lines
drivers/staging/rtl8192e/rtllib_softmac_wx.c +0 -1
-
  	if (proto_started)
  		rtllib_stop_protocol(ieee, true);

This patch cannot be applied on:
[PATCH] staging: rtl8192e: use explicitly signed char On 10/24/22 18:30, Jason A. Donenfeld
As line 456 was changed.

This now in my staging-linus branch, so perhaps you applied it to the wrong one.

thanks,

greg k-h

#7 lore raw

Re: [PATCH v2] staging: rtl8192e: remove bogus ssid character sign test

In reply to Philipp Hortmann
Quoted 36 lines · Philipp Hortmann
Quoted 34 lines · Jason A. Donenfeld

This error triggers on some architectures with unsigned char types:

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

But actually, the entire test is bogus, as ssids don't have any sign validity rules like that. So just remove this check look all together.

---
Changes v1->v2:
- Remove ssid sign test entirely rather than casting to s8 *.

  drivers/staging/rtl8192e/rtllib_softmac_wx.c | 9 +--------
  1 file changed, 1 insertion(+), 8 deletions(-)
drivers/staging/rtl8192e/rtllib_softmac_wx.c +1 -1
index f9589c5b62ba..1e5ad3b476ef 100644
@@ -439,7 +439,7 @@ int rtllib_wx_set_essid(struct rtllib_device *ieee,
                      union iwreq_data *wrqu, char *extra)
  {
 
-     int ret = 0, len, i;
+     int ret = 0, len;
      short proto_started;
      unsigned long flags;
 
@@ -455,13 +455,6 @@ int rtllib_wx_set_essid(struct rtllib_device *ieee,
              goto out;
      }
 
Quoted 12 lines

drivers/staging/rtl8192e/rtllib_softmac_wx.c int rtllib_wx_set_essid(struct rtllib_device *ieee, · line 459

Quoted 9 lines
drivers/staging/rtl8192e/rtllib_softmac_wx.c +0 -7
-     for (i = 0; i < len; i++) {
-             if (extra[i] < 0) {
-                     ret = -1;
-                     goto out;
-             }
-     }
-
      if (proto_started)
              rtllib_stop_protocol(ieee, true);

This patch cannot be applied on:
[PATCH] staging: rtl8192e: use explicitly signed char

They're mutually exclusive, which is why this one here was marked as a v2 and sent in reply to that one. Greg picked up the v2 and all is well.

Jason

Tested-by on v1 1/1
#8 lore raw
In reply to Jason A. Donenfeld
Quoted 20 lines · Jason A. Donenfeld

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)'

---
  drivers/staging/rtl8192e/rtllib_softmac_wx.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8192e/rtllib_softmac_wx.c +0 -0
index f9589c5b62ba..4563e3b5bd47 100644

drivers/staging/rtl8192e/rtllib_softmac_wx.c int rtllib_wx_set_essid(struct rtllib_device *ieee, · line 462

Quoted 8 lines
drivers/staging/rtl8192e/rtllib_softmac_wx.c +1 -1
@@ -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;
  		}