Skip to contentSkip to conversation

qmp: Add missing gcc format attribute and fix format string

PATCH Applied Stefan Weil 3 participants 3 messages Dec 23, 2011 – Jan 3, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qmp: Add missing gcc format attribute and fix format string

---
 test-qmp-input-visitor.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
test-qmp-input-visitor.c +4 -3
index 1f3ab03..bc410c6 100644
@@ -38,8 +38,9 @@ static void visitor_input_teardown(TestInputVisitorData *data,
 /* This is provided instead of a test setup function so that the JSON
    string used by the tests are kept in the test functions (and not
    int main()) */
-static Visitor *visitor_input_test_init(TestInputVisitorData *data,
-                                        const char *json_string, ...)
+static GCC_FMT_ATTR(2, 3)
+Visitor *visitor_input_test_init(TestInputVisitorData *data,
+                                 const char *json_string, ...)
 {
     Visitor *v;
     va_list ap;
@@ -66,7 +67,7 @@ static void test_visitor_in_int(TestInputVisitorData *data,
     Error *errp = NULL;
     Visitor *v;
 
-    v = visitor_input_test_init(data, "%d", value);
+    v = visitor_input_test_init(data, "%" PRId64, value);
 
     visit_type_int(v, &res, NULL, &errp);
     g_assert(!error_is_set(&errp));
Signature · 1 line
1.7.2.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Stefan Weil
---
 test-qmp-input-visitor.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

Although we're not strictly implementing printf format strings it's close enough that this seems worth having. If we ever introduce format specifiers that have a different meaning under printf then we need to rethink this.

#2 lore raw
Quoted 6 lines · On Fri, 30 Dec 2011 11:56:14 +0000 Stefan Hajnoczi <[email protected]> wrote:
Quoted 4 lines · Stefan Weil
---
 test-qmp-input-visitor.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
Quoted 6 lines

Although we're not strictly implementing printf format strings it's close enough that this seems worth having. If we ever introduce format specifiers that have a different meaning under printf then we need to rethink this.

Applied to the qmp branch, thanks Stefans.