[PATCH net-next v2 6/7] netconsole: improve code style in parser function

Breno Leitao posted 7 patches 4 months ago
There is a newer version of this series
[PATCH net-next v2 6/7] netconsole: improve code style in parser function
Posted by Breno Leitao 4 months ago
Split assignment from conditional checks and use preferred null pointer
check style (!delim instead of == NULL) in netconsole_parser_cmdline().
This improves code readability and follows kernel coding style
conventions.

Signed-off-by: Breno Leitao <leitao@debian.org>
---
 drivers/net/netconsole.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 7f1fed7871967..56d14294ddcaf 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -1705,7 +1705,8 @@ static int netconsole_parser_cmdline(struct netpoll *np, char *opt)
 	int ipv6;
 
 	if (*cur != '@') {
-		if ((delim = strchr(cur, '@')) == NULL)
+		delim = strchr(cur, '@');
+		if (!delim)
 			goto parse_failed;
 		*delim = 0;
 		if (kstrtou16(cur, 10, &np->local_port))
@@ -1716,7 +1717,8 @@ static int netconsole_parser_cmdline(struct netpoll *np, char *opt)
 
 	if (*cur != '/') {
 		ipversion_set = true;
-		if ((delim = strchr(cur, '/')) == NULL)
+		delim = strchr(cur, '/');
+		if (!delim)
 			goto parse_failed;
 		*delim = 0;
 		ipv6 = netpoll_parse_ip_addr(cur, &np->local_ip);
@@ -1730,7 +1732,8 @@ static int netconsole_parser_cmdline(struct netpoll *np, char *opt)
 
 	if (*cur != ',') {
 		/* parse out dev_name or dev_mac */
-		if ((delim = strchr(cur, ',')) == NULL)
+		delim = strchr(cur, ',');
+		if (!delim)
 			goto parse_failed;
 		*delim = 0;
 
@@ -1747,7 +1750,8 @@ static int netconsole_parser_cmdline(struct netpoll *np, char *opt)
 
 	if (*cur != '@') {
 		/* dst port */
-		if ((delim = strchr(cur, '@')) == NULL)
+		delim = strchr(cur, '@');
+		if (!delim)
 			goto parse_failed;
 		*delim = 0;
 		if (*cur == ' ' || *cur == '\t')
@@ -1759,7 +1763,8 @@ static int netconsole_parser_cmdline(struct netpoll *np, char *opt)
 	cur++;
 
 	/* dst ip */
-	if ((delim = strchr(cur, '/')) == NULL)
+	delim = strchr(cur, '/');
+	if (!delim)
 		goto parse_failed;
 	*delim = 0;
 	ipv6 = netpoll_parse_ip_addr(cur, &np->remote_ip);

-- 
2.47.1