From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47323) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yrpdd-00050T-LR for qemu-devel@nongnu.org; Mon, 11 May 2015 11:29:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YrpdX-0003jJ-T4 for qemu-devel@nongnu.org; Mon, 11 May 2015 11:29:01 -0400 Message-ID: <5550CAB4.409@redhat.com> Date: Mon, 11 May 2015 09:28:52 -0600 From: Eric Blake MIME-Version: 1.0 References: <1431105726-3682-1-git-send-email-kwolf@redhat.com> <1431105726-3682-2-git-send-email-kwolf@redhat.com> <554D174B.4010200@redhat.com> <20150511144044.GH4962@noname.redhat.com> In-Reply-To: <20150511144044.GH4962@noname.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="b1WAF0k6Qb1EFIx0Grp6ap31ApjPhHecI" Subject: Re: [Qemu-devel] [PATCH 01/34] qdict: Add qdict_array_entries() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: mreitz@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, armbru@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --b1WAF0k6Qb1EFIx0Grp6ap31ApjPhHecI Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 05/11/2015 08:40 AM, Kevin Wolf wrote: >>> + char indexstr[slen], prefix[slen]; >> >> And more dependence on a working C99 compiler, thanks to variable leng= th >> array (VLA). >> >>> + size_t snprintf_ret; >>> + >>> + snprintf_ret =3D snprintf(indexstr, slen, "%s%u", subqdict, = i); >>> + assert(snprintf_ret < slen); >> >> Since gcc may compile the allocation of indexstr into a malloc() >> anyways, would it be any simpler to just use g_strdup_printf() directl= y, >> instead of futzing around with VLA and snprintf() ourselves? It might= >> mean less code, as some of the error checking is taken care of on your= >> behalf. >=20 > This code parallels the code in qdict_array_split(), which looks almos > the same, except that the latter doesn't support subqict and therefore > has a fixed-size array rather than a VLA. >=20 > If you think that g_strdup_printf() is preferable, I would do that on > top of this series and change both functions. I'm not strongly opposed to keeping snprintf, but agree that if you want to clean it up to g_strdup_printf(), a separate patch hitting multiple uses would be cleaner than respinning this patch. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --b1WAF0k6Qb1EFIx0Grp6ap31ApjPhHecI Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJVUMq0AAoJEKeha0olJ0Nqf2AH/3Gycoh8uqsqgEpt/5H9GWGg Ec/CFg8DuHz5YwlfoLYx3k2eNz666oEExO0xM477C4rFgtUA+dQK6+POtiS80ATD yluqY2Xd+iZTFuT9r9g55GievJHYu/9X3DpMoM59X9WKXj2ADBLzo85xqyIRU6OI oTyuhji0TRBwMEg2pMbJ8MXppnmlcB9itOlpagq/9o2uwrKY8llruyOL1ZjDpcCC P3u0yd8vKTZT0RDjIHQyiaKDWl3ovWeBKP6U/0kLCcSPVWLQAjog2PU7d+Z4KZKJ ToLchoJ46j6j72MYFpYdhP/2zWPJpCPxQE/8TtSyHEVK9v8DEK7UeTadPEHPnw4= =iE6t -----END PGP SIGNATURE----- --b1WAF0k6Qb1EFIx0Grp6ap31ApjPhHecI--