Fix surfaceflinger on integer sanitized builds.
Refactors unsigned integer overflows in do_compare to fix integer
overflow sanitized builds. Also disables sanitization in
Layer::makeTraversalList.
Test: Compiled and checked output from sanitizer.
Bug: 30969751
Change-Id: I1a6d73435495e8b3ba3edb2587f62e4a0f2662f3
Merged-In: I1a6d73435495e8b3ba3edb2587f62e4a0f2662f3
diff --git a/services/surfaceflinger/LayerVector.cpp b/services/surfaceflinger/LayerVector.cpp
index 2233e78..d0f8fbe 100644
--- a/services/surfaceflinger/LayerVector.cpp
+++ b/services/surfaceflinger/LayerVector.cpp
@@ -35,14 +35,17 @@
uint32_t ls = l->getCurrentState().layerStack;
uint32_t rs = r->getCurrentState().layerStack;
if (ls != rs)
- return ls - rs;
+ return (ls > rs) ? 1 : -1;
uint32_t lz = l->getCurrentState().z;
uint32_t rz = r->getCurrentState().z;
if (lz != rz)
- return lz - rz;
+ return (lz > rz) ? 1 : -1;
- return l->sequence - r->sequence;
+ if (l->sequence == r->sequence)
+ return 0;
+
+ return (l->sequence > r->sequence) ? 1 : -1;
}
void LayerVector::traverseInZOrder(StateSet stateSet, const Visitor& visitor) const {