diff mbox

[3/8] policycoreutils/semodule: hide -Wwrite-strings warnings

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

Commit Message

Nicolas Iooss Feb. 5, 2017, 3:58 p.m. UTC
When building with "clang -Wwrite-strings", the compiler complains about
initializing a char* array (variable genhomedirconargv) with literal
strings (which are in read-only memory).

However the programs needs to use a non-const char* array in order to
fake arguments of getopt_long() (called by parse_command_line()). Silent
the compiler warnings by introducing casts to char*.

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

Patch

diff --git a/policycoreutils/semodule/semodule.c b/policycoreutils/semodule/semodule.c
index ce048bc061b9..36686d0230a8 100644
--- a/policycoreutils/semodule/semodule.c
+++ b/policycoreutils/semodule/semodule.c
@@ -341,7 +341,7 @@  int main(int argc, char *argv[])
 	int i, commit = 0;
 	int result;
 	int status = EXIT_FAILURE;
-	char *genhomedirconargv[] = { "genhomedircon", "-B", "-n" };
+	char *genhomedirconargv[] = { (char *)"genhomedircon", (char *)"-B", (char *)"-n" };
 	create_signal_handlers();
 	if (strcmp(basename(argv[0]), "genhomedircon") == 0) {
 		argc = 3;