Skip to contentSkip to conversation

cmd: pxe_utils: fix ipappend ip config empty vars

PATCH New Artem Lapkin 2 participants 2 messages Jan 21, 2021 – Jan 27, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cmd: pxe_utils: fix ipappend ip config empty vars

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

---
 cmd/pxe_utils.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
cmd/pxe_utils.c +5 -2
index 8716e782..2049c0f3 100644
@@ -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
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/1 cmd: pxe_utils: fix ipappend ip config empty vars

Quoted 23 lines · Artem Lapkin

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

---
 cmd/pxe_utils.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
cmd/pxe_utils.c +1 -0
index 8716e782..2049c0f3 100644
@@ -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");

cmd/pxe_utils.c static int label_boot(struct cmd_tbl *cmdtp, struct pxe_label *label) · line 406

Quoted 10 lines
cmd/pxe_utils.c +4 -2
+		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.

Signature · 8 lines
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>