diff mbox

[U-Boot,RESEND,v5] tftp.c: fix CONFIG_TFTP_TSIZE for small files

Message ID bf2785861edb4d3341204369045aaea6eb74307a.1438787144.git.marcel.ziswiler@toradex.com
State Accepted
Delegated to: Joe Hershberger
Headers show

Commit Message

Marcel Ziswiler Aug. 5, 2015, 3:17 p.m. UTC
From: Max Krummenacher <max.krummenacher@toradex.com>

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>
---
Changes in v5: split up into separate patches to be picked up by the
various subsystem maintainers as suggested by Marek
Changes in v2: run it through checkpatch.pl and fix missing space in
if clause as suggested by Marek

 net/tftp.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Joe Hershberger Aug. 11, 2015, 4:16 p.m. UTC | #1
Hi Marcel,

On Wed, Aug 5, 2015 at 10:17 AM, Marcel Ziswiler <marcel@ziswiler.com> wrote:
> From: Max Krummenacher <max.krummenacher@toradex.com>
>
> 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>

*The resend patch this time.
Joe Hershberger Aug. 12, 2015, 7:29 p.m. UTC | #2
Hi Marcel,

On Wed, Aug 5, 2015 at 10:17 AM, Marcel Ziswiler <marcel@ziswiler.com> wrote:
> From: Max Krummenacher <max.krummenacher@toradex.com>
>
> 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>

Applied to u-boot-net, thanks!
-Joe
diff mbox

Patch

diff --git a/net/tftp.c b/net/tftp.c
index 3e99e73..89be32a 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -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('#');