Commit d7920645 authored by Breno Leitao's avatar Breno Leitao Committed by Jakub Kicinski
Browse files

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: default avatarBreno Leitao <leitao@debian.org>
Link: https://patch.msgid.link/20250613-rework-v3-6-0752bf2e6912@debian.org


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent abebef96
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -1704,7 +1704,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))
@@ -1715,7 +1716,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);
@@ -1729,7 +1731,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;

@@ -1746,7 +1749,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')
@@ -1758,7 +1762,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);