Received: from eggs.gnu.org ([2001:4830:134:3::10]:42442) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWrkg-0004YU-7s for qemu-devel@nongnu.org; Mon, 08 Aug 2016 17:06:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bWrkb-0006Bq-Vt for qemu-devel@nongnu.org; Mon, 08 Aug 2016 17:06:25 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:49558 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWrkb-0006Bc-Pq for qemu-devel@nongnu.org; Mon, 08 Aug 2016 17:06:21 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u78Kxkka058590 for ; Mon, 8 Aug 2016 17:06:21 -0400 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0a-001b2d01.pphosted.com with ESMTP id 24nbvwr4h5-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 08 Aug 2016 17:06:21 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 8 Aug 2016 15:06:20 -0600 From: Michael Roth Date: Mon, 8 Aug 2016 16:04:18 -0500 In-Reply-To: <1470690267-31454-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1470690267-31454-1-git-send-email-mdroth@linux.vnet.ibm.com> Message-Id: <1470690267-31454-48-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 47/56] util: Fix MIN_NON_ZERO List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Fam Zheng , Paolo Bonzini From: Fam Zheng MIN_NON_ZERO(1, 0) is evaluated to 0. Rewrite the macro to fix it. Reported-by: Miroslav Rezanina Signed-off-by: Fam Zheng Message-Id: <1468306113-847-1-git-send-email-famz@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Paolo Bonzini (cherry picked from commit d27ba624aa1dfe5c07cc01200d95967ffce905d9) Signed-off-by: Michael Roth --- include/qemu/osdep.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 783270f..94a1603 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -149,7 +149,8 @@ extern int daemon(int, int); /* Minimum function that returns zero only iff both values are zero. * Intended for use with unsigned values only. */ #ifndef MIN_NON_ZERO -#define MIN_NON_ZERO(a, b) (((a) != 0 && (a) < (b)) ? (a) : (b)) +#define MIN_NON_ZERO(a, b) ((a) == 0 ? (b) : \ + ((b) == 0 ? (a) : (MIN(a, b)))) #endif /* Round number down to multiple */ -- 1.9.1