diff mbox series

[1/2] crypto: octeontx2 - fix -Wpointer-bool-conversion warning

Message ID 20210204154230.1702563-1-arnd@kernel.org
State New
Headers show
Series [1/2] crypto: octeontx2 - fix -Wpointer-bool-conversion warning | expand

Commit Message

Arnd Bergmann Feb. 4, 2021, 3:42 p.m. UTC
From: Arnd Bergmann <arnd@arndb.de>


When CONFIG_CPUMASK_OFFSTACK is disabled, clang reports a warning
about a bogus condition:

drivers/crypto/marvell/octeontx2/otx2_cptlf.c:334:21: error: address of array 'lfs->lf[slot].affinity_mask' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
                if (lfs->lf[slot].affinity_mask)
                ~~  ~~~~~~~~~~~~~~^~~~~~~~~~~~~

In this configuration, the free_cpumask_var() function does nothing,
so the condition could be skipped.

When the option is enabled, there is no warning, but the check
is also redundant because free_cpumask_var() falls back to kfree(),
which is documented as ignoring NULL pointers.

Remove the check to avoid the warning.

Fixes: 64506017030d ("crypto: octeontx2 - add LF framework")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

---
 drivers/crypto/marvell/octeontx2/otx2_cptlf.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

-- 
2.29.2

Comments

Nathan Chancellor Feb. 4, 2021, 9:22 p.m. UTC | #1
On Thu, Feb 04, 2021 at 04:42:15PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>

> 

> When CONFIG_CPUMASK_OFFSTACK is disabled, clang reports a warning

> about a bogus condition:

> 

> drivers/crypto/marvell/octeontx2/otx2_cptlf.c:334:21: error: address of array 'lfs->lf[slot].affinity_mask' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]

>                 if (lfs->lf[slot].affinity_mask)

>                 ~~  ~~~~~~~~~~~~~~^~~~~~~~~~~~~

> 

> In this configuration, the free_cpumask_var() function does nothing,

> so the condition could be skipped.

> 

> When the option is enabled, there is no warning, but the check

> is also redundant because free_cpumask_var() falls back to kfree(),

> which is documented as ignoring NULL pointers.

> 

> Remove the check to avoid the warning.

> 

> Fixes: 64506017030d ("crypto: octeontx2 - add LF framework")

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>


Reviewed-by: Nathan Chancellor <nathan@kernel.org>


> ---

>  drivers/crypto/marvell/octeontx2/otx2_cptlf.c | 3 +--

>  1 file changed, 1 insertion(+), 2 deletions(-)

> 

> diff --git a/drivers/crypto/marvell/octeontx2/otx2_cptlf.c b/drivers/crypto/marvell/octeontx2/otx2_cptlf.c

> index e27ea8909368..823a4571fd67 100644

> --- a/drivers/crypto/marvell/octeontx2/otx2_cptlf.c

> +++ b/drivers/crypto/marvell/octeontx2/otx2_cptlf.c

> @@ -331,8 +331,7 @@ void otx2_cptlf_free_irqs_affinity(struct otx2_cptlfs_info *lfs)

>  			irq_set_affinity_hint(pci_irq_vector(lfs->pdev,

>  					      lfs->lf[slot].msix_offset +

>  					      offs), NULL);

> -		if (lfs->lf[slot].affinity_mask)

> -			free_cpumask_var(lfs->lf[slot].affinity_mask);

> +		free_cpumask_var(lfs->lf[slot].affinity_mask);

>  	}

>  }

>  

> -- 

> 2.29.2

>
Herbert Xu Feb. 10, 2021, 7:24 a.m. UTC | #2
On Thu, Feb 04, 2021 at 04:42:15PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>

> 

> When CONFIG_CPUMASK_OFFSTACK is disabled, clang reports a warning

> about a bogus condition:

> 

> drivers/crypto/marvell/octeontx2/otx2_cptlf.c:334:21: error: address of array 'lfs->lf[slot].affinity_mask' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]

>                 if (lfs->lf[slot].affinity_mask)

>                 ~~  ~~~~~~~~~~~~~~^~~~~~~~~~~~~

> 

> In this configuration, the free_cpumask_var() function does nothing,

> so the condition could be skipped.

> 

> When the option is enabled, there is no warning, but the check

> is also redundant because free_cpumask_var() falls back to kfree(),

> which is documented as ignoring NULL pointers.

> 

> Remove the check to avoid the warning.

> 

> Fixes: 64506017030d ("crypto: octeontx2 - add LF framework")

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

> ---

>  drivers/crypto/marvell/octeontx2/otx2_cptlf.c | 3 +--

>  1 file changed, 1 insertion(+), 2 deletions(-)


Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
diff mbox series

Patch

diff --git a/drivers/crypto/marvell/octeontx2/otx2_cptlf.c b/drivers/crypto/marvell/octeontx2/otx2_cptlf.c
index e27ea8909368..823a4571fd67 100644
--- a/drivers/crypto/marvell/octeontx2/otx2_cptlf.c
+++ b/drivers/crypto/marvell/octeontx2/otx2_cptlf.c
@@ -331,8 +331,7 @@  void otx2_cptlf_free_irqs_affinity(struct otx2_cptlfs_info *lfs)
 			irq_set_affinity_hint(pci_irq_vector(lfs->pdev,
 					      lfs->lf[slot].msix_offset +
 					      offs), NULL);
-		if (lfs->lf[slot].affinity_mask)
-			free_cpumask_var(lfs->lf[slot].affinity_mask);
+		free_cpumask_var(lfs->lf[slot].affinity_mask);
 	}
 }