From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58121) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtDcC-0006vx-Rv for qemu-devel@nongnu.org; Mon, 02 Nov 2015 06:49:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZtDc8-0007xl-OH for qemu-devel@nongnu.org; Mon, 02 Nov 2015 06:49:32 -0500 Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]:36295) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtDc8-0007xg-IO for qemu-devel@nongnu.org; Mon, 02 Nov 2015 06:49:28 -0500 Received: by wmec75 with SMTP id c75so58003076wme.1 for ; Mon, 02 Nov 2015 03:49:28 -0800 (PST) Sender: Paolo Bonzini References: <5633C8EC.8030309@redhat.com> <874mh44wvs.fsf@blackfin.pond.sub.org> From: Paolo Bonzini Message-ID: <56374DC5.2050808@redhat.com> Date: Mon, 2 Nov 2015 12:49:25 +0100 MIME-Version: 1.0 In-Reply-To: <874mh44wvs.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] RFC: libyajl for JSON List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , Eric Blake Cc: Luiz Capitulino , "qemu-devel@nongnu.org" , "Dr. David Alan Gilbert" 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