ibmvnic: fix kernel build warning in strncpy
authorLijun Pan <lijunp213@gmail.com>
Fri, 11 Jun 2021 18:33:53 +0000 (13:33 -0500)
committerDavid S. Miller <davem@davemloft.net>
Fri, 11 Jun 2021 20:56:23 +0000 (13:56 -0700)
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 <lijunp213@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/ibm/ibmvnic.c

index d66e158..e2630b6 100644 (file)
@@ -4385,7 +4385,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);
 }