From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45084) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XpgqJ-0007Pu-Pt for qemu-devel@nongnu.org; Sat, 15 Nov 2014 12:09:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XpgqE-0008VW-T3 for qemu-devel@nongnu.org; Sat, 15 Nov 2014 12:08:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52259) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XpgqE-0008VC-Kn for qemu-devel@nongnu.org; Sat, 15 Nov 2014 12:08:54 -0500 Message-ID: <5467889F.8050708@redhat.com> Date: Sat, 15 Nov 2014 10:08:47 -0700 From: Eric Blake MIME-Version: 1.0 References: <1415970374-16811-1-git-send-email-mreitz@redhat.com> <1415970374-16811-9-git-send-email-mreitz@redhat.com> In-Reply-To: <1415970374-16811-9-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="2hnGdBm9Ir47bqa7qAg98jFNChmxt5mmC" Subject: Re: [Qemu-devel] [PATCH v2 08/21] qcow2: More helpers for refcount modification List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Lieven , Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --2hnGdBm9Ir47bqa7qAg98jFNChmxt5mmC Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 11/14/2014 06:06 AM, Max Reitz wrote: > Add helper functions for getting and setting refcounts in a refcount > array for any possible refcount order, and choose the correct one durin= g > refcount initialization. >=20 > Signed-off-by: Max Reitz > --- > block/qcow2-refcount.c | 146 +++++++++++++++++++++++++++++++++++++++++= +++++++- > 1 file changed, 144 insertions(+), 2 deletions(-) >=20 >=20 > +static void get_refcount_functions(int refcount_order, > + Qcow2GetRefcountFunc **get, > + Qcow2SetRefcountFunc **set) > +{ > + switch (refcount_order) { > + case 0: > + *get =3D &get_refcount_ro0; > + *set =3D &set_refcount_ro0; > + break; Bike-shedding: instead of a switch statement and open-coded assignments, is it worth setting up an array of function pointers where you just grab the correct functions by doing array[refcount_order]? But I don't see any strong reason to change style; what you have works. Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --2hnGdBm9Ir47bqa7qAg98jFNChmxt5mmC Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg iQEcBAEBCAAGBQJUZ4ifAAoJEKeha0olJ0Nq60kIAJsct+J9gTLjX1RkUskczEI9 zsMk/SCpOOY9L22dpB8/GfBfA0NwHX3+XgPHJh2nA/DXgCWjFbfQYkDJqans0HlH R3p+et7K1Od0wmKo6Wy+pY6Tryd4MpMsP9+53S2XS8lSsgjVNumVhP7lTIiZDQSk VgjEIZwJBdrgdjeozpuSsa+mK3ad6nTt0HXDY3SA1HFH++qbeXMkfHLgWWKbrqcM zWPvChD921RoqId4VrI8OLiQQuHlJ5fkc997KH36DFBkGf8EdwT31oXwxMHJRWq+ cp7gNwN1zyWd/jHLCBz0l0tTs/8K1eJy4TGhYlwR20JEvQt3MXe4GF9kV6G6frc= =2iA6 -----END PGP SIGNATURE----- --2hnGdBm9Ir47bqa7qAg98jFNChmxt5mmC--