[PATCH net-next] net: dsa: drop explicit NULL comparisons

Kai Kuang posted 1 patch 1 month, 2 weeks ago
net/dsa/dsa.c  | 2 +-
net/dsa/user.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
[PATCH net-next] net: dsa: drop explicit NULL comparisons
Posted by Kai Kuang 1 month, 2 weeks ago
Replace explicit NULL comparisons with the boolean form to follow
the kernel coding style:

  dev->class != NULL  -> dev->class
  user_dev == NULL    -> !user_dev

No functional changes intended.

Signed-off-by: Kai Kuang <kuangkai@kylinos.cn>
---
 net/dsa/dsa.c  | 2 +-
 net/dsa/user.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 9cb732f6b1e3..d72d7a49e113 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -1382,7 +1382,7 @@ static int dsa_switch_parse_of(struct dsa_switch *ds, struct device_node *dn)
 
 static int dev_is_class(struct device *dev, const void *class)
 {
-	if (dev->class != NULL && !strcmp(dev->class->name, class))
+	if (dev->class && !strcmp(dev->class->name, class))
 		return 1;
 
 	return 0;
diff --git a/net/dsa/user.c b/net/dsa/user.c
index 072fa76972cc..7d65bb307c91 100644
--- a/net/dsa/user.c
+++ b/net/dsa/user.c
@@ -2779,7 +2779,7 @@ int dsa_user_create(struct dsa_port *port)
 	user_dev = alloc_netdev_mqs(sizeof(struct dsa_user_priv), name,
 				    assign_type, ether_setup,
 				    ds->num_tx_queues, 1);
-	if (user_dev == NULL)
+	if (!user_dev)
 		return -ENOMEM;
 
 	user_dev->rtnl_link_ops = &dsa_link_ops;
-- 
2.25.1
Re: [PATCH net-next] net: dsa: drop explicit NULL comparisons
Posted by Joe Damato 1 month, 2 weeks ago
On Wed, Aug 12, 2026 at 02:06:44PM +0800, Kai Kuang wrote:
> Replace explicit NULL comparisons with the boolean form to follow
> the kernel coding style:
> 
>   dev->class != NULL  -> dev->class
>   user_dev == NULL    -> !user_dev
> 
> No functional changes intended.
> 
> Signed-off-by: Kai Kuang <kuangkai@kylinos.cn>
> ---
>  net/dsa/dsa.c  | 2 +-
>  net/dsa/user.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Joe Damato <joe@dama.to>
Re: [PATCH net-next] net: dsa: drop explicit NULL comparisons
Posted by Andrew Lunn 1 month, 2 weeks ago
On Wed, Aug 12, 2026 at 02:06:44PM +0800, Kai Kuang wrote:
> Replace explicit NULL comparisons with the boolean form to follow
> the kernel coding style:
> 
>   dev->class != NULL  -> dev->class
>   user_dev == NULL    -> !user_dev
> 
> No functional changes intended.
> 
> Signed-off-by: Kai Kuang <kuangkai@kylinos.cn>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew