LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] dpaa_eth: Remove unnecessary boolean expression in dpaa_get_headroom
@ 2020-03-10 22:06 Nathan Chancellor
  2020-03-11  6:28 ` Madalin Bucur (OSS)
  0 siblings, 1 reply; 3+ messages in thread
From: Nathan Chancellor @ 2020-03-10 22:06 UTC (permalink / raw)
  To: David S. Miller, Madalin Bucur
  Cc: netdev, linux-kernel, clang-built-linux, Nathan Chancellor

Clang warns:

drivers/net/ethernet/freescale/dpaa/dpaa_eth.c:2860:9: warning:
converting the result of '?:' with integer constants to a boolean always
evaluates to 'true' [-Wtautological-constant-compare]
        return DPAA_FD_DATA_ALIGNMENT ? ALIGN(headroom,
               ^
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c:131:34: note: expanded
from macro 'DPAA_FD_DATA_ALIGNMENT'
\#define DPAA_FD_DATA_ALIGNMENT  (fman_has_errata_a050385() ? 64 : 16)
                                 ^
1 warning generated.

This was exposed by commit 3c68b8fffb48 ("dpaa_eth: FMan erratum A050385
workaround") even though it appears to have been an issue since the
introductory commit 9ad1a3749333 ("dpaa_eth: add support for DPAA
Ethernet") since DPAA_FD_DATA_ALIGNMENT has never been able to be zero.

Just replace the whole boolean expression with the true branch, as it is
always been true.

Link: https://github.com/ClangBuiltLinux/linux/issues/928
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
index 190e4478128a..46039d80bb43 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
@@ -2857,9 +2857,7 @@ static inline u16 dpaa_get_headroom(struct dpaa_buffer_layout *bl)
 	headroom = (u16)(bl->priv_data_size + DPAA_PARSE_RESULTS_SIZE +
 		DPAA_TIME_STAMP_SIZE + DPAA_HASH_RESULTS_SIZE);
 
-	return DPAA_FD_DATA_ALIGNMENT ? ALIGN(headroom,
-					      DPAA_FD_DATA_ALIGNMENT) :
-					headroom;
+	return ALIGN(headroom, DPAA_FD_DATA_ALIGNMENT);
 }
 
 static int dpaa_eth_probe(struct platform_device *pdev)
-- 
2.26.0.rc1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] dpaa_eth: Remove unnecessary boolean expression in dpaa_get_headroom
  2020-03-10 22:06 [PATCH] dpaa_eth: Remove unnecessary boolean expression in dpaa_get_headroom Nathan Chancellor
@ 2020-03-11  6:28 ` Madalin Bucur (OSS)
  2020-03-11  6:28   ` Madalin Bucur (OSS)
  0 siblings, 1 reply; 3+ messages in thread
From: Madalin Bucur (OSS) @ 2020-03-11  6:28 UTC (permalink / raw)
  To: Nathan Chancellor, David S. Miller
  Cc: netdev, linux-kernel, clang-built-linux

> -----Original Message-----
> From: Nathan Chancellor <natechancellor@gmail.com>
> Sent: Wednesday, March 11, 2020 12:07 AM
> To: David S. Miller <davem@davemloft.net>; Madalin Bucur
> <madalin.bucur@nxp.com>
> Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org; clang-built-
> linux@googlegroups.com; Nathan Chancellor <natechancellor@gmail.com>
> Subject: [PATCH] dpaa_eth: Remove unnecessary boolean expression in
> dpaa_get_headroom
> 
> Clang warns:
> 
> drivers/net/ethernet/freescale/dpaa/dpaa_eth.c:2860:9: warning:
> converting the result of '?:' with integer constants to a boolean always
> evaluates to 'true' [-Wtautological-constant-compare]
>         return DPAA_FD_DATA_ALIGNMENT ? ALIGN(headroom,
>                ^
> drivers/net/ethernet/freescale/dpaa/dpaa_eth.c:131:34: note: expanded
> from macro 'DPAA_FD_DATA_ALIGNMENT'
> \#define DPAA_FD_DATA_ALIGNMENT  (fman_has_errata_a050385() ? 64 : 16)
>                                  ^
> 1 warning generated.
> 
> This was exposed by commit 3c68b8fffb48 ("dpaa_eth: FMan erratum A050385
> workaround") even though it appears to have been an issue since the
> introductory commit 9ad1a3749333 ("dpaa_eth: add support for DPAA
> Ethernet") since DPAA_FD_DATA_ALIGNMENT has never been able to be zero.
> 
> Just replace the whole boolean expression with the true branch, as it is
> always been true.
> 
> Link:
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.c
> om%2FClangBuiltLinux%2Flinux%2Fissues%2F928&amp;data=02%7C01%7Cmadalin.buc
> ur%40nxp.com%7C53f37e7dbf584248844608d7c53f5f70%7C686ea1d3bc2b4c6fa92cd99c
> 5c301635%7C0%7C0%7C637194748277007260&amp;sdata=GshtiHYyjvTcp87StdMoQDP5L6
> %2BhYN6nnUi6vbyuqic%3D&amp;reserved=0
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
>  drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
> b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
> index 190e4478128a..46039d80bb43 100644
> --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
> +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
> @@ -2857,9 +2857,7 @@ static inline u16 dpaa_get_headroom(struct
> dpaa_buffer_layout *bl)
>  	headroom = (u16)(bl->priv_data_size + DPAA_PARSE_RESULTS_SIZE +
>  		DPAA_TIME_STAMP_SIZE + DPAA_HASH_RESULTS_SIZE);
> 
> -	return DPAA_FD_DATA_ALIGNMENT ? ALIGN(headroom,
> -					      DPAA_FD_DATA_ALIGNMENT) :
> -					headroom;
> +	return ALIGN(headroom, DPAA_FD_DATA_ALIGNMENT);
>  }
> 
>  static int dpaa_eth_probe(struct platform_device *pdev)
> --	
> 2.26.0.rc1

Reviewed-by: Madalin Bucur <madalin.bucur@oss.nxp.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] dpaa_eth: Remove unnecessary boolean expression in dpaa_get_headroom
  2020-03-11  6:28 ` Madalin Bucur (OSS)
@ 2020-03-11  6:28   ` Madalin Bucur (OSS)
  0 siblings, 0 replies; 3+ messages in thread
From: Madalin Bucur (OSS) @ 2020-03-11  6:28 UTC (permalink / raw)
  To: Nathan Chancellor, David S. Miller
  Cc: netdev, linux-kernel, clang-built-linux

> -----Original Message-----
> From: Nathan Chancellor <natechancellor@gmail.com>
> Sent: Wednesday, March 11, 2020 12:07 AM
> To: David S. Miller <davem@davemloft.net>; Madalin Bucur
> <madalin.bucur@nxp.com>
> Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org; clang-built-
> linux@googlegroups.com; Nathan Chancellor <natechancellor@gmail.com>
> Subject: [PATCH] dpaa_eth: Remove unnecessary boolean expression in
> dpaa_get_headroom
> 
> Clang warns:
> 
> drivers/net/ethernet/freescale/dpaa/dpaa_eth.c:2860:9: warning:
> converting the result of '?:' with integer constants to a boolean always
> evaluates to 'true' [-Wtautological-constant-compare]
>         return DPAA_FD_DATA_ALIGNMENT ? ALIGN(headroom,
>                ^
> drivers/net/ethernet/freescale/dpaa/dpaa_eth.c:131:34: note: expanded
> from macro 'DPAA_FD_DATA_ALIGNMENT'
> \#define DPAA_FD_DATA_ALIGNMENT  (fman_has_errata_a050385() ? 64 : 16)
>                                  ^
> 1 warning generated.
> 
> This was exposed by commit 3c68b8fffb48 ("dpaa_eth: FMan erratum A050385
> workaround") even though it appears to have been an issue since the
> introductory commit 9ad1a3749333 ("dpaa_eth: add support for DPAA
> Ethernet") since DPAA_FD_DATA_ALIGNMENT has never been able to be zero.
> 
> Just replace the whole boolean expression with the true branch, as it is
> always been true.
> 
> Link:
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.c
> om%2FClangBuiltLinux%2Flinux%2Fissues%2F928&amp;data=02%7C01%7Cmadalin.buc
> ur%40nxp.com%7C53f37e7dbf584248844608d7c53f5f70%7C686ea1d3bc2b4c6fa92cd99c
> 5c301635%7C0%7C0%7C637194748277007260&amp;sdata=GshtiHYyjvTcp87StdMoQDP5L6
> %2BhYN6nnUi6vbyuqic%3D&amp;reserved=0
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
>  drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
> b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
> index 190e4478128a..46039d80bb43 100644
> --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
> +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
> @@ -2857,9 +2857,7 @@ static inline u16 dpaa_get_headroom(struct
> dpaa_buffer_layout *bl)
>  	headroom = (u16)(bl->priv_data_size + DPAA_PARSE_RESULTS_SIZE +
>  		DPAA_TIME_STAMP_SIZE + DPAA_HASH_RESULTS_SIZE);
> 
> -	return DPAA_FD_DATA_ALIGNMENT ? ALIGN(headroom,
> -					      DPAA_FD_DATA_ALIGNMENT) :
> -					headroom;
> +	return ALIGN(headroom, DPAA_FD_DATA_ALIGNMENT);
>  }
> 
>  static int dpaa_eth_probe(struct platform_device *pdev)
> --	
> 2.26.0.rc1

Reviewed-by: Madalin Bucur <madalin.bucur@oss.nxp.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-03-11  6:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-10 22:06 [PATCH] dpaa_eth: Remove unnecessary boolean expression in dpaa_get_headroom Nathan Chancellor
2020-03-11  6:28 ` Madalin Bucur (OSS)
2020-03-11  6:28   ` Madalin Bucur (OSS)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).