libselinux/utils: add noreturn attribute to selinux_check_access's usage
PATCH 1/2 libselinux/utils: add noreturn attribute to selinux_check_access's usage
When building libselinux, clang reports the following warning:
selinux_check_access.c:8:1: error: function 'usage' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn]
While at it, make progname const.
--- libselinux/utils/selinux_check_access.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libselinux/utils/selinux_check_access.c +1 -1
@@ -4,7 +4,7 @@#include <unistd.h> #include <selinux/selinux.h> -static void usage (char *progname) +static __attribute__ ((__noreturn__))void usage (const char *progname) {fprintf (stderr,"usage: %s [-a auditdata] scon tcon class perm\n" "\nWhere:\n\t"
Signature · 1 line
2.12.2
PATCH 2/2 libsepol: silence false-positive -Wwrite-strings warning
When compiling with -Wwrite-strings, the compiler complains about calling strs_add with a const char* value for a char* parameter (DEFAULT_OBJECT is defined to "object_r"). Silence this warning by casting the literal string to char*.
--- libsepol/src/kernel_to_cil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libsepol/src/kernel_to_cil.c +1 -1
@@ -2369,7 +2369,7 @@ static int write_user_decl_rules_to_cil(FILE *out, struct policydb *pdb) goto exit; } - rc =strs_add (role_strs,DEFAULT_OBJECT ); + rc =strs_add (role_strs, (char *)DEFAULT_OBJECT );if (rc !=0 ) {strs_destroy (&role_strs); goto exit;
Signature · 1 line
2.12.2
Stephen Smalley
AppliedRe: [PATCH 2/2] libsepol: silence false-positive -Wwrite-strings warning
Quoted 4 lines · Nicolas Iooss
When compiling with -Wwrite-strings, the compiler complains about calling
strs_addwith a const char* value for a char* parameter (DEFAULT_OBJECTis defined to "object_r"). Silence this warning by casting the literal string to char*.
Thanks, applied both patches. At some point we should likely fix strs_add() though to take const char *.
Quoted 22 lines
Signed-off-by Nicolas Iooss <[email protected]>---
libsepol/src/kernel_to_cil.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)libsepol/src/kernel_to_cil.c +0
-0@@ -2369,7 +2369,7 @@ static int write_user_decl_rules_to_cil(FILE *out, struct policydb *pdb) goto exit; }libsepol/src/kernel_to_cil.c +1
-1- rc =strs_add (role_strs,DEFAULT_OBJECT ); + rc = strs_add(role_strs, (char*)DEFAULT_OBJECT);
if (rc != 0) {strs_destroy(&role_strs); goto exit;