aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorFam Zheng <famz@redhat.com>2016-07-12 14:48:33 +0800
committerPaolo Bonzini <pbonzini@redhat.com>2016-07-13 12:55:11 +0200
commitd27ba624aa1dfe5c07cc01200d95967ffce905d9 (patch)
tree5ea4f41fa49742e710757ffe8b0038cdb74b9b73 /include
parent73f40c1895980dc705b6b0594ace6580b3f68537 (diff)
downloadqemu-d27ba624aa1dfe5c07cc01200d95967ffce905d9.zip
qemu-d27ba624aa1dfe5c07cc01200d95967ffce905d9.tar.gz
qemu-d27ba624aa1dfe5c07cc01200d95967ffce905d9.tar.bz2
util: Fix MIN_NON_ZERO
MIN_NON_ZERO(1, 0) is evaluated to 0. Rewrite the macro to fix it. Reported-by: Miroslav Rezanina <mrezanin@redhat.com> Signed-off-by: Fam Zheng <famz@redhat.com> Message-Id: <1468306113-847-1-git-send-email-famz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/qemu/osdep.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index e63da28..e4c6ae6 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -151,7 +151,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 */