Re: [PATCH 3/5] mlx5: Avoid that sparse complains about dubious !x & y expressions

Or Gerlitz
2016-12-08T09:26:32Z

On Tue, Dec 6, 2016 at 3:19 AM, Bart Van Assche
<bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org> wrote:
> This patch does not change any functionality.

Hi Bart,

Matan came up with a fix (below) which solves all these sparse
complaints in both drivers (mlx5 IB and core)
while basically not touching the code, we will be going with that fix
to 4.11, thanks, I will add reported
by pointing to you.

Doug, in case you picked that, I guess you have to drop it.

Or.

iff --git a/include/linux/mlx5/device.h b/include/linux/mlx5/device.h
index 9f48936..0abdc66 100644
--- a/include/linux/mlx5/device.h
+++ b/include/linux/mlx5/device.h
@@ -67,10 +67,11 @@

/* insert a value to a struct */
#define MLX5_SET(typ, p, fld, v) do { \
+ typeof( v ) _v = v; \
BUILD_BUG_ON(__mlx5_st_sz_bits(typ) % 32); \
*((__be32 *)(p) + __mlx5_dw_off(typ, fld)) = \
cpu_to_be32((be32_to_cpu(*((__be32 *)(p) + __mlx5_dw_off(typ, fld))) & \
- (~__mlx5_dw_mask(typ, fld))) | (((v) &
__mlx5_mask(typ, fld)) \
+ (~__mlx5_dw_mask(typ, fld))) | (((_v) &
__mlx5_mask(typ, fld)) \
<< __mlx5_dw_bit_off(typ, fld))); \
} while (0)