Received: from eggs.gnu.org ([208.118.235.92]:46831) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Th3xT-0002as-HV for qemu-devel@nongnu.org; Fri, 07 Dec 2012 14:51:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Th3xP-0000WP-AL for qemu-devel@nongnu.org; Fri, 07 Dec 2012 14:51:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:21086) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Th3xP-0000WJ-1s for qemu-devel@nongnu.org; Fri, 07 Dec 2012 14:51:35 -0500 Date: Fri, 7 Dec 2012 17:53:04 -0200 From: Eduardo Habkost Message-ID: <20121207195304.GG4255@otherpad.lan.raisama.net> References: <1354828325-16568-1-git-send-email-imammedo@redhat.com> <1354828325-16568-2-git-send-email-imammedo@redhat.com> <50C23C1F.6010102@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <50C23C1F.6010102@suse.de> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 1/2] qapi: add visitor for parsing int[KMGT] input string List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andreas =?iso-8859-1?Q?F=E4rber?= Cc: Igor Mammedov , qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com On Fri, Dec 07, 2012 at 07:57:35PM +0100, Andreas F=E4rber wrote: [...] > > +static void parse_type_unit_suffixed_int(Visitor *v, int64_t *obj, > > + const char *name, const int= unit, > > + Error **errp) > > +{ > > + StringInputVisitor *siv =3D DO_UPCAST(StringInputVisitor, visito= r, v); > > + char *endp =3D (char *) siv->string; > > + long long val =3D 0; > > + > > + if (siv->string) { > > + val =3D strtosz_suffix_unit(siv->string, &endp, > > + STRTOSZ_DEFSUFFIX_B, unit); > > + } > > + if (!siv->string || val =3D=3D -1 || *endp) { > > + error_set(errp, QERR_INVALID_PARAMETER_VALUE, name, > > + "a value representable as a non-negative int64"); >=20 > Weird indentation remaining, looks as if we could align with errp withi= n > 80 chars. >=20 > However, I wonder if "unit" is the (physically etc.) correct term here? > Isn't the "unit" Hz / byte / ... and 1000 more of a conversion factor o= r > something? At least that's the way I've seen unit used in the API of > another project, passing an enum of Hertz, gram, meter/second, etc. I also think that calling it "unit" is confusing. Strictly speaking, the "unit" we're dealing with is Hz (and the visitor simply don't care about unit, it only looks for "unit prefixes"). Can't we call the 1000/1024 parameter "base" or "factor", instead? --=20 Eduardo