ibmvnic: fix kernel build warning in strncpy
PATCH v2 1/1 ibmvnic: fix kernel build warning in strncpy
drivers/net/ethernet/ibm/ibmvnic.c: In function ‘handle_vpd_rsp’:drivers/net/ethernet/ibm/ibmvnic.c:4393:3: warning: ‘strncpy’ output truncated before terminating nul copying 3 bytes from a string of the same length [-Wstringop-truncation]
4393 | strncpy((char *)adapter->fw_version, "N/A", 3 * sizeof(char));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~---
v2: suggested by Shannon Nelson to use strlcpy
I looked up strscpy and it seems preferred to strlcpy.
drivers/net/ethernet/ibm/ibmvnic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/ibm/ibmvnic.c +1 -1
@@ -4390,7 +4390,7 @@ static void handle_vpd_rsp(union ibmvnic_crq *crq, complete:if (adapter->fw_version[0 ] =='\0' ) -strncpy ((char *)adapter->fw_version,"N/A" ,3 *sizeof (char )); +strscpy ((char *)adapter->fw_version,"N/A" ,sizeof (adapter->fw_version));complete (&adapter->fw_done); }
Signature · 1 line
2.23.0
This patch was applied to netdev/net-next.git (refs/heads/master):
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
Quoted 8 lines · On Fri, 11 Jun 2021 13:33:53 -0500 you wrote:
drivers/net/ethernet/ibm/ibmvnic.c: In function ‘handle_vpd_rsp’:drivers/net/ethernet/ibm/ibmvnic.c:4393:3: warning: ‘strncpy’ output truncated before terminating nul copying 3 bytes from a string of the same length [-Wstringop-truncation]4393 | strncpy((char *)adapter->fw_version, "N/A", 3 * sizeof(char)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Signed-off-by Lijun Pan <[email protected]>[...]
Here is the summary with links:
- [net-next,v2] ibmvnic: fix kernel build warning in strncpy
https://git.kernel.org/netdev/net-next/c/0b217d3d7462
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html