Enable -Wshadow for input code
To avoid common programming mistakes, enable -Wshadow for input code.
This requires several refactors, such as using range-based for loops and
avoiding repeating variable names that are already in scope.
To allow for -Wshadow, we convert to unordered_map and use a range-based
loop.
Bug: 142017994
Test: atest libinput_tests inputflinger_tests
Change-Id: Icb65045d3322eccc312bca63287e38897d9f9ff6
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 49f9c54..14f7caf 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -3864,9 +3864,8 @@
if (!mFocusedWindowHandlesByDisplay.empty()) {
ALOGE("But another display has a focused window:");
for (auto& it : mFocusedWindowHandlesByDisplay) {
- const int32_t displayId = it.first;
const sp<InputWindowHandle>& windowHandle = it.second;
- ALOGE("Display #%" PRId32 " has focused window: '%s'\n", displayId,
+ ALOGE("Display #%" PRId32 " has focused window: '%s'\n", it.first,
windowHandle->getName().c_str());
}
}