Skip to content

Commit 86dd9fd

Browse files
keespcmoore
authored andcommitted
LSM: Avoid warnings about potentially unused hook variables
Building with W=1 shows many unused const variable warnings. These can be silenced, as we're well aware of their being potentially unused: ./include/linux/lsm_hook_defs.h:36:18: error: 'ptrace_access_check_default' defined but not used [-Werror=unused-const-variable=] 36 | LSM_HOOK(int, 0, ptrace_access_check, struct task_struct *child, | ^~~~~~~~~~~~~~~~~~~ security/security.c:706:32: note: in definition of macro 'LSM_RET_DEFAULT' 706 | #define LSM_RET_DEFAULT(NAME) (NAME##_default) | ^~~~ security/security.c:711:9: note: in expansion of macro 'DECLARE_LSM_RET_DEFAULT_int' 711 | DECLARE_LSM_RET_DEFAULT_##RET(DEFAULT, NAME) | ^~~~~~~~~~~~~~~~~~~~~~~~ ./include/linux/lsm_hook_defs.h:36:1: note: in expansion of macro 'LSM_HOOK' 36 | LSM_HOOK(int, 0, ptrace_access_check, struct task_struct *child, | ^~~~~~~~ Cc: James Morris <jmorris@namei.org> Cc: "Serge E. Hallyn" <serge@hallyn.com> Cc: Paul Moore <paul@paul-moore.com> Cc: Casey Schaufler <casey@schaufler-ca.com> Cc: KP Singh <kpsingh@chromium.org> Cc: linux-security-module@vger.kernel.org Reported-by: kernel test robot <lkp@intel.com> Link: https://lore.kernel.org/linux-mm/202110131608.zms53FPR-lkp@intel.com/ Fixes: 98e828a ("security: Refactor declaration of LSM hooks") Signed-off-by: Kees Cook <keescook@chromium.org> Acked-by: James Morris <jamorris@linux.microsoft.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent e9fd729 commit 86dd9fd

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

security/security.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ static int lsm_superblock_alloc(struct super_block *sb)
706706
#define LSM_RET_DEFAULT(NAME) (NAME##_default)
707707
#define DECLARE_LSM_RET_DEFAULT_void(DEFAULT, NAME)
708708
#define DECLARE_LSM_RET_DEFAULT_int(DEFAULT, NAME) \
709-
static const int LSM_RET_DEFAULT(NAME) = (DEFAULT);
709+
static const int __maybe_unused LSM_RET_DEFAULT(NAME) = (DEFAULT);
710710
#define LSM_HOOK(RET, DEFAULT, NAME, ...) \
711711
DECLARE_LSM_RET_DEFAULT_##RET(DEFAULT, NAME)
712712

0 commit comments

Comments
 (0)