summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChen Zhou <chenzhou10@huawei.com>2020-01-20 15:50:33 +0300
committerDavid S. Miller <davem@davemloft.net>2020-01-21 12:48:40 +0300
commitbea5416561b1b997adbe3a04a5665e647c589a13 (patch)
tree3c4b8f4d0e7cadc32b8127bd8b062854dfdf7181
parent49e211c0e357d8c5ccdc3c6c5fb8f94ab85d037f (diff)
downloadlinux-bea5416561b1b997adbe3a04a5665e647c589a13.tar.xz
net: hns3: replace snprintf with scnprintf in hns3_update_strings
snprintf returns the number of bytes that would be written, which may be greater than the the actual length to be written. Here use extra code to handle this. scnprintf returns the number of bytes that was actually written, just use scnprintf to simplify the code. Signed-off-by: Chen Zhou <chenzhou10@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index 6e0212b79438..c03856e63320 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -423,9 +423,8 @@ static void *hns3_update_strings(u8 *data, const struct hns3_stats *stats,
data[ETH_GSTRING_LEN - 1] = '\0';
/* first, prepend the prefix string */
- n1 = snprintf(data, MAX_PREFIX_SIZE, "%s%d_",
- prefix, i);
- n1 = min_t(uint, n1, MAX_PREFIX_SIZE - 1);
+ n1 = scnprintf(data, MAX_PREFIX_SIZE, "%s%d_",
+ prefix, i);
size_left = (ETH_GSTRING_LEN - 1) - n1;
/* now, concatenate the stats string to it */