linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mlxsw: core: mlxsw: core: avoid -Wint-in-bool-context warning
@ 2019-03-18 16:35 Arnd Bergmann
  2019-03-18 20:05 ` Jiri Pirko
  2019-03-19 20:26 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2019-03-18 16:35 UTC (permalink / raw)
  To: Jiri Pirko, Ido Schimmel, David S. Miller
  Cc: Masahiro Yamada, Arnd Bergmann, Vadim Pasternak, netdev, linux-kernel

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")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/net/ethernet/mellanox/mlxsw/core_env.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
index 7a15e932ed2f..c1c1965d7acc 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
@@ -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;
 		}
-- 
2.20.0


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

* Re: [PATCH] mlxsw: core: mlxsw: core: avoid -Wint-in-bool-context warning
  2019-03-18 16:35 [PATCH] mlxsw: core: mlxsw: core: avoid -Wint-in-bool-context warning Arnd Bergmann
@ 2019-03-18 20:05 ` Jiri Pirko
  2019-03-19 20:26 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Jiri Pirko @ 2019-03-18 20:05 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Jiri Pirko, Ido Schimmel, David S. Miller, Masahiro Yamada,
	Vadim Pasternak, netdev, linux-kernel

Mon, Mar 18, 2019 at 05:35:11PM CET, arnd@arndb.de 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.
>
>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")
>Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Acked-by: Jiri Pirko <jiri@mellanox.com>

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

* Re: [PATCH] mlxsw: core: mlxsw: core: avoid -Wint-in-bool-context warning
  2019-03-18 16:35 [PATCH] mlxsw: core: mlxsw: core: avoid -Wint-in-bool-context warning Arnd Bergmann
  2019-03-18 20:05 ` Jiri Pirko
@ 2019-03-19 20:26 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-03-19 20:26 UTC (permalink / raw)
  To: arnd; +Cc: jiri, idosch, yamada.masahiro, vadimp, netdev, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>
Date: Mon, 18 Mar 2019 17:35:11 +0100

> 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")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied, thanks Arnd.

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

end of thread, other threads:[~2019-03-19 20:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-18 16:35 [PATCH] mlxsw: core: mlxsw: core: avoid -Wint-in-bool-context warning Arnd Bergmann
2019-03-18 20:05 ` Jiri Pirko
2019-03-19 20:26 ` David Miller

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