[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PULL 08/33] spapr_drc: Fix potential undefined behaviour
From: |
David Gibson |
Subject: |
[Qemu-ppc] [PULL 08/33] spapr_drc: Fix potential undefined behaviour |
Date: |
Mon, 21 Sep 2015 11:06:03 +1000 |
The DRC_INDEX_ID_MASK macro does a left shift on ~0, which is a signed
quantity, and therefore undefined behaviour according to the C spec. In
particular this causes warnings from the clang sanitizer.
This fixes it by calculating the same mask without using ~0 (I think the
new method is a more common idiom for generating masks anyway). For good
measure I also use 1ULL to force the expression's type to unsigned long
long, which should be good for assigning to anything we're going to want
to.
Reported-by: Peter Maydell <address@hidden>
Signed-off-by: David Gibson <address@hidden>
Reviewed-by: Alexey Kardashevskiy <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..8cbcf4d 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 ((1ULL << DRC_INDEX_TYPE_SHIFT) - 1)
static sPAPRDRConnectorTypeShift get_type_shift(sPAPRDRConnectorType type)
{
--
2.4.3
- [Qemu-ppc] [PULL 00/33] spapr-next queue 2015-09-16, David Gibson, 2015/09/20
- [Qemu-ppc] [PULL 01/33] spapr: Provide an error message when migration fails due to htab_shift mismatch, David Gibson, 2015/09/20
- [Qemu-ppc] [PULL 05/33] spapr: Make ibm, change-msi respect 3 return values, David Gibson, 2015/09/20
- [Qemu-ppc] [PULL 08/33] spapr_drc: Fix potential undefined behaviour,
David Gibson <=
- [Qemu-ppc] [PULL 07/33] spapr: add dumpdtb support, David Gibson, 2015/09/20
- [Qemu-ppc] [PULL 03/33] spapr: Add /ibm,partition-name, David Gibson, 2015/09/20
- [Qemu-ppc] [PULL 10/33] spapr_rtas: Prevent QEMU crash during hotplug without a prior device_add, David Gibson, 2015/09/20
- [Qemu-ppc] [PULL 06/33] spapr: SPLPAR Characteristics, David Gibson, 2015/09/20
- [Qemu-ppc] [PULL 09/33] ppc/spapr: Use qemu_log_mask() for hcall_dprintf(), David Gibson, 2015/09/20
- [Qemu-ppc] [PULL 04/33] spapr: Add /rtas/ibm,change-msix-capable, David Gibson, 2015/09/20
- [Qemu-ppc] [PULL 16/33] spapr_pci: fix device tree props for MSI/MSI-X, David Gibson, 2015/09/20
- [Qemu-ppc] [PULL 14/33] pseries: Fix incorrect calculation of threads per socket for chip-id, David Gibson, 2015/09/20
- [Qemu-ppc] [PULL 02/33] spapr: Create pseries-2.5 machine, David Gibson, 2015/09/20
- [Qemu-ppc] [PULL 11/33] sPAPR: Introduce rtas_ldq(), David Gibson, 2015/09/20