Declare the prefix string variable in va_report() as const
Subsystems (2)
PATCH 1/1 Declare the prefix string variable in va_report() as const
This way, the code can be compiled with "-Wwrite-strings", too.
---
Not sure whether we want to enable "-Wwrite-strings" globally (since strings in kvm-unit-test are theoretically writable if the test is running without MMU), so I only fixed the code here, without adding it to the Makefile. But if we agree that it is a good idea I can respin the patch and add it to the Makefile, too.
lib/report.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/report.c +3 -3
@@ -81,9 +81,9 @@ void report_prefix_pop(void)static void va_report (const char *msg_fmt,bool pass,bool xfail,bool skip,va_list va) { -char *prefix = skip ?"SKIP" - : xfail ? (pass ?"XPASS" :"XFAIL" ) - : (pass ?"PASS" :"FAIL" ); +const char *prefix = skip ?"SKIP" + : xfail ? (pass ?"XPASS" :"XFAIL" ) + : (pass ?"PASS" :"FAIL" );spin_lock (&lock);
Signature · 1 line
1.8.3.1
Quoted 9 lines · Thomas Huth
This way, the code can be compiled with "-Wwrite-strings", too.
Signed-off-by Thomas Huth <[email protected]>---
Not sure whether we want to enable "-Wwrite-strings" globally (since strings in kvm-unit-test are theoretically writable if the test is running without MMU), so I only fixed the code here, without adding it to theMakefile. But if we agree that it is a good idea I can respin the patch and add it to theMakefile, too.
Make sense to me. I'd vote for adding it as long as all targets can be compiled without any problems.
Quoted 9 lines
lib/report.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)lib/report.c +0
-0
lib/report.c void report_prefix_pop(void) · line 86
Quoted 9 lines
lib/report.c +3
-3@@ -81,9 +81,9 @@ void report_prefix_pop(void)static void va_report (const char *msg_fmt,bool pass,bool xfail,bool skip,va_list va) { -char *prefix = skip ?"SKIP" - : xfail ? (pass ?"XPASS" :"XFAIL" ) - : (pass ?"PASS" :"FAIL" ); +const char *prefix = skip ?"SKIP" + : xfail ? (pass ?"XPASS" :"XFAIL" ) + : (pass ?"PASS" :"FAIL" );
Hmm, think I liked the old indentation better. (":" directly below the matching "?")
Quoted 4 lines
lib/report.c +0
-0spin_lock (&lock);
Signature · 3 lines
Thanks, David
Quoted 27 lines · David Hildenbrand
Quoted 9 lines · Thomas Huth
This way, the code can be compiled with "-Wwrite-strings", too.
Signed-off-by Thomas Huth <[email protected]>---
Not sure whether we want to enable "-Wwrite-strings" globally (since strings in kvm-unit-test are theoretically writable if the test is running without MMU), so I only fixed the code here, without adding it to theMakefile. But if we agree that it is a good idea I can respin the patch and add it to theMakefile, too.Make sense to me. I'd vote for adding it as long as all targets can be compiled without any problems.
Quoted 13 lines
lib/report.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)lib/report.c +0
-1@@ -81,9 +81,9 @@ void report_prefix_pop(void)static void va_report (const char *msg_fmt,bool pass,bool xfail,bool skip,va_list va) { - char *prefix = skip ? "SKIP"
Quoted 8 lines
lib/report.c void report_prefix_pop(void) · line 86
Quoted 5 lines
lib/report.c +3
-2- : xfail ? (pass ? "XPASS" : "XFAIL") - : (pass ?"PASS" :"FAIL" ); +const char *prefix = skip ?"SKIP" + : xfail ? (pass ?"XPASS" :"XFAIL" ) + : (pass ?"PASS" :"FAIL" );Hmm, think I liked the old indentation better. (":" directly below the matching "?")
Oh, right, thanks! That apparently happens when sending patches too early in the morning ;-)
I'll wait for some more comments about whether to include "-Wwrite-strings" or not, then I'll respin this patch.
Thomas
Quoted 37 lines · Thomas Huth
Quoted 27 lines · David Hildenbrand
Quoted 9 lines · Thomas Huth
This way, the code can be compiled with "-Wwrite-strings", too.
Signed-off-by Thomas Huth <[email protected]>---
Not sure whether we want to enable "-Wwrite-strings" globally (since strings in kvm-unit-test are theoretically writable if the test is running without MMU), so I only fixed the code here, without adding it to theMakefile. But if we agree that it is a good idea I can respin the patch and add it to theMakefile, too.Make sense to me. I'd vote for adding it as long as all targets can be compiled without any problems.
Quoted 13 lines
lib/report.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)lib/report.c +0
-1@@ -81,9 +81,9 @@ void report_prefix_pop(void)static void va_report (const char *msg_fmt,bool pass,bool xfail,bool skip,va_list va) { - char *prefix = skip ? "SKIP"Quoted 8 lines
lib/report.c void report_prefix_pop(void) · line 86
Quoted 5 lines
lib/report.c +3
-2- : xfail ? (pass ? "XPASS" : "XFAIL") - : (pass ?"PASS" :"FAIL" ); +const char *prefix = skip ?"SKIP" + : xfail ? (pass ?"XPASS" :"XFAIL" ) + : (pass ?"PASS" :"FAIL" );Hmm, think I liked the old indentation better. (":" directly below the matching "?")
Quoted 4 lines
Oh, right, thanks! That apparently happens when sending patches too early in the morning ;-)
I'll wait for some more comments about whether to include "-Wwrite-strings" or not, then I'll respin this patch.
I vote turn it on globally, and then if a unit test is introduced where it needs to be off, then that's the beauty of having it fine grained, that unit test can modify its make target accordingly to remove it.
Thanks,
drew
Paolo Bonzini
maintainerQuoted 4 lines · Thomas Huth
Oh, right, thanks! That apparently happens when sending patches too early in the morning ;-)
I'll wait for some more comments about whether to include "-Wwrite-strings" or not, then I'll respin this patch.
Yes, please do.
Paolo