diff mbox series

[net-next] net/mlx5: Use cpumask_available() in mlx5_eq_create_generic()

Message ID 20210618000358.2402567-1-nathan@kernel.org (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net/mlx5: Use cpumask_available() in mlx5_eq_create_generic() | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers fail 1 blamed authors not CCed: shayd@nvidia.com; 1 maintainers not CCed: shayd@nvidia.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Nathan Chancellor June 18, 2021, 12:03 a.m. UTC
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")
Link: https://github.com/ClangBuiltLinux/linux/issues/1400
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 drivers/net/ethernet/mellanox/mlx5/core/eq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


base-commit: 8fe088bd4fd12f4c8899b51d5bc3daad98767d49

Comments

Leon Romanovsky June 21, 2021, 8:53 a.m. UTC | #1
On Thu, Jun 17, 2021 at 05:03:59PM -0700, Nathan Chancellor wrote:
> 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")
> Link: https://github.com/ClangBuiltLinux/linux/issues/1400
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/eq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Saeed Mahameed June 22, 2021, 9:39 p.m. UTC | #2
On Thu, 2021-06-17 at 17:03 -0700, Nathan Chancellor wrote:
> 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")
> Link: https://github.com/ClangBuiltLinux/linux/issues/1400
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---

Applied to net-next-mlx5
Thanks!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eq.c b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
index 7e5b3826eae5..d3356771e628 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eq.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
@@ -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)