]> git.baikalelectronics.ru Git - kernel.git/commit
security: declare member holding string literal const
authorChristian Göttsche <cgzones@googlemail.com>
Thu, 17 Feb 2022 14:18:57 +0000 (15:18 +0100)
committerPaul Moore <paul@paul-moore.com>
Fri, 13 May 2022 18:51:06 +0000 (14:51 -0400)
commitcdee63fd776cff2accefe3fa7d5a0b3d69783927
treeb8f66a9f9847db2187757f50ae0c999b09e8caae
parentfe60df752f684936252148f795962d8b73f63c09
security: declare member holding string literal const

The struct security_hook_list member lsm is assigned in
security_add_hooks() with string literals passed from the individual
security modules.  Declare the function parameter and the struct member
const to signal their immutability.

Reported by Clang [-Wwrite-strings]:

    security/selinux/hooks.c:7388:63: error: passing 'const char [8]'
      to parameter of type 'char *' discards qualifiers
      [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
            security_add_hooks(selinux_hooks,
                               ARRAY_SIZE(selinux_hooks), selinux);
                                                          ^~~~~~~~~
    ./include/linux/lsm_hooks.h:1629:11: note: passing argument to
      parameter 'lsm' here
                                    char *lsm);
                                          ^

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Reviewed-by: Paul Moore <paul@paul-moore.com>
Reviewed-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
include/linux/lsm_hooks.h
security/security.c