diff mbox series

[net-next,v2,08/10] net: netconsole: do not pass userdata up to the tail

Message ID 20240909130756.2722126-9-leitao@debian.org (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series netconsole refactoring and warning fix | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 16 this patch: 14
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang fail Errors and warnings before: 16 this patch: 19
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 16 this patch: 14
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 61 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Breno Leitao Sept. 9, 2024, 1:07 p.m. UTC
Do not pass userdata to send_msg_fragmented, since we can get it later.

This will be more useful in the next patch, where send_msg_fragmented()
will be split even more, and userdata is only necessary in the last
function.

Suggested-by: Simon Horman <horms@kernel.org>
Signed-off-by: Breno Leitao <leitao@debian.org>
---
 drivers/net/netconsole.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

Comments

Simon Horman Sept. 9, 2024, 4:05 p.m. UTC | #1
On Mon, Sep 09, 2024 at 06:07:49AM -0700, Breno Leitao wrote:
> Do not pass userdata to send_msg_fragmented, since we can get it later.
> 
> This will be more useful in the next patch, where send_msg_fragmented()
> will be split even more, and userdata is only necessary in the last
> function.
> 
> Suggested-by: Simon Horman <horms@kernel.org>
> Signed-off-by: Breno Leitao <leitao@debian.org>

...

> @@ -1094,7 +1098,6 @@ static void append_release(char *buf)
>  
>  static void send_msg_fragmented(struct netconsole_target *nt,
>  				const char *msg,
> -				const char *userdata,
>  				int msg_len,
>  				int release_len)
>  {
> @@ -1103,8 +1106,10 @@ static void send_msg_fragmented(struct netconsole_target *nt,
>  	int offset = 0, userdata_len = 0;
>  	const char *header, *msgbody;
>  
> -	if (userdata)
> -		userdata_len = nt->userdata_length;
> +#ifdef CONFIG_NETCONSOLE_DYNAMIC
> +	userdata = nt->userdata_complete;
> +	userdata_len = nt->userdata_length;
> +#endif

userdata does not appear to be declared in this scope :(

.../netconsole.c:1110:9: error: 'userdata' undeclared (first use in this function)
 1110 |         userdata = nt->userdata_complete;

>  
>  	/* need to insert extra header fields, detect header and msgbody */
>  	header = msg;

...
Breno Leitao Sept. 10, 2024, 9:44 a.m. UTC | #2
On Mon, Sep 09, 2024 at 05:05:28PM +0100, Simon Horman wrote:
> On Mon, Sep 09, 2024 at 06:07:49AM -0700, Breno Leitao wrote:
> > Do not pass userdata to send_msg_fragmented, since we can get it later.
> > 
> > This will be more useful in the next patch, where send_msg_fragmented()
> > will be split even more, and userdata is only necessary in the last
> > function.
> > 
> > Suggested-by: Simon Horman <horms@kernel.org>
> > Signed-off-by: Breno Leitao <leitao@debian.org>
> 
> ...
> 
> > @@ -1094,7 +1098,6 @@ static void append_release(char *buf)
> >  
> >  static void send_msg_fragmented(struct netconsole_target *nt,
> >  				const char *msg,
> > -				const char *userdata,
> >  				int msg_len,
> >  				int release_len)
> >  {
> > @@ -1103,8 +1106,10 @@ static void send_msg_fragmented(struct netconsole_target *nt,
> >  	int offset = 0, userdata_len = 0;
> >  	const char *header, *msgbody;
> >  
> > -	if (userdata)
> > -		userdata_len = nt->userdata_length;
> > +#ifdef CONFIG_NETCONSOLE_DYNAMIC
> > +	userdata = nt->userdata_complete;
> > +	userdata_len = nt->userdata_length;
> > +#endif
> 
> userdata does not appear to be declared in this scope :(
> 
> .../netconsole.c:1110:9: error: 'userdata' undeclared (first use in this function)
>  1110 |         userdata = nt->userdata_complete;

Oh, during my rebase, I moved the declaration to a patch forward, and I
didn't catch this because I was just compiling and testing with the
whole patchset applied.

Thanks for catching it. I will send an updated version.
--breno
diff mbox series

Patch

diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 2cdd2d6a2a18..4044a6307d44 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -1060,13 +1060,17 @@  static struct notifier_block netconsole_netdev_notifier = {
 
 static void send_msg_no_fragmentation(struct netconsole_target *nt,
 				      const char *msg,
-				      const char *userdata,
 				      int msg_len,
 				      int release_len)
 {
 	static char buf[MAX_PRINT_CHUNK]; /* protected by target_list_lock */
+	const char *userdata = NULL;
 	const char *release;
 
+#ifdef CONFIG_NETCONSOLE_DYNAMIC
+	userdata = nt->userdata_complete;
+#endif
+
 	if (release_len) {
 		release = init_utsname()->release;
 
@@ -1094,7 +1098,6 @@  static void append_release(char *buf)
 
 static void send_msg_fragmented(struct netconsole_target *nt,
 				const char *msg,
-				const char *userdata,
 				int msg_len,
 				int release_len)
 {
@@ -1103,8 +1106,10 @@  static void send_msg_fragmented(struct netconsole_target *nt,
 	int offset = 0, userdata_len = 0;
 	const char *header, *msgbody;
 
-	if (userdata)
-		userdata_len = nt->userdata_length;
+#ifdef CONFIG_NETCONSOLE_DYNAMIC
+	userdata = nt->userdata_complete;
+	userdata_len = nt->userdata_length;
+#endif
 
 	/* need to insert extra header fields, detect header and msgbody */
 	header = msg;
@@ -1201,12 +1206,10 @@  static void send_msg_fragmented(struct netconsole_target *nt,
 static void send_ext_msg_udp(struct netconsole_target *nt, const char *msg,
 			     int msg_len)
 {
-	char *userdata = NULL;
 	int userdata_len = 0;
 	int release_len = 0;
 
 #ifdef CONFIG_NETCONSOLE_DYNAMIC
-	userdata = nt->userdata_complete;
 	userdata_len = nt->userdata_length;
 #endif
 
@@ -1214,10 +1217,9 @@  static void send_ext_msg_udp(struct netconsole_target *nt, const char *msg,
 		release_len = strlen(init_utsname()->release) + 1;
 
 	if (msg_len + release_len + userdata_len <= MAX_PRINT_CHUNK)
-		return send_msg_no_fragmentation(nt, msg, userdata, msg_len,
-						 release_len);
+		return send_msg_no_fragmentation(nt, msg, msg_len, release_len);
 
-	return send_msg_fragmented(nt, msg, userdata, msg_len, release_len);
+	return send_msg_fragmented(nt, msg, msg_len, release_len);
 }
 
 static void write_ext_msg(struct console *con, const char *msg,