Use -Werror in frameworks/native/libs/gui and ui
* Remove unused variable and function.
* Suppress warning of unused return results.
Bug: 66996870
Test: build with WITH_TIDY=1
Change-Id: If6f445be1e7677a37bf780844a79b84d6d7e1c1e
diff --git a/libs/gui/Android.bp b/libs/gui/Android.bp
index 50bb7b2..37fae64 100644
--- a/libs/gui/Android.bp
+++ b/libs/gui/Android.bp
@@ -25,9 +25,12 @@
},
clang: true,
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
cppflags: [
"-Weverything",
- "-Werror",
// The static constructors and destructors in this library have not been noted to
// introduce significant overheads
diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp
index 7b2b5c3..5bee7a4 100644
--- a/libs/gui/Surface.cpp
+++ b/libs/gui/Surface.cpp
@@ -153,7 +153,10 @@
ATRACE_CALL();
DisplayStatInfo stats;
- status_t err = composerService()->getDisplayStats(NULL, &stats);
+ status_t result = composerService()->getDisplayStats(NULL, &stats);
+ if (result != NO_ERROR) {
+ return result;
+ }
*outRefreshDuration = stats.vsyncPeriod;
diff --git a/libs/gui/tests/Android.bp b/libs/gui/tests/Android.bp
index fa87f29..908959c 100644
--- a/libs/gui/tests/Android.bp
+++ b/libs/gui/tests/Android.bp
@@ -7,6 +7,10 @@
test_suites: ["device-tests"],
clang: true,
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
srcs: [
"BufferItemConsumer_test.cpp",
diff --git a/libs/gui/tests/CpuConsumer_test.cpp b/libs/gui/tests/CpuConsumer_test.cpp
index 0982d7e..588e541 100644
--- a/libs/gui/tests/CpuConsumer_test.cpp
+++ b/libs/gui/tests/CpuConsumer_test.cpp
@@ -310,8 +310,6 @@
uint32_t h = buf.height;
const int blockWidth = w > 16 ? w / 16 : 1;
const int blockHeight = h > 16 ? h / 16 : 1;
- const int blockRows = h / blockHeight;
- const int blockCols = w / blockWidth;
// Top-left square is bright
checkPixel(buf, 0, 0, 191);
@@ -349,8 +347,6 @@
uint32_t h = buf.height;
const int blockWidth = w > 16 ? w / 16 : 1;
const int blockHeight = h > 16 ? h / 16 : 1;
- const int blockRows = h / blockHeight;
- const int blockCols = w / blockWidth;
// Top-left square is bright red
checkPixel(buf, 0, 0, 191, 63, 63);
@@ -392,8 +388,6 @@
uint32_t h = buf.height;
const int blockWidth = (w > 16 ? w / 8 : 2) & ~0x1;
const int blockHeight = (h > 16 ? h / 8 : 2) & ~0x1;
- const int blockRows = h / blockHeight;
- const int blockCols = w / blockWidth;
// Top-left square is red
checkPixel(buf, 0, 0, 1000, 200, 200);
diff --git a/libs/gui/tests/SurfaceTextureGL_test.cpp b/libs/gui/tests/SurfaceTextureGL_test.cpp
index c6745d0..5639286 100644
--- a/libs/gui/tests/SurfaceTextureGL_test.cpp
+++ b/libs/gui/tests/SurfaceTextureGL_test.cpp
@@ -323,7 +323,6 @@
for (int j = 0; j < numTestPixels; j++) {
int x = testPixels[j].x;
int y = testPixels[j].y;
- uint8_t value = 0;
if (j == (i % numTestPixels)) {
// We must y-invert the texture coords
EXPECT_TRUE(checkPixel(x, texHeight-y-1, 255, 255, 255, 255));
diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp
index e18af17..e572e51 100644
--- a/libs/gui/tests/Surface_test.cpp
+++ b/libs/gui/tests/Surface_test.cpp
@@ -1075,7 +1075,6 @@
EXPECT_EQ(initialCompositorTiming.presentLatency,
compositeToPresentLatency);
- const uint64_t fId1 = getNextFrameId();
dequeueAndQueue(0);
addFrameEvents(true, NO_FRAME_INDEX, 0);
@@ -1089,7 +1088,6 @@
EXPECT_EQ(initialCompositorTiming.presentLatency,
compositeToPresentLatency);
- const uint64_t fId2 = getNextFrameId();
dequeueAndQueue(1);
addFrameEvents(true, 0, 1);
@@ -1162,7 +1160,6 @@
nsecs_t expectedDeadline = initialCompositorTiming.deadline;
EXPECT_EQ(expectedDeadline, compositeDeadline);
- const uint64_t fId1 = getNextFrameId();
dequeueAndQueue(0);
addFrameEvents(true, NO_FRAME_INDEX, 0);
@@ -1175,7 +1172,6 @@
initialCompositorTiming.deadline +initialCompositorTiming.interval;
EXPECT_EQ(expectedDeadline, compositeDeadline);
- const uint64_t fId2 = getNextFrameId();
dequeueAndQueue(1);
addFrameEvents(true, 0, 1);
diff --git a/libs/ui/Android.bp b/libs/ui/Android.bp
index 28b8ab3..14c0d5c 100644
--- a/libs/ui/Android.bp
+++ b/libs/ui/Android.bp
@@ -20,9 +20,12 @@
},
clang: true,
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
cppflags: [
"-Weverything",
- "-Werror",
// The static constructors and destructors in this library have not been noted to
// introduce significant overheads
diff --git a/libs/ui/GraphicBufferMapper.cpp b/libs/ui/GraphicBufferMapper.cpp
index 5b0e7f6..d5a30d7 100644
--- a/libs/ui/GraphicBufferMapper.cpp
+++ b/libs/ui/GraphicBufferMapper.cpp
@@ -125,29 +125,6 @@
return static_cast<status_t>(error);
}
-static inline bool isValidYCbCrPlane(const android_flex_plane_t& plane) {
- if (plane.bits_per_component != 8) {
- ALOGV("Invalid number of bits per component: %d",
- plane.bits_per_component);
- return false;
- }
- if (plane.bits_used != 8) {
- ALOGV("Invalid number of bits used: %d", plane.bits_used);
- return false;
- }
-
- bool hasValidIncrement = plane.h_increment == 1 ||
- (plane.component != FLEX_COMPONENT_Y && plane.h_increment == 2);
- hasValidIncrement = hasValidIncrement && plane.v_increment > 0;
- if (!hasValidIncrement) {
- ALOGV("Invalid increment: h %d v %d", plane.h_increment,
- plane.v_increment);
- return false;
- }
-
- return true;
-}
-
status_t GraphicBufferMapper::lockAsyncYCbCr(buffer_handle_t handle,
uint32_t usage, const Rect& bounds, android_ycbcr *ycbcr, int fenceFd)
{
diff --git a/libs/ui/tests/Android.bp b/libs/ui/tests/Android.bp
index 6733505..08067fc 100644
--- a/libs/ui/tests/Android.bp
+++ b/libs/ui/tests/Android.bp
@@ -18,10 +18,12 @@
name: "Region_test",
shared_libs: ["libui"],
srcs: ["Region_test.cpp"],
+ cflags: ["-Wall", "-Werror"],
}
cc_test {
name: "colorspace_test",
shared_libs: ["libui"],
srcs: ["colorspace_test.cpp"],
+ cflags: ["-Wall", "-Werror"],
}