qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] RFC: libyajl for JSON


From: Paolo Bonzini
Subject: Re: [Qemu-devel] RFC: libyajl for JSON
Date: Mon, 2 Nov 2015 12:49:25 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0


On 02/11/2015 09:40, Markus Armbruster wrote:
> 
> * Optional interpolation
> 
>   If you pass a va_list to the parser, it replaces certain escape
>   sequences by values from that va_list.  The escape sequences are a
>   subset of printf conversion specifiers, to enable compile-time
>   checking with __attribute__((format...)).
> 
>   We used to rely on this for creating "rich" error objects, but those
>   are long gone (commit df1e608).  Perhaps two dozen uses are left.

Most of these are probably in the tests, where they are used to send QMP
commands.

>   We could convert them to use "normal" interpolation, i.e. first format
>   the arguments as JSON, then interpolate with g_strdup_printf() or
>   similar, then parse.  Formatting only to parse it right back is
>   inelegant.  Also inefficient, but that probably doesn't matter here.

I don't care about inefficiency or elegance, but I care about bugs.  One
difference between printf-ing \"%s\" and JSON-parsing %s is that the
latter performs backslash escaping.  The lack of backslash escaping has
been the source of bugs in the past, so it's important that the API
remains as convenient as it is now.

There is one alternative: rewriting tests in Python.  I'm only
half-kidding, probably less than half.  It would be great for example to
reuse the work on BITS (http://biosbits.org/) within qtest.

>   Unlike the extensions above, this one is essential: any parser that
>   can't do it is useless for us.  Can yajl do it?

I think it does.

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]