Simplify range check for audio_mode_t
AudioSystem::setMode previously allowed negative modes, but these were
then rejected by AudioFlinger.
Now negative modes (including AUDIO_MODE_INVALID and AUDIO_MODE_CURRENT)
are explicitly disallowed.
Change-Id: I0bac8fea737c8eb1f5b6afbb893e48739f88d745
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 4ddefdb..3b5b1b1 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -574,7 +574,7 @@
if (!settingsAllowed()) {
return PERMISSION_DENIED;
}
- if ((mode < 0) || (mode >= AUDIO_MODE_CNT)) {
+ if (uint32_t(mode) >= AUDIO_MODE_CNT) {
ALOGW("Illegal value: setMode(%d)", mode);
return BAD_VALUE;
}
diff --git a/services/audioflinger/AudioPolicyService.cpp b/services/audioflinger/AudioPolicyService.cpp
index f572fce..3f86d58 100644
--- a/services/audioflinger/AudioPolicyService.cpp
+++ b/services/audioflinger/AudioPolicyService.cpp
@@ -193,7 +193,7 @@
if (!checkPermission()) {
return PERMISSION_DENIED;
}
- if (state < 0 || state >= AUDIO_MODE_CNT) {
+ if (uint32_t(state) >= AUDIO_MODE_CNT) {
return BAD_VALUE;
}