coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] maint: avoid discarded-qualifiers warnings with SELinux 3.5


From: Pádraig Brady
Subject: Re: [PATCH] maint: avoid discarded-qualifiers warnings with SELinux 3.5
Date: Fri, 17 Mar 2023 12:16:28 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Thunderbird/109.0

On 16/03/2023 23:12, Bernhard Voelker wrote:
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 | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/selinux.c b/src/selinux.c
index 2bd91d071..d56010bba 100644
--- a/src/selinux.c
+++ b/src/selinux.c
@@ -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)

For backwards compat, do we need to use something like
the se_const wrapper we used to have?
https://github.com/coreutils/coreutils/commit/8e764584f

(eventually removed in):
https://github.com/coreutils/coreutils/commit/e53bb7ad0

cheers,
Pádraig



reply via email to

[Prev in Thread] Current Thread [Next in Thread]