Re: [PATCH net-next] net: hisilicon: use ethtool string helpers
From: Jakub Kicinski
Date: Sun Nov 03 2024 - 16:54:41 EST
On Wed, 30 Oct 2024 15:07:46 -0700 Rosen Penev wrote:
> -static void *hns3_update_strings(u8 *data, const struct hns3_stats *stats,
> - u32 stat_count, u32 num_tqps, const char *prefix)
> +static void hns3_update_strings(u8 **data, const struct hns3_stats *stats,
> + u32 stat_count, u32 num_tqps,
> + const char *prefix)
> {
> #define MAX_PREFIX_SIZE (6 + 4)
This define can also go away
> - u32 size_left;
> u32 i, j;
> - u32 n1;
>
> - for (i = 0; i < num_tqps; i++) {
> - for (j = 0; j < stat_count; j++) {
> - data[ETH_GSTRING_LEN - 1] = '\0';
> -
> - /* first, prepend the prefix string */
> - n1 = scnprintf(data, MAX_PREFIX_SIZE, "%s%u_",
> - prefix, i);
> - size_left = (ETH_GSTRING_LEN - 1) - n1;
> -
> - /* now, concatenate the stats string to it */
> - strncat(data, stats[j].stats_string, size_left);
> - data += ETH_GSTRING_LEN;
> - }
> - }
> -
> - return data;
> + for (i = 0; i < num_tqps; i++)
> + for (j = 0; j < stat_count; j++)
> + ethtool_sprintf(data, "%s%u_%s", prefix, i,
> + stats[j].stats_string);
> }
--
pw-bot: cr