Skip to contentSkip to conversation

net/mlx5: Use cpumask_available() in mlx5_eq_create_generic()

PATCH Applied Nathan Chancellor 3 participants 3 messages Jun 18, 2021 – Jun 22, 2021

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

PATCH 1/1 net/mlx5: Use cpumask_available() in mlx5_eq_create_generic()

When CONFIG_CPUMASK_OFFSTACK is unset, cpumask_var_t is not a pointer but a single element array, meaning its address in a structure cannot be NULL as long as it is not the first element, which it is not. This results in a clang warning:

drivers/net/ethernet/mellanox/mlx5/core/eq.c:715:14: warning: address of array 'param->affinity' will always evaluate to 'true' [-Wpointer-bool-conversion]

        if (!param->affinity)
            ~~~~~~~~^~~~~~~~

1 warning generated.

The helper cpumask_available was added in commit f7e30f01a9e2 ("cpumask:
Add helper cpumask_available()") to handle situations like this so use it to keep the meaning of the code the same while resolving the warning.

Fixes e4e3f24b822f ("net/mlx5: Provide cpumask at EQ creation phase")
---
 drivers/net/ethernet/mellanox/mlx5/core/eq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/eq.c +1 -1
index 7e5b3826eae5..d3356771e628 100644
@@ -710,7 +710,7 @@ mlx5_eq_create_generic(struct mlx5_core_dev *dev,
 	struct mlx5_eq *eq = kvzalloc(sizeof(*eq), GFP_KERNEL);
 	int err;
 
-	if (!param->affinity)
+	if (!cpumask_available(param->affinity))
 		return ERR_PTR(-EINVAL);
 
 	if (!eq)

base-commit: 8fe088bd4fd12f4c8899b51d5bc3daad98767d49

Signature · 1 line
2.32.0.93.g670b81a890
Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · Nathan Chancellor

When CONFIG_CPUMASK_OFFSTACK is unset, cpumask_var_t is not a pointer but a single element array, meaning its address in a structure cannot be NULL as long as it is not the first element, which it is not. This results in a clang warning:

drivers/net/ethernet/mellanox/mlx5/core/eq.c:715:14: warning: address of array 'param->affinity' will always evaluate to 'true' [-Wpointer-bool-conversion]

        if (!param->affinity)
            ~~~~~~~~^~~~~~~~

1 warning generated.

The helper cpumask_available was added in commit f7e30f01a9e2 ("cpumask:
Add helper cpumask_available()") to handle situations like this so use it to keep the meaning of the code the same while resolving the warning.

Quoted 7 lines
Fixes e4e3f24b822f ("net/mlx5: Provide cpumask at EQ creation phase")
---
 drivers/net/ethernet/mellanox/mlx5/core/eq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Thanks,

#2 lore raw
In reply to Nathan Chancellor
Quoted 20 lines · Nathan Chancellor

When CONFIG_CPUMASK_OFFSTACK is unset, cpumask_var_t is not a pointer but a single element array, meaning its address in a structure cannot be
NULL as long as it is not the first element, which it is not. This results in a clang warning:

drivers/net/ethernet/mellanox/mlx5/core/eq.c:715:14: warning: address of
array 'param->affinity' will always evaluate to 'true' [-Wpointer-bool-conversion]
        if (!param->affinity)
            ~~~~~~~~^~~~~~~~
1 warning generated.

The helper cpumask_available was added in commit f7e30f01a9e2 ("cpumask:
Add helper cpumask_available()") to handle situations like this so use it to keep the meaning of the code the same while resolving the warning.

Quoted 4 lines
Fixes e4e3f24b822f ("net/mlx5: Provide cpumask at EQ creation phase")

---

Applied to net-next-mlx5
Thanks!