This helps detecting wrong format strings. Signed-off-by: Stefan Weil <s...@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