All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: r8188eu: fix -Wrestrict warnings
@ 2021-09-20  9:55 Arnd Bergmann
  2021-09-20 10:09 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2021-09-20  9:55 UTC (permalink / raw)
  To: Larry Finger, Phillip Potter, Greg Kroah-Hartman
  Cc: Arnd Bergmann, Michael Straube, Martin Kaiser, linux-staging,
	linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

Adding back the nonstandard ioctl commands caused -Wrestrict warnings
when building with 'make W=1':

drivers/staging/r8188eu/os_dep/ioctl_linux.c: In function 'rtw_mp_read_rf':
drivers/staging/r8188eu/os_dep/ioctl_linux.c:5515:27: error: 'sprintf' argument 3 overlaps destination object 'extra' [-Werror=restrict]
 5515 |                           sprintf(extra, "%s %d", extra, strtou);
      |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/staging/r8188eu/os_dep/ioctl_linux.c:5470:54: note: destination object referenced by 'restrict'-qualified argument 1 was declared here
 5470 |                         struct iw_point *wrqu, char *extra)
      |                                                ~~~~~~^~~~~

Change these to the same construct used elsewhere in that driver,
with an offset to the string to make the warning go away.

The ioctl commands were previously removed, and it's unlikely that
anything is actually using them, so ideally I would prefer to have
them removed again.

The lack of range checking of the 'extra' output buffer is also
slightly worrying, but I did not check whether this could cause
harm.

Fixes: 2b42bd58b321 ("staging: r8188eu: introduce new os_dep dir for RTL8188eu driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/staging/r8188eu/os_dep/ioctl_linux.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
index 81d4255d1785..1fd375076001 100644
--- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
@@ -5372,8 +5372,8 @@ static int rtw_mp_read_reg(struct net_device *dev,
 
 			pnext++;
 			if (*pnext != '\0') {
-				  strtout = simple_strtoul(pnext, &ptmp, 16);
-				  sprintf(extra, "%s %d", extra, strtout);
+				strtout = simple_strtoul(pnext, &ptmp, 16);
+				sprintf(extra + strlen(extra), " %d", strtout);
 			} else {
 				  break;
 			}
@@ -5405,7 +5405,7 @@ static int rtw_mp_read_reg(struct net_device *dev,
 			pnext++;
 			if (*pnext != '\0') {
 				strtout = simple_strtoul(pnext, &ptmp, 16);
-				sprintf(extra, "%s %d", extra, strtout);
+				sprintf(extra + strlen(extra), " %d", strtout);
 			} else {
 				break;
 			}
@@ -5512,7 +5512,7 @@ static int rtw_mp_read_rf(struct net_device *dev,
 		pnext++;
 		if (*pnext != '\0') {
 			  strtou = simple_strtoul(pnext, &ptmp, 16);
-			  sprintf(extra, "%s %d", extra, strtou);
+			  sprintf(extra + strlen(extra), " %d", strtou);
 		} else {
 			  break;
 		}
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] staging: r8188eu: fix -Wrestrict warnings
  2021-09-20  9:55 [PATCH] staging: r8188eu: fix -Wrestrict warnings Arnd Bergmann
@ 2021-09-20 10:09 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2021-09-20 10:09 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Larry Finger, Phillip Potter, Arnd Bergmann, Michael Straube,
	Martin Kaiser, linux-staging, linux-kernel

On Mon, Sep 20, 2021 at 11:55:09AM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Adding back the nonstandard ioctl commands caused -Wrestrict warnings
> when building with 'make W=1':
> 
> drivers/staging/r8188eu/os_dep/ioctl_linux.c: In function 'rtw_mp_read_rf':
> drivers/staging/r8188eu/os_dep/ioctl_linux.c:5515:27: error: 'sprintf' argument 3 overlaps destination object 'extra' [-Werror=restrict]
>  5515 |                           sprintf(extra, "%s %d", extra, strtou);
>       |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/staging/r8188eu/os_dep/ioctl_linux.c:5470:54: note: destination object referenced by 'restrict'-qualified argument 1 was declared here
>  5470 |                         struct iw_point *wrqu, char *extra)
>       |                                                ~~~~~~^~~~~
> 
> Change these to the same construct used elsewhere in that driver,
> with an offset to the string to make the warning go away.
> 
> The ioctl commands were previously removed, and it's unlikely that
> anything is actually using them, so ideally I would prefer to have
> them removed again.

I'll apply this to get rid of the warning, but will also work on
removing the ioctls entirely.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-20 10:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-20  9:55 [PATCH] staging: r8188eu: fix -Wrestrict warnings Arnd Bergmann
2021-09-20 10:09 ` Greg Kroah-Hartman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.