kernel icon indicating copy to clipboard operation
kernel copied to clipboard

dhd_linux.c:6965:39: warning argument to 'sizeof' in 'strncpy' call is the same expression as the source; did you mean to use the size of the destination?

Open g4jc opened this issue 5 years ago • 0 comments

Attempting to build the kernel on Debian GNU/Linux, gcc version 8.3.0

drivers/net/wireless/rockchip_wlan/wkwifi/bcmdhd/dhd_linux.c:6965:39: warning argument to 'sizeof' in 'strncpy' call is the same expression as the source; did you mean to use the size of the destination? [-Wsizeof-pointer-memaccess]
error, forbidding warning:dhd_linux.c:6965

Possible fix:

diff --git a/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/dhd_linux.c b/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/dhd_linux.c
index 25529144f400..7c5a771ba7e2 100644
--- a/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/dhd_linux.c
+++ b/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/dhd_linux.c
@@ -6962,7 +6962,7 @@ dhd_ethtool(dhd_info_t *dhd, void *uaddr)
 		/* Copy out any request driver name */
 		if (copy_from_user(&info, uaddr, sizeof(info)))
 			return -EFAULT;
-		strncpy(drvname, info.driver, sizeof(info.driver));
+		strncpy(drvname, info.driver, sizeof(drvname));
 		drvname[sizeof(info.driver)-1] = '\0';
 
 		/* clear struct for return */

g4jc avatar Nov 07 '20 18:11 g4jc