From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41898) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XqHv4-0000nA-Qz for qemu-devel@nongnu.org; Mon, 17 Nov 2014 03:44:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XqHuv-0006oh-Po for qemu-devel@nongnu.org; Mon, 17 Nov 2014 03:44:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52709) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XqHuv-0006o2-JT for qemu-devel@nongnu.org; Mon, 17 Nov 2014 03:44:13 -0500 Message-ID: <5469B557.4010804@redhat.com> Date: Mon, 17 Nov 2014 09:44:07 +0100 From: Max Reitz MIME-Version: 1.0 References: <1415970374-16811-1-git-send-email-mreitz@redhat.com> <1415970374-16811-9-git-send-email-mreitz@redhat.com> <5467889F.8050708@redhat.com> In-Reply-To: <5467889F.8050708@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit 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: Eric Blake , qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Lieven , Stefan Hajnoczi On 2014-11-15 at 18:08, Eric Blake wrote: > 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 during >> refcount initialization. >> >> Signed-off-by: Max Reitz >> --- >> block/qcow2-refcount.c | 146 ++++++++++++++++++++++++++++++++++++++++++++++++- >> 1 file changed, 144 insertions(+), 2 deletions(-) >> >> +static void get_refcount_functions(int refcount_order, >> + Qcow2GetRefcountFunc **get, >> + Qcow2SetRefcountFunc **set) >> +{ >> + switch (refcount_order) { >> + case 0: >> + *get = &get_refcount_ro0; >> + *set = &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. I thought about it, but it wouldn't get much shorter. But maybe it looks nicer. I ought to think about it again. Max > Reviewed-by: Eric Blake