|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [win-pv-devel] [PATCH] Have another go at __CacheMaskScan()
Trying to BUG() at the end of the function if an available index is not
found is proving to be too challenging for the compilier. It seems that,
in general, a free build may object if there's (an effectively dead) return
statement after the BUG() and a checked build will fail if the return
statement is *not* there. Rock. Hard place.
This patch instead gets rid of the BUG(), makes __CacheMaskScan() return
and out-of-range index if there is no available index and then adds a
suitable BUG_ON() into CacheGetObjectFromSlab(), the only caller.
The patch also fixes a hole in the logic where an out-of-range index
could have been returned if it was less than the maximum occupancy
rounded up to the next 32-bit boundary.
Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
---
src/xenbus/cache.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/xenbus/cache.c b/src/xenbus/cache.c
index 7daf8da..479c411 100644
--- a/src/xenbus/cache.c
+++ b/src/xenbus/cache.c
@@ -369,10 +369,11 @@ __CacheMaskScan(
continue;
Bit += Index * BITS_PER_ULONG;
- return Bit;
+ if (Bit < Maximum)
+ return Bit;
}
- BUG("CACHE SCAN FAILED");
+ return Maximum;
}
static FORCEINLINE VOID
@@ -425,6 +426,7 @@ CacheGetObjectFromSlab(
return NULL;
Index = __CacheMaskScan(Slab->Mask, Slab->MaximumOccupancy);
+ BUG_ON(Index >= Slab->MaximumOccupancy);
__CacheMaskSet(Slab->Mask, Index);
Slab->CurrentOccupancy++;
--
2.5.3
_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/win-pv-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |