gui: fix uses of uninitialized values
Clang's static analyzer complained about `ui::toRotation(rotationInt)`:
frameworks/native/libs/gui/LayerState.cpp:544:16: warning: 1st function
call argument is an uninitialized value
[clang-analyzer-core.CallAndMessage]
Looks like there're a few other places in the area where we're
doing things with uninit bit patterns. Initializing things to 0 should
at least make us consistent in the face of Parcel read failures.
Bug: None
Test: TreeHugger
Change-Id: I7ef2a71171b9939cb14611deea1f5b7132c54eaf
diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp
index dd95b92..55dbcd1 100644
--- a/libs/gui/LayerState.cpp
+++ b/libs/gui/LayerState.cpp
@@ -509,7 +509,7 @@
}
status_t CaptureArgs::read(const Parcel& input) {
- int32_t format;
+ int32_t format = 0;
status_t status = input.readInt32(&format) ?:
input.read(sourceCrop) ?:
input.readFloat(&frameScale) ?:
@@ -533,7 +533,7 @@
status_t DisplayCaptureArgs::read(const Parcel& input) {
status_t status = CaptureArgs::read(input);
- int32_t rotationInt;
+ int32_t rotationInt = 0;
status |= input.readStrongBinder(&displayToken) ?:
input.readUint32(&width) ?:
@@ -562,7 +562,7 @@
status |= input.readStrongBinder(&layerHandle);
- int32_t numExcludeHandles;
+ int32_t numExcludeHandles = 0;
status |= input.readInt32(&numExcludeHandles);
excludeHandles.reserve(numExcludeHandles);
for (int i = 0; i < numExcludeHandles; i++) {
@@ -584,7 +584,7 @@
status_t ScreenCaptureResults::read(const Parcel& input) {
buffer = new GraphicBuffer();
- uint32_t dataspace;
+ uint32_t dataspace = 0;
status_t status = input.read(*buffer) ?:
input.readBool(&capturedSecureLayers) ?:
input.readUint32(&dataspace);