From: Chi Minghao <[email protected]>
Fix the following coccicheck REVIEW:
./drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:3266:5-8 REVIEW Unneeded
variable
Reported-by: Zeal Robot <[email protected]>
Signed-off-by: Chi Minghao <[email protected]>
---
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index 5e8ac42ac6ab..c986a414414b 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -3263,8 +3263,6 @@ int t4_get_scfg_version(struct adapter *adapter, u32 *vers)
*/
int t4_get_version_info(struct adapter *adapter)
{
- int ret = 0;
-
#define FIRST_RET(__getvinfo) \
do { \
int __ret = __getvinfo; \
@@ -3280,7 +3278,7 @@ int t4_get_version_info(struct adapter *adapter)
FIRST_RET(t4_get_vpd_version(adapter, &adapter->params.vpd_vers));
#undef FIRST_RET
- return ret;
+ return 0;
}
/**
--
2.25.1
On 31.08.2021 08:22, [email protected] wrote:
> From: Chi Minghao <[email protected]>
>
> Fix the following coccicheck REVIEW:
> ./drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:3266:5-8 REVIEW Unneeded
> variable
>
> Reported-by: Zeal Robot <[email protected]>
> Signed-off-by: Chi Minghao <[email protected]>
This patch is simply wrong and obviously not even compile-tested.
You would have found out by looking 5s at the code of the function.
Look at what the FIRST_RET macro is doing.
Please don't blindly trust tools and check patches proposed by tools.
> ---
> drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
> index 5e8ac42ac6ab..c986a414414b 100644
> --- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
> +++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
> @@ -3263,8 +3263,6 @@ int t4_get_scfg_version(struct adapter *adapter, u32 *vers)
> */
> int t4_get_version_info(struct adapter *adapter)
> {
> - int ret = 0;
> -
> #define FIRST_RET(__getvinfo) \
> do { \
> int __ret = __getvinfo; \
> @@ -3280,7 +3278,7 @@ int t4_get_version_info(struct adapter *adapter)
> FIRST_RET(t4_get_vpd_version(adapter, &adapter->params.vpd_vers));
>
> #undef FIRST_RET
> - return ret;
> + return 0;
> }
>
> /**
>
Hi,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on ipvs/master]
[also build test ERROR on linus/master v5.14 next-20210831]
[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/cxgb4-remove-unneeded-variable/20210831-143101
base: https://git.kernel.org/pub/scm/linux/kernel/git/horms/ipvs.git master
config: x86_64-randconfig-a016-20210831 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 4b1fde8a2b681dad2ce0c082a5d6422caa06b0bc)
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/5e7aa69068077aeaa75149d0935c3d7d0e8c328f
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review cgel-zte-gmail-com/cxgb4-remove-unneeded-variable/20210831-143101
git checkout 5e7aa69068077aeaa75149d0935c3d7d0e8c328f
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross O=build_dir ARCH=x86_64 SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>
All errors (new ones prefixed by >>):
>> drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:3293:2: error: use of undeclared identifier 'ret'
FIRST_RET(t4_get_fw_version(adapter, &adapter->params.fw_vers));
^
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:3289:17: note: expanded from macro 'FIRST_RET'
if (__ret && !ret) \
^
>> drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:3293:2: error: use of undeclared identifier 'ret'
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:3290:4: note: expanded from macro 'FIRST_RET'
ret = __ret; \
^
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:3294:2: error: use of undeclared identifier 'ret'
FIRST_RET(t4_get_bs_version(adapter, &adapter->params.bs_vers));
^
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:3289:17: note: expanded from macro 'FIRST_RET'
if (__ret && !ret) \
^
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:3294:2: error: use of undeclared identifier 'ret'
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:3290:4: note: expanded from macro 'FIRST_RET'
ret = __ret; \
^
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:3295:2: error: use of undeclared identifier 'ret'
FIRST_RET(t4_get_tp_version(adapter, &adapter->params.tp_vers));
^
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:3289:17: note: expanded from macro 'FIRST_RET'
if (__ret && !ret) \
^
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:3295:2: error: use of undeclared identifier 'ret'
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:3290:4: note: expanded from macro 'FIRST_RET'
ret = __ret; \
^
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:3296:2: error: use of undeclared identifier 'ret'
FIRST_RET(t4_get_exprom_version(adapter, &adapter->params.er_vers));
^
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:3289:17: note: expanded from macro 'FIRST_RET'
if (__ret && !ret) \
^
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:3296:2: error: use of undeclared identifier 'ret'
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:3290:4: note: expanded from macro 'FIRST_RET'
ret = __ret; \
^
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:3297:2: error: use of undeclared identifier 'ret'
FIRST_RET(t4_get_scfg_version(adapter, &adapter->params.scfg_vers));
^
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:3289:17: note: expanded from macro 'FIRST_RET'
if (__ret && !ret) \
^
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:3297:2: error: use of undeclared identifier 'ret'
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:3290:4: note: expanded from macro 'FIRST_RET'
ret = __ret; \
^
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:3298:2: error: use of undeclared identifier 'ret'
FIRST_RET(t4_get_vpd_version(adapter, &adapter->params.vpd_vers));
^
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:3289:17: note: expanded from macro 'FIRST_RET'
if (__ret && !ret) \
^
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:3298:2: error: use of undeclared identifier 'ret'
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:3290:4: note: expanded from macro 'FIRST_RET'
ret = __ret; \
^
12 errors generated.
vim +/ret +3293 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
760446f967678e Ganesh Goudar 2017-07-20 3274
760446f967678e Ganesh Goudar 2017-07-20 3275 /**
760446f967678e Ganesh Goudar 2017-07-20 3276 * t4_get_version_info - extract various chip/firmware version information
760446f967678e Ganesh Goudar 2017-07-20 3277 * @adapter: the adapter
760446f967678e Ganesh Goudar 2017-07-20 3278 *
760446f967678e Ganesh Goudar 2017-07-20 3279 * Reads various chip/firmware version numbers and stores them into the
760446f967678e Ganesh Goudar 2017-07-20 3280 * adapter Adapter Parameters structure. If any of the efforts fails
760446f967678e Ganesh Goudar 2017-07-20 3281 * the first failure will be returned, but all of the version numbers
760446f967678e Ganesh Goudar 2017-07-20 3282 * will be read.
760446f967678e Ganesh Goudar 2017-07-20 3283 */
760446f967678e Ganesh Goudar 2017-07-20 3284 int t4_get_version_info(struct adapter *adapter)
760446f967678e Ganesh Goudar 2017-07-20 3285 {
760446f967678e Ganesh Goudar 2017-07-20 3286 #define FIRST_RET(__getvinfo) \
760446f967678e Ganesh Goudar 2017-07-20 3287 do { \
760446f967678e Ganesh Goudar 2017-07-20 3288 int __ret = __getvinfo; \
760446f967678e Ganesh Goudar 2017-07-20 3289 if (__ret && !ret) \
760446f967678e Ganesh Goudar 2017-07-20 3290 ret = __ret; \
760446f967678e Ganesh Goudar 2017-07-20 3291 } while (0)
760446f967678e Ganesh Goudar 2017-07-20 3292
760446f967678e Ganesh Goudar 2017-07-20 @3293 FIRST_RET(t4_get_fw_version(adapter, &adapter->params.fw_vers));
760446f967678e Ganesh Goudar 2017-07-20 3294 FIRST_RET(t4_get_bs_version(adapter, &adapter->params.bs_vers));
760446f967678e Ganesh Goudar 2017-07-20 3295 FIRST_RET(t4_get_tp_version(adapter, &adapter->params.tp_vers));
760446f967678e Ganesh Goudar 2017-07-20 3296 FIRST_RET(t4_get_exprom_version(adapter, &adapter->params.er_vers));
760446f967678e Ganesh Goudar 2017-07-20 3297 FIRST_RET(t4_get_scfg_version(adapter, &adapter->params.scfg_vers));
760446f967678e Ganesh Goudar 2017-07-20 3298 FIRST_RET(t4_get_vpd_version(adapter, &adapter->params.vpd_vers));
760446f967678e Ganesh Goudar 2017-07-20 3299
760446f967678e Ganesh Goudar 2017-07-20 3300 #undef FIRST_RET
5e7aa69068077a Chi Minghao 2021-08-30 3301 return 0;
760446f967678e Ganesh Goudar 2017-07-20 3302 }
760446f967678e Ganesh Goudar 2017-07-20 3303
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]
Hi,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on ipvs/master]
[also build test ERROR on linus/master sparc-next/master v5.14 next-20210831]
[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/cxgb4-remove-unneeded-variable/20210831-143101
base: https://git.kernel.org/pub/scm/linux/kernel/git/horms/ipvs.git master
config: i386-randconfig-a001-20210831 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
# https://github.com/0day-ci/linux/commit/5e7aa69068077aeaa75149d0935c3d7d0e8c328f
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review cgel-zte-gmail-com/cxgb4-remove-unneeded-variable/20210831-143101
git checkout 5e7aa69068077aeaa75149d0935c3d7d0e8c328f
# save the attached .config to linux build tree
mkdir build_dir
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>
All errors (new ones prefixed by >>):
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c: In function 't4_get_version_info':
>> drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:3289:17: error: 'ret' undeclared (first use in this function); did you mean 'net'?
3289 | if (__ret && !ret) \
| ^~~
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:3293:2: note: in expansion of macro 'FIRST_RET'
3293 | FIRST_RET(t4_get_fw_version(adapter, &adapter->params.fw_vers));
| ^~~~~~~~~
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:3289:17: note: each undeclared identifier is reported only once for each function it appears in
3289 | if (__ret && !ret) \
| ^~~
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:3293:2: note: in expansion of macro 'FIRST_RET'
3293 | FIRST_RET(t4_get_fw_version(adapter, &adapter->params.fw_vers));
| ^~~~~~~~~
vim +3289 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
760446f967678e Ganesh Goudar 2017-07-20 3274
760446f967678e Ganesh Goudar 2017-07-20 3275 /**
760446f967678e Ganesh Goudar 2017-07-20 3276 * t4_get_version_info - extract various chip/firmware version information
760446f967678e Ganesh Goudar 2017-07-20 3277 * @adapter: the adapter
760446f967678e Ganesh Goudar 2017-07-20 3278 *
760446f967678e Ganesh Goudar 2017-07-20 3279 * Reads various chip/firmware version numbers and stores them into the
760446f967678e Ganesh Goudar 2017-07-20 3280 * adapter Adapter Parameters structure. If any of the efforts fails
760446f967678e Ganesh Goudar 2017-07-20 3281 * the first failure will be returned, but all of the version numbers
760446f967678e Ganesh Goudar 2017-07-20 3282 * will be read.
760446f967678e Ganesh Goudar 2017-07-20 3283 */
760446f967678e Ganesh Goudar 2017-07-20 3284 int t4_get_version_info(struct adapter *adapter)
760446f967678e Ganesh Goudar 2017-07-20 3285 {
760446f967678e Ganesh Goudar 2017-07-20 3286 #define FIRST_RET(__getvinfo) \
760446f967678e Ganesh Goudar 2017-07-20 3287 do { \
760446f967678e Ganesh Goudar 2017-07-20 3288 int __ret = __getvinfo; \
760446f967678e Ganesh Goudar 2017-07-20 @3289 if (__ret && !ret) \
760446f967678e Ganesh Goudar 2017-07-20 3290 ret = __ret; \
760446f967678e Ganesh Goudar 2017-07-20 3291 } while (0)
760446f967678e Ganesh Goudar 2017-07-20 3292
760446f967678e Ganesh Goudar 2017-07-20 3293 FIRST_RET(t4_get_fw_version(adapter, &adapter->params.fw_vers));
760446f967678e Ganesh Goudar 2017-07-20 3294 FIRST_RET(t4_get_bs_version(adapter, &adapter->params.bs_vers));
760446f967678e Ganesh Goudar 2017-07-20 3295 FIRST_RET(t4_get_tp_version(adapter, &adapter->params.tp_vers));
760446f967678e Ganesh Goudar 2017-07-20 3296 FIRST_RET(t4_get_exprom_version(adapter, &adapter->params.er_vers));
760446f967678e Ganesh Goudar 2017-07-20 3297 FIRST_RET(t4_get_scfg_version(adapter, &adapter->params.scfg_vers));
760446f967678e Ganesh Goudar 2017-07-20 3298 FIRST_RET(t4_get_vpd_version(adapter, &adapter->params.vpd_vers));
760446f967678e Ganesh Goudar 2017-07-20 3299
760446f967678e Ganesh Goudar 2017-07-20 3300 #undef FIRST_RET
5e7aa69068077a Chi Minghao 2021-08-30 3301 return 0;
760446f967678e Ganesh Goudar 2017-07-20 3302 }
760446f967678e Ganesh Goudar 2017-07-20 3303
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]