linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: dsa: sja1105: Do not use address of compatible member in sja1105_check_device_id
@ 2020-08-21 22:25 Nathan Chancellor
  2020-08-21 22:33 ` Florian Fainelli
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Nathan Chancellor @ 2020-08-21 22:25 UTC (permalink / raw)
  To: Vladimir Oltean, Andrew Lunn, Vivien Didelot, Florian Fainelli
  Cc: David S. Miller, Jakub Kicinski, linux-kernel, netdev,
	clang-built-linux, Nathan Chancellor

Clang warns:

drivers/net/dsa/sja1105/sja1105_main.c:3418:38: warning: address of
array 'match->compatible' will always evaluate to 'true'
[-Wpointer-bool-conversion]
        for (match = sja1105_dt_ids; match->compatible; match++) {
        ~~~                          ~~~~~~~^~~~~~~~~~
1 warning generated.

We should check the value of the first character in compatible to see if
it is empty or not. This matches how the rest of the tree iterates over
IDs.

Fixes: 0b0e299720bb ("net: dsa: sja1105: use detected device id instead of DT one on mismatch")
Link: https://github.com/ClangBuiltLinux/linux/issues/1139
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 drivers/net/dsa/sja1105/sja1105_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c
index c3f6f124e5f0..5a28dfb36ec3 100644
--- a/drivers/net/dsa/sja1105/sja1105_main.c
+++ b/drivers/net/dsa/sja1105/sja1105_main.c
@@ -3415,7 +3415,7 @@ static int sja1105_check_device_id(struct sja1105_private *priv)
 
 	sja1105_unpack(prod_id, &part_no, 19, 4, SJA1105_SIZE_DEVICE_ID);
 
-	for (match = sja1105_dt_ids; match->compatible; match++) {
+	for (match = sja1105_dt_ids; match->compatible[0]; match++) {
 		const struct sja1105_info *info = match->data;
 
 		/* Is what's been probed in our match table at all? */

base-commit: 4af7b32f84aa4cd60e39b355bc8a1eab6cd8d8a4
-- 
2.28.0


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

* Re: [PATCH] net: dsa: sja1105: Do not use address of compatible member in sja1105_check_device_id
  2020-08-21 22:25 [PATCH] net: dsa: sja1105: Do not use address of compatible member in sja1105_check_device_id Nathan Chancellor
@ 2020-08-21 22:33 ` Florian Fainelli
  2020-08-21 22:57 ` Vladimir Oltean
  2020-08-24 23:13 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Florian Fainelli @ 2020-08-21 22:33 UTC (permalink / raw)
  To: Nathan Chancellor, Vladimir Oltean, Andrew Lunn, Vivien Didelot
  Cc: David S. Miller, Jakub Kicinski, linux-kernel, netdev, clang-built-linux

On 8/21/20 3:25 PM, Nathan Chancellor wrote:
> Clang warns:
> 
> drivers/net/dsa/sja1105/sja1105_main.c:3418:38: warning: address of
> array 'match->compatible' will always evaluate to 'true'
> [-Wpointer-bool-conversion]
>         for (match = sja1105_dt_ids; match->compatible; match++) {
>         ~~~                          ~~~~~~~^~~~~~~~~~
> 1 warning generated.
> 
> We should check the value of the first character in compatible to see if
> it is empty or not. This matches how the rest of the tree iterates over
> IDs.
> 
> Fixes: 0b0e299720bb ("net: dsa: sja1105: use detected device id instead of DT one on mismatch")
> Link: https://github.com/ClangBuiltLinux/linux/issues/1139
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

Acked-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* Re: [PATCH] net: dsa: sja1105: Do not use address of compatible member in sja1105_check_device_id
  2020-08-21 22:25 [PATCH] net: dsa: sja1105: Do not use address of compatible member in sja1105_check_device_id Nathan Chancellor
  2020-08-21 22:33 ` Florian Fainelli
@ 2020-08-21 22:57 ` Vladimir Oltean
  2020-08-24 23:13 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Vladimir Oltean @ 2020-08-21 22:57 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Andrew Lunn, Vivien Didelot, Florian Fainelli, David S. Miller,
	Jakub Kicinski, linux-kernel, netdev, clang-built-linux

On Fri, Aug 21, 2020 at 03:25:16PM -0700, Nathan Chancellor wrote:
> Clang warns:
> 
> drivers/net/dsa/sja1105/sja1105_main.c:3418:38: warning: address of
> array 'match->compatible' will always evaluate to 'true'
> [-Wpointer-bool-conversion]
>         for (match = sja1105_dt_ids; match->compatible; match++) {
>         ~~~                          ~~~~~~~^~~~~~~~~~
> 1 warning generated.
> 
> We should check the value of the first character in compatible to see if
> it is empty or not. This matches how the rest of the tree iterates over
> IDs.
> 
> Fixes: 0b0e299720bb ("net: dsa: sja1105: use detected device id instead of DT one on mismatch")
> Link: https://github.com/ClangBuiltLinux/linux/issues/1139
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
>  drivers/net/dsa/sja1105/sja1105_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c
> index c3f6f124e5f0..5a28dfb36ec3 100644
> --- a/drivers/net/dsa/sja1105/sja1105_main.c
> +++ b/drivers/net/dsa/sja1105/sja1105_main.c
> @@ -3415,7 +3415,7 @@ static int sja1105_check_device_id(struct sja1105_private *priv)
>  
>  	sja1105_unpack(prod_id, &part_no, 19, 4, SJA1105_SIZE_DEVICE_ID);
>  
> -	for (match = sja1105_dt_ids; match->compatible; match++) {
> +	for (match = sja1105_dt_ids; match->compatible[0]; match++) {
>  		const struct sja1105_info *info = match->data;
>  
>  		/* Is what's been probed in our match table at all? */
> 
> base-commit: 4af7b32f84aa4cd60e39b355bc8a1eab6cd8d8a4
> -- 
> 2.28.0
> 

Thanks, Nathan.

Acked-by: Vladimir Oltean <olteanv@gmail.com>

-Vladimir

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

* Re: [PATCH] net: dsa: sja1105: Do not use address of compatible member in sja1105_check_device_id
  2020-08-21 22:25 [PATCH] net: dsa: sja1105: Do not use address of compatible member in sja1105_check_device_id Nathan Chancellor
  2020-08-21 22:33 ` Florian Fainelli
  2020-08-21 22:57 ` Vladimir Oltean
@ 2020-08-24 23:13 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2020-08-24 23:13 UTC (permalink / raw)
  To: natechancellor
  Cc: olteanv, andrew, vivien.didelot, f.fainelli, kuba, linux-kernel,
	netdev, clang-built-linux

From: Nathan Chancellor <natechancellor@gmail.com>
Date: Fri, 21 Aug 2020 15:25:16 -0700

> Clang warns:
> 
> drivers/net/dsa/sja1105/sja1105_main.c:3418:38: warning: address of
> array 'match->compatible' will always evaluate to 'true'
> [-Wpointer-bool-conversion]
>         for (match = sja1105_dt_ids; match->compatible; match++) {
>         ~~~                          ~~~~~~~^~~~~~~~~~
> 1 warning generated.
> 
> We should check the value of the first character in compatible to see if
> it is empty or not. This matches how the rest of the tree iterates over
> IDs.
> 
> Fixes: 0b0e299720bb ("net: dsa: sja1105: use detected device id instead of DT one on mismatch")
> Link: https://github.com/ClangBuiltLinux/linux/issues/1139
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

Applied, thanks.

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

end of thread, other threads:[~2020-08-24 23:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-21 22:25 [PATCH] net: dsa: sja1105: Do not use address of compatible member in sja1105_check_device_id Nathan Chancellor
2020-08-21 22:33 ` Florian Fainelli
2020-08-21 22:57 ` Vladimir Oltean
2020-08-24 23:13 ` David Miller

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).