Skip to content

Commit e1b41e4

Browse files
Joelgranadosmcgrof
authored andcommitted
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 <[email protected]> Suggested-by: Jani Nikula <[email protected]> Signed-off-by: Luis Chamberlain <[email protected]>
1 parent 3ca9aa7 commit e1b41e4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/net/net_namespace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ void unregister_pernet_device(struct pernet_operations *);
470470
struct ctl_table;
471471

472472
#define register_net_sysctl(net, path, table) \
473-
register_net_sysctl_sz(net, path, table, SIZE_MAX)
473+
register_net_sysctl_sz(net, path, table, ARRAY_SIZE(table))
474474
#ifdef CONFIG_SYSCTL
475475
int net_sysctl_init(void);
476476
struct ctl_table_header *register_net_sysctl_sz(struct net *net, const char *path,

0 commit comments

Comments
 (0)