From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60026) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xh9pH-00044U-Qv for qemu-devel@nongnu.org; Thu, 23 Oct 2014 00:16:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xh9pD-0004y8-CS for qemu-devel@nongnu.org; Thu, 23 Oct 2014 00:16:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:6566) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xh9pD-0004y4-3s for qemu-devel@nongnu.org; Thu, 23 Oct 2014 00:16:35 -0400 Message-ID: <544830E5.4020203@redhat.com> Date: Wed, 22 Oct 2014 16:34:13 -0600 From: Eric Blake MIME-Version: 1.0 References: <1413446090-30050-1-git-send-email-pl@kamp.de> <1413446090-30050-2-git-send-email-pl@kamp.de> In-Reply-To: <1413446090-30050-2-git-send-email-pl@kamp.de> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="o1c5StMB8n6NVJg55FEcJx0hkEPN4uJ7B" Subject: Re: [Qemu-devel] [PATCHv4 1/4] util: introduce MIN_NON_ZERO List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Lieven , qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, ronniesahlberg@gmail.com, stefanha@redhat.com, mreitz@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --o1c5StMB8n6NVJg55FEcJx0hkEPN4uJ7B Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 10/16/2014 01:54 AM, Peter Lieven wrote: > at least in block layer we have the case of limits being defined for a > BlockDriverState. However, in this context often zero (0) has the speci= al > meanining of undefined which means no limit. If two of those limits are= > combined and the minimum is needed the minimum function should only ret= urn > zero if both parameters are zero. >=20 > Signed-off-by: Peter Lieven > --- > include/qemu/osdep.h | 4 ++++ > 1 file changed, 4 insertions(+) >=20 > diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h > index 1565404..9a238df 100644 > --- a/include/qemu/osdep.h > +++ b/include/qemu/osdep.h > @@ -68,6 +68,10 @@ typedef signed int int_fast16_t; > #define MAX(a, b) (((a) > (b)) ? (a) : (b)) > #endif > =20 > +#ifndef MIN_NON_ZERO > +#define MIN_NON_ZERO(a, b) ((!!(a) && (a) < (b)) ? (a) : (b)) '(a) && expr' is already forcing the evaluation of (a) as a boolean; thus rendering the '!!(a)' conversion to boolean redundant. The patch is correct as is, so I'll leave a positive review, but if you have a reason to respin, making it two characters shorter is probably worth it. Maybe it's also worth a comment that this macro is only designed to work on unsigned values. Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --o1c5StMB8n6NVJg55FEcJx0hkEPN4uJ7B 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 iQEcBAEBCAAGBQJUSDDlAAoJEKeha0olJ0NqaRIH/iUHfDH3BwBOb/Ae6Z35q8Tu ezE5ingYW6e0DwezUPIWe7KxZAJk9g7DPNqCj1+083l7pnfs0Eprp4V6E36Ih8kr qGOudiPthBarmzUrMZgdv5vy06nIm+GgzIK5Mku4tOHGNLwaXkoHgBu/zdlmYtzX kJLoycDUVcaNoTpqGDTNipnyGnVzhFple+PJUG5VRUoKEeFixeV8c6/+XbTvwemk 88RX2qiXLyQqPTVprTLQ7QUHLXk7Z3DuaAU9tQ2/p+F6xKXPTIBiEoad77GSSt4u Qs/LGSL4cQyRLRuh1yjfvD57dyZLdv++mW/FKryI0NNs33jyfHsn8F9XieoOod8= =LPiw -----END PGP SIGNATURE----- --o1c5StMB8n6NVJg55FEcJx0hkEPN4uJ7B--