orangefs: move s_kmod_keyword_mask_map[] into debugfs.c
PATCH 1/1 orangefs: move s_kmod_keyword_mask_map[] into debugfs.c
From: Arnd Bergmann <[email protected]>
gcc warns about unused const variables when building with W=1
In file included from fs/orangefs/protocol.h:287,
from fs/orangefs/acl.c:8:
fs/orangefs/orangefs-debug.h:86:18: error: 'num_kmod_keyword_mask_map' defined but not used [-Werror=unused-const-variable=]
86 | static const int num_kmod_keyword_mask_map = (int)
| ^~~~~~~~~~~~~~~~~~~~~~~~~
This one is only used in one file, so just move the definition next to its only user.
--- fs/orangefs/orangefs-debug.h | 43 ---------------------------------- fs/orangefs/orangefs-debugfs.c | 43 ++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 43 deletions(-)
fs/orangefs/orangefs-debug.h +0 -43
@@ -43,47 +43,4 @@#define GOSSIP_MAX_NR 16#define GOSSIP_MAX_DEBUG (((__u64)1 << GOSSIP_MAX_NR) - 1) -/* a private internal type */ -struct __keyword_mask_s { -const char *keyword; -__u64 mask_val; -}; - -/* -* Map all kmod keywords to kmod debug masks here. Keep this -* structure "packed": -* -* "all" is always last... -* -* keyword mask_val index -* foo 1 0 -* bar 2 1 -* baz 4 2 -* qux 8 3 -* . . . -*/ -static struct __keyword_mask_s s_kmod_keyword_mask_map[] = { - {"super" ,GOSSIP_SUPER_DEBUG }, - {"inode" ,GOSSIP_INODE_DEBUG }, - {"file" ,GOSSIP_FILE_DEBUG }, - {"dir" ,GOSSIP_DIR_DEBUG }, - {"utils" ,GOSSIP_UTILS_DEBUG }, - {"wait" ,GOSSIP_WAIT_DEBUG }, - {"acl" ,GOSSIP_ACL_DEBUG }, - {"dcache" ,GOSSIP_DCACHE_DEBUG }, - {"dev" ,GOSSIP_DEV_DEBUG }, - {"name" ,GOSSIP_NAME_DEBUG }, - {"bufmap" ,GOSSIP_BUFMAP_DEBUG }, - {"cache" ,GOSSIP_CACHE_DEBUG }, - {"debugfs" ,GOSSIP_DEBUGFS_DEBUG }, - {"xattr" ,GOSSIP_XATTR_DEBUG }, - {"init" ,GOSSIP_INIT_DEBUG }, - {"sysfs" ,GOSSIP_SYSFS_DEBUG }, - {"none" ,GOSSIP_NO_DEBUG }, - {"all" ,GOSSIP_MAX_DEBUG } -}; - -static const int num_kmod_keyword_mask_map = (int ) - (ARRAY_SIZE (s_kmod_keyword_mask_map)); -#endif /* __ORANGEFS_DEBUG_H */
fs/orangefs/orangefs-debugfs.c +43 -0
49 lines not on this page · raw message
Signature · 1 line
2.39.5
Le 25/02/2025 à 21:08, Arnd Bergmann a écrit :
Quoted 89 lines
From: Arnd Bergmann <[email protected]>
gcc warns about unused const variables when building with W=1
In file included from
fs/orangefs/protocol.h:287,
fromfs/orangefs/acl.c:8:
fs/orangefs/orangefs-debug.h:86:18: error: 'num_kmod_keyword_mask_map' defined but not used [-Werror=unused-const-variable=]
86 | static const intnum_kmod_keyword_mask_map= (int)
| ^~~~~~~~~~~~~~~~~~~~~~~~~This one is only used in one file, so just move the definition next to its only user.
Signed-off-by Arnd Bergmann <[email protected]>--- fs/orangefs/orangefs-debug.h | 43 ---------------------------------- fs/orangefs/orangefs-debugfs.c | 43 ++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 43 deletions(-)fs/orangefs/orangefs-debug.h +0
-43@@ -43,47 +43,4 @@#define GOSSIP_MAX_NR 16#define GOSSIP_MAX_DEBUG (((__u64)1 << GOSSIP_MAX_NR) - 1) -/* a private internal type */ -struct __keyword_mask_s { -const char *keyword; -__u64 mask_val; -}; - -/* -* Map all kmod keywords to kmod debug masks here. Keep this -* structure "packed": -* -* "all" is always last... -* -* keyword mask_val index -* foo 1 0 -* bar 2 1 -* baz 4 2 -* qux 8 3 -* . . . -*/ -static struct __keyword_mask_s s_kmod_keyword_mask_map[] = { - {"super" ,GOSSIP_SUPER_DEBUG }, - {"inode" ,GOSSIP_INODE_DEBUG }, - {"file" ,GOSSIP_FILE_DEBUG }, - {"dir" ,GOSSIP_DIR_DEBUG }, - {"utils" ,GOSSIP_UTILS_DEBUG }, - {"wait" ,GOSSIP_WAIT_DEBUG }, - {"acl" ,GOSSIP_ACL_DEBUG }, - {"dcache" ,GOSSIP_DCACHE_DEBUG }, - {"dev" ,GOSSIP_DEV_DEBUG }, - {"name" ,GOSSIP_NAME_DEBUG }, - {"bufmap" ,GOSSIP_BUFMAP_DEBUG }, - {"cache" ,GOSSIP_CACHE_DEBUG }, - {"debugfs" ,GOSSIP_DEBUGFS_DEBUG }, - {"xattr" ,GOSSIP_XATTR_DEBUG }, - {"init" ,GOSSIP_INIT_DEBUG }, - {"sysfs" ,GOSSIP_SYSFS_DEBUG }, - {"none" ,GOSSIP_NO_DEBUG }, - {"all" ,GOSSIP_MAX_DEBUG } -}; - -static const int num_kmod_keyword_mask_map = (int ) - (ARRAY_SIZE (s_kmod_keyword_mask_map)); -#endif /* __ORANGEFS_DEBUG_H */ fs/orangefs/orangefs-debugfs.c +10
-0@@ -54,6 +54,49 @@#define ORANGEFS_VERBOSE "verbose"#define ORANGEFS_ALL "all" +/* a private internal type */ +struct __keyword_mask_s { +const char *keyword; +__u64 mask_val; +}; + +/* +* Map all kmod keywords to kmod debug masks here. Keep this +* structure "packed": +*
fs/orangefs/orangefs-debugfs.c line 76
Quoted 10 lines
fs/orangefs/orangefs-debugfs.c +10
-0+* "all" is always last... +* +* keyword mask_val index +* foo 1 0 +* bar 2 1 +* baz 4 2 +* qux 8 3 +* . . . +*/ +static struct __keyword_mask_s s_kmod_keyword_mask_map[] = {
Unrelated to your patch, but I think that this could be made const.
Just my 2c.
CJ
Quoted 26 lines
fs/orangefs/orangefs-debugfs.c +23
-0+ {"super", GOSSIP_SUPER_DEBUG}, + {"inode", GOSSIP_INODE_DEBUG}, + {"file", GOSSIP_FILE_DEBUG}, + {"dir", GOSSIP_DIR_DEBUG}, + {"utils", GOSSIP_UTILS_DEBUG}, + {"wait", GOSSIP_WAIT_DEBUG}, + {"acl", GOSSIP_ACL_DEBUG}, + {"dcache", GOSSIP_DCACHE_DEBUG}, + {"dev", GOSSIP_DEV_DEBUG}, + {"name", GOSSIP_NAME_DEBUG}, + {"bufmap", GOSSIP_BUFMAP_DEBUG}, + {"cache", GOSSIP_CACHE_DEBUG}, + {"debugfs", GOSSIP_DEBUGFS_DEBUG}, + {"xattr", GOSSIP_XATTR_DEBUG}, + {"init", GOSSIP_INIT_DEBUG}, + {"sysfs", GOSSIP_SYSFS_DEBUG}, + {"none", GOSSIP_NO_DEBUG}, + {"all", GOSSIP_MAX_DEBUG} +}; + +static const int num_kmod_keyword_mask_map = (int ) + (ARRAY_SIZE (s_kmod_keyword_mask_map)); +/* * An array of client_debug_mask will be built to hold debug keyword/mask * values fetched from userspace.
Quoted 9 lines · Christophe JAILLET
Le 25/02/2025 à 21:08, Arnd Bergmann a écrit :
Quoted 5 lines
From: Arnd Bergmann <[email protected]>
+ * . . .
+ */
+static struct__keyword_mask_ss_kmod_keyword_mask_map[] = {Unrelated to your patch, but I think that this could be made const.
Right, but not trivially, probably something like the change below.
There are obviously countless variables that should be const.
Arnd
fs/orangefs/orangefs-debugfs.c +4 -4
@@ -73,7 +73,7 @@ struct __keyword_mask_s {* qux 8 3 * . . . */ -static struct __keyword_mask_s s_kmod_keyword_mask_map[] = { +static const struct __keyword_mask_s s_kmod_keyword_mask_map[] = { {"super" ,GOSSIP_SUPER_DEBUG }, {"inode" ,GOSSIP_INODE_DEBUG }, {"file" ,GOSSIP_FILE_DEBUG },
@@ -131,7 +131,7 @@ static int orangefs_prepare_cdm_array(char *);static void debug_mask_to_string (void *,int );static void do_k_string (void *,int );static void do_c_string (void *,int ); -static int keyword_is_amalgam (char *); +static int keyword_is_amalgam (const char *);static int check_amalgam_keyword (void *,int );static void debug_string_to_mask (char *,void *,int );static void do_c_mask (int ,char *,struct client_debug_mask **);
@@ -764,7 +764,7 @@ static void do_k_string(void *k_mask, int index) {__u64 *mask = (__u64 *) k_mask; -if (keyword_is_amalgam ((char *) s_kmod_keyword_mask_map[index].keyword)) +if (keyword_is_amalgam ((const char *) s_kmod_keyword_mask_map[index].keyword)) goto out;if (*mask & s_kmod_keyword_mask_map[index].mask_val) {
@@ -811,7 +811,7 @@ static void do_c_string(void *c_mask, int index)return ; } -static int keyword_is_amalgam (char *keyword) +static int keyword_is_amalgam (const char *keyword) {int rc =0 ;