qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH for-2.4] spapr_drc: fix clang -fsanitizer=shift warn


From: Michael Roth
Subject: [Qemu-devel] [PATCH for-2.4] spapr_drc: fix clang -fsanitizer=shift warning
Date: Tue, 21 Jul 2015 18:40:16 -0500

Current code for generating DRC type mask generates the following warning with
clang -fsanitizer=undefined -fsanitizer=shift:

  runtime error: left shift of negative value -1

Fix this by calculating the mask like a sane person would.

Signed-off-by: Michael Roth <address@hidden>
---
 hw/ppc/spapr_drc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
index ee87432..0e7d725 100644
--- a/hw/ppc/spapr_drc.c
+++ b/hw/ppc/spapr_drc.c
@@ -32,7 +32,7 @@
 
 #define DRC_CONTAINER_PATH "/dr-connector"
 #define DRC_INDEX_TYPE_SHIFT 28
-#define DRC_INDEX_ID_MASK (~(~0 << DRC_INDEX_TYPE_SHIFT))
+#define DRC_INDEX_ID_MASK ((1 << DRC_INDEX_TYPE_SHIFT) - 1)
 
 static sPAPRDRConnectorTypeShift get_type_shift(sPAPRDRConnectorType type)
 {
-- 
1.9.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]