瀏覽代碼

sntp: avoid use of uninitialized variable

When we use the ntpserverip environment variable argv[1] may not be set.
Printing the error message using the NetNtpServerIP variable ensures the
correct output in both cases.

Signed-off-by: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
Acked-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Cc: Ben Warren <biggerbadderben@gmail.com>
Acked-by: Detlev Zundel <dzu@denx.de>
Luuk Paulussen 14 年之前
父節點
當前提交
d6840e3d7a
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      common/cmd_net.c

+ 2 - 1
common/cmd_net.c

@@ -341,7 +341,8 @@ int do_sntp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	else NetTimeOffset = simple_strtol (toff, NULL, 10);
 	else NetTimeOffset = simple_strtol (toff, NULL, 10);
 
 
 	if (NetLoop(SNTP) < 0) {
 	if (NetLoop(SNTP) < 0) {
-		printf("SNTP failed: host %s not responding\n", argv[1]);
+		printf("SNTP failed: host %pI4 not responding\n",
+			&NetNtpServerIP);
 		return 1;
 		return 1;
 	}
 	}