fix a sign-compare warning and use -Wall

Test: mma
Bug: 34901468
Change-Id: If68c1540a88ea28987fb7359a0ee01cf45263579
This commit is contained in:
Keun Soo Yim
2017-02-10 19:36:53 -08:00
parent e4c0bd5c45
commit 7e71a0cfcb
2 changed files with 12 additions and 2 deletions

View File

@@ -17,6 +17,11 @@ cc_library_shared {
relative_install_path: "hw",
srcs: ["Power.cpp"],
cflags: [
"-Wall",
"-Werror",
],
shared_libs: [
"liblog",
"libhardware",
@@ -35,6 +40,11 @@ cc_binary {
init_rc: ["android.hardware.power@1.0-service.rc"],
srcs: ["service.cpp"],
cflags: [
"-Wall",
"-Werror",
],
shared_libs: [
"liblog",
"libdl",

View File

@@ -81,7 +81,7 @@ Return<void> Power::getPlatformLowPowerStats(getPlatformLowPowerStats_cb _hidl_c
number_platform_modes = mModule->get_number_of_platform_modes(mModule);
if (number_platform_modes)
{
if (SIZE_MAX / sizeof(size_t) <= number_platform_modes) // overflow
if ((ssize_t) (SIZE_MAX / sizeof(size_t)) <= number_platform_modes) // overflow
goto done;
voters = new (std::nothrow) size_t [number_platform_modes];
if (voters == nullptr)
@@ -91,7 +91,7 @@ Return<void> Power::getPlatformLowPowerStats(getPlatformLowPowerStats_cb _hidl_c
if (ret != 0)
goto done;
if (SIZE_MAX / sizeof(power_state_platform_sleep_state_t)
if ((ssize_t) (SIZE_MAX / sizeof(power_state_platform_sleep_state_t))
<= number_platform_modes) // overflow
goto done;
legacy_states = new (std::nothrow)