]> git.sur5r.net Git - u-boot/commitdiff
tftp.c: fix CONFIG_TFTP_TSIZE for small files
authorMax Krummenacher <max.krummenacher@toradex.com>
Wed, 5 Aug 2015 15:17:05 +0000 (17:17 +0200)
committerJoe Hershberger <joe.hershberger@ni.com>
Wed, 12 Aug 2015 19:15:28 +0000 (14:15 -0500)
CONFIG_TFTP_TSIZE should limit a tftp downloads progress to 50 '#'
chars. Make this work also for small files.

If the file size is small, i.e. smaller than 2 tftp block sizes the
number of '#' can get much larger. i.e. with a 1 byte file 65000
characters are printed, with a 512 byte file around 500.

When using CONFIG TFTP BLOCKSIZE together with CONFIG_IP_DEFRAG the
issue is more notable.

Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Reviewed-by: Marek Vasut <marex@denx.de>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
net/tftp.c

index 3e99e7309116c333576a366735214ccb66c6fdc3..89be32a26bd8cfaca738bda523cc400830088fa4 100644 (file)
@@ -249,6 +249,8 @@ static void show_block_marker(void)
        if (tftp_tsize) {
                ulong pos = tftp_cur_block * tftp_block_size +
                        tftp_block_wrap_offset;
+               if (pos > tftp_tsize)
+                       pos = tftp_tsize;
 
                while (tftp_tsize_num_hash < pos * 50 / tftp_tsize) {
                        putc('#');