* [PATCH] net: marvell: Use min() instead of doing it manually
@ 2022-03-01 6:16 Haowen Bai
2022-03-01 7:33 ` Heiner Kallweit
2022-03-01 10:29 ` kernel test robot
0 siblings, 2 replies; 5+ messages in thread
From: Haowen Bai @ 2022-03-01 6:16 UTC (permalink / raw)
To: sebastian.hesselbarth, davem, kuba; +Cc: netdev, linux-kernel, Haowen Bai
Fix following coccicheck warning:
drivers/net/ethernet/marvell/mv643xx_eth.c:1664:35-36: WARNING opportunity for min()
Signed-off-by: Haowen Bai <baihaowen88@gmail.com>
---
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);
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)
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] net: marvell: Use min() instead of doing it manually
2022-03-01 6:16 [PATCH] net: marvell: Use min() instead of doing it manually Haowen Bai
@ 2022-03-01 7:33 ` Heiner Kallweit
2022-03-01 10:29 ` kernel test robot
1 sibling, 0 replies; 5+ messages in thread
From: Heiner Kallweit @ 2022-03-01 7:33 UTC (permalink / raw)
To: Haowen Bai, sebastian.hesselbarth, davem, kuba; +Cc: netdev, linux-kernel
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@gmail.com>
> ---
> 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)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net: marvell: Use min() instead of doing it manually
2022-03-01 6:16 [PATCH] net: marvell: Use min() instead of doing it manually Haowen Bai
2022-03-01 7:33 ` Heiner Kallweit
@ 2022-03-01 10:29 ` kernel test robot
2022-03-02 1:38 ` lotte bai
1 sibling, 1 reply; 5+ messages in thread
From: kernel test robot @ 2022-03-01 10:29 UTC (permalink / raw)
To: Haowen Bai, sebastian.hesselbarth, davem, kuba
Cc: llvm, kbuild-all, netdev, linux-kernel, Haowen Bai
Hi Haowen,
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.17-rc6 next-20220228]
[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/Haowen-Bai/net-marvell-Use-min-instead-of-doing-it-manually/20220301-141800
base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git f2b77012ddd5b2532d262f100be3394ceae3ea59
config: hexagon-randconfig-r041-20220301 (https://download.01.org/0day-ci/archive/20220301/202203011855.FRrOViok-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project d271fc04d5b97b12e6b797c6067d3c96a8d7470e)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/55e43d9d6e3e0a8774e6a5e3976808e5736f6c9f
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Haowen-Bai/net-marvell-Use-min-instead-of-doing-it-manually/20220301-141800
git checkout 55e43d9d6e3e0a8774e6a5e3976808e5736f6c9f
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/net/ethernet/marvell/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
>> drivers/net/ethernet/marvell/mv643xx_eth.c:1664:21: warning: comparison of distinct pointer types ('typeof (er->rx_pending) *' (aka 'unsigned int *') and 'typeof (4096) *' (aka 'int *')) [-Wcompare-distinct-pointer-types]
mp->rx_ring_size = min(er->rx_pending, 4096);
^~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/minmax.h:45:19: note: expanded from macro 'min'
#define min(x, y) __careful_cmp(x, y, <)
^~~~~~~~~~~~~~~~~~~~~~
include/linux/minmax.h:36:24: note: expanded from macro '__careful_cmp'
__builtin_choose_expr(__safe_cmp(x, y), \
^~~~~~~~~~~~~~~~
include/linux/minmax.h:26:4: note: expanded from macro '__safe_cmp'
(__typecheck(x, y) && __no_side_effects(x, y))
^~~~~~~~~~~~~~~~~
include/linux/minmax.h:20:28: note: expanded from macro '__typecheck'
(!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~
1 warning generated.
vim +1664 drivers/net/ethernet/marvell/mv643xx_eth.c
1653
1654 static int
1655 mv643xx_eth_set_ringparam(struct net_device *dev, struct ethtool_ringparam *er,
1656 struct kernel_ethtool_ringparam *kernel_er,
1657 struct netlink_ext_ack *extack)
1658 {
1659 struct mv643xx_eth_private *mp = netdev_priv(dev);
1660
1661 if (er->rx_mini_pending || er->rx_jumbo_pending)
1662 return -EINVAL;
1663
> 1664 mp->rx_ring_size = min(er->rx_pending, 4096);
1665 mp->tx_ring_size = clamp_t(unsigned int, er->tx_pending,
1666 MV643XX_MAX_SKB_DESCS * 2, 4096);
1667 if (mp->tx_ring_size != er->tx_pending)
1668 netdev_warn(dev, "TX queue size set to %u (requested %u)\n",
1669 mp->tx_ring_size, er->tx_pending);
1670
1671 if (netif_running(dev)) {
1672 mv643xx_eth_stop(dev);
1673 if (mv643xx_eth_open(dev)) {
1674 netdev_err(dev,
1675 "fatal error on re-opening device after ring param change\n");
1676 return -ENOMEM;
1677 }
1678 }
1679
1680 return 0;
1681 }
1682
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net: marvell: Use min() instead of doing it manually
2022-03-01 10:29 ` kernel test robot
@ 2022-03-02 1:38 ` lotte bai
0 siblings, 0 replies; 5+ messages in thread
From: lotte bai @ 2022-03-02 1:38 UTC (permalink / raw)
To: kernel test robot
Cc: sebastian.hesselbarth, davem, kuba, llvm, kbuild-all, netdev,
linux-kernel
@Heiner Kallweit
Thank you for your kindly response.
kernel test robot <lkp@intel.com> 于2022年3月1日周二 18:30写道:
>
> Hi Haowen,
>
> 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.17-rc6 next-20220228]
> [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/Haowen-Bai/net-marvell-Use-min-instead-of-doing-it-manually/20220301-141800
> base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git f2b77012ddd5b2532d262f100be3394ceae3ea59
> config: hexagon-randconfig-r041-20220301 (https://download.01.org/0day-ci/archive/20220301/202203011855.FRrOViok-lkp@intel.com/config)
> compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project d271fc04d5b97b12e6b797c6067d3c96a8d7470e)
> reproduce (this is a W=1 build):
> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # https://github.com/0day-ci/linux/commit/55e43d9d6e3e0a8774e6a5e3976808e5736f6c9f
> git remote add linux-review https://github.com/0day-ci/linux
> git fetch --no-tags linux-review Haowen-Bai/net-marvell-Use-min-instead-of-doing-it-manually/20220301-141800
> git checkout 55e43d9d6e3e0a8774e6a5e3976808e5736f6c9f
> # save the config file to linux build tree
> mkdir build_dir
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/net/ethernet/marvell/
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
> All warnings (new ones prefixed by >>):
>
> >> drivers/net/ethernet/marvell/mv643xx_eth.c:1664:21: warning: comparison of distinct pointer types ('typeof (er->rx_pending) *' (aka 'unsigned int *') and 'typeof (4096) *' (aka 'int *')) [-Wcompare-distinct-pointer-types]
> mp->rx_ring_size = min(er->rx_pending, 4096);
> ^~~~~~~~~~~~~~~~~~~~~~~~~
> include/linux/minmax.h:45:19: note: expanded from macro 'min'
> #define min(x, y) __careful_cmp(x, y, <)
> ^~~~~~~~~~~~~~~~~~~~~~
> include/linux/minmax.h:36:24: note: expanded from macro '__careful_cmp'
> __builtin_choose_expr(__safe_cmp(x, y), \
> ^~~~~~~~~~~~~~~~
> include/linux/minmax.h:26:4: note: expanded from macro '__safe_cmp'
> (__typecheck(x, y) && __no_side_effects(x, y))
> ^~~~~~~~~~~~~~~~~
> include/linux/minmax.h:20:28: note: expanded from macro '__typecheck'
> (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
> ~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~
> 1 warning generated.
>
>
> vim +1664 drivers/net/ethernet/marvell/mv643xx_eth.c
>
> 1653
> 1654 static int
> 1655 mv643xx_eth_set_ringparam(struct net_device *dev, struct ethtool_ringparam *er,
> 1656 struct kernel_ethtool_ringparam *kernel_er,
> 1657 struct netlink_ext_ack *extack)
> 1658 {
> 1659 struct mv643xx_eth_private *mp = netdev_priv(dev);
> 1660
> 1661 if (er->rx_mini_pending || er->rx_jumbo_pending)
> 1662 return -EINVAL;
> 1663
> > 1664 mp->rx_ring_size = min(er->rx_pending, 4096);
> 1665 mp->tx_ring_size = clamp_t(unsigned int, er->tx_pending,
> 1666 MV643XX_MAX_SKB_DESCS * 2, 4096);
> 1667 if (mp->tx_ring_size != er->tx_pending)
> 1668 netdev_warn(dev, "TX queue size set to %u (requested %u)\n",
> 1669 mp->tx_ring_size, er->tx_pending);
> 1670
> 1671 if (netif_running(dev)) {
> 1672 mv643xx_eth_stop(dev);
> 1673 if (mv643xx_eth_open(dev)) {
> 1674 netdev_err(dev,
> 1675 "fatal error on re-opening device after ring param change\n");
> 1676 return -ENOMEM;
> 1677 }
> 1678 }
> 1679
> 1680 return 0;
> 1681 }
> 1682
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net: marvell: Use min() instead of doing it manually
@ 2022-03-02 1:38 ` lotte bai
0 siblings, 0 replies; 5+ messages in thread
From: lotte bai @ 2022-03-02 1:38 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 4703 bytes --]
@Heiner Kallweit
Thank you for your kindly response.
kernel test robot <lkp@intel.com> 于2022年3月1日周二 18:30写道:
>
> Hi Haowen,
>
> 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.17-rc6 next-20220228]
> [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/Haowen-Bai/net-marvell-Use-min-instead-of-doing-it-manually/20220301-141800
> base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git f2b77012ddd5b2532d262f100be3394ceae3ea59
> config: hexagon-randconfig-r041-20220301 (https://download.01.org/0day-ci/archive/20220301/202203011855.FRrOViok-lkp(a)intel.com/config)
> compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project d271fc04d5b97b12e6b797c6067d3c96a8d7470e)
> reproduce (this is a W=1 build):
> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # https://github.com/0day-ci/linux/commit/55e43d9d6e3e0a8774e6a5e3976808e5736f6c9f
> git remote add linux-review https://github.com/0day-ci/linux
> git fetch --no-tags linux-review Haowen-Bai/net-marvell-Use-min-instead-of-doing-it-manually/20220301-141800
> git checkout 55e43d9d6e3e0a8774e6a5e3976808e5736f6c9f
> # save the config file to linux build tree
> mkdir build_dir
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/net/ethernet/marvell/
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
> All warnings (new ones prefixed by >>):
>
> >> drivers/net/ethernet/marvell/mv643xx_eth.c:1664:21: warning: comparison of distinct pointer types ('typeof (er->rx_pending) *' (aka 'unsigned int *') and 'typeof (4096) *' (aka 'int *')) [-Wcompare-distinct-pointer-types]
> mp->rx_ring_size = min(er->rx_pending, 4096);
> ^~~~~~~~~~~~~~~~~~~~~~~~~
> include/linux/minmax.h:45:19: note: expanded from macro 'min'
> #define min(x, y) __careful_cmp(x, y, <)
> ^~~~~~~~~~~~~~~~~~~~~~
> include/linux/minmax.h:36:24: note: expanded from macro '__careful_cmp'
> __builtin_choose_expr(__safe_cmp(x, y), \
> ^~~~~~~~~~~~~~~~
> include/linux/minmax.h:26:4: note: expanded from macro '__safe_cmp'
> (__typecheck(x, y) && __no_side_effects(x, y))
> ^~~~~~~~~~~~~~~~~
> include/linux/minmax.h:20:28: note: expanded from macro '__typecheck'
> (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
> ~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~
> 1 warning generated.
>
>
> vim +1664 drivers/net/ethernet/marvell/mv643xx_eth.c
>
> 1653
> 1654 static int
> 1655 mv643xx_eth_set_ringparam(struct net_device *dev, struct ethtool_ringparam *er,
> 1656 struct kernel_ethtool_ringparam *kernel_er,
> 1657 struct netlink_ext_ack *extack)
> 1658 {
> 1659 struct mv643xx_eth_private *mp = netdev_priv(dev);
> 1660
> 1661 if (er->rx_mini_pending || er->rx_jumbo_pending)
> 1662 return -EINVAL;
> 1663
> > 1664 mp->rx_ring_size = min(er->rx_pending, 4096);
> 1665 mp->tx_ring_size = clamp_t(unsigned int, er->tx_pending,
> 1666 MV643XX_MAX_SKB_DESCS * 2, 4096);
> 1667 if (mp->tx_ring_size != er->tx_pending)
> 1668 netdev_warn(dev, "TX queue size set to %u (requested %u)\n",
> 1669 mp->tx_ring_size, er->tx_pending);
> 1670
> 1671 if (netif_running(dev)) {
> 1672 mv643xx_eth_stop(dev);
> 1673 if (mv643xx_eth_open(dev)) {
> 1674 netdev_err(dev,
> 1675 "fatal error on re-opening device after ring param change\n");
> 1676 return -ENOMEM;
> 1677 }
> 1678 }
> 1679
> 1680 return 0;
> 1681 }
> 1682
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-03-02 1:39 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-01 6:16 [PATCH] net: marvell: Use min() instead of doing it manually Haowen Bai
2022-03-01 7:33 ` Heiner Kallweit
2022-03-01 10:29 ` kernel test robot
2022-03-02 1:38 ` lotte bai
2022-03-02 1:38 ` lotte bai
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.