Skip to contentSkip to conversation

net: wget: Add a global struct wget_http_info

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

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 3/7 net: wget: Add a global struct wget_http_info

Declare and define a global struct wget_http_info. The default values are so that wget works as it used to, but they can be changed by an application before issuing an http request using wget, and restored afterwards. This struct is common to legacy wget and lwip wget.

---
 include/net-common.h |  2 ++
 net/net-common.c     | 10 ++++++++++
 2 files changed, 12 insertions(+)
include/net-common.h +2 -0
index 38ba95cf60..3039dfdce7 100644
@@ -533,4 +533,6 @@ struct wget_http_info {
 	char *headers;
 };
 
+extern struct wget_http_info wget_info;
+
 #endif /* __NET_COMMON_H__ */
net/net-common.c +10 -0
index a7f767d5e9..e969d508cc 100644
@@ -1,4 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
+#include <net-common.h>
 
 void copy_filename(char *dst, const char *src, int size)
 {
@@ -11,3 +12,12 @@ void copy_filename(char *dst, const char *src, int size)
 		*dst++ = *src++;
 	*dst = '\0';
 }
+
+struct wget_http_info wget_info = {
+	.method = WGET_HTTP_METHOD_GET,
+	.file_size = 0,
+	.buffer_size = 0,
+	.set_bootdev = true,
+	.check_buffer_size = false,
+	.headers = NULL,
+};
Signature · 1 line
2.43.0
Reviewed-by on v1 3/7
#1 lore raw
Quoted 36 lines · Adriano Cordova

Declare and define a global struct wget_http_info. The default values are so that wget works as it used to, but they can be changed by an application before issuing an http request using wget, and restored afterwards. This struct is common to legacy wget and lwip wget.

---
 include/net-common.h |  2 ++
 net/net-common.c     | 10 ++++++++++
 2 files changed, 12 insertions(+)
include/net-common.h +2 -0
index 38ba95cf60..3039dfdce7 100644
@@ -533,4 +533,6 @@ struct wget_http_info {
 	char *headers;
 };
 
+extern struct wget_http_info wget_info;
+
 #endif /* __NET_COMMON_H__ */
net/net-common.c +1 -0
index a7f767d5e9..e969d508cc 100644
@@ -1,4 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
+#include <net-common.h>
 
 void copy_filename(char *dst, const char *src, int size)
 {
@@ -11,3 +12,12 @@ void copy_filename(char *dst, const char *src, int size)
 		*dst++ = *src++;
 	*dst = '\0';

net/net-common.c void copy_filename(char *dst, const char *src, int size) · line 23

Quoted 10 lines
net/net-common.c +9 -0
 }
+
+struct wget_http_info wget_info = {
+	.method = WGET_HTTP_METHOD_GET,
+	.file_size = 0,
+	.buffer_size = 0,
+	.set_bootdev = true,
+	.check_buffer_size = false,
+	.headers = NULL,
+};

Thanks,

Signature · 1 line
Jerome
#2 lore raw
Quoted 32 lines · Jerome Forissier
Quoted 31 lines · Adriano Cordova

Declare and define a global struct wget_http_info. The default values are so that wget works as it used to, but they can be changed by an application before issuing an http request using wget, and restored afterwards. This struct is common to legacy wget and lwip wget.

---
  include/net-common.h |  2 ++
  net/net-common.c     | 10 ++++++++++
  2 files changed, 12 insertions(+)
include/net-common.h +2 -0
index 38ba95cf60..3039dfdce7 100644
@@ -533,4 +533,6 @@ struct wget_http_info {
  	char *headers;
  };
 
+extern struct wget_http_info wget_info;
+
  #endif /* __NET_COMMON_H__ */
net/net-common.c +1 -0
index a7f767d5e9..e969d508cc 100644
@@ -1,4 +1,5 @@
  // SPDX-License-Identifier: GPL-2.0
+#include <net-common.h>
 
Quoted 14 lines
Quoted 4 lines
net/net-common.c +0 -0
  void copy_filename(char *dst, const char *src, int size)
  {
@@ -11,3 +12,12 @@ void copy_filename(char *dst, const char *src, int size)
  		*dst++ = *src++;

net/net-common.c void copy_filename(char *dst, const char *src, int size) · line 22

Quoted 10 lines
net/net-common.c +8 -0
  	*dst = '\0';
  }
+
+struct wget_http_info wget_info = {
+	.method = WGET_HTTP_METHOD_GET,
+	.file_size = 0,
+	.buffer_size = 0,
+	.set_bootdev = true,
+	.check_buffer_size = false,
+	.headers = NULL,

wget_info is a global symbol. It will be reused in every wget transaction. The values initialized here may be overwritten in a first transaction and the current initialization would have no impact on a second transaction.

Please, move the initialization to the function that starts a new transaction.

For static and global variables only used after relocation it is not necessary to initialize members to 0 in the definition.

Best regards

Heinrich

Quoted 5 lines

net/net-common.c void copy_filename(char *dst, const char *src, int size) · line 23

Quoted 1 line
net/net-common.c +1 -0
+};

Thanks,