Skip to contentSkip to conversation

net: tftp: Remove tftp_init_load_addr error path

PATCH Superseded Leonard Anderweit 2 participants 2 messages Nov 19, 2025 – Nov 20, 2025 Networking

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: tftp: Remove tftp_init_load_addr error path

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.

---
 net/tftp.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)
net/tftp.c +2 -13
index 1760877107fa..18f72b6a74ac 100644
@@ -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);
Signature · 1 line
2.43.0
#1 lore raw

Hi Leonard,

Quoted 4 lines · Leonard Anderweit

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,

Quoted 13 lines

---
 net/tftp.c | 15 ++-------------

 1 file changed, 2 insertions(+), 13 deletions(-)
net/tftp.c +0 -0
index 1760877107fa..18f72b6a74ac 100644
@@ -901,13 +901,7 @@ void tftp_start(enum proto_t protocol)
  	} else
  #endif

net/tftp.c void tftp_start(enum proto_t protocol) · line 905

Quoted 10 lines
net/tftp.c +1 -7
  	{
-		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

Quoted 18 lines
net/tftp.c +0 -0
  		printf("Load address: 0x%lx\n", tftp_load_addr);
  		puts("Loading: *\b");

  tftp_state = STATE_SEND_RRQ;

net/tftp.c +0 -0
@@ -953,12 +947,7 @@ void tftp_start_server(void)
  {
  	tftp_filename[0] = 0;

net/tftp.c +0 -4
-	if (tftp_init_load_addr()) {
-		eth_halt();
-		net_set_state(NETLOOP_FAIL);
-		puts("\nTFTP error: trying to overwrite reserved

memory...\n");

net/tftp.c +1 -2
-		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);