Message ID | 20240827084005.3815912-1-yanzhen@vivo.com (mailing list archive) |
---|---|
State | Rejected |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [v1] netronome: nfp: Use min macro | expand |
On Tue, 27 Aug 2024 16:40:05 +0800 Yan Zhen wrote: > Using min macro not only makes the code more concise and readable > but also improves efficiency sometimes. The code is fine, you're making it worse. How many of those pointless min()/max() conversions do you have for drivers/net ?
From: Jakub Kicinski > Sent: 27 August 2024 15:24 > > On Tue, 27 Aug 2024 16:40:05 +0800 Yan Zhen wrote: > > Using min macro not only makes the code more concise and readable > > but also improves efficiency sometimes. > > The code is fine, you're making it worse. > > How many of those pointless min()/max() conversions do you have > for drivers/net ? Maybe someone who understands cochineal should change the pattern so that is require one of the 'arguments' to be non-trivial. (or perhaps just delete the script ;-) David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c index 182ba0a8b095..e6cb255ac914 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c @@ -2857,10 +2857,8 @@ int nfp_net_init(struct nfp_net *nn) /* Set default MTU and Freelist buffer size */ if (!nfp_net_is_data_vnic(nn) && nn->app->ctrl_mtu) { nn->dp.mtu = min(nn->app->ctrl_mtu, nn->max_mtu); - } else if (nn->max_mtu < NFP_NET_DEFAULT_MTU) { - nn->dp.mtu = nn->max_mtu; } else { - nn->dp.mtu = NFP_NET_DEFAULT_MTU; + nn->dp.mtu = min(nn->max_mtu, NFP_NET_DEFAULT_MTU); } nn->dp.fl_bufsz = nfp_net_calc_fl_bufsz(&nn->dp); diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp_eth.c b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp_eth.c index 5cfddc9a5d87..3d7225cb24aa 100644 --- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp_eth.c +++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp_eth.c @@ -412,7 +412,7 @@ int nfp_eth_config_commit_end(struct nfp_nsp *nsp) if (nfp_nsp_config_modified(nsp)) { ret = nfp_nsp_write_eth_table(nsp, entries, NSP_ETH_TABLE_SIZE); - ret = ret < 0 ? ret : 0; + ret = min(ret, 0); } nfp_eth_config_cleanup_end(nsp);
Using min macro not only makes the code more concise and readable but also improves efficiency sometimes. Signed-off-by: Yan Zhen <yanzhen@vivo.com> --- drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 4 +--- drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp_eth.c | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-)