cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
34b321
From 6e14ac55a7b40804cf69de560f38561214129b07 Mon Sep 17 00:00:00 2001
34b321
From: Fam Zheng <famz@redhat.com>
34b321
Date: Mon, 11 Jul 2016 05:33:34 +0200
34b321
Subject: [PATCH 1/7] util: introduce MIN_NON_ZERO
34b321
34b321
RH-Author: Fam Zheng <famz@redhat.com>
34b321
Message-id: <1468215219-30793-2-git-send-email-famz@redhat.com>
34b321
Patchwork-id: 71105
34b321
O-Subject: [RHEL-7.3 qemu-kvm PATCH 1/6] util: introduce MIN_NON_ZERO
34b321
Bugzilla: 1318199
34b321
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
34b321
RH-Acked-by: John Snow <jsnow@redhat.com>
34b321
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
34b321
34b321
From: Peter Lieven <pl@kamp.de>
34b321
34b321
at least in block layer we have the case of limits being defined for a
34b321
BlockDriverState. However, in this context often zero (0) has the special
34b321
meanining of undefined which means no limit. If two of those limits are
34b321
combined and the minimum is needed the minimum function should only return
34b321
zero if both parameters are zero.
34b321
34b321
Signed-off-by: Peter Lieven <pl@kamp.de>
34b321
Reviewed-by: Max Reitz <mreitz@redhat.com>
34b321
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
34b321
(cherry picked from commit ac3a8726644d4783eacf54212d23db01d1d30044)
34b321
Signed-off-by: Fam Zheng <famz@redhat.com>
34b321
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
34b321
---
34b321
 include/qemu/osdep.h | 6 ++++++
34b321
 1 file changed, 6 insertions(+)
34b321
34b321
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
34b321
index 8984da0..c47a600 100644
34b321
--- a/include/qemu/osdep.h
34b321
+++ b/include/qemu/osdep.h
34b321
@@ -68,6 +68,12 @@ typedef signed int              int_fast16_t;
34b321
 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
34b321
 #endif
34b321
 
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
+#endif
34b321
+
34b321
 #ifndef ROUND_UP
34b321
 #define ROUND_UP(n,d) (((n) + (d) - 1) & -(d))
34b321
 #endif
34b321
-- 
34b321
1.8.3.1
34b321