Re: [PATCH 0/3] ethtool: Add ethtool_puts()

2023-10-26 Thread Joe Perches
On Thu, 2023-10-26 at 10:49 -0700, Kees Cook wrote:
> On Thu, Oct 26, 2023 at 09:33:17AM -0700, Joe Perches wrote:
> > On Thu, 2023-10-26 at 08:47 -0700, Kees Cook wrote:
> > > On Wed, Oct 25, 2023 at 11:40:31PM +, Justin Stitt wrote:
> > > > @replace_2_args@
> > > > identifier BUF;
> > > > expression VAR;
> > > > @@
> > > > 
> > > > -   ethtool_sprintf
> > > > +   ethtool_puts
> > > > (, VAR)
> > > 
> > > I think cocci will do a better job at line folding if we adjust this
> > > rule like I had to adjust the next rule: completely remove and re-add
> > > the arguments:
> > > 
> > > -   ethtool_sprintf(, VAR)
> > > +   ethtool_puts(, VAR)
> > > 
> > > Then I think the handful of weird line wraps in the treewide patch will
> > > go away.
> > > 
> > 
> > Perhaps this, but i believe spatch needs
> >  --max-width=80
> > to fill all 80 columns
> 
> Ah, yeah. Default is 78. Current coding style max is 100... I'll adjust
> my local wrappers.

Coding style max is still 80 with exceptions allowed to 100
not a generic use of 100.





Re: [PATCH 0/3] ethtool: Add ethtool_puts()

2023-10-26 Thread Kees Cook
On Thu, Oct 26, 2023 at 09:33:17AM -0700, Joe Perches wrote:
> On Thu, 2023-10-26 at 08:47 -0700, Kees Cook wrote:
> > On Wed, Oct 25, 2023 at 11:40:31PM +, Justin Stitt wrote:
> > > @replace_2_args@
> > > identifier BUF;
> > > expression VAR;
> > > @@
> > > 
> > > -   ethtool_sprintf
> > > +   ethtool_puts
> > > (, VAR)
> > 
> > I think cocci will do a better job at line folding if we adjust this
> > rule like I had to adjust the next rule: completely remove and re-add
> > the arguments:
> > 
> > -   ethtool_sprintf(, VAR)
> > +   ethtool_puts(, VAR)
> > 
> > Then I think the handful of weird line wraps in the treewide patch will
> > go away.
> > 
> 
> Perhaps this, but i believe spatch needs
>--max-width=80
> to fill all 80 columns

Ah, yeah. Default is 78. Current coding style max is 100... I'll adjust
my local wrappers.

-- 
Kees Cook



Re: [PATCH 0/3] ethtool: Add ethtool_puts()

2023-10-26 Thread Joe Perches
On Thu, 2023-10-26 at 08:47 -0700, Kees Cook wrote:
> On Wed, Oct 25, 2023 at 11:40:31PM +, Justin Stitt wrote:
> > @replace_2_args@
> > identifier BUF;
> > expression VAR;
> > @@
> > 
> > -   ethtool_sprintf
> > +   ethtool_puts
> > (, VAR)
> 
> I think cocci will do a better job at line folding if we adjust this
> rule like I had to adjust the next rule: completely remove and re-add
> the arguments:
> 
> -   ethtool_sprintf(, VAR)
> +   ethtool_puts(, VAR)
> 
> Then I think the handful of weird line wraps in the treewide patch will
> go away.
> 

Perhaps this, but i believe spatch needs
 --max-width=80
to fill all 80 columns

$ cat ethtool_puts.cocci
@@
expression a, b;
@@

-   ethtool_sprintf(a, b)
+   ethtool_puts(a, b)

@@
expression a, b;
@@

-   ethtool_sprintf(a, "%s", b)
+   ethtool_puts(a, b)

$ spatch -sp-file ethtool_puts.cocci --in-place --max-width=80 drivers/net
$ git diff --stat -p drivers/net
 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(-)

diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c
index 1a2d5797bf98c..ff67bbf5a789b 100644
--- a/drivers/net/dsa/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq_gswip.c
@@ -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(, "%s", gswip_rmon_cnt[i].name);
+   ethtool_puts(, gswip_rmon_cnt[i].name);
 }
 
 static u32 gswip_bcm_ram_entry_read(struct gswip_priv *priv, u32 table,
diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index ecf5d3deb36eb..3c2cce442facf 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -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(, "%s", mt7530_mib[i].name);
+   ethtool_puts(, mt7530_mib[i].name);
 }
 
 static void
diff --git a/drivers/net/dsa/qca/qca8k-common.c 
b/drivers/net/dsa/qca/qca8k-common.c
index 9ff0a3c1cb91d..94a949e27445f 100644
--- a/drivers/net/dsa/qca/qca8k-common.c
+++ b/drivers/net/dsa/qca/qca8k-common.c
@@ -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(, "%s", ar8327_mib[i].name);
+   ethtool_puts(, ar8327_mib[i].name);
 }
 
 void qca8k_get_ethtool_stats(struct dsa_switch *ds, int port,
diff --git a/drivers/net/dsa/realtek/rtl8365mb.c 
b/drivers/net/dsa/realtek/rtl8365mb.c
index d171c18dd354c..ba0bafaca9aa9 100644
--- a/drivers/net/dsa/realtek/rtl8365mb.c
+++ b/drivers/net/dsa/realtek/rtl8365mb.c
@@ -1303,7 +1303,7 @@ static void rtl8365mb_get_strings(struct dsa_switch *ds, 
int port, u32 stringset
 
for (i = 0; i < RTL8365MB_MIB_END; i++) {
struct rtl8365mb_mib_counter *mib = _mib_counters[i];
-   ethtool_sprintf(, "%s", mib->name);
+   ethtool_puts(, mib->name);
}
 }
 
diff --git a/drivers/net/dsa/realtek/rtl8366-core.c 
b/drivers/net/dsa/realtek/rtl8366-core.c

Re: [PATCH 0/3] ethtool: Add ethtool_puts()

2023-10-26 Thread Kees Cook
On Wed, Oct 25, 2023 at 11:40:31PM +, Justin Stitt wrote:
> @replace_2_args@
> identifier BUF;
> expression VAR;
> @@
> 
> -   ethtool_sprintf
> +   ethtool_puts
> (, VAR)

I think cocci will do a better job at line folding if we adjust this
rule like I had to adjust the next rule: completely remove and re-add
the arguments:

-   ethtool_sprintf(, VAR)
+   ethtool_puts(, VAR)

Then I think the handful of weird line wraps in the treewide patch will
go away.

-- 
Kees Cook