Skip to contentSkip to conversation

net/mlx4: Use cpumask_available for eq->affinity_mask

PATCH In review Nathan Chancellor 2 participants 2 messages Sep 21, 2018 – Sep 23, 2018

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

PATCH 1/1 net/mlx4: Use cpumask_available for eq->affinity_mask

Clang warns that the address of a pointer will always evaluated as true in a boolean context:

drivers/net/ethernet/mellanox/mlx4/eq.c:243:11: warning: address of array 'eq->affinity_mask' will always evaluate to 'true' [-Wpointer-bool-conversion]

        if (!eq->affinity_mask || cpumask_empty(eq->affinity_mask))
            ~~~~~^~~~~~~~~~~~~

1 warning generated.

Use cpumask_available, introduced in commit f7e30f01a9e2 ("cpumask: Add helper cpumask_available()"), which does the proper checking and avoids this warning.

---
 drivers/net/ethernet/mellanox/mlx4/eq.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx4/eq.c +2 -1
index 1f3372c1802e..2df92dbd38e1 100644
@@ -240,7 +240,8 @@ static void mlx4_set_eq_affinity_hint(struct mlx4_priv *priv, int vec)
 	struct mlx4_dev *dev = &priv->dev;
 	struct mlx4_eq *eq = &priv->eq_table.eq[vec];
 
-	if (!eq->affinity_mask || cpumask_empty(eq->affinity_mask))
+	if (!cpumask_available(eq->affinity_mask) ||
+	    cpumask_empty(eq->affinity_mask))
 		return;
 
 	hint_err = irq_set_affinity_hint(eq->irq, eq->affinity_mask);
Signature · 1 line
2.19.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 26 lines · Nathan Chancellor

Clang warns that the address of a pointer will always evaluated as true in a boolean context:

drivers/net/ethernet/mellanox/mlx4/eq.c:243:11: warning: address of array 'eq->affinity_mask' will always evaluate to 'true' [-Wpointer-bool-conversion]

         if (!eq->affinity_mask || cpumask_empty(eq->affinity_mask))
             ~~~~~^~~~~~~~~~~~~

1 warning generated.

Use cpumask_available, introduced in commit f7e30f01a9e2 ("cpumask: Add helper cpumask_available()"), which does the proper checking and avoids this warning.

---
  drivers/net/ethernet/mellanox/mlx4/eq.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx4/eq.c +0 -0
index 1f3372c1802e..2df92dbd38e1 100644

drivers/net/ethernet/mellanox/mlx4/eq.c static void mlx4_set_eq_affinity_hint(struct mlx4_priv *priv, int vec) · line 247

Quoted 9 lines
drivers/net/ethernet/mellanox/mlx4/eq.c +2 -1
@@ -240,7 +240,8 @@ static void mlx4_set_eq_affinity_hint(struct mlx4_priv *priv, int vec)
  	struct mlx4_dev *dev = &priv->dev;
  	struct mlx4_eq *eq = &priv->eq_table.eq[vec];
 
-	if (!eq->affinity_mask || cpumask_empty(eq->affinity_mask))
+	if (!cpumask_available(eq->affinity_mask) ||
+	    cpumask_empty(eq->affinity_mask))
  		return;
 
  	hint_err = irq_set_affinity_hint(eq->irq, eq->affinity_mask);

Thanks.