qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] libvixl: Add gcc format attribute
@ 2014-06-17 21:07 Stefan Weil
  2014-06-17 22:09 ` Peter Maydell
  2014-06-18  4:28 ` Richard Henderson
  0 siblings, 2 replies; 12+ messages in thread
From: Stefan Weil @ 2014-06-17 21:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Stefan Weil, Richard Henderson

This helps detecting wrong format strings.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---

This patch is not intended to be applied before fixing some potential errors.

Addings the GNU gcc format attribute results in lots of compiler errors like these ones:

  CXX   disas/libvixl/a64/disasm-a64.o
disas/libvixl/a64/disasm-a64.cc: In member function ‘int vixl::Disassembler::SubstituteImmediateField(vixl::Instruction*, const char*)’:
disas/libvixl/a64/disasm-a64.cc:1372:66: error: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘int64_t {aka long int}’ [-Werror=format]
disas/libvixl/a64/disasm-a64.cc:1421:52: error: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘int64_t {aka long int}’ [-Werror=format]
disas/libvixl/a64/disasm-a64.cc:1442:48: error: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘int64_t {aka long int}’ [-Werror=format]
disas/libvixl/a64/disasm-a64.cc:1449:42: error: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘int64_t {aka long int}’ [-Werror=format]

I don't know the reason, because all locations seem to have arguments
which are function calls, and the called function returns Instr which
is uint32_t, not int64_t.

Stefan

 disas/libvixl/a64/disasm-a64.h |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/disas/libvixl/a64/disasm-a64.h b/disas/libvixl/a64/disasm-a64.h
index 3a56e15..30df187 100644
--- a/disas/libvixl/a64/disasm-a64.h
+++ b/disas/libvixl/a64/disasm-a64.h
@@ -27,6 +27,7 @@
 #ifndef VIXL_A64_DISASM_A64_H
 #define VIXL_A64_DISASM_A64_H
 
+#include "qemu/compiler.h"      // GCC_FMT_ATTR
 #include "globals.h"
 #include "utils.h"
 #include "instructions-a64.h"
@@ -85,7 +86,7 @@ class Disassembler: public DecoderVisitor {
   bool IsMovzMovnImm(unsigned reg_size, uint64_t value);
 
   void ResetOutput();
-  void AppendToOutput(const char* string, ...);
+  void GCC_FMT_ATTR(2, 3) AppendToOutput(const char* string, ...);
 
   char* buffer_;
   uint32_t buffer_pos_;
-- 
1.7.10.4

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

end of thread, other threads:[~2014-06-18 17:44 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-17 21:07 [Qemu-devel] [PATCH] libvixl: Add gcc format attribute Stefan Weil
2014-06-17 22:09 ` Peter Maydell
2014-06-18  4:16   ` Stefan Weil
2014-06-18  4:28 ` Richard Henderson
2014-06-18  4:31   ` Stefan Weil
2014-06-18  4:45     ` Stefan Weil
2014-06-18  8:26       ` Peter Maydell
2014-06-18 14:52       ` Paolo Bonzini
2014-06-18 15:19       ` Richard Henderson
2014-06-18 17:27         ` Stefan Weil
2014-06-18 17:33           ` Peter Maydell
2014-06-18 17:43           ` Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).