diff mbox series

[4/4] netlink: Move an assignment for the variable “cb_mutex” in __netlink_kernel_create()

Message ID d250255b-fd88-4ea9-aa08-bc8d911143af@web.de (mailing list archive)
State Changes Requested
Headers show
Series netlink: Adjustments for __netlink_kernel_create() | expand

Checks

Context Check Description
netdev/series_format warning Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be 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 success Errors and warnings before: 1118 this patch: 1118
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/build_clang success Errors and warnings before: 1144 this patch: 1144
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 success Errors and warnings before: 1145 this patch: 1145
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 15 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

Markus Elfring Dec. 31, 2023, 5:48 p.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 31 Dec 2023 18:16:26 +0100

Move one assignment for the variable “cb_mutex” closer to the place
where this pointer is used.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/netlink/af_netlink.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--
2.43.0

Comments

Stephen Hemminger Jan. 1, 2024, 6:18 p.m. UTC | #1
On Sun, 31 Dec 2023 18:48:11 +0100
Markus Elfring <Markus.Elfring@web.de> wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 31 Dec 2023 18:16:26 +0100
> 
> Move one assignment for the variable “cb_mutex” closer to the place
> where this pointer is used.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

NAK
Useless code churn, no improvement in performance or readablilty.
Compiler optimizer will do this already if it wants.
diff mbox series

Patch

diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index cfddc9c6a376..12a0b6f8be19 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -2019,7 +2019,7 @@  __netlink_kernel_create(struct net *net, int unit, struct module *module,
 	struct sock *sk;
 	struct netlink_sock *nlk;
 	struct listeners *listeners;
-	struct mutex *cb_mutex = cfg ? cfg->cb_mutex : NULL;
+	struct mutex *cb_mutex; /* Serialize data processing with callbacks */
 	unsigned int groups;

 	BUG_ON(!nl_table);
@@ -2030,6 +2030,7 @@  __netlink_kernel_create(struct net *net, int unit, struct module *module,
 	if (sock_create_lite(PF_NETLINK, SOCK_DGRAM, unit, &sock))
 		return NULL;

+	cb_mutex = (cfg ? cfg->cb_mutex : NULL);
 	if (__netlink_create(net, sock, cb_mutex, unit, 1) < 0)
 		goto out_sock_release_nosk;