All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cmd: pxe_utils: fix ipappend ip config empty vars
@ 2021-01-21  7:44 ` Artem Lapkin
  0 siblings, 0 replies; 4+ messages in thread
From: Artem Lapkin @ 2021-01-21  7:44 UTC (permalink / raw)
  To: u-boot

PROBLEM: If ipaddr, serverip, gatewayip or netmask variable undefined
we can have for example ip=192.168.2.33:<NULL>:192.168.2.1:255.255.255.0
yes its works same for linux kernel, but im think no need print <NULL>

SUGGESTED SOLUTION:
if some variable was undefined we need just print empty place like this
ip=192.168.2.33::192.168.2.1:255.255.255.0

Signed-off-by: Artem Lapkin <art@khadas.com>

---
 cmd/pxe_utils.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/cmd/pxe_utils.c b/cmd/pxe_utils.c
index 8716e782..2049c0f3 100644
--- a/cmd/pxe_utils.c
+++ b/cmd/pxe_utils.c
@@ -395,9 +395,12 @@ static int label_boot(struct cmd_tbl *cmdtp, struct pxe_label *label)
 	}
 
 	if (label->ipappend & 0x1) {
+		char *a = env_get("ipaddr");
+		char *b = env_get("serverip");
+		char *c = env_get("gatewayip");
+		char *d = env_get("netmask");
 		sprintf(ip_str, " ip=%s:%s:%s:%s",
-			env_get("ipaddr"), env_get("serverip"),
-			env_get("gatewayip"), env_get("netmask"));
+			a ? a : "", b ? b : "", c ? c : "", d ? d : "");
 	}
 
 #ifdef CONFIG_CMD_NET
-- 
2.25.1

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

* [PATCH] cmd: pxe_utils: fix ipappend ip config empty vars
@ 2021-01-21  7:44 ` Artem Lapkin
  0 siblings, 0 replies; 4+ messages in thread
From: Artem Lapkin @ 2021-01-21  7:44 UTC (permalink / raw)
  To: trini; +Cc: u-boot, u-boot-amlogic, art, nick, gouwa

PROBLEM: If ipaddr, serverip, gatewayip or netmask variable undefined
we can have for example ip=192.168.2.33:<NULL>:192.168.2.1:255.255.255.0
yes its works same for linux kernel, but im think no need print <NULL>

SUGGESTED SOLUTION:
if some variable was undefined we need just print empty place like this
ip=192.168.2.33::192.168.2.1:255.255.255.0

Signed-off-by: Artem Lapkin <art@khadas.com>

---
 cmd/pxe_utils.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/cmd/pxe_utils.c b/cmd/pxe_utils.c
index 8716e782..2049c0f3 100644
--- a/cmd/pxe_utils.c
+++ b/cmd/pxe_utils.c
@@ -395,9 +395,12 @@ static int label_boot(struct cmd_tbl *cmdtp, struct pxe_label *label)
 	}
 
 	if (label->ipappend & 0x1) {
+		char *a = env_get("ipaddr");
+		char *b = env_get("serverip");
+		char *c = env_get("gatewayip");
+		char *d = env_get("netmask");
 		sprintf(ip_str, " ip=%s:%s:%s:%s",
-			env_get("ipaddr"), env_get("serverip"),
-			env_get("gatewayip"), env_get("netmask"));
+			a ? a : "", b ? b : "", c ? c : "", d ? d : "");
 	}
 
 #ifdef CONFIG_CMD_NET
-- 
2.25.1


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

* [PATCH] cmd: pxe_utils: fix ipappend ip config empty vars
  2021-01-21  7:44 ` Artem Lapkin
@ 2021-01-27 13:21   ` Tom Rini
  -1 siblings, 0 replies; 4+ messages in thread
From: Tom Rini @ 2021-01-27 13:21 UTC (permalink / raw)
  To: u-boot

On Thu, Jan 21, 2021 at 03:44:35PM +0800, Artem Lapkin wrote:

> PROBLEM: If ipaddr, serverip, gatewayip or netmask variable undefined
> we can have for example ip=192.168.2.33:<NULL>:192.168.2.1:255.255.255.0
> yes its works same for linux kernel, but im think no need print <NULL>
> 
> SUGGESTED SOLUTION:
> if some variable was undefined we need just print empty place like this
> ip=192.168.2.33::192.168.2.1:255.255.255.0
> 
> Signed-off-by: Artem Lapkin <art@khadas.com>
> 
> ---
>  cmd/pxe_utils.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/cmd/pxe_utils.c b/cmd/pxe_utils.c
> index 8716e782..2049c0f3 100644
> --- a/cmd/pxe_utils.c
> +++ b/cmd/pxe_utils.c
> @@ -395,9 +395,12 @@ static int label_boot(struct cmd_tbl *cmdtp, struct pxe_label *label)
>  	}
>  
>  	if (label->ipappend & 0x1) {
> +		char *a = env_get("ipaddr");
> +		char *b = env_get("serverip");
> +		char *c = env_get("gatewayip");
> +		char *d = env_get("netmask");
>  		sprintf(ip_str, " ip=%s:%s:%s:%s",
> -			env_get("ipaddr"), env_get("serverip"),
> -			env_get("gatewayip"), env_get("netmask"));
> +			a ? a : "", b ? b : "", c ? c : "", d ? d : "");
>  	}
>  
>  #ifdef CONFIG_CMD_NET

If Linux is happily parsing this, I'm not sure it's worth changing.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210127/97143425/attachment.sig>

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

* Re: [PATCH] cmd: pxe_utils: fix ipappend ip config empty vars
@ 2021-01-27 13:21   ` Tom Rini
  0 siblings, 0 replies; 4+ messages in thread
From: Tom Rini @ 2021-01-27 13:21 UTC (permalink / raw)
  To: Artem Lapkin; +Cc: u-boot, u-boot-amlogic, art, nick, gouwa

[-- Attachment #1: Type: text/plain, Size: 1321 bytes --]

On Thu, Jan 21, 2021 at 03:44:35PM +0800, Artem Lapkin wrote:

> PROBLEM: If ipaddr, serverip, gatewayip or netmask variable undefined
> we can have for example ip=192.168.2.33:<NULL>:192.168.2.1:255.255.255.0
> yes its works same for linux kernel, but im think no need print <NULL>
> 
> SUGGESTED SOLUTION:
> if some variable was undefined we need just print empty place like this
> ip=192.168.2.33::192.168.2.1:255.255.255.0
> 
> Signed-off-by: Artem Lapkin <art@khadas.com>
> 
> ---
>  cmd/pxe_utils.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/cmd/pxe_utils.c b/cmd/pxe_utils.c
> index 8716e782..2049c0f3 100644
> --- a/cmd/pxe_utils.c
> +++ b/cmd/pxe_utils.c
> @@ -395,9 +395,12 @@ static int label_boot(struct cmd_tbl *cmdtp, struct pxe_label *label)
>  	}
>  
>  	if (label->ipappend & 0x1) {
> +		char *a = env_get("ipaddr");
> +		char *b = env_get("serverip");
> +		char *c = env_get("gatewayip");
> +		char *d = env_get("netmask");
>  		sprintf(ip_str, " ip=%s:%s:%s:%s",
> -			env_get("ipaddr"), env_get("serverip"),
> -			env_get("gatewayip"), env_get("netmask"));
> +			a ? a : "", b ? b : "", c ? c : "", d ? d : "");
>  	}
>  
>  #ifdef CONFIG_CMD_NET

If Linux is happily parsing this, I'm not sure it's worth changing.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

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

end of thread, other threads:[~2021-01-27 13:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-21  7:44 [PATCH] cmd: pxe_utils: fix ipappend ip config empty vars Artem Lapkin
2021-01-21  7:44 ` Artem Lapkin
2021-01-27 13:21 ` Tom Rini
2021-01-27 13:21   ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.