[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230809105006.1198165-3-j.granados@samsung.com>
Date: Wed, 9 Aug 2023 12:49:54 +0200
From: Joel Granados <joel.granados@...il.com>
To: mcgrof@...nel.org
Cc: rds-devel@....oracle.com, "David S. Miller" <davem@...emloft.net>,
Florian Westphal <fw@...len.de>, willy@...radead.org,
Jan Karcher <jaka@...ux.ibm.com>,
Wen Gu <guwen@...ux.alibaba.com>,
Simon Horman <horms@...ge.net.au>,
Tony Lu <tonylu@...ux.alibaba.com>, linux-wpan@...r.kernel.org,
Matthieu Baerts <matthieu.baerts@...sares.net>,
Christian Borntraeger <borntraeger@...ux.ibm.com>,
mptcp@...ts.linux.dev, Heiko Carstens <hca@...ux.ibm.com>,
Stefan Schmidt <stefan@...enfreihafen.org>,
Will Deacon <will@...nel.org>, Julian Anastasov <ja@....bg>,
netfilter-devel@...r.kernel.org, Joerg Reuter <jreuter@...na.de>,
linux-kernel@...r.kernel.org,
Alexander Gordeev <agordeev@...ux.ibm.com>,
linux-sctp@...r.kernel.org, Xin Long <lucien.xin@...il.com>,
Herbert Xu <herbert@...dor.apana.org.au>,
linux-hams@...r.kernel.org, Vasily Gorbik <gor@...ux.ibm.com>,
coreteam@...filter.org, Ralf Baechle <ralf@...ux-mips.org>,
Steffen Klassert <steffen.klassert@...unet.com>,
Pablo Neira Ayuso <pablo@...filter.org>,
keescook@...omium.org, Roopa Prabhu <roopa@...dia.com>,
David Ahern <dsahern@...nel.org>,
linux-arm-kernel@...ts.infradead.org,
Catalin Marinas <catalin.marinas@....com>,
Jozsef Kadlecsik <kadlec@...filter.org>,
Wenjia Zhang <wenjia@...ux.ibm.com>, josh@...htriplett.org,
linux-fsdevel@...r.kernel.org,
Alexander Aring <alex.aring@...il.com>,
Nikolay Aleksandrov <razor@...ckwall.org>,
netdev@...r.kernel.org,
Santosh Shilimkar <santosh.shilimkar@...cle.com>,
linux-s390@...r.kernel.org, Sven Schnelle <svens@...ux.ibm.com>,
"D. Wythe" <alibuda@...ux.alibaba.com>,
Eric Dumazet <edumazet@...gle.com>, lvs-devel@...r.kernel.org,
linux-rdma@...r.kernel.org, Paolo Abeni <pabeni@...hat.com>,
Iurii Zaikin <yzaikin@...gle.com>,
Marcelo Ricardo Leitner <marcelo.leitner@...il.com>,
bridge@...ts.linux-foundation.org,
Karsten Graul <kgraul@...ux.ibm.com>,
Mat Martineau <martineau@...nel.org>,
Miquel Raynal <miquel.raynal@...tlin.com>,
Jakub Kicinski <kuba@...nel.org>,
Joel Granados <j.granados@...sung.com>
Subject: [PATCH v3 02/14] sysctl: Use ctl_table_header in list_for_each_table_entry
We replace the ctl_table with the ctl_table_header pointer in
list_for_each_table_entry which is the macro responsible for traversing
the ctl_table arrays. This is a preparation commit that will make it
easier to add the ctl_table array size (that will be added to
ctl_table_header in subsequent commits) to the already existing loop
logic based on empty ctl_table elements (so called sentinels).
Signed-off-by: Joel Granados <j.granados@...sung.com>
---
fs/proc/proc_sysctl.c | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 94d71446da39..884460b0385b 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -19,8 +19,8 @@
#include <linux/kmemleak.h>
#include "internal.h"
-#define list_for_each_table_entry(entry, table) \
- for ((entry) = (table); (entry)->procname; (entry)++)
+#define list_for_each_table_entry(entry, header) \
+ for ((entry) = (header->ctl_table); (entry)->procname; (entry)++)
static const struct dentry_operations proc_sys_dentry_operations;
static const struct file_operations proc_sys_file_operations;
@@ -204,7 +204,7 @@ static void init_header(struct ctl_table_header *head,
if (node) {
struct ctl_table *entry;
- list_for_each_table_entry(entry, table) {
+ list_for_each_table_entry(entry, head) {
node->header = head;
node++;
}
@@ -215,7 +215,7 @@ static void erase_header(struct ctl_table_header *head)
{
struct ctl_table *entry;
- list_for_each_table_entry(entry, head->ctl_table)
+ list_for_each_table_entry(entry, head)
erase_entry(head, entry);
}
@@ -242,7 +242,7 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header)
err = insert_links(header);
if (err)
goto fail_links;
- list_for_each_table_entry(entry, header->ctl_table) {
+ list_for_each_table_entry(entry, header) {
err = insert_entry(header, entry);
if (err)
goto fail;
@@ -1129,7 +1129,7 @@ static int sysctl_check_table(const char *path, struct ctl_table_header *header)
{
struct ctl_table *entry;
int err = 0;
- list_for_each_table_entry(entry, header->ctl_table) {
+ list_for_each_table_entry(entry, header) {
if ((entry->proc_handler == proc_dostring) ||
(entry->proc_handler == proc_dobool) ||
(entry->proc_handler == proc_dointvec) ||
@@ -1169,7 +1169,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table_
name_bytes = 0;
nr_entries = 0;
- list_for_each_table_entry(entry, head->ctl_table) {
+ list_for_each_table_entry(entry, head) {
nr_entries++;
name_bytes += strlen(entry->procname) + 1;
}
@@ -1188,7 +1188,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table_
link_name = (char *)&link_table[nr_entries + 1];
link = link_table;
- list_for_each_table_entry(entry, head->ctl_table) {
+ list_for_each_table_entry(entry, head) {
int len = strlen(entry->procname) + 1;
memcpy(link_name, entry->procname, len);
link->procname = link_name;
@@ -1211,7 +1211,7 @@ static bool get_links(struct ctl_dir *dir,
struct ctl_table *entry, *link;
/* Are there links available for every entry in table? */
- list_for_each_table_entry(entry, header->ctl_table) {
+ list_for_each_table_entry(entry, header) {
const char *procname = entry->procname;
link = find_entry(&tmp_head, dir, procname, strlen(procname));
if (!link)
@@ -1224,7 +1224,7 @@ static bool get_links(struct ctl_dir *dir,
}
/* The checks passed. Increase the registration count on the links */
- list_for_each_table_entry(entry, header->ctl_table) {
+ list_for_each_table_entry(entry, header) {
const char *procname = entry->procname;
link = find_entry(&tmp_head, dir, procname, strlen(procname));
tmp_head->nreg++;
@@ -1356,12 +1356,14 @@ struct ctl_table_header *__register_sysctl_table(
{
struct ctl_table_root *root = set->dir.header.root;
struct ctl_table_header *header;
+ struct ctl_table_header h_tmp;
struct ctl_dir *dir;
struct ctl_table *entry;
struct ctl_node *node;
int nr_entries = 0;
- list_for_each_table_entry(entry, table)
+ h_tmp.ctl_table = table;
+ list_for_each_table_entry(entry, (&h_tmp))
nr_entries++;
header = kzalloc(sizeof(struct ctl_table_header) +
@@ -1471,7 +1473,7 @@ static void put_links(struct ctl_table_header *header)
if (IS_ERR(core_parent))
return;
- list_for_each_table_entry(entry, header->ctl_table) {
+ list_for_each_table_entry(entry, header) {
struct ctl_table_header *link_head;
struct ctl_table *link;
const char *name = entry->procname;
--
2.30.2
Powered by blists - more mailing lists