netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: mvneta: use min() to make code cleaner
@ 2021-12-20 11:36 cgel.zte
  2021-12-23  2:54 ` kernel test robot
  0 siblings, 1 reply; 2+ messages in thread
From: cgel.zte @ 2021-12-20 11:36 UTC (permalink / raw)
  To: thomas.petazzoni
  Cc: davem, kuba, netdev, linux-kernel, Changcheng Deng, Zeal Robot

From: Changcheng Deng <deng.changcheng@zte.com.cn>

Use min() in order to make code cleaner.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Changcheng Deng <deng.changcheng@zte.com.cn>
---
 drivers/net/ethernet/marvell/mvneta.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 83c8908f0cc7..cf1319fe7b0f 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -4634,8 +4634,7 @@ mvneta_ethtool_set_ringparam(struct net_device *dev,
 
 	if ((ring->rx_pending == 0) || (ring->tx_pending == 0))
 		return -EINVAL;
-	pp->rx_ring_size = ring->rx_pending < MVNETA_MAX_RXD ?
-		ring->rx_pending : MVNETA_MAX_RXD;
+	pp->rx_ring_size = min(ring->rx_pending, MVNETA_MAX_RXD);
 
 	pp->tx_ring_size = clamp_t(u16, ring->tx_pending,
 				   MVNETA_MAX_SKB_DESCS * 2, MVNETA_MAX_TXD);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: mvneta: use min() to make code cleaner
  2021-12-20 11:36 [PATCH] net: mvneta: use min() to make code cleaner cgel.zte
@ 2021-12-23  2:54 ` kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2021-12-23  2:54 UTC (permalink / raw)
  To: cgel.zte, thomas.petazzoni
  Cc: kbuild-all, davem, kuba, netdev, linux-kernel, Changcheng Deng,
	Zeal Robot

Hi,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]
[also build test WARNING on net/master horms-ipvs/master linus/master v5.16-rc6 next-20211222]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/cgel-zte-gmail-com/net-mvneta-use-min-to-make-code-cleaner/20211220-193846
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 434ed21389948a45c238f63258bd5aae4237e20b
config: sh-randconfig-s032-20211222 (https://download.01.org/0day-ci/archive/20211223/202112231021.c93ilPDO-lkp@intel.com/config)
compiler: sh4-linux-gcc (GCC) 11.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.4-dirty
        # https://github.com/0day-ci/linux/commit/be0462f87c94afd5304c286f4b7041e92f5df0bd
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review cgel-zte-gmail-com/net-mvneta-use-min-to-make-code-cleaner/20211220-193846
        git checkout be0462f87c94afd5304c286f4b7041e92f5df0bd
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=sh SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)
   drivers/net/ethernet/marvell/mvneta.c:1787:25: sparse: sparse: restricted __be16 degrades to integer
   drivers/net/ethernet/marvell/mvneta.c:1969:45: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected int l3_proto @@     got restricted __be16 [usertype] l3_proto @@
   drivers/net/ethernet/marvell/mvneta.c:1969:45: sparse:     expected int l3_proto
   drivers/net/ethernet/marvell/mvneta.c:1969:45: sparse:     got restricted __be16 [usertype] l3_proto
>> drivers/net/ethernet/marvell/mvneta.c:4637:28: sparse: sparse: incompatible types in comparison expression (different signedness):
>> drivers/net/ethernet/marvell/mvneta.c:4637:28: sparse:    unsigned int *
>> drivers/net/ethernet/marvell/mvneta.c:4637:28: sparse:    int *

vim +4637 drivers/net/ethernet/marvell/mvneta.c

  4626	
  4627	static int
  4628	mvneta_ethtool_set_ringparam(struct net_device *dev,
  4629				     struct ethtool_ringparam *ring,
  4630				     struct kernel_ethtool_ringparam *kernel_ring,
  4631				     struct netlink_ext_ack *extack)
  4632	{
  4633		struct mvneta_port *pp = netdev_priv(dev);
  4634	
  4635		if ((ring->rx_pending == 0) || (ring->tx_pending == 0))
  4636			return -EINVAL;
> 4637		pp->rx_ring_size = min(ring->rx_pending, MVNETA_MAX_RXD);
  4638	
  4639		pp->tx_ring_size = clamp_t(u16, ring->tx_pending,
  4640					   MVNETA_MAX_SKB_DESCS * 2, MVNETA_MAX_TXD);
  4641		if (pp->tx_ring_size != ring->tx_pending)
  4642			netdev_warn(dev, "TX queue size set to %u (requested %u)\n",
  4643				    pp->tx_ring_size, ring->tx_pending);
  4644	
  4645		if (netif_running(dev)) {
  4646			mvneta_stop(dev);
  4647			if (mvneta_open(dev)) {
  4648				netdev_err(dev,
  4649					   "error on opening device after ring param change\n");
  4650				return -ENOMEM;
  4651			}
  4652		}
  4653	
  4654		return 0;
  4655	}
  4656	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-23  2:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-20 11:36 [PATCH] net: mvneta: use min() to make code cleaner cgel.zte
2021-12-23  2:54 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).