Patchwork Silence compiler warning in json test case

login
register
mail settings
Submitter Jan Kiszka
Date Oct. 16, 2010, 5:42 p.m.
Message ID <4CB9E413.5090400@web.de>
Download mbox | patch
Permalink /patch/68049/
State New
Headers show

Comments

Jan Kiszka - Oct. 16, 2010, 5:42 p.m.
Am 16.10.2010 18:28, Blue Swirl wrote:
> On Sat, Oct 16, 2010 at 12:37 AM, Paolo Bonzini <pbonzini@redhat.com> wrote:
>> On 10/15/2010 07:41 PM, Blue Swirl wrote:
>>>
>>> Which functions are optimized away and which aren't?
>>
>> It's builtins only that are optimized away or otherwise inlined (printf,
>> sprintf, etc.).  Other calls stay, together with side effects and clock
>> cycles.
> 
> Then the warning makes sense (slightly) and should remain on main QEMU side.
> 

From: Jan Kiszka <jan.kiszka@siemens.com>

This avoids

    error: zero-length gnu_printf format string

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 check-qjson.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
Luiz Capitulino - Oct. 18, 2010, 2:14 p.m.
On Sat, 16 Oct 2010 19:42:43 +0200
Jan Kiszka <jan.kiszka@web.de> wrote:

> Am 16.10.2010 18:28, Blue Swirl wrote:
> > On Sat, Oct 16, 2010 at 12:37 AM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> >> On 10/15/2010 07:41 PM, Blue Swirl wrote:
> >>>
> >>> Which functions are optimized away and which aren't?
> >>
> >> It's builtins only that are optimized away or otherwise inlined (printf,
> >> sprintf, etc.).  Other calls stay, together with side effects and clock
> >> cycles.
> > 
> > Then the warning makes sense (slightly) and should remain on main QEMU side.
> > 
> 
> From: Jan Kiszka <jan.kiszka@siemens.com>
> 
> This avoids
> 
>     error: zero-length gnu_printf format string
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>

I've applied this one to the QMP queue, but of course that Blue can
push it if he wants to.

> ---
>  check-qjson.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/check-qjson.c b/check-qjson.c
> index 0b60e45..64fcdcb 100644
> --- a/check-qjson.c
> +++ b/check-qjson.c
> @@ -639,7 +639,9 @@ END_TEST
>  
>  START_TEST(empty_input)
>  {
> -    QObject *obj = qobject_from_json("");
> +    const char *empty = "";
> +
> +    QObject *obj = qobject_from_json(empty);
>      fail_unless(obj == NULL);
>  }
>  END_TEST
>

Patch

diff --git a/check-qjson.c b/check-qjson.c
index 0b60e45..64fcdcb 100644
--- a/check-qjson.c
+++ b/check-qjson.c
@@ -639,7 +639,9 @@  END_TEST
 
 START_TEST(empty_input)
 {
-    QObject *obj = qobject_from_json("");
+    const char *empty = "";
+
+    QObject *obj = qobject_from_json(empty);
     fail_unless(obj == NULL);
 }
 END_TEST