From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wolfgang Denk Date: Sat, 19 Jul 2003 21:28:14 +0200 Subject: [U-Boot-Users] [PATCH] fixed tftp error message output In-Reply-To: Your message of "19 Jul 2003 04:34:30 +0200." <1058582070.943.37.camel@localhost> Message-ID: <20030719192819.B3ED3C6D82@atlas.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Andreas, in message <1058582070.943.37.camel@localhost> you wrote: > > This patch fixes tftp error message output, i.e. does not print the last > two bytes which contain garbage (at least for my setup, I hope this is > not a tftp server issue). Is there a way to provoke such an error, so we can test this? > case TFTP_ERROR: > - printf ("\nTFTP error: '%s' (%d)\n", > - pkt + 2, ntohs(*(ushort *)pkt)); > + printf ("\nTFTP error %d: ", ntohs(*(ushort *)pkt)); > + pkt += 2; > + len -= 2; > + while (len--) > + printf("%c", *pkt++); > + printf("\n"); > + Patch rejected. What happens if "len" turns out to be zero? Also, the code is unnecessary complex. If there really is such a problem, this should do as well (and maybe better): printf ("\nTFTP error: '%.*s' (%d)\n", len - 2, pkt + 2, ntohs(*(ushort *)pkt) ); Can you please test this (and eventually re-submit the patch) ? Thanks. Best regards, Wolfgang Denk -- Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-4596-87 Fax: (+49)-8142-4596-88 Email: wd at denx.de A memorandum is written not to inform the reader, but to protect the writer. -- Dean Acheson