Fix some ordered comparisons with zero for pointers.
Bug: http://b/31532493
The latest clang will trigger an error diagnostic "ordered comparison
between pointer and zero ..." when you do something like "p > 0". This
change replaces the ordered comparisons with proper checks instead.
Test: Validated with latest toolchain.
Change-Id: I4a127fe2551688c8176bdd31210cf7f2f40baeba
diff --git a/memtrack/1.0/default/Memtrack.cpp b/memtrack/1.0/default/Memtrack.cpp
index 5c1a5c4..fa09c25 100644
--- a/memtrack/1.0/default/Memtrack.cpp
+++ b/memtrack/1.0/default/Memtrack.cpp
@@ -79,7 +79,7 @@
memtrack_module_t *memtrack_module = NULL;
ret = hw_get_module(name, &hw_module);
- if (ret == 0 && hw_module->methods->open > 0)
+ if (ret == 0 && hw_module->methods->open)
{
ret = hw_module->methods->open(hw_module, name,
reinterpret_cast<hw_device_t**>(&memtrack_module));
diff --git a/power/1.0/default/Power.cpp b/power/1.0/default/Power.cpp
index 656a2ae..6233a14 100644
--- a/power/1.0/default/Power.cpp
+++ b/power/1.0/default/Power.cpp
@@ -40,14 +40,14 @@
// Methods from ::android::hardware::power::V1_0::IPower follow.
Return<void> Power::setInteractive(bool interactive) {
- if (mModule->setInteractive > 0)
+ if (mModule->setInteractive)
mModule->setInteractive(mModule, interactive ? 1 : 0);
return Void();
}
Return<void> Power::powerHint(PowerHint hint, int32_t data) {
int32_t param = data;
- if (mModule->powerHint > 0) {
+ if (mModule->powerHint) {
if (data)
mModule->powerHint(mModule, static_cast<power_hint_t>(hint), ¶m);
else
@@ -57,7 +57,7 @@
}
Return<void> Power::setFeature(Feature feature, bool activate) {
- if (mModule->setFeature > 0)
+ if (mModule->setFeature)
mModule->setFeature(mModule, static_cast<feature_t>(feature),
activate ? 1 : 0);
return Void();
@@ -79,7 +79,7 @@
}
number_platform_modes = mModule->get_number_of_platform_modes(mModule);
- if (number_platform_modes > 0)
+ if (number_platform_modes)
{
if (SIZE_MAX / sizeof(size_t) <= number_platform_modes) // overflow
goto done;
@@ -149,7 +149,7 @@
const hw_module_t* hw_module = NULL;
power_module_t *power_module;
ret = hw_get_module(name, &hw_module);
- if (ret == 0 && hw_module->methods->open > 0) {
+ if (ret == 0 && hw_module->methods->open) {
ret = hw_module->methods->open(hw_module, name,
reinterpret_cast<hw_device_t**>(&power_module));
if (ret == 0) {