Skip to content

Commit bea5416

Browse files
Chen Zhoudavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 49e211c commit bea5416

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,8 @@ static void *hns3_update_strings(u8 *data, const struct hns3_stats *stats,
423423
data[ETH_GSTRING_LEN - 1] = '\0';
424424

425425
/* first, prepend the prefix string */
426-
n1 = snprintf(data, MAX_PREFIX_SIZE, "%s%d_",
427-
prefix, i);
428-
n1 = min_t(uint, n1, MAX_PREFIX_SIZE - 1);
426+
n1 = scnprintf(data, MAX_PREFIX_SIZE, "%s%d_",
427+
prefix, i);
429428
size_left = (ETH_GSTRING_LEN - 1) - n1;
430429

431430
/* now, concatenate the stats string to it */

0 commit comments

Comments
 (0)