aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJoel Granados <joel.granados@gmail.com>2023-08-09 12:50:05 +0200
committerLuis Chamberlain <mcgrof@kernel.org>2023-08-15 15:26:18 -0700
commite1b41e4f4f44dbdc4fbb8ed37919182104d7699c (patch)
treef6cb1a13939170af80324da566f01787611fe916
parentvrf: Update to register_net_sysctl_sz (diff)
downloadwireguard-linux-e1b41e4f4f44dbdc4fbb8ed37919182104d7699c.tar.xz
wireguard-linux-e1b41e4f4f44dbdc4fbb8ed37919182104d7699c.zip
sysctl: SIZE_MAX->ARRAY_SIZE in register_net_sysctl
Replace SIZE_MAX with ARRAY_SIZE in the register_net_sysctl macro. Now that all the callers to register_net_sysctl are actual arrays, we can call ARRAY_SIZE() without any compilation warnings. By calculating the actual array size, this commit is making sure that register_net_sysctl and all its callers forward the table_size into sysctl backend for when the sentinel elements in the ctl_table arrays (last empty markers) are removed. Without it the removal would fail lacking a stopping criteria for traversing the ctl_table arrays. Stopping condition continues to be based on both table size and the procname null test. This is needed in order to allow for the systematic removal al the sentinel element in subsequent commits: Before removing sentinel the stopping criteria will be the last null element. When the sentinel is removed then the (correct) size will take over. Signed-off-by: Joel Granados <j.granados@samsung.com> Suggested-by: Jani Nikula <jani.nikula@linux.intel.com> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
-rw-r--r--include/net/net_namespace.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index e4e5fe75a281..75dba309e043 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -470,7 +470,7 @@ void unregister_pernet_device(struct pernet_operations *);
struct ctl_table;
#define register_net_sysctl(net, path, table) \
- register_net_sysctl_sz(net, path, table, SIZE_MAX)
+ register_net_sysctl_sz(net, path, table, ARRAY_SIZE(table))
#ifdef CONFIG_SYSCTL
int net_sysctl_init(void);
struct ctl_table_header *register_net_sysctl_sz(struct net *net, const char *path,