]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: avoid discarded-qualifiers warnings with SELinux 3.5
authorBernhard Voelker <mail@bernhard-voelker.de>
Thu, 16 Mar 2023 22:11:47 +0000 (23:11 +0100)
committerBernhard Voelker <mail@bernhard-voelker.de>
Thu, 16 Mar 2023 23:12:18 +0000 (00:12 +0100)
Since SELinux version 3.5, the return value of context_str(3) is
declared as const; see:
  https://github.com/SELinuxProject/selinux/commit/dd98fa322766
Therefore, GCC complains (here with -Werror):
  src/selinux.c: In function 'defaultcon':
  src/selinux.c:152:16: error: assignment discards 'const' qualifier \
    from pointer target type [-Werror=discarded-qualifiers]
    152 |   if (!(constr = context_str (tcontext)))
        |                ^
  src/selinux.c: In function 'restorecon_private':
  src/selinux.c:252:16: error: assignment discards 'const' qualifier \
    from pointer target type [-Werror=discarded-qualifiers]
    252 |   if (!(constr = context_str (tcontext)))
      |                ^

* src/selinux.c (defaultcon): Define CONSTR as const.
(restorecon_private): Likewise.

src/selinux.c

index 2bd91d0716ea11ca172f0794177622e5eac5770b..d56010bbaafe8ac73753cad3c511a3311eedd2d2 100644 (file)
@@ -115,7 +115,7 @@ defaultcon (struct selabel_handle *selabel_handle,
   char *tcon = NULL;
   context_t scontext = 0, tcontext = 0;
   char const *contype;
-  char *constr;
+  char const *constr;
   char *newpath = NULL;
 
   if (! IS_ABSOLUTE_FILE_NAME (path))
@@ -183,7 +183,7 @@ restorecon_private (struct selabel_handle *selabel_handle, char const *path)
   char *tcon = NULL;
   context_t scontext = 0, tcontext = 0;
   char const *contype;
-  char *constr;
+  char const *constr;
   int fd;
 
   if (!selabel_handle)