diff mbox

[U-Boot] tftp: Displace check for server ip

Message ID 1412527147-32585-1-git-send-email-maxime.hadjinlian@gmail.com
State Changes Requested
Delegated to: Tom Rini
Headers show

Commit Message

Maxime Hadjinlian Oct. 5, 2014, 4:39 p.m. UTC
If for some reason, 'serverip' is not set, and you are passing the
remote IP on the command line, the tftp command will fail, stating that
the 'serverip' is not set.

By displacing this check, it fixes the issues.

Signed-off-by: Maxime Hadjinlian <maxime.hadjinlian@gmail.com>
---

 net/net.c  | 6 ------
 net/tftp.c | 4 ++++
 2 files changed, 4 insertions(+), 6 deletions(-)

Comments

Tom Rini Oct. 27, 2014, 2:50 p.m. UTC | #1
On Sun, Oct 05, 2014 at 06:39:07PM +0200, Maxime Hadjinlian wrote:

> If for some reason, 'serverip' is not set, and you are passing the
> remote IP on the command line, the tftp command will fail, stating that
> the 'serverip' is not set.
> 
> By displacing this check, it fixes the issues.
> 
> Signed-off-by: Maxime Hadjinlian <maxime.hadjinlian@gmail.com>
> ---
> 
>  net/net.c  | 6 ------
>  net/tftp.c | 4 ++++
>  2 files changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/net/net.c b/net/net.c
> index 722089f..044ee71 100644
> --- a/net/net.c
> +++ b/net/net.c
> @@ -1235,12 +1235,6 @@ static int net_check_prereq(enum proto_t protocol)
>  #if defined(CONFIG_CMD_NFS)
>  	case NFS:
>  #endif
> -	case TFTPGET:
> -	case TFTPPUT:
> -		if (NetServerIP == 0) {
> -			puts("*** ERROR: `serverip' not set\n");
> -			return 1;
> -		}

Moving the check to TftpServer() seems fine but right here you've also
removed the check from the NFS cmd which is wrong.  This needs to be
re-worked so that the current check is under #if defined(CONFIG_CMD_NFS)
and we continue case'ing TFTPGET/TFTPPUT through the common part that
follows and so forth.  Thanks!

>  #if	defined(CONFIG_CMD_PING) || defined(CONFIG_CMD_SNTP) || \
>  	defined(CONFIG_CMD_DNS)
>  common:
> diff --git a/net/tftp.c b/net/tftp.c
> index 966d1cf..eb93df5 100644
> --- a/net/tftp.c
> +++ b/net/tftp.c
> @@ -736,6 +736,10 @@ void TftpStart(enum proto_t protocol)
>  			tftp_filename[MAX_LEN-1] = 0;
>  		}
>  	}
> +	if (TftpRemoteIP == 0) {
> +		printf("*** ERRROR: No server IP found.\n");
> +		return;
> +	}
>  
>  	printf("Using %s device\n", eth_get_name());
>  	printf("TFTP %s server %pI4; our IP address is %pI4",
> -- 
> 2.1.1
> 
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
diff mbox

Patch

diff --git a/net/net.c b/net/net.c
index 722089f..044ee71 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1235,12 +1235,6 @@  static int net_check_prereq(enum proto_t protocol)
 #if defined(CONFIG_CMD_NFS)
 	case NFS:
 #endif
-	case TFTPGET:
-	case TFTPPUT:
-		if (NetServerIP == 0) {
-			puts("*** ERROR: `serverip' not set\n");
-			return 1;
-		}
 #if	defined(CONFIG_CMD_PING) || defined(CONFIG_CMD_SNTP) || \
 	defined(CONFIG_CMD_DNS)
 common:
diff --git a/net/tftp.c b/net/tftp.c
index 966d1cf..eb93df5 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -736,6 +736,10 @@  void TftpStart(enum proto_t protocol)
 			tftp_filename[MAX_LEN-1] = 0;
 		}
 	}
+	if (TftpRemoteIP == 0) {
+		printf("*** ERRROR: No server IP found.\n");
+		return;
+	}
 
 	printf("Using %s device\n", eth_get_name());
 	printf("TFTP %s server %pI4; our IP address is %pI4",