diff mbox

[2/2] libsepol: silence false-positive -Wwrite-strings warning

Message ID 20170503205802.19751-2-nicolas.iooss@m4x.org (mailing list archive)
State Not Applicable
Headers show

Commit Message

Nicolas Iooss May 3, 2017, 8:58 p.m. UTC
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*.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
 libsepol/src/kernel_to_cil.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stephen Smalley May 5, 2017, 5:10 p.m. UTC | #1
On Wed, 2017-05-03 at 22:58 +0200, Nicolas Iooss wrote:
> 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*.

Thanks, applied both patches.  At some point we should likely fix
strs_add() though to take const char *.

> 
> Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
> ---
>  libsepol/src/kernel_to_cil.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libsepol/src/kernel_to_cil.c
> b/libsepol/src/kernel_to_cil.c
> index e873ac3a1981..3a1c0be76f45 100644
> --- a/libsepol/src/kernel_to_cil.c
> +++ b/libsepol/src/kernel_to_cil.c
> @@ -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;
diff mbox

Patch

diff --git a/libsepol/src/kernel_to_cil.c b/libsepol/src/kernel_to_cil.c
index e873ac3a1981..3a1c0be76f45 100644
--- a/libsepol/src/kernel_to_cil.c
+++ b/libsepol/src/kernel_to_cil.c
@@ -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;