enic: fix build warning without CONFIG_CPUMASK_OFFSTACK
Subsystems (3)
PATCH v2 1/1 enic: fix build warning without CONFIG_CPUMASK_OFFSTACK
The enic driver relies on the CONFIG_CPUMASK_OFFSTACK feature to dynamically allocate a struct member, but this is normally intended for local variables.
Building with clang, I get a warning for a few locations that check the address of the cpumask_var_t:
drivers/net/ethernet/cisco/enic/enic_main.c:122:22: error: address of array 'enic->msix[i].affinity_mask' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
As far as I can tell, the code is still correct, as the truth value of the pointer is what we need in this configuration. To get rid of the warning, use cpumask_available() instead of checking the pointer directly.
---
v2: use cpumask_available() instead of open-coding a copy
--- drivers/net/ethernet/cisco/enic/enic_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/cisco/enic/enic_main.c +3 -3
@@ -119,7 +119,7 @@ static void enic_init_affinity_hint(struct enic *enic)for (i =0 ; i < enic->intr_count; i++) {if (enic_is_err_intr (enic, i) ||enic_is_notify_intr (enic, i) || - (enic->msix[i].affinity_mask && + (cpumask_available (enic->msix[i].affinity_mask) && !cpumask_empty (enic->msix[i].affinity_mask)))continue ; if (zalloc_cpumask_var(&enic->msix[i].affinity_mask,
@@ -148,7 +148,7 @@ static void enic_set_affinity_hint(struct enic *enic)for (i =0 ; i < enic->intr_count; i++) {if (enic_is_err_intr (enic, i) ||enic_is_notify_intr (enic, i) || - !enic->msix[i].affinity_mask || + !cpumask_available (enic->msix[i].affinity_mask) ||cpumask_empty (enic->msix[i].affinity_mask))continue ; err = irq_set_affinity_hint(enic->msix_entry[i].vector,
@@ -161,7 +161,7 @@ static void enic_set_affinity_hint(struct enic *enic)for (i =0 ; i < enic->wq_count; i++) {int wq_intr =enic_msix_wq_intr (enic, i); -if (enic->msix[wq_intr].affinity_mask && +if (cpumask_available (enic->msix[wq_intr].affinity_mask) && !cpumask_empty (enic->msix[wq_intr].affinity_mask)) netif_set_xps_queue(enic->netdev, enic->msix[wq_intr].affinity_mask,
Signature · 1 line
2.20.0
Quoted 9 lines · Arnd Bergmann
The enic driver relies on the
CONFIG_CPUMASK_OFFSTACKfeature to dynamically allocate a struct member, but this is normally intended for local variables.Building with clang, I get a warning for a few locations that check the address of the
cpumask_var_t:
drivers/net/ethernet/cisco/enic/enic_main.c:122:22: error: address of array 'enic->msix[i].affinity_mask' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
Quoted 7 lines
As far as I can tell, the code is still correct, as the truth value of the pointer is what we need in this configuration. To get rid of the warning, use
cpumask_available()instead of checking the pointer directly.Fixes 322cf7e3a4e8 ("enic: assign affinity hint to interrupts")Signed-off-by Arnd Bergmann <[email protected]>
Quoted 40 lines
---
v2: usecpumask_available()instead of open-coding a copy--- drivers/net/ethernet/cisco/enic/enic_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/net/ethernet/cisco/enic/enic_main.c +3
-3@@ -119,7 +119,7 @@ static void enic_init_affinity_hint(struct enic *enic)for (i =0 ; i < enic->intr_count; i++) {if (enic_is_err_intr (enic, i) ||enic_is_notify_intr (enic, i) || - (enic->msix[i].affinity_mask && + (cpumask_available (enic->msix[i].affinity_mask) && !cpumask_empty (enic->msix[i].affinity_mask)))continue ; if (zalloc_cpumask_var(&enic->msix[i].affinity_mask,@@ -148,7 +148,7 @@ static void enic_set_affinity_hint(struct enic *enic)for (i =0 ; i < enic->intr_count; i++) {if (enic_is_err_intr (enic, i) ||enic_is_notify_intr (enic, i) || - !enic->msix[i].affinity_mask || + !cpumask_available (enic->msix[i].affinity_mask) ||cpumask_empty (enic->msix[i].affinity_mask))continue ; err = irq_set_affinity_hint(enic->msix_entry[i].vector,@@ -161,7 +161,7 @@ static void enic_set_affinity_hint(struct enic *enic)for (i =0 ; i < enic->wq_count; i++) {int wq_intr =enic_msix_wq_intr (enic, i); -if (enic->msix[wq_intr].affinity_mask && +if (cpumask_available (enic->msix[wq_intr].affinity_mask) && !cpumask_empty (enic->msix[wq_intr].affinity_mask)) netif_set_xps_queue(enic->netdev, enic->msix[wq_intr].affinity_mask,Signature · 1 line
2.20.0
From: Arnd Bergmann <[email protected]>
Date: Thu, 7 Mar 2019 16:52:24 +0100
Quoted 14 lines
The enic driver relies on the
CONFIG_CPUMASK_OFFSTACKfeature to dynamically allocate a struct member, but this is normally intended for local variables.Building with clang, I get a warning for a few locations that check the address of the
cpumask_var_t:
drivers/net/ethernet/cisco/enic/enic_main.c:122:22: error: address of array 'enic->msix[i].affinity_mask' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]As far as I can tell, the code is still correct, as the truth value of the pointer is what we need in this configuration. To get rid of the warning, use
cpumask_available()instead of checking the pointer directly.
Quoted 4 lines
Fixes 322cf7e3a4e8 ("enic: assign affinity hint to interrupts")Signed-off-by Arnd Bergmann <[email protected]>---
v2: usecpumask_available()instead of open-coding a copy
Applied.