yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
34b321
From 756b23c15387acefe4139831c2f3c8a5f3d41bb2 Mon Sep 17 00:00:00 2001
34b321
From: Fam Zheng <famz@redhat.com>
34b321
Date: Mon, 18 Jul 2016 01:32:10 +0200
34b321
Subject: [PATCH 7/7] util: Fix MIN_NON_ZERO
34b321
34b321
RH-Author: Fam Zheng <famz@redhat.com>
34b321
Message-id: <1468805530-19033-1-git-send-email-famz@redhat.com>
34b321
Patchwork-id: 71200
34b321
O-Subject: [RHEL-7.3 qemu-kvm PATCH 7/6] util: Fix MIN_NON_ZERO
34b321
Bugzilla: 1318199
34b321
RH-Acked-by: John Snow <jsnow@redhat.com>
34b321
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
34b321
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
34b321
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
34b321
34b321
MIN_NON_ZERO(1, 0) is evaluated to 0. Rewrite the macro to fix it.
34b321
34b321
Reported-by: Miroslav Rezanina <mrezanin@redhat.com>
34b321
Signed-off-by: Fam Zheng <famz@redhat.com>
34b321
Message-Id: <1468306113-847-1-git-send-email-famz@redhat.com>
34b321
Reviewed-by: Eric Blake <eblake@redhat.com>
34b321
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
34b321
(cherry picked from commit d27ba624aa1dfe5c07cc01200d95967ffce905d9)
34b321
Signed-off-by: Fam Zheng <famz@redhat.com>
34b321
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
34b321
---
34b321
 include/qemu/osdep.h | 3 ++-
34b321
 1 file changed, 2 insertions(+), 1 deletion(-)
34b321
34b321
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
34b321
index c47a600..5ca05bc 100644
34b321
--- a/include/qemu/osdep.h
34b321
+++ b/include/qemu/osdep.h
34b321
@@ -71,7 +71,8 @@ typedef signed int              int_fast16_t;
34b321
 /* Minimum function that returns zero only iff both values are zero.
34b321
  * Intended for use with unsigned values only. */
34b321
 #ifndef MIN_NON_ZERO
34b321
-#define MIN_NON_ZERO(a, b) (((a) != 0 && (a) < (b)) ? (a) : (b))
34b321
+#define MIN_NON_ZERO(a, b) ((a) == 0 ? (b) : \
34b321
+                                ((b) == 0 ? (a) : (MIN(a, b))))
34b321
 #endif
34b321
 
34b321
 #ifndef ROUND_UP
34b321
-- 
34b321
1.8.3.1
34b321