public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH 1/3] x86: fix "format not a string literal" errors
@ 2017-05-24 21:31 David Matlack
  2017-05-24 21:31 ` [kvm-unit-tests PATCH 2/3] api: fix "ignoring return value" of posix_memalign errors David Matlack
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: David Matlack @ 2017-05-24 21:31 UTC (permalink / raw)
  To: kvm; +Cc: jmattson, David Matlack

Fix the following two compilation errors:

x86/msr.c: In function ‘test_msr_rw’:
x86/msr.c:94:5: error: format not a string literal and no format arguments [-Werror=format-security]
     report(sptr, expected == r);
          ^

x8e/vmx.c: In function ‘test_vmx_caps’:
x86/vmx.c:1412:3: error: format not a string literal and no format arguments [-Werror=format-security]
   report(vmx_ctl_msr[n].name, ok);
      ^

Signed-off-by: David Matlack <dmatlack@google.com>
---
 x86/msr.c | 2 +-
 x86/vmx.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/x86/msr.c b/x86/msr.c
index ab97d21d3acb..1d4003144bb5 100644
--- a/x86/msr.c
+++ b/x86/msr.c
@@ -91,7 +91,7 @@ static void test_msr_rw(int msr_index, unsigned long long input, unsigned long l
         printf("testing %s: output = %#x:%#x expected = %#x:%#x\n", sptr,
                (u32)(r >> 32), (u32)r, (u32)(expected >> 32), (u32)expected);
     }
-    report(sptr, expected == r);
+    report("%s", expected == r, sptr);
 }
 
 static void test_syscall_lazy_load(void)
diff --git a/x86/vmx.c b/x86/vmx.c
index 13366180f514..9189a66759ec 100644
--- a/x86/vmx.c
+++ b/x86/vmx.c
@@ -1409,7 +1409,7 @@ static void test_vmx_caps(void)
 			ok = ctrl.clr == true_ctrl.clr;
 			ok = ok && ctrl.set == (true_ctrl.set | default1);
 		}
-		report(vmx_ctl_msr[n].name, ok);
+		report("%s", ok, vmx_ctl_msr[n].name);
 	}
 
 	fixed0 = rdmsr(MSR_IA32_VMX_CR0_FIXED0);
-- 
2.13.0.219.gdb65acc882-goog

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [kvm-unit-tests PATCH 2/3] api: fix "ignoring return value" of posix_memalign errors
  2017-05-24 21:31 [kvm-unit-tests PATCH 1/3] x86: fix "format not a string literal" errors David Matlack
@ 2017-05-24 21:31 ` David Matlack
  2017-05-24 21:31 ` [kvm-unit-tests PATCH 3/3] api: add api binaries to .gitignore David Matlack
  2017-06-07 14:24 ` [kvm-unit-tests PATCH 1/3] x86: fix "format not a string literal" errors Radim Krčmář
  2 siblings, 0 replies; 4+ messages in thread
From: David Matlack @ 2017-05-24 21:31 UTC (permalink / raw)
  To: kvm; +Cc: jmattson, David Matlack

posix_memalign returns zero on success and an errno value otherwise. The
value of the global variable "errno" is actually indeterminiate after a
call to posix_memalign(), according to the man page.

This patch also fixes the compilation errors:

api/dirty-log.cc:55:50: error: ignoring return value of ‘int posix_memalign(void**, size_t, size_t)’, declared with attribute warn_unused_result [-Werror=unused-result]
     posix_memalign(&logged_slot_virt, 4096, 4096);

api/identity.cc:23:41: error: ignoring return value of ‘int posix_memalign(void**, size_t, size_t)’, declared with attribute warn_unused_result [-Werror=unused-result]
     posix_memalign(&tss, 4096, 4 * 4096);

Signed-off-by: David Matlack <dmatlack@google.com>
---
 api/dirty-log.cc | 5 ++++-
 api/identity.cc  | 6 +++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/api/dirty-log.cc b/api/dirty-log.cc
index 47fbac2b1cc6..9891e98fde9e 100644
--- a/api/dirty-log.cc
+++ b/api/dirty-log.cc
@@ -52,7 +52,10 @@ int test_main(int ac, char **av)
     kvm::vm vm(sys);
     mem_map memmap(vm);
     void* logged_slot_virt;
-    posix_memalign(&logged_slot_virt, 4096, 4096);
+    int ret = posix_memalign(&logged_slot_virt, 4096, 4096);
+    if (ret) {
+        throw errno_exception(ret);
+    }
     volatile int* shared_var = static_cast<volatile int*>(logged_slot_virt);
     identity::hole hole(logged_slot_virt, 4096);
     identity::vm ident_vm(vm, memmap, hole);
diff --git a/api/identity.cc b/api/identity.cc
index 6dd42315a0af..24609ef9d6d0 100644
--- a/api/identity.cc
+++ b/api/identity.cc
@@ -20,9 +20,9 @@ hole::hole(void* address, size_t size)
 
 vm::vm(kvm::vm& vm, mem_map& mmap, hole h)
 {
-    posix_memalign(&tss, 4096, 4 * 4096);
-    if (!tss) {
-        throw errno_exception(errno);
+    int ret = posix_memalign(&tss, 4096, 4 * 4096);
+    if (ret) {
+        throw errno_exception(ret);
     }
 
     uint64_t hole_gpa = reinterpret_cast<uintptr_t>(h.address);
-- 
2.13.0.219.gdb65acc882-goog

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [kvm-unit-tests PATCH 3/3] api: add api binaries to .gitignore
  2017-05-24 21:31 [kvm-unit-tests PATCH 1/3] x86: fix "format not a string literal" errors David Matlack
  2017-05-24 21:31 ` [kvm-unit-tests PATCH 2/3] api: fix "ignoring return value" of posix_memalign errors David Matlack
@ 2017-05-24 21:31 ` David Matlack
  2017-06-07 14:24 ` [kvm-unit-tests PATCH 1/3] x86: fix "format not a string literal" errors Radim Krčmář
  2 siblings, 0 replies; 4+ messages in thread
From: David Matlack @ 2017-05-24 21:31 UTC (permalink / raw)
  To: kvm; +Cc: jmattson, David Matlack

Signed-off-by: David Matlack <dmatlack@google.com>
---
 .gitignore | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/.gitignore b/.gitignore
index 2213b9b10d8e..2405a8087ae5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,3 +17,6 @@ cscope.*
 /build-head
 /logs/
 /logs.old/
+/api/api-sample
+/api/dirty-log
+/api/dirty-log-perf
-- 
2.13.0.219.gdb65acc882-goog

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [kvm-unit-tests PATCH 1/3] x86: fix "format not a string literal" errors
  2017-05-24 21:31 [kvm-unit-tests PATCH 1/3] x86: fix "format not a string literal" errors David Matlack
  2017-05-24 21:31 ` [kvm-unit-tests PATCH 2/3] api: fix "ignoring return value" of posix_memalign errors David Matlack
  2017-05-24 21:31 ` [kvm-unit-tests PATCH 3/3] api: add api binaries to .gitignore David Matlack
@ 2017-06-07 14:24 ` Radim Krčmář
  2 siblings, 0 replies; 4+ messages in thread
From: Radim Krčmář @ 2017-06-07 14:24 UTC (permalink / raw)
  To: David Matlack; +Cc: kvm, jmattson

2017-05-24 14:31-0700, David Matlack:
> Fix the following two compilation errors:
> 
> x86/msr.c: In function ‘test_msr_rw’:
> x86/msr.c:94:5: error: format not a string literal and no format arguments [-Werror=format-security]
>      report(sptr, expected == r);
>           ^
> 
> x8e/vmx.c: In function ‘test_vmx_caps’:
> x86/vmx.c:1412:3: error: format not a string literal and no format arguments [-Werror=format-security]
>    report(vmx_ctl_msr[n].name, ok);
>       ^
> 
> Signed-off-by: David Matlack <dmatlack@google.com>
> ---

Applied all, thanks.  Looks like rawhide fedora's GCC is too old.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-06-07 14:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-24 21:31 [kvm-unit-tests PATCH 1/3] x86: fix "format not a string literal" errors David Matlack
2017-05-24 21:31 ` [kvm-unit-tests PATCH 2/3] api: fix "ignoring return value" of posix_memalign errors David Matlack
2017-05-24 21:31 ` [kvm-unit-tests PATCH 3/3] api: add api binaries to .gitignore David Matlack
2017-06-07 14:24 ` [kvm-unit-tests PATCH 1/3] x86: fix "format not a string literal" errors Radim Krčmář

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox