public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH 6/7] net/lwip: wget: put server_name and port into wget_ctx
@ 2024-11-06 13:04 Adriano Cordova
  2024-11-07 11:21 ` Jerome Forissier
  0 siblings, 1 reply; 3+ messages in thread
From: Adriano Cordova @ 2024-11-06 13:04 UTC (permalink / raw)
  To: u-boot
  Cc: joe.hershberger, rfried.dev, jerome.forissier, xypron.glpk,
	Adriano Cordova

Currently server_name and port are local variables in wget_loop.
This commit puts them inside ctx, so that they are accessible
from the http callbacks.

Signed-off-by: Adriano Cordova <adrianox@gmail.com>
---
 net/lwip/wget.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/lwip/wget.c b/net/lwip/wget.c
index b495ebd1aa..4add520045 100644
--- a/net/lwip/wget.c
+++ b/net/lwip/wget.c
@@ -23,6 +23,8 @@ enum done_state {
 };
 
 struct wget_ctx {
+	char server_name[SERVER_NAME_SIZE];
+	u16 port;
 	char *path;
 	ulong daddr;
 	ulong saved_daddr;
@@ -209,13 +211,11 @@ static void httpc_result_cb(void *arg, httpc_result_t httpc_result,
 
 static int wget_loop(struct udevice *udev, ulong dst_addr, char *uri)
 {
-	char server_name[SERVER_NAME_SIZE];
 	httpc_connection_t conn;
 	httpc_state_t *state;
 	struct netif *netif;
 	struct wget_ctx ctx;
 	char *path;
-	u16 port;
 
 	ctx.daddr = dst_addr;
 	ctx.saved_daddr = dst_addr;
@@ -224,7 +224,7 @@ static int wget_loop(struct udevice *udev, ulong dst_addr, char *uri)
 	ctx.prevsize = 0;
 	ctx.start_time = 0;
 
-	if (parse_url(uri, server_name, &port, &path))
+	if (parse_url(uri, ctx.server_name, &ctx.port, &path))
 		return CMD_RET_USAGE;
 
 	netif = net_lwip_new_netif(udev);
@@ -234,7 +234,7 @@ static int wget_loop(struct udevice *udev, ulong dst_addr, char *uri)
 	memset(&conn, 0, sizeof(conn));
 	conn.result_fn = httpc_result_cb;
 	ctx.path = path;
-	if (httpc_get_file_dns(server_name, port, path, &conn, httpc_recv_cb,
+	if (httpc_get_file_dns(ctx.server_name, ctx.port, path, &conn, httpc_recv_cb,
 			       &ctx, &state)) {
 		net_lwip_remove_netif(netif);
 		return CMD_RET_FAILURE;
-- 
2.43.0


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

* Re: [PATCH 6/7] net/lwip: wget: put server_name and port into wget_ctx
  2024-11-06 13:04 [PATCH 6/7] net/lwip: wget: put server_name and port into wget_ctx Adriano Cordova
@ 2024-11-07 11:21 ` Jerome Forissier
  2024-11-08 17:48   ` Heinrich Schuchardt
  0 siblings, 1 reply; 3+ messages in thread
From: Jerome Forissier @ 2024-11-07 11:21 UTC (permalink / raw)
  To: Adriano Cordova, u-boot; +Cc: joe.hershberger, rfried.dev, xypron.glpk

On 11/6/24 13:04, Adriano Cordova wrote:
> Currently server_name and port are local variables in wget_loop.
> This commit puts them inside ctx, so that they are accessible
> from the http callbacks.
> 
> Signed-off-by: Adriano Cordova <adrianox@gmail.com>
> ---
>  net/lwip/wget.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/net/lwip/wget.c b/net/lwip/wget.c
> index b495ebd1aa..4add520045 100644
> --- a/net/lwip/wget.c
> +++ b/net/lwip/wget.c
> @@ -23,6 +23,8 @@ enum done_state {
>  };
>  
>  struct wget_ctx {
> +	char server_name[SERVER_NAME_SIZE];
> +	u16 port;
>  	char *path;
>  	ulong daddr;
>  	ulong saved_daddr;
> @@ -209,13 +211,11 @@ static void httpc_result_cb(void *arg, httpc_result_t httpc_result,
>  
>  static int wget_loop(struct udevice *udev, ulong dst_addr, char *uri)
>  {
> -	char server_name[SERVER_NAME_SIZE];
>  	httpc_connection_t conn;
>  	httpc_state_t *state;
>  	struct netif *netif;
>  	struct wget_ctx ctx;
>  	char *path;
> -	u16 port;
>  
>  	ctx.daddr = dst_addr;
>  	ctx.saved_daddr = dst_addr;
> @@ -224,7 +224,7 @@ static int wget_loop(struct udevice *udev, ulong dst_addr, char *uri)
>  	ctx.prevsize = 0;
>  	ctx.start_time = 0;
>  
> -	if (parse_url(uri, server_name, &port, &path))
> +	if (parse_url(uri, ctx.server_name, &ctx.port, &path))
>  		return CMD_RET_USAGE;
>  
>  	netif = net_lwip_new_netif(udev);
> @@ -234,7 +234,7 @@ static int wget_loop(struct udevice *udev, ulong dst_addr, char *uri)
>  	memset(&conn, 0, sizeof(conn));
>  	conn.result_fn = httpc_result_cb;
>  	ctx.path = path;
> -	if (httpc_get_file_dns(server_name, port, path, &conn, httpc_recv_cb,
> +	if (httpc_get_file_dns(ctx.server_name, ctx.port, path, &conn, httpc_recv_cb,
>  			       &ctx, &state)) {
>  		net_lwip_remove_netif(netif);
>  		return CMD_RET_FAILURE;

Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>

Thanks,
-- 
Jerome

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

* Re: [PATCH 6/7] net/lwip: wget: put server_name and port into wget_ctx
  2024-11-07 11:21 ` Jerome Forissier
@ 2024-11-08 17:48   ` Heinrich Schuchardt
  0 siblings, 0 replies; 3+ messages in thread
From: Heinrich Schuchardt @ 2024-11-08 17:48 UTC (permalink / raw)
  To: Adriano Cordova
  Cc: joe.hershberger, rfried.dev, Ilias Apalodimas, u-boot,
	Jerome Forissier

On 11/7/24 12:21, Jerome Forissier wrote:
> On 11/6/24 13:04, Adriano Cordova wrote:
>> Currently server_name and port are local variables in wget_loop.
>> This commit puts them inside ctx, so that they are accessible
>> from the http callbacks.
>>
>> Signed-off-by: Adriano Cordova <adrianox@gmail.com>
>> ---
>>   net/lwip/wget.c | 8 ++++----
>>   1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/net/lwip/wget.c b/net/lwip/wget.c
>> index b495ebd1aa..4add520045 100644
>> --- a/net/lwip/wget.c
>> +++ b/net/lwip/wget.c
>> @@ -23,6 +23,8 @@ enum done_state {
>>   };
>>
>>   struct wget_ctx {
>> +	char server_name[SERVER_NAME_SIZE];

cf.
[PATCH 1/1] net: lwip/wget: correct SERVER_NAME_SIZE
https://lists.denx.de/pipermail/u-boot/2024-November/571167.html

Acked-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

>> +	u16 port;
>>   	char *path;
>>   	ulong daddr;
>>   	ulong saved_daddr;
>> @@ -209,13 +211,11 @@ static void httpc_result_cb(void *arg, httpc_result_t httpc_result,
>>
>>   static int wget_loop(struct udevice *udev, ulong dst_addr, char *uri)
>>   {
>> -	char server_name[SERVER_NAME_SIZE];
>>   	httpc_connection_t conn;
>>   	httpc_state_t *state;
>>   	struct netif *netif;
>>   	struct wget_ctx ctx;
>>   	char *path;
>> -	u16 port;
>>
>>   	ctx.daddr = dst_addr;
>>   	ctx.saved_daddr = dst_addr;
>> @@ -224,7 +224,7 @@ static int wget_loop(struct udevice *udev, ulong dst_addr, char *uri)
>>   	ctx.prevsize = 0;
>>   	ctx.start_time = 0;
>>
>> -	if (parse_url(uri, server_name, &port, &path))
>> +	if (parse_url(uri, ctx.server_name, &ctx.port, &path))
>>   		return CMD_RET_USAGE;
>>
>>   	netif = net_lwip_new_netif(udev);
>> @@ -234,7 +234,7 @@ static int wget_loop(struct udevice *udev, ulong dst_addr, char *uri)
>>   	memset(&conn, 0, sizeof(conn));
>>   	conn.result_fn = httpc_result_cb;
>>   	ctx.path = path;
>> -	if (httpc_get_file_dns(server_name, port, path, &conn, httpc_recv_cb,
>> +	if (httpc_get_file_dns(ctx.server_name, ctx.port, path, &conn, httpc_recv_cb,
>>   			       &ctx, &state)) {
>>   		net_lwip_remove_netif(netif);
>>   		return CMD_RET_FAILURE;
>
> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
>
> Thanks,


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

end of thread, other threads:[~2024-11-08 17:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-06 13:04 [PATCH 6/7] net/lwip: wget: put server_name and port into wget_ctx Adriano Cordova
2024-11-07 11:21 ` Jerome Forissier
2024-11-08 17:48   ` Heinrich Schuchardt

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