U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: tftp: Remove tftp_init_load_addr error path
@ 2025-11-19  8:37 Leonard Anderweit
  2025-11-20  8:07 ` Yannic Moog
  0 siblings, 1 reply; 2+ messages in thread
From: Leonard Anderweit @ 2025-11-19  8:37 UTC (permalink / raw)
  To: u-boot; +Cc: joe.hershberger, rfried.dev, jerome.forissier

tftp_init_load_addr() always returns 0 since commit af45c84871e4 ("tftp:
rework the logic to validate the load address"), so we don't need to
check if it failed and can remove the error handling.

Signed-off-by: Leonard Anderweit <l.anderweit@phytec.de>
---
 net/tftp.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/net/tftp.c b/net/tftp.c
index 1760877107fa..18f72b6a74ac 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -901,13 +901,7 @@ void tftp_start(enum proto_t protocol)
 	} else
 #endif
 	{
-		if (tftp_init_load_addr()) {
-			eth_halt();
-			net_set_state(NETLOOP_FAIL);
-			puts("\nTFTP error: ");
-			puts("trying to overwrite reserved memory...\n");
-			return;
-		}
+		tftp_init_load_addr();
 		printf("Load address: 0x%lx\n", tftp_load_addr);
 		puts("Loading: *\b");
 		tftp_state = STATE_SEND_RRQ;
@@ -953,12 +947,7 @@ void tftp_start_server(void)
 {
 	tftp_filename[0] = 0;
 
-	if (tftp_init_load_addr()) {
-		eth_halt();
-		net_set_state(NETLOOP_FAIL);
-		puts("\nTFTP error: trying to overwrite reserved memory...\n");
-		return;
-	}
+	tftp_init_load_addr();
 	printf("Using %s device\n", eth_get_name());
 	printf("Listening for TFTP transfer on %pI4\n", &net_ip);
 	printf("Load address: 0x%lx\n", tftp_load_addr);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: tftp: Remove tftp_init_load_addr error path
  2025-11-19  8:37 [PATCH] net: tftp: Remove tftp_init_load_addr error path Leonard Anderweit
@ 2025-11-20  8:07 ` Yannic Moog
  0 siblings, 0 replies; 2+ messages in thread
From: Yannic Moog @ 2025-11-20  8:07 UTC (permalink / raw)
  To: Leonard Anderweit, u-boot@lists.denx.de
  Cc: joe.hershberger@ni.com, rfried.dev@gmail.com,
	jerome.forissier@linaro.org

Hi Leonard,

On Wed, 2025-11-19 at 09:37 +0100, Leonard Anderweit wrote:
> tftp_init_load_addr() always returns 0 since commit af45c84871e4
> ("tftp:
> rework the logic to validate the load address"), so we don't need to
> check if it failed and can remove the error handling.

Idea looks good,

> 
> Signed-off-by: Leonard Anderweit <l.anderweit@phytec.de>
> ---
>  net/tftp.c | 15 ++-------------
>  1 file changed, 2 insertions(+), 13 deletions(-)
> 
> diff --git a/net/tftp.c b/net/tftp.c
> index 1760877107fa..18f72b6a74ac 100644
> --- a/net/tftp.c
> +++ b/net/tftp.c
> @@ -901,13 +901,7 @@ void tftp_start(enum proto_t protocol)
>  	} else
>  #endif
>  	{
> -		if (tftp_init_load_addr()) {
> -			eth_halt();
> -			net_set_state(NETLOOP_FAIL);
> -			puts("\nTFTP error: ");
> -			puts("trying to overwrite reserved
> memory...\n");
> -			return;
> -		}
> +		tftp_init_load_addr();

since return value is unused then, change to

static void tftp_init_load_addr()

Yannic

>  		printf("Load address: 0x%lx\n", tftp_load_addr);
>  		puts("Loading: *\b");
>  		tftp_state = STATE_SEND_RRQ;
> @@ -953,12 +947,7 @@ void tftp_start_server(void)
>  {
>  	tftp_filename[0] = 0;
>  
> -	if (tftp_init_load_addr()) {
> -		eth_halt();
> -		net_set_state(NETLOOP_FAIL);
> -		puts("\nTFTP error: trying to overwrite reserved
> memory...\n");
> -		return;
> -	}
> +	tftp_init_load_addr();
>  	printf("Using %s device\n", eth_get_name());
>  	printf("Listening for TFTP transfer on %pI4\n", &net_ip);
>  	printf("Load address: 0x%lx\n", tftp_load_addr);

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-11-20  8:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-19  8:37 [PATCH] net: tftp: Remove tftp_init_load_addr error path Leonard Anderweit
2025-11-20  8:07 ` Yannic Moog

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox