Received: from eggs.gnu.org ([2001:4830:134:3::10]:41452) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9CdF-0002QM-5Y for qemu-devel@nongnu.org; Tue, 22 Nov 2016 10:05:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c9CdC-0001om-04 for qemu-devel@nongnu.org; Tue, 22 Nov 2016 10:05:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60396) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c9CdB-0001o4-QP for qemu-devel@nongnu.org; Tue, 22 Nov 2016 10:05:09 -0500 From: Markus Armbruster References: <673F175E-AF65-4F4F-9895-C7335A36AC29@gmail.com> <8b136de6-490a-d194-b7a6-eabfb87daf2c@redhat.com> <16AF327F-E1FE-4F2E-9919-A474276474FF@gmail.com> <182f25fb-98bd-73db-62f3-ff18b30a49cd@redhat.com> <3c5fdd4e-da35-46d9-9c64-a1a269f41646@redhat.com> <87twaz3k2h.fsf@dusky.pond.sub.org> <442795206.1194764.1479819273263.JavaMail.zimbra@redhat.com> Date: Tue, 22 Nov 2016 16:05:06 +0100 In-Reply-To: <442795206.1194764.1479819273263.JavaMail.zimbra@redhat.com> (Paolo Bonzini's message of "Tue, 22 Nov 2016 07:54:33 -0500 (EST)") Message-ID: <87h96zy2ql.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] qobject/qjson.c:69: failed assertion `obj != NULL' List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Eric Blake , G 3 , qemu-devel qemu-devel Paolo Bonzini writes: >> > I kind of like the %-escapes, because they provide a compact and legible >> > way to build QObjects. But with so little use, they're hardly earning >> > their keep. >> >> What drives me most insane about them is that they are NOT the same >> escapes as printf(), so the compiler can't help us with type safety, and The intent was to pick conversion specifiers so that __attribute__((format(gnu_printf, ...))) catches the type errors it can catch. What exactly makes you think we've failed at that? >> things like PRId64 don't always do what we want. What would you want it to do? Mind. we're *not* building a string from a template here, we're building a QObject from a template. Therefore, PRId64 is for creating a QInt holding an int64_t value. >> And except for %p for >> injecting nested objects, most of our escapes are just as easy to >> perform with g_strdup_printf() (injecting a string, integer, or >> boolean), or by manual creation of the QDict. > > Oh wait. Now I remember where we most used %-escapes and they're actually > much more useful and pervasive than you estimated. See commit 563890c > ("libqtest: escape strings in QMP commands, fix leak", 2014-07-01); > they cannot be produced with g_strdup_printf, because %s automatically > escapes strings. Precisely. g_strdup_printf() is much easier to screw up than qobject_from_jsonf() or building a QObject by hand. > The patch actually fixed a failure in qom-test, if I'm not mistaken, due > to a " appearing in a QOM path. > > However, I'm still in favor of limiting % to the testsuite. Dunno. Let's have a look at the actual patches.