Patchwork [U-Boot,PATCHv2] sntp: avoid use of uninitialized variable

login
register
mail settings
Submitter Chris Packham
Date May 17, 2011, 4:27 a.m.
Message ID <1305606431-13473-1-git-send-email-judge.packham@gmail.com>
Download mbox | patch
Permalink /patch/95850/
State Accepted
Commit d6840e3d7abb71c2a45c3788dcc6edf7feb1d303
Headers show

Comments

Chris Packham - May 17, 2011, 4:27 a.m.
From: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>

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>
---
Changes since v1:
- run through checkpatch.pl, fix line > 80 chars

 common/cmd_net.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
Detlev Zundel - May 17, 2011, 8:32 a.m.
Hi Chris,

> From: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
>
> 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>
> ---
> Changes since v1:
> - run through checkpatch.pl, fix line > 80 chars
>
>  common/cmd_net.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/common/cmd_net.c b/common/cmd_net.c
> index 8c6f5c8..fae3c7f 100644
> --- a/common/cmd_net.c
> +++ b/common/cmd_net.c
> @@ -324,7 +324,8 @@ int do_sntp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>  	else NetTimeOffset = simple_strtol (toff, NULL, 10);
>  
>  	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;
>  	}

Acked-by: Detlev Zundel <dzu@denx.de>

Cheers
  Detlev

Patch

diff --git a/common/cmd_net.c b/common/cmd_net.c
index 8c6f5c8..fae3c7f 100644
--- a/common/cmd_net.c
+++ b/common/cmd_net.c
@@ -324,7 +324,8 @@  int do_sntp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	else NetTimeOffset = simple_strtol (toff, NULL, 10);
 
 	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;
 	}