ethtool: Add ethtool_puts()
Subsystems (24)
v2 cover ethtool: Add ethtool_puts()
Hi,
This series aims to implement ethtool_puts() and send out a wave 1 of conversions from ethtool_sprintf(). There's also a checkpatch patch included to check for the cases listed below.
This was sparked from recent discussion here [1]
The conversions are used in cases where ethtool_sprintf() was being used with just two arguments:
| ethtool_sprintf(&data, buffer[i].name);
or when it's used with format string: "%s"
| ethtool_sprintf(&data, "%s", buffer[i].name);
which both now become:
| ethtool_puts(&data, buffer[i].name);
The first case commonly triggers a -Wformat-security warning with Clang due to potential problems with format flags present in the strings [3].
The second is just a bit weird with a plain-ol' "%s".
v2 (and newer) of this patch is targeted at linux-next so that we can catch some of the patches I sent [2] using this "%s" pattern and replace them before they hit mainline.
Changes found with Cocci [4] and grep [5].
[1]: https://lore.kernel.org/all/202310141935.B326C9E@keescook/
[2]: https://lore.kernel.org/all/?q=dfb%3Aethtool_sprintf+AND+f%3Ajustinstitt
[3]: https://lore.kernel.org/all/202310101528.9496539BE@keescook/
[4]: (script authored by Kees w/ modifications from Joe) @replace_2_args@
expression BUF;
expression VAR;
@@
- ethtool_sprintf(BUF, VAR)
+ ethtool_puts(BUF, VAR)
@replace_3_args@
expression BUF;
expression VAR;
@@
- ethtool_sprintf(BUF, "%s", VAR)
+ ethtool_puts(BUF, VAR)
- ethtool_sprintf(&BUF, "%s", VAR)
+ ethtool_puts(&BUF, VAR)
[5]: $ rg "ethtool_sprintf\(\s*[^,)]+\s*,\s*[^,)]+\s*\)"
---
Changes in v2:
- wrap lines better in replacement (thanks Joe, Kees)
- add --fix to checkpatch (thanks Joe)
- clean up checkpatch formatting (thanks Joe, et al.)
- rebase against next
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Justin Stitt (3):
ethtool: Implement ethtool_puts()
checkpatch: add ethtool_sprintf rules
treewide: Convert some ethtool_sprintf() to ethtool_puts()
drivers/net/dsa/lantiq_gswip.c | 2 +- drivers/net/dsa/mt7530.c | 2 +- drivers/net/dsa/qca/qca8k-common.c | 2 +- drivers/net/dsa/realtek/rtl8365mb.c | 2 +- drivers/net/dsa/realtek/rtl8366-core.c | 2 +- drivers/net/dsa/vitesse-vsc73xx-core.c | 8 +-- drivers/net/ethernet/amazon/ena/ena_ethtool.c | 4 +- drivers/net/ethernet/brocade/bna/bnad_ethtool.c | 2 +- drivers/net/ethernet/freescale/fec_main.c | 4 +- .../net/ethernet/fungible/funeth/funeth_ethtool.c | 8 +-- drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c | 2 +- .../net/ethernet/hisilicon/hns/hns_dsaf_xgmac.c | 2 +- drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 65 +++++++++++----------- drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 6 +- drivers/net/ethernet/intel/iavf/iavf_ethtool.c | 3 +- drivers/net/ethernet/intel/ice/ice_ethtool.c | 9 +-- drivers/net/ethernet/intel/idpf/idpf_ethtool.c | 2 +- drivers/net/ethernet/intel/igb/igb_ethtool.c | 6 +- drivers/net/ethernet/intel/igc/igc_ethtool.c | 6 +- drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 5 +- .../net/ethernet/microchip/sparx5/sparx5_ethtool.c | 2 +- .../net/ethernet/netronome/nfp/nfp_net_ethtool.c | 44 +++++++-------- drivers/net/ethernet/pensando/ionic/ionic_stats.c | 4 +- drivers/net/ethernet/wangxun/libwx/wx_ethtool.c | 2 +- drivers/net/hyperv/netvsc_drv.c | 4 +- drivers/net/phy/nxp-tja11xx.c | 2 +- drivers/net/phy/smsc.c | 2 +- drivers/net/vmxnet3/vmxnet3_ethtool.c | 10 ++-- include/linux/ethtool.h | 34 +++++++---- net/ethtool/ioctl.c | 7 +++ scripts/checkpatch.pl | 19 +++++++ 31 files changed, 149 insertions(+), 123 deletions(-)
---
base-commit: 2ef7141596eed0b4b45ef18b3626f428a6b0a822
change-id: 20231025-ethtool_puts_impl-a1479ffbc7e0
Best regards,
--
Justin Stitt <[email protected]>
PATCH v2 1/3 ethtool: Implement ethtool_puts()
Use strscpy() to implement ethtool_puts().
Functionally the same as ethtool_sprintf() when it's used with two arguments or with just "%s" format specifier.
--- include/linux/ethtool.h | 34 +++++++++++++++++++++++----------- net/ethtool/ioctl.c | 7 +++++++ 2 files changed, 30 insertions(+), 11 deletions(-)
include/linux/ethtool.h +23 -11
@@ -1053,22 +1053,34 @@ static inline int ethtool_mm_frag_size_min_to_add(u32 val_min, u32 *val_add,*/ extern __printf(2, 3) void ethtool_sprintf(u8 **data, const char *fmt, ...); +/** +* ethtool_puts - Write string to ethtool string data +* @data: Pointer to start of string to update +* @str: String to write +* +* Write string to data. Update data to point at start of next +* string. +* +* Prefer this function to ethtool_sprintf() when given only +* two arguments or if @fmt is just "%s". +*/ +extern void ethtool_puts(u8 **data, const char *str); +/* Link mode to forced speed capabilities maps */ struct ethtool_forced_speed_map { - u32 speed; +u32 speed;__ETHTOOL_DECLARE_LINK_MODE_MASK (caps); - const u32 *cap_arr; - u32 arr_size; +const u32 *cap_arr; +u32 arr_size; }; -#define ETHTOOL_FORCED_SPEED_MAP(prefix, value) \ -{ \ - .speed = SPEED_##value, \ - .cap_arr = prefix##_##value, \ - .arr_size = ARRAY_SIZE(prefix##_##value), \ -} +#define ETHTOOL_FORCED_SPEED_MAP (prefix, value) \ + { \ + .speed = SPEED_##value, .cap_arr = prefix##_##value, \ + .arr_size = ARRAY_SIZE(prefix##_##value), \ + } -void -ethtool_forced_speed_maps_init (struct ethtool_forced_speed_map *maps,u32 size); +void ethtool_forced_speed_maps_init (struct ethtool_forced_speed_map *maps, +u32 size);#endif /* _LINUX_ETHTOOL_H */
net/ethtool/ioctl.c +7 -0
@@ -1991,6 +1991,13 @@ __printf(2, 3) void ethtool_sprintf(u8 **data, const char *fmt, ...) }EXPORT_SYMBOL (ethtool_sprintf); +void ethtool_puts (u8 **data,const char *str) +{ +strscpy (*data, str,ETH_GSTRING_LEN ); + *data +=ETH_GSTRING_LEN ; +} +EXPORT_SYMBOL (ethtool_puts); +static int ethtool_phys_id (struct net_device *dev,void __user *useraddr) {struct ethtool_value id;
Signature · 1 line
2.42.0.820.g83a721a137-goog
Vladimir Oltean
maintainerRe: [PATCH next v2 1/3] ethtool: Implement ethtool_puts()
Hi Justin,
Quoted 51 lines · Justin Stitt
Use
strscpy()to implementethtool_puts().Functionally the same as
ethtool_sprintf()when it's used with two arguments or with just "%s" format specifier.Signed-off-by Justin Stitt <[email protected]>--- include/linux/ethtool.h | 34 +++++++++++++++++++++++----------- net/ethtool/ioctl.c | 7 +++++++ 2 files changed, 30 insertions(+), 11 deletions(-)include/linux/ethtool.h +17
-9@@ -1053,22 +1053,34 @@ static inline int ethtool_mm_frag_size_min_to_add(u32 val_min, u32 *val_add,*/ extern __printf(2, 3) void ethtool_sprintf(u8 **data, const char *fmt, ...); +/** +* ethtool_puts - Write string to ethtool string data +* @data: Pointer to start of string to update +* @str: String to write +* +* Write string to data. Update data to point at start of next +* string. +* +* Prefer this function to ethtool_sprintf() when given only +* two arguments or if @fmt is just "%s". +*/ +extern void ethtool_puts(u8 **data, const char *str); +/* Link mode to forced speed capabilities maps */ struct ethtool_forced_speed_map { - u32 speed; +u32 speed;__ETHTOOL_DECLARE_LINK_MODE_MASK (caps); - const u32 *cap_arr; - u32 arr_size; +const u32 *cap_arr; +u32 arr_size; }; -#define ETHTOOL_FORCED_SPEED_MAP(prefix, value) \ -{ \ - .speed = SPEED_##value, \ - .cap_arr = prefix##_##value, \ - .arr_size = ARRAY_SIZE(prefix##_##value), \ -} +#define ETHTOOL_FORCED_SPEED_MAP (prefix, value) \
include/linux/ethtool.h static inline int ethtool_mm_frag_size_min_to_add(u32 val_min, u32 *val_add, · line 1086
Quoted 10 lines
include/linux/ethtool.h +6
-2+ { \ + .speed = SPEED_##value, .cap_arr = prefix##_##value, \ + .arr_size = ARRAY_SIZE(prefix##_##value), \ + } -void -ethtool_forced_speed_maps_init (struct ethtool_forced_speed_map *maps,u32 size); +void ethtool_forced_speed_maps_init(struct ethtool_forced_speed_map *maps, + u32 size); #endif /* _LINUX_ETHTOOL_H */
Maybe this is due to an incorrect rebase conflict resolution, but you shouldn't have touched any of the ethtool force speed maps.
Please wait for at least 24 hours to pass before posting a new version, to allow for more comments to come in.
Re: [PATCH next v2 1/3] ethtool: Implement ethtool_puts()
Quoted 60 lines · Vladimir Oltean
Hi Justin,
Quoted 56 lines · Justin Stitt
Use
strscpy()to implementethtool_puts().Functionally the same as
ethtool_sprintf()when it's used with two arguments or with just "%s" format specifier.Signed-off-by Justin Stitt <[email protected]>--- include/linux/ethtool.h | 34 +++++++++++++++++++++++----------- net/ethtool/ioctl.c | 7 +++++++ 2 files changed, 30 insertions(+), 11 deletions(-)include/linux/ethtool.h +21
-9@@ -1053,22 +1053,34 @@ static inline int ethtool_mm_frag_size_min_to_add(u32 val_min, u32 *val_add,*/ extern __printf(2, 3) void ethtool_sprintf(u8 **data, const char *fmt, ...); +/** +* ethtool_puts - Write string to ethtool string data +* @data: Pointer to start of string to update +* @str: String to write +* +* Write string to data. Update data to point at start of next +* string. +* +* Prefer this function to ethtool_sprintf() when given only +* two arguments or if @fmt is just "%s". +*/ +extern void ethtool_puts(u8 **data, const char *str); +/* Link mode to forced speed capabilities maps */ struct ethtool_forced_speed_map { - u32 speed; +u32 speed;__ETHTOOL_DECLARE_LINK_MODE_MASK (caps); - const u32 *cap_arr; - u32 arr_size; +const u32 *cap_arr; +u32 arr_size; }; -#define ETHTOOL_FORCED_SPEED_MAP(prefix, value) \ -{ \ - .speed = SPEED_##value, \ - .cap_arr = prefix##_##value, \ - .arr_size = ARRAY_SIZE(prefix##_##value), \ -} +#define ETHTOOL_FORCED_SPEED_MAP (prefix, value) \ + { \ + .speed = SPEED_##value, .cap_arr = prefix##_##value, \ + .arr_size = ARRAY_SIZE(prefix##_##value), \ + }
Quoted 8 lines
include/linux/ethtool.h static inline int ethtool_mm_frag_size_min_to_add(u32 val_min, u32 *val_add, · line 1086
Quoted 5 lines
include/linux/ethtool.h +2
-2-void -ethtool_forced_speed_maps_init (struct ethtool_forced_speed_map *maps,u32 size); +void ethtool_forced_speed_maps_init (struct ethtool_forced_speed_map *maps, +u32 size);#endif /* _LINUX_ETHTOOL_H */ Maybe this is due to an incorrect rebase conflict resolution, but you shouldn't have touched any of the ethtool force speed maps.
Ah, I did have a conflict and resolved by simply moving the hunks out of each other's way. Trivial resolution.
Should I undo this? I want my patch against next since it's targeting some stuff in-flight over there. BUT, I also want ethtool_puts() to be directly below ethtool_sprintf() in the source code. What to do?
Quoted 3 lines
Please wait for at least 24 hours to pass before posting a new version, to allow for more comments to come in.
Ok :)
Thanks
Justin
Re: [PATCH next v2 1/3] ethtool: Implement ethtool_puts()
Quoted 71 lines · Justin Stitt
Quoted 60 lines · Vladimir Oltean
Hi Justin,
Quoted 56 lines · Justin Stitt
Use
strscpy()to implementethtool_puts().Functionally the same as
ethtool_sprintf()when it's used with two arguments or with just "%s" format specifier.Signed-off-by Justin Stitt <[email protected]>--- include/linux/ethtool.h | 34 +++++++++++++++++++++++----------- net/ethtool/ioctl.c | 7 +++++++ 2 files changed, 30 insertions(+), 11 deletions(-)include/linux/ethtool.h +21
-9@@ -1053,22 +1053,34 @@ static inline int ethtool_mm_frag_size_min_to_add(u32 val_min, u32 *val_add,*/ extern __printf(2, 3) void ethtool_sprintf(u8 **data, const char *fmt, ...); +/** +* ethtool_puts - Write string to ethtool string data +* @data: Pointer to start of string to update +* @str: String to write +* +* Write string to data. Update data to point at start of next +* string. +* +* Prefer this function to ethtool_sprintf() when given only +* two arguments or if @fmt is just "%s". +*/ +extern void ethtool_puts(u8 **data, const char *str); +/* Link mode to forced speed capabilities maps */ struct ethtool_forced_speed_map { - u32 speed; +u32 speed;__ETHTOOL_DECLARE_LINK_MODE_MASK (caps); - const u32 *cap_arr; - u32 arr_size; +const u32 *cap_arr; +u32 arr_size; }; -#define ETHTOOL_FORCED_SPEED_MAP(prefix, value) \ -{ \ - .speed = SPEED_##value, \ - .cap_arr = prefix##_##value, \ - .arr_size = ARRAY_SIZE(prefix##_##value), \ -} +#define ETHTOOL_FORCED_SPEED_MAP (prefix, value) \ + { \ + .speed = SPEED_##value, .cap_arr = prefix##_##value, \ + .arr_size = ARRAY_SIZE(prefix##_##value), \ + }Quoted 8 lines
include/linux/ethtool.h static inline int ethtool_mm_frag_size_min_to_add(u32 val_min, u32 *val_add, · line 1086
Quoted 5 lines
include/linux/ethtool.h +2
-2-void -ethtool_forced_speed_maps_init (struct ethtool_forced_speed_map *maps,u32 size); +void ethtool_forced_speed_maps_init (struct ethtool_forced_speed_map *maps, +u32 size);#endif /* _LINUX_ETHTOOL_H */ Maybe this is due to an incorrect rebase conflict resolution, but you shouldn't have touched any of the ethtool force speed maps.
Quoted 6 lines
Ah, I did have a conflict and resolved by simply moving the hunks out of each other's way. Trivial resolution.
Should I undo this? I want my patch against next since it's targeting some stuff in-flight over there. BUT, I also want
ethtool_puts()to be directly belowethtool_sprintf()in the source code. What to do?
Oh, I just realized my auto formatter had a field day with that function. I will rectify this in a new version after waiting 24hrs for comments to trickle in as well.
Quoted 9 lines
Quoted 4 lines
Please wait for at least 24 hours to pass before posting a new version, to allow for more comments to come in.
Ok :)
Thanks
Justin
Thanks
Justin
Vladimir Oltean
maintainerRe: [PATCH next v2 1/3] ethtool: Implement ethtool_puts()
Quoted 8 lines · Justin Stitt
Quoted 7 lines · Justin Stitt
Quoted 2 lines · Vladimir Oltean
Maybe this is due to an incorrect rebase conflict resolution, but you shouldn't have touched any of the ethtool force speed maps.
Ah, I did have a conflict and resolved by simply moving the hunks out of each other's way. Trivial resolution.
Quoted 7 lines
Quoted 3 lines
Should I undo this? I want my patch against next since it's targeting some stuff in-flight over there. BUT, I also want
ethtool_puts()to be directly belowethtool_sprintf()in the source code. What to do?Oh, I just realized my auto formatter had a field day with that function. I will rectify this in a new version after waiting 24hrs for comments to trickle in as well.
Nothing other than ethtool_puts() should appear in the patch delta.
pw-bot: cr
Vladimir Oltean
maintainerRe: [PATCH next v2 1/3] ethtool: Implement ethtool_puts()
In reply to Justin StittQuoted 3 lines · Justin Stitt
Should I undo this? I want my patch against next since it's targeting some stuff in-flight over there. BUT, I also want
ethtool_puts()to be directly belowethtool_sprintf()in the source code. What to do?
(removing everyone except the lists from CC, I don't want to go to email arest because of spamming too many recipients)
What is the stuff in-flight in next that this is targeting?
And why would anything prevent you from putting ethtool_puts() directly below ethtool_sprintf()?
Re: [PATCH next v2 1/3] ethtool: Implement ethtool_puts()
Quoted 6 lines · Vladimir Oltean
Quoted 3 lines · Justin Stitt
Should I undo this? I want my patch against next since it's targeting some stuff in-flight over there. BUT, I also want
ethtool_puts()to be directly belowethtool_sprintf()in the source code. What to do?
Quoted 7 lines
(removing everyone except the lists from CC, I don't want to go to email arest because of spamming too many recipients)
What is the stuff in-flight in next that this is targeting?
And why would anything prevent you from putting
ethtool_puts()directly belowethtool_sprintf()?
The in-flight stuff consists of patches I sent changing some strncpy() usage to
ethtool_sprintf(&data, "%s", something[i].name);
We can see them here [1]. I went for this approach initially but then discussion came up about introducing ethtool_puts() which now made my patches (some accepted into next already) semi-outdated and in need of another swap from sprintf->puts() -- hence this series.
As far as the rebase, I simply took my commits and placed them on top of next/master and got merge conflicts when ethtool_puts() was placed below ethtool_sprintf(). All I have to do is move the hunks around but since I formatted the file it's appearing in the diff. v3 will be a clean diff.
[1]: https://lore.kernel.org/all/?q=dfb:ethtool_sprintf%20AND%20f:justinstitt
Thanks
Justin
PATCH v2 2/3 checkpatch: add ethtool_sprintf rules
In reply to Justin StittAdd some warnings for using ethtool_sprintf() where a simple ethtool_puts() would suffice.
The two cases are:
1) Use ethtool_sprintf() with just two arguments:
| ethtool_sprintf(&data, driver[i].name);
or
2) Use ethtool_sprintf() with a standalone "%s" fmt string:
| ethtool_sprintf(&data, "%s", driver[i].name);
The former may cause -Wformat-security warnings while the latter is just not preferred. Both are safely in the category of warnings, not errors.
--- scripts/checkpatch.pl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
scripts/checkpatch.pl +19 -0
@@ -7011,6 +7011,25 @@ sub process { "Prefer strscpy, strscpy_pad, or __nonstring over strncpy - see: https://github.com/KSPP/linux/issues/90\n" . $herecurr); } +# ethtool_sprintf uses that should likely be ethtool_puts + if ($line =~ /\bethtool_sprintf\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\)/) { + if(WARN("ETHTOOL_SPRINTF", + "Prefer ethtool_puts over ethtool_sprintf with only two arguments\n" . $herecurr) && + $fix) { + $fixed[$fixlinenr] =~ s/ethtool_sprintf\s*\(/ethtool_puts\(/; + } + } + + # use $rawline because $line loses %s via sanitization and thus we can't match against it. + if ($rawline =~ /\bethtool_sprintf\s*\(\s*$FuncArg\s*,\s*\"\%s\"\s*,\s*$FuncArg\s*\)/) { + if(WARN("ETHTOOL_SPRINTF", + "Prefer ethtool_puts over ethtool_sprintf with standalone \"%s\" specifier\n" . $herecurr) && + $fix) { + $fixed[$fixlinenr] =~ s/ethtool_sprintf\s*\(\s*(.*?),.*?,(.*?)\)/ethtool_puts\($1,$2)/; + } + } + + # typecasts on min/max could be min_t/max_t if ($perl_version_ok && defined $stat &&
Signature · 1 line
2.42.0.820.g83a721a137-goog
Vladimir Oltean
maintainerRe: [PATCH next v2 2/3] checkpatch: add ethtool_sprintf rules
Quoted 53 lines · Justin Stitt
Add some warnings for using
ethtool_sprintf()where a simpleethtool_puts()would suffice.The two cases are:
1) Use
ethtool_sprintf()with just two arguments:
|ethtool_sprintf(&data, driver[i].name);
or
2) Useethtool_sprintf()with a standalone "%s" fmt string:
|ethtool_sprintf(&data, "%s", driver[i].name);The former may cause -Wformat-security warnings while the latter is just not preferred. Both are safely in the category of warnings, not errors.
Signed-off-by Justin Stitt <[email protected]>--- scripts/checkpatch.pl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)scripts/checkpatch.pl +19
-0@@ -7011,6 +7011,25 @@ sub process { "Prefer strscpy, strscpy_pad, or __nonstring over strncpy - see: https://github.com/KSPP/linux/issues/90\n" . $herecurr); } +# ethtool_sprintf uses that should likely be ethtool_puts + if ($line =~ /\bethtool_sprintf\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\)/) { + if(WARN("ETHTOOL_SPRINTF", + "Prefer ethtool_puts over ethtool_sprintf with only two arguments\n" . $herecurr) && + $fix) { + $fixed[$fixlinenr] =~ s/ethtool_sprintf\s*\(/ethtool_puts\(/; + } + } + + # use $rawline because $line loses %s via sanitization and thus we can't match against it. + if ($rawline =~ /\bethtool_sprintf\s*\(\s*$FuncArg\s*,\s*\"\%s\"\s*,\s*$FuncArg\s*\)/) { + if(WARN("ETHTOOL_SPRINTF", + "Prefer ethtool_puts over ethtool_sprintf with standalone \"%s\" specifier\n" . $herecurr) && + $fix) { + $fixed[$fixlinenr] =~ s/ethtool_sprintf\s*\(\s*(.*?),.*?,(.*?)\)/ethtool_puts\($1,$2)/; + } + } + + # typecasts on min/max could be min_t/max_t if ($perl_version_ok && defined $stat &&Signature · 2 lines
-- 2.42.0.820.g83a721a137-goog
I don't really know Perl, but does the indentation and coding style here conform to any rules, or is it just free-form? The rest of the script looks almost as you'd expect from C. This is unreadable to me.
Re: [PATCH next v2 2/3] checkpatch: add ethtool_sprintf rules
Quoted 52 lines · Vladimir Oltean
Quoted 50 lines · Justin Stitt
Add some warnings for using
ethtool_sprintf()where a simpleethtool_puts()would suffice.The two cases are:
1) Use
ethtool_sprintf()with just two arguments:
|ethtool_sprintf(&data, driver[i].name);
or
2) Useethtool_sprintf()with a standalone "%s" fmt string:
|ethtool_sprintf(&data, "%s", driver[i].name);The former may cause -Wformat-security warnings while the latter is just not preferred. Both are safely in the category of warnings, not errors.
Signed-off-by Justin Stitt <[email protected]>--- scripts/checkpatch.pl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)scripts/checkpatch.pl +19
-0@@ -7011,6 +7011,25 @@ sub process { "Prefer strscpy, strscpy_pad, or __nonstring over strncpy - see: https://github.com/KSPP/linux/issues/90\n" . $herecurr); } +# ethtool_sprintf uses that should likely be ethtool_puts + if ($line =~ /\bethtool_sprintf\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\)/) { + if(WARN("ETHTOOL_SPRINTF", + "Prefer ethtool_puts over ethtool_sprintf with only two arguments\n" . $herecurr) && + $fix) { + $fixed[$fixlinenr] =~ s/ethtool_sprintf\s*\(/ethtool_puts\(/; + } + } + + # use $rawline because $line loses %s via sanitization and thus we can't match against it. + if ($rawline =~ /\bethtool_sprintf\s*\(\s*$FuncArg\s*,\s*\"\%s\"\s*,\s*$FuncArg\s*\)/) { + if(WARN("ETHTOOL_SPRINTF", + "Prefer ethtool_puts over ethtool_sprintf with standalone \"%s\" specifier\n" . $herecurr) && + $fix) { + $fixed[$fixlinenr] =~ s/ethtool_sprintf\s*\(\s*(.*?),.*?,(.*?)\)/ethtool_puts\($1,$2)/; + } + } + + # typecasts on min/max could be min_t/max_t if ($perl_version_ok && defined $stat &&
Quoted 7 lines
Quoted 3 lines
--
2.42.0.820.g83a721a137-googI don't really know Perl, but does the indentation and coding style here conform to any rules, or is it just free-form? The rest of the script looks almost as you'd expect from C. This is unreadable to me.
There was some discussion here [1] but AFAICT I need to use EMACS or configure my vim in a very particular way to get the same formatting
But yeah, look around line 7000 -- lots of this pattern matching code is pretty hard to read. Not sure there's much to be done as far as readability is concerned.
[1]: https://lore.kernel.org/all/[email protected]/
Thanks
Justin
Vladimir Oltean
maintainerRe: [PATCH next v2 2/3] checkpatch: add ethtool_sprintf rules
Quoted 8 lines · Justin Stitt
There was some discussion here [1] but AFAICT I need to use EMACS or configure my vim in a very particular way to get the same formatting
But yeah, look around line 7000 -- lots of this pattern matching code is pretty hard to read. Not sure there's much to be done as far as readability is concerned.
Hard to read because of pattern matching is one thing, but your indentation is unlike anything else in this file. There are inner curly brackets which are less indented than the outer curly brackets. I cannot read/review this, sorry, I hope somebody else can.
Joe Perches
maintainerRe: [PATCH next v2 2/3] checkpatch: add ethtool_sprintf rules
In reply to Justin StittQuoted 2 lines · Justin Stitt
Add some warnings for using
ethtool_sprintf()where a simpleethtool_puts()would suffice.
[]
scripts/checkpatch.pl
Quoted 1 line
scripts/checkpatch.pl +0
-0
[]
Quoted 9 lines
scripts/checkpatch.pl +5
-0@@ -7011,6 +7011,25 @@ sub process { "Prefer strscpy, strscpy_pad, or __nonstring over strncpy - see: https://github.com/KSPP/linux/issues/90\n" . $herecurr); } +# ethtool_sprintf uses that should likely be ethtool_puts + if ($line =~ /\bethtool_sprintf\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\)/) { + if(WARN("ETHTOOL_SPRINTF", + "Prefer ethtool_puts over ethtool_sprintf with only two arguments\n" . $herecurr) && + $fix) {
scripts/checkpatch.pl sub process { · line 7028
Quoted 10 lines
scripts/checkpatch.pl +10
-0+ $fixed[$fixlinenr] =~ s/ethtool_sprintf\s*\(/ethtool_puts\(/; + } + } + + # use $rawline because $line loses %s via sanitization and thus we can't match against it. + if ($rawline =~ /\bethtool_sprintf\s*\(\s*$FuncArg\s*,\s*\"\%s\"\s*,\s*$FuncArg\s*\)/) { + if(WARN("ETHTOOL_SPRINTF", + "Prefer ethtool_puts over ethtool_sprintf with standalone \"%s\" specifier\n" . $herecurr) && + $fix) { + $fixed[$fixlinenr] =~ s/ethtool_sprintf\s*\(\s*(.*?),.*?,(.*?)\)/ethtool_puts\($1,$2)/;
Thanks, but:
This fix wouldn't work if the first argument was itself a function with multiple arguments.
And this is whitespace formatted incorrectly.
It:
o needs a space after if
o needs a space after the comma in the fix
o needs to use the appropriate amount and tabs for indentation
o needs alignment to open parentheses
o the backslashes are not required in the fix block
Do you want me to push what I wrote in the link below?
https://lore.kernel.org/lkml/[email protected]/
Quoted 8 lines
scripts/checkpatch.pl +4
-0+ } + } + + # typecasts on min/max could be min_t/max_t if ($perl_version_ok && defined $stat &&
Re: [PATCH next v2 2/3] checkpatch: add ethtool_sprintf rules
Quoted 36 lines · Joe Perches
Quoted 2 lines · Justin Stitt
Add some warnings for using
ethtool_sprintf()where a simpleethtool_puts()would suffice.[]
scripts/checkpatch.pl
Quoted 1 line
scripts/checkpatch.pl +0
-0[]
Quoted 9 lines
scripts/checkpatch.pl +5
-0@@ -7011,6 +7011,25 @@ sub process { "Prefer strscpy, strscpy_pad, or __nonstring over strncpy - see: https://github.com/KSPP/linux/issues/90\n" . $herecurr); } +# ethtool_sprintf uses that should likely be ethtool_puts + if ($line =~ /\bethtool_sprintf\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\)/) { + if(WARN("ETHTOOL_SPRINTF", + "Prefer ethtool_puts over ethtool_sprintf with only two arguments\n" . $herecurr) && + $fix) {scripts/checkpatch.pl sub process { · line 7028
Quoted 10 lines
scripts/checkpatch.pl +10
-0+ $fixed[$fixlinenr] =~ s/ethtool_sprintf\s*\(/ethtool_puts\(/; + } + } + + # use $rawline because $line loses %s via sanitization and thus we can't match against it. + if ($rawline =~ /\bethtool_sprintf\s*\(\s*$FuncArg\s*,\s*\"\%s\"\s*,\s*$FuncArg\s*\)/) { + if(WARN("ETHTOOL_SPRINTF", + "Prefer ethtool_puts over ethtool_sprintf with standalone \"%s\" specifier\n" . $herecurr) && + $fix) { + $fixed[$fixlinenr] =~ s/ethtool_sprintf\s*\(\s*(.*?),.*?,(.*?)\)/ethtool_puts\($1,$2)/;Thanks, but:
This fix wouldn't work if the first argument was itself a function with multiple arguments.
And this is whitespace formatted incorrectly.
It:
Quoted 8 lines
o needs a space after if
o needs a space after the comma in the fix
o needs to use the appropriate amount and tabs for indentation
o needs alignment to open parentheses
o the backslashes are not required in the fix blockDo you want me to push what I wrote in the link below?
https://lore.kernel.org/lkml/[email protected]/
Ah, I didn't see you provided a diff in previous thread.
Yeah you can push it but it's not really a standalone so perhaps I'll just steal the diff and
wrap into v3?
Quoted 10 lines
scripts/checkpatch.pl sub process { · line 7035
Quoted 9 lines
scripts/checkpatch.pl +4
-0+ } + } + + # typecasts on min/max could be min_t/max_t if ($perl_version_ok && defined $stat &&
Thanks
Justin
Joe Perches
maintainerRe: [PATCH next v2 2/3] checkpatch: add ethtool_sprintf rules
Quoted 3 lines · Justin Stitt
Yeah you can push it but it's not really a standalone so perhaps I'll just steal the diff and
wrap into v3?
Fine by me.
No need for my sign off.
PATCH v2 3/3 treewide: Convert some ethtool_sprintf() to ethtool_puts()
In reply to Justin StittThis patch converts some basic cases of ethtool_sprintf() to ethtool_puts().
The conversions are used in cases where ethtool_sprintf() was being used with just two arguments:
| ethtool_sprintf(&data, buffer[i].name);
or when it's used with format string: "%s"
| ethtool_sprintf(&data, "%s", buffer[i].name);
which both now become:
| ethtool_puts(&data, buffer[i].name);
--- drivers/net/dsa/lantiq_gswip.c | 2 +- drivers/net/dsa/mt7530.c | 2 +- drivers/net/dsa/qca/qca8k-common.c | 2 +- drivers/net/dsa/realtek/rtl8365mb.c | 2 +- drivers/net/dsa/realtek/rtl8366-core.c | 2 +- drivers/net/dsa/vitesse-vsc73xx-core.c | 8 +-- drivers/net/ethernet/amazon/ena/ena_ethtool.c | 4 +- drivers/net/ethernet/brocade/bna/bnad_ethtool.c | 2 +- drivers/net/ethernet/freescale/fec_main.c | 4 +- .../net/ethernet/fungible/funeth/funeth_ethtool.c | 8 +-- drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c | 2 +- .../net/ethernet/hisilicon/hns/hns_dsaf_xgmac.c | 2 +- drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 65 +++++++++++----------- drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 6 +- drivers/net/ethernet/intel/iavf/iavf_ethtool.c | 3 +- drivers/net/ethernet/intel/ice/ice_ethtool.c | 9 +-- drivers/net/ethernet/intel/idpf/idpf_ethtool.c | 2 +- drivers/net/ethernet/intel/igb/igb_ethtool.c | 6 +- drivers/net/ethernet/intel/igc/igc_ethtool.c | 6 +- drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 5 +- .../net/ethernet/microchip/sparx5/sparx5_ethtool.c | 2 +- .../net/ethernet/netronome/nfp/nfp_net_ethtool.c | 44 +++++++-------- drivers/net/ethernet/pensando/ionic/ionic_stats.c | 4 +- drivers/net/ethernet/wangxun/libwx/wx_ethtool.c | 2 +- drivers/net/hyperv/netvsc_drv.c | 4 +- drivers/net/phy/nxp-tja11xx.c | 2 +- drivers/net/phy/smsc.c | 2 +- drivers/net/vmxnet3/vmxnet3_ethtool.c | 10 ++-- 28 files changed, 100 insertions(+), 112 deletions(-)
drivers/net/dsa/lantiq_gswip.c +1 -1
@@ -1759,7 +1759,7 @@ static void gswip_get_strings(struct dsa_switch *ds, int port, u32 stringset,return ;for (i =0 ; i <ARRAY_SIZE (gswip_rmon_cnt); i++) -ethtool_sprintf (&data,"%s" , gswip_rmon_cnt[i].name); +ethtool_puts (&data, gswip_rmon_cnt[i].name); } static u32 gswip_bcm_ram_entry_read(struct gswip_priv *priv, u32 table,
drivers/net/dsa/mt7530.c +1 -1
@@ -836,7 +836,7 @@ mt7530_get_strings(struct dsa_switch *ds, int port, u32 stringset,return ;for (i =0 ; i <ARRAY_SIZE (mt7530_mib); i++) -ethtool_sprintf (&data,"%s" , mt7530_mib[i].name); +ethtool_puts (&data, mt7530_mib[i].name); } static void
drivers/net/dsa/qca/qca8k-common.c +1 -1
@@ -487,7 +487,7 @@ void qca8k_get_strings(struct dsa_switch *ds, int port, u32 stringset,return ;for (i =0 ; i < priv->info->mib_count; i++) -ethtool_sprintf (&data,"%s" , ar8327_mib[i].name); +ethtool_puts (&data, ar8327_mib[i].name); } void qca8k_get_ethtool_stats(struct dsa_switch *ds, int port,
drivers/net/dsa/realtek/rtl8365mb.c +1 -1
@@ -1303,7 +1303,7 @@ static void rtl8365mb_get_strings(struct dsa_switch *ds, int port, u32 stringsetfor (i =0 ; i <RTL8365MB_MIB_END ; i++) {struct rtl8365mb_mib_counter *mib = &rtl8365mb_mib_counters[i]; -ethtool_sprintf (&data,"%s" , mib->name); +ethtool_puts (&data, mib->name); } }
drivers/net/dsa/realtek/rtl8366-core.c +1 -1
@@ -401,7 +401,7 @@ void rtl8366_get_strings(struct dsa_switch *ds, int port, u32 stringset,return ;for (i =0 ; i < priv->num_mib_counters; i++) -ethtool_sprintf (&data,"%s" , priv->mib_counters[i].name); +ethtool_puts (&data, priv->mib_counters[i].name); }EXPORT_SYMBOL_GPL (rtl8366_get_strings);
drivers/net/dsa/vitesse-vsc73xx-core.c +4 -4
@@ -949,7 +949,7 @@ static void vsc73xx_get_strings(struct dsa_switch *ds, int port, u32 stringset, indices[5 ] = ((val >>26 ) &0x1f );/* TX counter 2 */ /* The first counters is the RX octets */ -ethtool_sprintf (&buf,"RxEtherStatsOctets" ); +ethtool_puts (&buf,"RxEtherStatsOctets" );/* Each port supports recording 3 RX counters and 3 TX counters, * figure out what counters we use in this set-up and return the
@@ -959,15 +959,15 @@ static void vsc73xx_get_strings(struct dsa_switch *ds, int port, u32 stringset,*/ for (i =0 ; i <3 ; i++) { cnt =vsc73xx_find_counter (vsc, indices[i], false); -ethtool_sprintf (&buf,"%s" , cnt ? cnt->name :"" ); +ethtool_puts (&buf, cnt ? cnt->name :"" ); }/* TX stats begins with the number of TX octets */ -ethtool_sprintf (&buf,"TxEtherStatsOctets" ); +ethtool_puts (&buf,"TxEtherStatsOctets" );for (i =3 ; i <6 ; i++) { cnt =vsc73xx_find_counter (vsc, indices[i], true); -ethtool_sprintf (&buf,"%s" , cnt ? cnt->name :"" ); +ethtool_puts (&buf, cnt ? cnt->name :"" ); } }
drivers/net/ethernet/amazon/ena/ena_ethtool.c +2 -2
@@ -299,13 +299,13 @@ static void ena_get_strings(struct ena_adapter *adapter,for (i =0 ; i <ENA_STATS_ARRAY_GLOBAL ; i++) { ena_stats = &ena_stats_global_strings[i]; -ethtool_sprintf (&data, ena_stats->name); +ethtool_puts (&data, ena_stats->name); }if (eni_stats_needed) {for (i =0 ; i <ENA_STATS_ARRAY_ENI (adapter); i++) { ena_stats = &ena_stats_eni_strings[i]; -ethtool_sprintf (&data, ena_stats->name); +ethtool_puts (&data, ena_stats->name); } }
drivers/net/ethernet/brocade/bna/bnad_ethtool.c +1 -1
@@ -608,7 +608,7 @@ bnad_get_strings(struct net_device *netdev, u32 stringset, u8 *string)for (i =0 ; i <BNAD_ETHTOOL_STATS_NUM ; i++) {BUG_ON (!(strlen (bnad_net_stats_strings[i]) <ETH_GSTRING_LEN )); -ethtool_sprintf (&string, bnad_net_stats_strings[i]); +ethtool_puts (&string, bnad_net_stats_strings[i]); } bmap =bna_tx_rid_mask (&bnad->bna);
drivers/net/ethernet/freescale/fec_main.c +2 -2
@@ -2932,10 +2932,10 @@ static void fec_enet_get_strings(struct net_device *netdev,switch (stringset) {case ETH_SS_STATS :for (i =0 ; i <ARRAY_SIZE (fec_stats); i++) { -ethtool_sprintf (&data,"%s" , fec_stats[i].name); +ethtool_puts (&data, fec_stats[i].name); }for (i =0 ; i <ARRAY_SIZE (fec_xdp_stat_strs); i++) { -ethtool_sprintf (&data,"%s" , fec_xdp_stat_strs[i]); +ethtool_puts (&data, fec_xdp_stat_strs[i]); }page_pool_ethtool_stats_get_strings (data);
drivers/net/ethernet/fungible/funeth/funeth_ethtool.c +4 -4
@@ -655,7 +655,7 @@ static void fun_get_strings(struct net_device *netdev, u32 sset, u8 *data) i); }for (j =0 ; j <ARRAY_SIZE (txq_stat_names); j++) -ethtool_sprintf (&p, txq_stat_names[j]); +ethtool_puts (&p, txq_stat_names[j]);for (i =0 ; i < fp->num_xdpqs; i++) {for (j =0 ; j <ARRAY_SIZE (xdpq_stat_names); j++)
@@ -663,7 +663,7 @@ static void fun_get_strings(struct net_device *netdev, u32 sset, u8 *data) xdpq_stat_names[j], i); }for (j =0 ; j <ARRAY_SIZE (xdpq_stat_names); j++) -ethtool_sprintf (&p, xdpq_stat_names[j]); +ethtool_puts (&p, xdpq_stat_names[j]);for (i =0 ; i < netdev->real_num_rx_queues; i++) {for (j =0 ; j <ARRAY_SIZE (rxq_stat_names); j++)
@@ -671,10 +671,10 @@ static void fun_get_strings(struct net_device *netdev, u32 sset, u8 *data) i); }for (j =0 ; j <ARRAY_SIZE (rxq_stat_names); j++) -ethtool_sprintf (&p, rxq_stat_names[j]); +ethtool_puts (&p, rxq_stat_names[j]);for (j =0 ; j <ARRAY_SIZE (tls_stat_names); j++) -ethtool_sprintf (&p, tls_stat_names[j]); +ethtool_puts (&p, tls_stat_names[j]);break ;default :break ;
drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c +1 -1
@@ -678,7 +678,7 @@ static void hns_gmac_get_strings(u32 stringset, u8 *data)return ;for (i =0 ; i <ARRAY_SIZE (g_gmac_stats_string); i++) -ethtool_sprintf (&buff, g_gmac_stats_string[i].desc); +ethtool_puts (&buff, g_gmac_stats_string[i].desc); }static int hns_gmac_get_sset_count (int stringset)
drivers/net/ethernet/hisilicon/hns/hns_dsaf_xgmac.c +1 -1
@@ -752,7 +752,7 @@ static void hns_xgmac_get_strings(u32 stringset, u8 *data)return ;for (i =0 ; i <ARRAY_SIZE (g_xgmac_stats_string); i++) -ethtool_sprintf (&buff, g_xgmac_stats_string[i].desc); +ethtool_puts (&buff, g_xgmac_stats_string[i].desc); }/**
drivers/net/ethernet/hisilicon/hns/hns_ethtool.c +32 -33
74 lines not on this page · raw message
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +2 -4
@@ -2514,13 +2514,11 @@ static void i40e_get_priv_flag_strings(struct net_device *netdev, u8 *data)u8 *p = data;for (i =0 ; i <I40E_PRIV_FLAGS_STR_LEN ; i++) -ethtool_sprintf (&p,"%s" , - i40e_gstrings_priv_flags[i].flag_string); +ethtool_puts (&p, i40e_gstrings_priv_flags[i].flag_string);if (pf->hw.pf_id !=0 )return ;for (i =0 ; i <I40E_GL_PRIV_FLAGS_STR_LEN ; i++) -ethtool_sprintf (&p,"%s" , - i40e_gl_gstrings_priv_flags[i].flag_string); +ethtool_puts (&p, i40e_gl_gstrings_priv_flags[i].flag_string); } static void i40e_get_strings(struct net_device *netdev, u32 stringset,
drivers/net/ethernet/intel/iavf/iavf_ethtool.c +1 -2
@@ -396,8 +396,7 @@ static void iavf_get_priv_flag_strings(struct net_device *netdev, u8 *data)unsigned int i;for (i =0 ; i <IAVF_PRIV_FLAGS_STR_LEN ; i++) -ethtool_sprintf (&data,"%s" , - iavf_gstrings_priv_flags[i].flag_string); +ethtool_puts (&data, iavf_gstrings_priv_flags[i].flag_string); }/**
drivers/net/ethernet/intel/ice/ice_ethtool.c +3 -6
@@ -1133,8 +1133,7 @@ __ice_get_strings(struct net_device *netdev, u32 stringset, u8 *data,switch (stringset) {case ETH_SS_STATS :for (i =0 ; i <ICE_VSI_STATS_LEN ; i++) -ethtool_sprintf (&p,"%s" , - ice_gstrings_vsi_stats[i].stat_string); +ethtool_puts (&p, ice_gstrings_vsi_stats[i].stat_string);if (ice_is_port_repr_netdev (netdev))return ;
@@ -1153,8 +1152,7 @@ __ice_get_strings(struct net_device *netdev, u32 stringset, u8 *data,return ;for (i =0 ; i <ICE_PF_STATS_LEN ; i++) -ethtool_sprintf (&p,"%s" , - ice_gstrings_pf_stats[i].stat_string); +ethtool_puts (&p, ice_gstrings_pf_stats[i].stat_string);for (i =0 ; i <ICE_MAX_USER_PRIORITY ; i++) {ethtool_sprintf (&p,"tx_priority_%u_xon.nic" , i);
@@ -1170,8 +1168,7 @@ __ice_get_strings(struct net_device *netdev, u32 stringset, u8 *data,break ;case ETH_SS_PRIV_FLAGS :for (i =0 ; i <ICE_PRIV_FLAG_ARRAY_SIZE ; i++) -ethtool_sprintf (&p,"%s" , - ice_gstrings_priv_flags[i].name); +ethtool_puts (&p, ice_gstrings_priv_flags[i].name);break ;default :break ;
drivers/net/ethernet/intel/idpf/idpf_ethtool.c +1 -1
@@ -532,7 +532,7 @@ static void idpf_add_stat_strings(u8 **p, const struct idpf_stats *stats,unsigned int i;for (i =0 ; i < size; i++) -ethtool_sprintf (p,"%s" , stats[i].stat_string); +ethtool_puts (p, stats[i].stat_string); }/**
drivers/net/ethernet/intel/igb/igb_ethtool.c +2 -4
@@ -2356,11 +2356,9 @@ static void igb_get_strings(struct net_device *netdev, u32 stringset, u8 *data)break ;case ETH_SS_STATS :for (i =0 ; i <IGB_GLOBAL_STATS_LEN ; i++) -ethtool_sprintf (&p,"%s" , - igb_gstrings_stats[i].stat_string); +ethtool_puts (&p, igb_gstrings_stats[i].stat_string);for (i =0 ; i <IGB_NETDEV_STATS_LEN ; i++) -ethtool_sprintf (&p,"%s" , - igb_gstrings_net_stats[i].stat_string); +ethtool_puts (&p, igb_gstrings_net_stats[i].stat_string);for (i =0 ; i < adapter->num_tx_queues; i++) {ethtool_sprintf (&p,"tx_queue_%u_packets" , i);ethtool_sprintf (&p,"tx_queue_%u_bytes" , i);
drivers/net/ethernet/intel/igc/igc_ethtool.c +2 -4
@@ -773,11 +773,9 @@ static void igc_ethtool_get_strings(struct net_device *netdev, u32 stringset,break ;case ETH_SS_STATS :for (i =0 ; i <IGC_GLOBAL_STATS_LEN ; i++) -ethtool_sprintf (&p,"%s" , - igc_gstrings_stats[i].stat_string); +ethtool_puts (&p, igc_gstrings_stats[i].stat_string);for (i =0 ; i <IGC_NETDEV_STATS_LEN ; i++) -ethtool_sprintf (&p,"%s" , - igc_gstrings_net_stats[i].stat_string); +ethtool_puts (&p, igc_gstrings_net_stats[i].stat_string);for (i =0 ; i < adapter->num_tx_queues; i++) {ethtool_sprintf (&p,"tx_queue_%u_packets" , i);ethtool_sprintf (&p,"tx_queue_%u_bytes" , i);
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +2 -3
@@ -1413,12 +1413,11 @@ static void ixgbe_get_strings(struct net_device *netdev, u32 stringset,switch (stringset) {case ETH_SS_TEST :for (i =0 ; i <IXGBE_TEST_LEN ; i++) -ethtool_sprintf (&p,"%s" , ixgbe_gstrings_test[i]); +ethtool_puts (&p, ixgbe_gstrings_test[i]);break ;case ETH_SS_STATS :for (i =0 ; i <IXGBE_GLOBAL_STATS_LEN ; i++) -ethtool_sprintf (&p,"%s" , - ixgbe_gstrings_stats[i].stat_string); +ethtool_puts (&p, ixgbe_gstrings_stats[i].stat_string);for (i =0 ; i < netdev->num_tx_queues; i++) {ethtool_sprintf (&p,"tx_queue_%u_packets" , i);ethtool_sprintf (&p,"tx_queue_%u_bytes" , i);
drivers/net/ethernet/microchip/sparx5/sparx5_ethtool.c +1 -1
@@ -1012,7 +1012,7 @@ static void sparx5_get_sset_strings(struct net_device *ndev, u32 sset, u8 *data)return ;for (idx =0 ; idx < sparx5->num_ethtool_stats; idx++) -ethtool_sprintf (&data,"%s" , sparx5->stats_layout[idx]); +ethtool_puts (&data, sparx5->stats_layout[idx]); } static void sparx5_get_sset_data(struct net_device *ndev,
drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c +22 -22
66 lines not on this page · raw message
drivers/net/ethernet/pensando/ionic/ionic_stats.c +2 -2
@@ -258,10 +258,10 @@ static void ionic_sw_stats_get_strings(struct ionic_lif *lif, u8 **buf)int i, q_num;for (i =0 ; i <IONIC_NUM_LIF_STATS ; i++) -ethtool_sprintf (buf, ionic_lif_stats_desc[i].name); +ethtool_puts (buf, ionic_lif_stats_desc[i].name);for (i =0 ; i <IONIC_NUM_PORT_STATS ; i++) -ethtool_sprintf (buf, ionic_port_stats_desc[i].name); +ethtool_puts (buf, ionic_port_stats_desc[i].name);for (q_num =0 ; q_num <MAX_Q (lif); q_num++)ionic_sw_stats_get_tx_strings (lif, buf, q_num);
drivers/net/ethernet/wangxun/libwx/wx_ethtool.c +1 -1
@@ -75,7 +75,7 @@ void wx_get_strings(struct net_device *netdev, u32 stringset, u8 *data)switch (stringset) {case ETH_SS_STATS :for (i =0 ; i <WX_GLOBAL_STATS_LEN ; i++) -ethtool_sprintf (&p, wx_gstrings_stats[i].stat_string); +ethtool_puts (&p, wx_gstrings_stats[i].stat_string);for (i =0 ; i < netdev->num_tx_queues; i++) {ethtool_sprintf (&p,"tx_queue_%u_packets" , i);ethtool_sprintf (&p,"tx_queue_%u_bytes" , i);
drivers/net/hyperv/netvsc_drv.c +2 -2
@@ -1582,10 +1582,10 @@ static void netvsc_get_strings(struct net_device *dev, u32 stringset, u8 *data)switch (stringset) {case ETH_SS_STATS :for (i =0 ; i <ARRAY_SIZE (netvsc_stats); i++) -ethtool_sprintf (&p, netvsc_stats[i].name); +ethtool_puts (&p, netvsc_stats[i].name);for (i =0 ; i <ARRAY_SIZE (vf_stats); i++) -ethtool_sprintf (&p, vf_stats[i].name); +ethtool_puts (&p, vf_stats[i].name);for (i =0 ; i < nvdev->num_chn; i++) {ethtool_sprintf (&p,"tx_queue_%u_packets" , i);
drivers/net/phy/nxp-tja11xx.c +1 -1
@@ -415,7 +415,7 @@ static void tja11xx_get_strings(struct phy_device *phydev, u8 *data)int i;for (i =0 ; i <ARRAY_SIZE (tja11xx_hw_stats); i++) -ethtool_sprintf (&data,"%s" , tja11xx_hw_stats[i].string); +ethtool_puts (&data, tja11xx_hw_stats[i].string); } static void tja11xx_get_stats(struct phy_device *phydev,
drivers/net/phy/smsc.c +1 -1
@@ -508,7 +508,7 @@ static void smsc_get_strings(struct phy_device *phydev, u8 *data)int i;for (i =0 ; i <ARRAY_SIZE (smsc_hw_stats); i++) -ethtool_sprintf (&data,"%s" , smsc_hw_stats[i].string); +ethtool_puts (&data, smsc_hw_stats[i].string); }static u64 smsc_get_stat (struct phy_device *phydev,int i)
drivers/net/vmxnet3/vmxnet3_ethtool.c +5 -5
@@ -245,20 +245,20 @@ vmxnet3_get_strings(struct net_device *netdev, u32 stringset, u8 *buf)for (j =0 ; j < adapter->num_tx_queues; j++) {for (i =0 ; i <ARRAY_SIZE (vmxnet3_tq_dev_stats); i++) -ethtool_sprintf (&buf, vmxnet3_tq_dev_stats[i].desc); +ethtool_puts (&buf, vmxnet3_tq_dev_stats[i].desc);for (i =0 ; i <ARRAY_SIZE (vmxnet3_tq_driver_stats); i++) -ethtool_sprintf (&buf, vmxnet3_tq_driver_stats[i].desc); +ethtool_puts (&buf, vmxnet3_tq_driver_stats[i].desc); }for (j =0 ; j < adapter->num_rx_queues; j++) {for (i =0 ; i <ARRAY_SIZE (vmxnet3_rq_dev_stats); i++) -ethtool_sprintf (&buf, vmxnet3_rq_dev_stats[i].desc); +ethtool_puts (&buf, vmxnet3_rq_dev_stats[i].desc);for (i =0 ; i <ARRAY_SIZE (vmxnet3_rq_driver_stats); i++) -ethtool_sprintf (&buf, vmxnet3_rq_driver_stats[i].desc); +ethtool_puts (&buf, vmxnet3_rq_driver_stats[i].desc); }for (i =0 ; i <ARRAY_SIZE (vmxnet3_global_stats); i++) -ethtool_sprintf (&buf, vmxnet3_global_stats[i].desc); +ethtool_puts (&buf, vmxnet3_global_stats[i].desc); } netdev_features_t vmxnet3_fix_features(struct net_device *netdev,
Signature · 1 line
2.42.0.820.g83a721a137-goog
Vladimir Oltean
maintainerRe: [PATCH next v2 3/3] treewide: Convert some ethtool_sprintf() to ethtool_puts()
Quoted 34 lines · Justin Stitt
This patch converts some basic cases of
ethtool_sprintf()toethtool_puts().The conversions are used in cases where
ethtool_sprintf()was being used with just two arguments:
|ethtool_sprintf(&data, buffer[i].name);
or when it's used with format string: "%s"
|ethtool_sprintf(&data, "%s", buffer[i].name);
which both now become:
|ethtool_puts(&data, buffer[i].name);Signed-off-by Justin Stitt <[email protected]>--- drivers/net/dsa/lantiq_gswip.c | 2 +- drivers/net/dsa/mt7530.c | 2 +- drivers/net/dsa/qca/qca8k-common.c | 2 +- drivers/net/dsa/realtek/rtl8365mb.c | 2 +- drivers/net/dsa/realtek/rtl8366-core.c | 2 +- drivers/net/dsa/vitesse-vsc73xx-core.c | 8 +-- drivers/net/ethernet/amazon/ena/ena_ethtool.c | 4 +- drivers/net/ethernet/brocade/bna/bnad_ethtool.c | 2 +- drivers/net/ethernet/freescale/fec_main.c | 4 +- .../net/ethernet/fungible/funeth/funeth_ethtool.c | 8 +-- drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c | 2 +- .../net/ethernet/hisilicon/hns/hns_dsaf_xgmac.c | 2 +- drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 65 +++++++++++----------- drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 6 +- drivers/net/ethernet/intel/iavf/iavf_ethtool.c | 3 +- drivers/net/ethernet/intel/ice/ice_ethtool.c | 9 +-- drivers/net/ethernet/intel/idpf/idpf_ethtool.c | 2 +- drivers/net/ethernet/intel/igb/igb_ethtool.c | 6 +- drivers/net/ethernet/intel/igc/igc_ethtool.c | 6 +- drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 5 +- .../net/ethernet/microchip/sparx5/sparx5_ethtool.c | 2 +-
Quoted 8 lines
.../net/ethernet/netronome/nfp/nfp_net_ethtool.c | 44 +++++++-------- drivers/net/ethernet/pensando/ionic/ionic_stats.c | 4 +- drivers/net/ethernet/wangxun/libwx/wx_ethtool.c | 2 +- drivers/net/hyperv/netvsc_drv.c | 4 +- drivers/net/phy/nxp-tja11xx.c | 2 +- drivers/net/phy/smsc.c | 2 +- drivers/net/vmxnet3/vmxnet3_ethtool.c | 10 ++-- 28 files changed, 100 insertions(+), 112 deletions(-)
What's the "next" branch that you expect this to be applied through, and why is the patch "treewide"? It only affects networking drivers (I see nothing outside of drivers/net/) - so it's "net: Convert ..." and it should go through the "net-next.git" tree. The patch should be formatted as "PATCH net-next" not "PATCH next", to make this absolutely clear.
Andrew Lunn
maintainerQuoted 5 lines
Changes in v2:
- wrap lines better in replacement (thanks Joe, Kees)
- add --fix to checkpatch (thanks Joe)
- clean up checkpatch formatting (thanks Joe, et al.)
- rebase against next
Please could you explain the rebase against next? As Vladimir pointed out, all the patches are to drivers/net, so anything in flight should be in net-next, merged by the netdev Maintainers.
Andrew
Quoted 10 lines · Andrew Lunn
Quoted 6 lines
Changes in v2:
- wrap lines better in replacement (thanks Joe, Kees)
- add --fix to checkpatch (thanks Joe)
- clean up checkpatch formatting (thanks Joe, et al.)
- rebase against nextPlease could you explain the rebase against next? As Vladimir pointed out, all the patches are to
drivers/net, so anything in flight should be in net-next, merged by the netdev Maintainers.
OK, should v3 be against net-next? I opted for next as a catch-all.
Quoted 2 lines
Andrew
Thanks
Justin