Re: [PATCH] net: marvell: Use min() instead of doing it manually

From: Heiner Kallweit
Date: Tue Mar 01 2022 - 02:33:50 EST


On 01.03.2022 07:16, Haowen Bai wrote:
> Fix following coccicheck warning:
> drivers/net/ethernet/marvell/mv643xx_eth.c:1664:35-36: WARNING opportunity for min()
>
> Signed-off-by: Haowen Bai <baihaowen88@xxxxxxxxx>
> ---
> drivers/net/ethernet/marvell/mv643xx_eth.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
> index 143ca8b..1018b9e 100644
> --- a/drivers/net/ethernet/marvell/mv643xx_eth.c
> +++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
> @@ -1661,7 +1661,7 @@ mv643xx_eth_set_ringparam(struct net_device *dev, struct ethtool_ringparam *er,
> if (er->rx_mini_pending || er->rx_jumbo_pending)
> return -EINVAL;
>
> - mp->rx_ring_size = er->rx_pending < 4096 ? er->rx_pending : 4096;
> + mp->rx_ring_size = min(er->rx_pending, 4096);

Did you test this? Supposedly it won't compile cleanly due to the
min macro type checking (rx_pending is __u32, 4096 is int).

> mp->tx_ring_size = clamp_t(unsigned int, er->tx_pending,
> MV643XX_MAX_SKB_DESCS * 2, 4096);
> if (mp->tx_ring_size != er->tx_pending)