summaryrefslogtreecommitdiffstats
path: root/net/sysctl_net.c
diff options
context:
space:
mode:
authorJoel Granados <j.granados@samsung.com>2024-06-04 08:29:21 +0200
committerJoel Granados <j.granados@samsung.com>2024-06-13 10:50:52 +0200
commitd7a76ec87195ced6910b0ca10ca133bb316c90f5 (patch)
tree70fc6091ac3e45e52a446659907628231ff2397a /net/sysctl_net.c
parente2a6c472de7a5e5a1455a9fff1cfc55a1dd888af (diff)
downloadlinux-d7a76ec87195ced6910b0ca10ca133bb316c90f5.tar.gz
linux-d7a76ec87195ced6910b0ca10ca133bb316c90f5.tar.bz2
linux-d7a76ec87195ced6910b0ca10ca133bb316c90f5.zip
sysctl: Remove check for sentinel element in ctl_table arrays
Use ARRAY_SIZE exclusively by removing the check to ->procname in the stopping criteria of the loops traversing ctl_table arrays. This commit finalizes the removal of the sentinel elements at the end of ctl_table arrays which reduces the build time size and run time memory bloat by ~64 bytes per sentinel (further information Link : https://lore.kernel.org/all/ZO5Yx5JFogGi%2FcBo@bombadil.infradead.org/) Remove the entry->procname evaluation from the for loop stopping criteria in sysctl and sysctl_net. Signed-off-by: Joel Granados <j.granados@samsung.com>
Diffstat (limited to 'net/sysctl_net.c')
-rw-r--r--net/sysctl_net.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/net/sysctl_net.c b/net/sysctl_net.c
index f5017012a049..19e8048241ba 100644
--- a/net/sysctl_net.c
+++ b/net/sysctl_net.c
@@ -127,7 +127,7 @@ static void ensure_safe_net_sysctl(struct net *net, const char *path,
pr_debug("Registering net sysctl (net %p): %s\n", net, path);
ent = table;
- for (size_t i = 0; i < table_size && ent->procname; ent++, i++) {
+ for (size_t i = 0; i < table_size; ent++, i++) {
unsigned long addr;
const char *where;
@@ -165,17 +165,10 @@ struct ctl_table_header *register_net_sysctl_sz(struct net *net,
struct ctl_table *table,
size_t table_size)
{
- int count;
- struct ctl_table *entry;
-
if (!net_eq(net, &init_net))
ensure_safe_net_sysctl(net, path, table, table_size);
- entry = table;
- for (count = 0 ; count < table_size && entry->procname; entry++, count++)
- ;
-
- return __register_sysctl_table(&net->sysctls, path, table, count);
+ return __register_sysctl_table(&net->sysctls, path, table, table_size);
}
EXPORT_SYMBOL_GPL(register_net_sysctl_sz);