]> Git Repo - qemu.git/commit
spapr_drc: Fix potential undefined behaviour
authorDavid Gibson <[email protected]>
Thu, 3 Sep 2015 00:08:23 +0000 (10:08 +1000)
committerDavid Gibson <[email protected]>
Wed, 23 Sep 2015 00:51:09 +0000 (10:51 +1000)
commit627c2ef7898794a28d706ecdf094491bebbb083a
tree0d53ae00210a3b7dd6451a799bbcfea25bf433b2
parentad440b4ae0727dbef5cace419d94d774de96886c
spapr_drc: Fix potential undefined behaviour

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 <[email protected]>
Signed-off-by: David Gibson <[email protected]>
Reviewed-by: Alexey Kardashevskiy <[email protected]>
hw/ppc/spapr_drc.c
This page took 0.025035 seconds and 4 git commands to generate.