From 756b23c15387acefe4139831c2f3c8a5f3d41bb2 Mon Sep 17 00:00:00 2001 From: Fam Zheng Date: Mon, 18 Jul 2016 01:32:10 +0200 Subject: [PATCH 7/7] util: Fix MIN_NON_ZERO RH-Author: Fam Zheng Message-id: <1468805530-19033-1-git-send-email-famz@redhat.com> Patchwork-id: 71200 O-Subject: [RHEL-7.3 qemu-kvm PATCH 7/6] util: Fix MIN_NON_ZERO Bugzilla: 1318199 RH-Acked-by: John Snow RH-Acked-by: Stefan Hajnoczi RH-Acked-by: Paolo Bonzini RH-Acked-by: Miroslav Rezanina 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: Fam Zheng Signed-off-by: Miroslav Rezanina --- 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 c47a600..5ca05bc 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -71,7 +71,8 @@ typedef signed int int_fast16_t; /* 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 #ifndef ROUND_UP -- 1.8.3.1