[BusyBox] [PATCH] tftp client

Magnus Damm damm at opensource.se
Sun Mar 4 14:38:14 UTC 2001


Hi,

thanks for the patch.

> 1)
> -error_msg("bla-bla\n");
> +error_msg("bla_bla");

looks good. thanks.
 
> 2)
> -return 0;
> +return EXIT_SUCCESS;
> -return 1;
> +return EXIT_FAILURE;

That's the correct way of doing it... =)

 > 3) size optimization

Your changes look good to me.
They compile clean but makes the application act really wierd.

Tried to track it down, but didn't find the problem.
I added printouts and then the problem disappeared.
Seems like a stack related problem to me.

I have attached a patch with your error_msg() and EXIT_ stuff. 
Mark, could you apply my attached patch with Vladimir's changes to cvs?
Thanks.

Vladimir, you will have to try out your size optimization code by
yourself.
It makes the tftp-app unstable on my machine and I have no idea why...
=(

Thanks.

Cheers / 

Magnus
-------------- next part --------------
--- tftp-orig.c	Sun Mar  4 15:28:25 2001
+++ tftp.c	Sun Mar  4 15:19:19 2001
@@ -110,7 +110,7 @@
 
 	if ((socketfd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) {
 		perror_msg("socket");
-		return 1;
+		return EXIT_FAILURE;
 	}
 
 	len = sizeof(sa);
@@ -157,7 +157,7 @@
 			}
 
 			if ((*cp != '\0') || (&buf[BUFSIZE - 1] - cp) < 7) {
-				error_msg("too long server-filename.\n");
+				error_msg("too long server-filename");
 				break;
 			}
 
@@ -212,7 +212,7 @@
 
 			if (sendto(socketfd, buf, len, 0,
 					   (struct sockaddr *) &sa, sizeof(sa)) < 0) {
-				perror_msg("send()");
+				perror_msg("send");
 				len = -1;
 				break;
 			}
@@ -256,7 +256,7 @@
 				/* discard the packet - treat as timeout */
 
 			case 0:
-				error_msg("timeout.\n");
+				error_msg("timeout");
 
 				if (!timeout) {
 					timeout = BB_TFTP_NO_RETRIES;
@@ -266,7 +266,7 @@
 
 				if (!timeout) {
 					len = -1;
-					error_msg("last timeout!\n");
+					error_msg("last timeout");
 				}
 				break;
 
@@ -333,7 +333,7 @@
 			}
 
 			if (msg) {
-				error_msg("server says: %s.\n", msg);
+				error_msg("server says: %s", msg);
 			}
 
 			break;
@@ -342,11 +342,7 @@
 
 	close(socketfd);
 
-	if (finished) {
-		return 0;
-	}
-
-	return 1;
+	return finished ? EXIT_SUCCESS : EXIT_FAILURE;
 }
 
 int tftp_main(int argc, char **argv)
@@ -402,7 +398,7 @@
 		free(s);
 	}
 	if (bad) {
-		perror_msg_and_die("bad \"server:file\" combination");
+		error_msg_and_die("bad \"server:file\" combination");
 	}
 
 	if (BB_TFTP_DEBUG) {


More information about the busybox mailing list