Skip to contentSkip to conversation

net: wget: make wget_with_dns return value compatible with its lwip version

PATCH Superseded Adriano Cordova 2 participants 2 messages Nov 6, 2024 – Nov 8, 2024 Networking

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 5/7 net: wget: make wget_with_dns return value compatible with its lwip version

There are two wget_with_dns functions, one in the legacy network stack and one in lwip, but the return values are not compatible. This commit modifies the legacy version of wget_with_dns so that the return values are compatible: 0 on success, otherwise a negative error. This way wget_with_dns can be called in a network stack agnostic way.

---
 net/wget.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/wget.c +1 -1
index 24be0a4932..6cf721070b 100644
@@ -576,7 +576,7 @@ int wget_with_dns(ulong dst_addr, char *uri)
 out:
 	free(str_copy);
 
-	return ret;
+	return ret < 0 ? ret : 0;
 }
 #endif
 
Signature · 1 line
2.43.0
#1 lore raw
Quoted 17 lines · Adriano Cordova

There are two wget_with_dns functions, one in the legacy network stack and one in lwip, but the return values are not compatible. This commit modifies the legacy version of wget_with_dns so that the return values are compatible: 0 on success, otherwise a negative error. This way wget_with_dns can be called in a network stack agnostic way.

---
  net/wget.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
net/wget.c +0 -0
index 24be0a4932..6cf721070b 100644

net/wget.c int wget_with_dns(ulong dst_addr, char *uri) · line 579

Quoted 5 lines
net/wget.c +1 -1
@@ -576,7 +576,7 @@ int wget_with_dns(ulong dst_addr, char *uri)
  out:
  	free(str_copy);
 
-	return ret;
+	return ret < 0 ? ret : 0;

include/net-lwip.h descibes wget with dns() as

Return: downloaded file size, negative if failed

There is a second definition in net/common.h with

Return: downloaded file size, negative if failed

Your change does not match the declaration in the includes.

The function should only be defined in one include, i.e. net_common.h.

Function try_load_from_uri_path() uses

env_get_hex("filesize", 0)

to retrieve the file size. Isn't it be preferable to use the return value of wget with dns() instead?

There is ongoing work to load installation images via http and boot from these. If we return the filesize, the return type should be ssize_t to avoid a 2 GiB limit on the filesize.

Best regards

Heinrich

Quoted 3 lines
net/wget.c +0 -0
  }
  #endif