On 02/05/2017 10:58 AM, Nicolas Iooss wrote:
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@xxxxxxx>
---
policycoreutils/semodule/semodule.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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;
I think that I would prefer the following for this one:
diff --git a/policycoreutils/semodule/semodule.c
b/policycoreutils/semodule/semodule.c
index ce048bc..c63a864 100644
--- a/policycoreutils/semodule/semodule.c
+++ b/policycoreutils/semodule/semodule.c
@@ -341,11 +341,11 @@ int main(int argc, char *argv[])
int i, commit = 0;
int result;
int status = EXIT_FAILURE;
- char *genhomedirconargv[] = { "genhomedircon", "-B", "-n" };
+ const char *genhomedirconargv[] = { "genhomedircon", "-B", "-n" };
create_signal_handlers();
if (strcmp(basename(argv[0]), "genhomedircon") == 0) {
argc = 3;
- argv=genhomedirconargv;
+ argv = (char **)genhomedirconargv;
}
parse_command_line(argc, argv);
--
James Carter <jwcart2@xxxxxxxxxxxxx>
National Security Agency
_______________________________________________
Selinux mailing list
Selinux@xxxxxxxxxxxxx
To unsubscribe, send email to Selinux-leave@xxxxxxxxxxxxx.
To get help, send an email containing "help" to Selinux-request@xxxxxxxxxxxxx.