From: Stefan Weil <sw@weilnetz.de>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Stefan Weil <sw@weilnetz.de>, Richard Henderson <rth@twiddle.net>
Subject: [Qemu-devel] [PATCH] libvixl: Add gcc format attribute
Date: Tue, 17 Jun 2014 23:07:10 +0200 [thread overview]
Message-ID: <1403039230-3427-1-git-send-email-sw@weilnetz.de> (raw)
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
next reply other threads:[~2014-06-17 21:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-17 21:07 Stefan Weil [this message]
2014-06-17 22:09 ` [Qemu-devel] [PATCH] libvixl: Add gcc format attribute 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1403039230-3427-1-git-send-email-sw@weilnetz.de \
--to=sw@weilnetz.de \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).