diff mbox series

[v2,5/7] net: wget: make wget_with_dns return value compatible with its lwip version

Message ID 20241111210901.560691-6-adrianox@gmail.com
State Accepted, archived
Delegated to: Heinrich Schuchardt
Headers show
Series wget: Expose wget to applications | expand

Commit Message

Adriano Cordova Nov. 11, 2024, 9:08 p.m. UTC
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.

Signed-off-by: Adriano Cordova <adrianox@gmail.com>
---

Changes in v2:
- Remove wget_with_dns from include/net-lwip.h, as it already is in include/net-common.h
- Adjust return value in the documentation of wget_with_dns.

 include/net-common.h | 2 +-
 include/net-lwip.h   | 9 ---------
 net/wget.c           | 2 +-
 3 files changed, 2 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/include/net-common.h b/include/net-common.h
index 1efb0db9ff..3cd0f34374 100644
--- a/include/net-common.h
+++ b/include/net-common.h
@@ -495,7 +495,7 @@  int do_tftpb(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
  *
  * @dst_addr:	destination address to download the file
  * @uri:	uri string of target file of wget
- * Return:	downloaded file size, negative if failed
+ * Return:	zero on success, negative if failed
  */
 int wget_with_dns(ulong dst_addr, char *uri);
 /**
diff --git a/include/net-lwip.h b/include/net-lwip.h
index 1c3583f82a..4d7f9387d1 100644
--- a/include/net-lwip.h
+++ b/include/net-lwip.h
@@ -16,15 +16,6 @@  void net_lwip_remove_netif(struct netif *netif);
 struct netif *net_lwip_get_netif(void);
 int net_lwip_rx(struct udevice *udev, struct netif *netif);
 
-/**
- * wget_with_dns() - runs dns host IP address resulution before wget
- *
- * @dst_addr:	destination address to download the file
- * @uri:	uri string of target file of wget
- * Return:	downloaded file size, negative if failed
- */
-
-int wget_with_dns(ulong dst_addr, char *uri);
 /**
  * wget_validate_uri() - varidate the uri
  *
diff --git a/net/wget.c b/net/wget.c
index 21f1875866..3bc2522cde 100644
--- a/net/wget.c
+++ b/net/wget.c
@@ -579,7 +579,7 @@  int wget_with_dns(ulong dst_addr, char *uri)
 out:
 	free(str_copy);
 
-	return ret;
+	return ret < 0 ? ret : 0;
 }
 #endif