Skip to contentSkip to conversation

mlxsw: core: mlxsw: core: avoid -Wint-in-bool-context warning

PATCH Applied Arnd Bergmann 3 participants 3 messages Mar 18, 2019 – Mar 19, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mlxsw: core: mlxsw: core: avoid -Wint-in-bool-context warning

A recently added function in mlxsw triggers a harmless compiler warning:

In file included from drivers/net/ethernet/mellanox/mlxsw/core.h:17,
from drivers/net/ethernet/mellanox/mlxsw/core_env.c:7:
drivers/net/ethernet/mellanox/mlxsw/core_env.c: In function 'mlxsw_env_module_temp_thresholds_get':
drivers/net/ethernet/mellanox/mlxsw/reg.h:8015:45: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]

 #define MLXSW_REG_MTMP_TEMP_TO_MC(val) (val * 125)
                                        ~~~~~^~~~~~
drivers/net/ethernet/mellanox/mlxsw/core_env.c:116:8: note: in expansion of macro 'MLXSW_REG_MTMP_TEMP_TO_MC'
   if (!MLXSW_REG_MTMP_TEMP_TO_MC(module_temp)) {
        ^~~~~~~~~~~~~~~~~~~~~~~~~

The warning is normally disabled, but it would be nice to enable it to find real bugs, and there are no other known instances at the moment.

Replace the negation with a zero-comparison, which also matches the comment above it.

Fixes d93c19a1d95c ("mlxsw: core: Add API for QSFP module temperature thresholds reading")
---
 drivers/net/ethernet/mellanox/mlxsw/core_env.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/core_env.c +1 -1
index 7a15e932ed2f..c1c1965d7acc 100644
@@ -113,7 +113,7 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module,
 		return 0;
 	default:
 		/* Do not consider thresholds for zero temperature. */
-		if (!MLXSW_REG_MTMP_TEMP_TO_MC(module_temp)) {
+		if (MLXSW_REG_MTMP_TEMP_TO_MC(module_temp) == 0) {
 			*temp = 0;
 			return 0;
 		}
Signature · 1 line
2.20.0
Acked-by on v1 1/1
#1 lore raw
Quoted 16 lines · Mon, Mar 18, 2019 at 05:35:11PM CET, [email protected] wrote:

A recently added function in mlxsw triggers a harmless compiler warning:

In file included from drivers/net/ethernet/mellanox/mlxsw/core.h:17,
from drivers/net/ethernet/mellanox/mlxsw/core_env.c:7:
drivers/net/ethernet/mellanox/mlxsw/core_env.c: In function 'mlxsw_env_module_temp_thresholds_get':
drivers/net/ethernet/mellanox/mlxsw/reg.h:8015:45: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]

#define MLXSW_REG_MTMP_TEMP_TO_MC(val) (val * 125)
                                       ~~~~~^~~~~~
drivers/net/ethernet/mellanox/mlxsw/core_env.c:116:8: note: in expansion of macro 'MLXSW_REG_MTMP_TEMP_TO_MC'
  if (!MLXSW_REG_MTMP_TEMP_TO_MC(module_temp)) {
       ^~~~~~~~~~~~~~~~~~~~~~~~~

The warning is normally disabled, but it would be nice to enable it to find real bugs, and there are no other known instances at the moment.

Quoted 5 lines

Replace the negation with a zero-comparison, which also matches the comment above it.

Fixes d93c19a1d95c ("mlxsw: core: Add API for QSFP module temperature thresholds reading")
maintainer Applied
#2 lore raw
In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>
Date: Mon, 18 Mar 2019 17:35:11 +0100

Quoted 16 lines

A recently added function in mlxsw triggers a harmless compiler warning:

In file included from drivers/net/ethernet/mellanox/mlxsw/core.h:17,
from drivers/net/ethernet/mellanox/mlxsw/core_env.c:7:
drivers/net/ethernet/mellanox/mlxsw/core_env.c: In function 'mlxsw_env_module_temp_thresholds_get':
drivers/net/ethernet/mellanox/mlxsw/reg.h:8015:45: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]

 #define MLXSW_REG_MTMP_TEMP_TO_MC(val) (val * 125)
                                        ~~~~~^~~~~~
drivers/net/ethernet/mellanox/mlxsw/core_env.c:116:8: note: in expansion of macro 'MLXSW_REG_MTMP_TEMP_TO_MC'
   if (!MLXSW_REG_MTMP_TEMP_TO_MC(module_temp)) {
        ^~~~~~~~~~~~~~~~~~~~~~~~~

The warning is normally disabled, but it would be nice to enable it to find real bugs, and there are no other known instances at the moment.

Quoted 5 lines

Replace the negation with a zero-comparison, which also matches the comment above it.

Fixes d93c19a1d95c ("mlxsw: core: Add API for QSFP module temperature thresholds reading")

Applied, thanks Arnd.