public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Artem Lapkin <email2tema@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH] cmd: pxe_utils: fix ipappend ip config empty vars
Date: Thu, 21 Jan 2021 15:44:35 +0800	[thread overview]
Message-ID: <20210121074435.2754687-1-art@khadas.com> (raw)

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

             reply	other threads:[~2021-01-21  7:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-21  7:44 Artem Lapkin [this message]
2021-01-27 13:21 ` [PATCH] cmd: pxe_utils: fix ipappend ip config empty vars Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210121074435.2754687-1-art@khadas.com \
    --to=email2tema@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox