summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2019-04-02 09:19:46 -0700
committerElliott Hughes <enh@google.com>2019-04-02 09:19:46 -0700
commit66e5ae0f5ab9148e92ccf28c0dc1e1094871d8d9 (patch)
treefe2e03de2e508d9fad8163037635a33b7cb5f527
parent43f29072a974a4e57a519a098b6e81a1027eb77c (diff)
downloadsystem_core-66e5ae0f5ab9148e92ccf28c0dc1e1094871d8d9.tar.gz
system_core-66e5ae0f5ab9148e92ccf28c0dc1e1094871d8d9.tar.bz2
system_core-66e5ae0f5ab9148e92ccf28c0dc1e1094871d8d9.zip
libcutils: android_reboot command should be unsigned.
Hex literals have the type of the first type they fit in. The reboot constants are large enough that that's `unsigned` rather than `int`. Bug: http://b/76110968 Test: treehugger Change-Id: Iac4fe61d1fe572297febf0b57e34d698942469f9
-rw-r--r--libcutils/android_reboot.cpp4
-rw-r--r--libcutils/include/cutils/android_reboot.h9
2 files changed, 5 insertions, 8 deletions
diff --git a/libcutils/android_reboot.cpp b/libcutils/android_reboot.cpp
index ce41cd320..e0def711d 100644
--- a/libcutils/android_reboot.cpp
+++ b/libcutils/android_reboot.cpp
@@ -23,12 +23,12 @@
#define TAG "android_reboot"
-int android_reboot(int cmd, int /*flags*/, const char* arg) {
+int android_reboot(unsigned cmd, int /*flags*/, const char* arg) {
int ret;
const char* restart_cmd = NULL;
char* prop_value;
- switch (static_cast<unsigned>(cmd)) {
+ switch (cmd) {
case ANDROID_RB_RESTART: // deprecated
case ANDROID_RB_RESTART2:
restart_cmd = "reboot";
diff --git a/libcutils/include/cutils/android_reboot.h b/libcutils/include/cutils/android_reboot.h
index 99030eddd..cd27eef88 100644
--- a/libcutils/include/cutils/android_reboot.h
+++ b/libcutils/include/cutils/android_reboot.h
@@ -14,8 +14,7 @@
* limitations under the License.
*/
-#ifndef __CUTILS_ANDROID_REBOOT_H__
-#define __CUTILS_ANDROID_REBOOT_H__
+#pragma once
#include <sys/cdefs.h>
@@ -36,10 +35,8 @@ __BEGIN_DECLS
/* Reboot or shutdown the system.
* This call uses ANDROID_RB_PROPERTY to request reboot to init process.
* Due to that, process calling this should have proper selinux permission
- * to write to the property. Otherwise, the call will fail.
+ * to write to the property or the call will fail.
*/
-int android_reboot(int cmd, int flags, const char *arg);
+int android_reboot(unsigned cmd, int flags, const char* arg);
__END_DECLS
-
-#endif /* __CUTILS_ANDROID_REBOOT_H__ */