diff mbox series

net: mvneta: use min() to make code cleaner

Message ID 20211220113648.473204-1-deng.changcheng@zte.com.cn (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: mvneta: use min() to make code cleaner | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 2 this patch: 4
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/build_clang fail Errors and warnings before: 0 this patch: 2
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 2 this patch: 4
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

CGEL Dec. 20, 2021, 11:36 a.m. UTC
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(-)

Comments

kernel test robot Dec. 23, 2021, 2:54 a.m. UTC | #1
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
diff mbox series

Patch

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);