Skip to contentSkip to conversation

tftp return value

PATCH In review Jan Weitzel 2 participants 2 messages Apr 14, 2010 – Apr 17, 2010 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tftp return value

tftp returns transfered bytes on success and 1 in error case. Bad for scripting. Change to 0 on success

---
Index: barebox-2010.04.0/net/tftp.c
===================================================================
--- barebox-2010.04.0.orig/net/tftp.c 2010-04-14 09:41:37.489858785
+0200
+++ barebox-2010.04.0/net/tftp.c 2010-04-14 09:43:33.899445811 +0200
@@ -281,8 +281,7 @@

TftpStart(remotefile);

- rcode = NetLoop();
- if (rcode < 0) {
+ if (NetLoop() < 0) {
rcode = 1;
goto out;
}

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#1 lore raw

Hello Jan,

Quoted 11 lines · Jan Weitzel

tftp returns transfered bytes on success and 1 in error case. Bad for scripting. Change to 0 on success

---
Index: barebox-2010.04.0/net/tftp.c
===================================================================
--- barebox-2010.04.0.orig/net/tftp.c 2010-04-14 09:41:37.489858785
+0200
+++ barebox-2010.04.0/net/tftp.c 2010-04-14 09:43:33.899445811 +0200

Review line 287

Quoted 9 lines
(quoted diff) +1 -2
@@ -281,8 +281,7 @@
 
 	TftpStart(remotefile);
 
-	rcode = NetLoop();
-	if (rcode < 0) {
+	if (NetLoop() < 0) {
 		rcode = 1;
 		goto out;
 	}

Some time ago I created a patch that had the same effect. (I changed the return code of NetLoop() instead of its interpretation, but that shouldn't matter much---I didn't (re)verify it though.)

But I had an additional hunk to let tftp return 1 if initializing the network failed.

Below is my complete patch.

Best regards
Uwe

---------------------->8-----------------------
From: Uwe Kleine-König <[email protected]>
Date: Fri, 26 Mar 2010 12:55:37 +0100
Subject: net/tftp: let tftp return 0 on success and 1 on failure

---
 net/net.c  |    2 +-
 net/tftp.c |    4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)
net/net.c +1 -1
index 4554d49..e73ee31 100644
@@ -316,7 +316,7 @@ int NetLoop(void)
 				setenv("filesize", buf);
 			}
 			eth_halt();
-			return NetBootFileXferSize;
+			return 0;
 
 		case NETLOOP_FAIL:
 			eth_halt();
net/tftp.c +3 -1
index 26f0c43..bcb3793 100644
@@ -276,8 +276,10 @@ static int do_tftpb(struct command *cmdtp, int argc, char *argv[])
 		return 1;
 	}
 
-	if (NetLoopInit(TFTP) < 0)
+	if (NetLoopInit(TFTP) < 0) {
+		rcode = 1;
 		goto out;
+	}
 
 	TftpStart(remotefile);
 
Signature · 12 lines
1.7.0



-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox