Skip to content

Commit d792064

Browse files
leitaokuba-moo
authored andcommitted
netconsole: improve code style in parser function
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 <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent abebef9 commit d792064

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

drivers/net/netconsole.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,7 +1704,8 @@ static int netconsole_parser_cmdline(struct netpoll *np, char *opt)
17041704
int ipv6;
17051705

17061706
if (*cur != '@') {
1707-
if ((delim = strchr(cur, '@')) == NULL)
1707+
delim = strchr(cur, '@');
1708+
if (!delim)
17081709
goto parse_failed;
17091710
*delim = 0;
17101711
if (kstrtou16(cur, 10, &np->local_port))
@@ -1715,7 +1716,8 @@ static int netconsole_parser_cmdline(struct netpoll *np, char *opt)
17151716

17161717
if (*cur != '/') {
17171718
ipversion_set = true;
1718-
if ((delim = strchr(cur, '/')) == NULL)
1719+
delim = strchr(cur, '/');
1720+
if (!delim)
17191721
goto parse_failed;
17201722
*delim = 0;
17211723
ipv6 = netpoll_parse_ip_addr(cur, &np->local_ip);
@@ -1729,7 +1731,8 @@ static int netconsole_parser_cmdline(struct netpoll *np, char *opt)
17291731

17301732
if (*cur != ',') {
17311733
/* parse out dev_name or dev_mac */
1732-
if ((delim = strchr(cur, ',')) == NULL)
1734+
delim = strchr(cur, ',');
1735+
if (!delim)
17331736
goto parse_failed;
17341737
*delim = 0;
17351738

@@ -1746,7 +1749,8 @@ static int netconsole_parser_cmdline(struct netpoll *np, char *opt)
17461749

17471750
if (*cur != '@') {
17481751
/* dst port */
1749-
if ((delim = strchr(cur, '@')) == NULL)
1752+
delim = strchr(cur, '@');
1753+
if (!delim)
17501754
goto parse_failed;
17511755
*delim = 0;
17521756
if (*cur == ' ' || *cur == '\t')
@@ -1758,7 +1762,8 @@ static int netconsole_parser_cmdline(struct netpoll *np, char *opt)
17581762
cur++;
17591763

17601764
/* dst ip */
1761-
if ((delim = strchr(cur, '/')) == NULL)
1765+
delim = strchr(cur, '/');
1766+
if (!delim)
17621767
goto parse_failed;
17631768
*delim = 0;
17641769
ipv6 = netpoll_parse_ip_addr(cur, &np->remote_ip);

0 commit comments

Comments
 (0)