Convert system/core to Result::ok()
No functionality changes, this is a mechanical cleanup.
Test: m
Test: cd system/core && atest
Change-Id: Ifdaa3ce1947ed578f656d5a446978726eb416c36
diff --git a/init/init.cpp b/init/init.cpp
index 10701da..5bf1b36 100644
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -237,7 +237,7 @@
auto restart_time = s->time_started() + s->restart_period();
if (boot_clock::now() > restart_time) {
- if (auto result = s->Start(); !result) {
+ if (auto result = s->Start(); !result.ok()) {
LOG(ERROR) << "Could not restart process '" << s->name() << "': " << result.error();
}
} else {
@@ -333,7 +333,7 @@
return false;
}
- if (auto result = function.action(svc); !result) {
+ if (auto result = function.action(svc); !result.ok()) {
LOG(ERROR) << "Control message: Could not ctl." << msg << " for '" << name
<< "' from pid: " << pid << " (" << process_cmdline << "): " << result.error();
return false;
@@ -478,7 +478,7 @@
PLOG(FATAL) << "failed to create signalfd";
}
- if (auto result = epoll->RegisterHandler(signal_fd, HandleSignalFd); !result) {
+ if (auto result = epoll->RegisterHandler(signal_fd, HandleSignalFd); !result.ok()) {
LOG(FATAL) << result.error();
}
}
@@ -499,7 +499,7 @@
found = true;
LOG(INFO) << "Starting service '" << svc->name() << "' from keychord "
<< android::base::Join(keycodes, ' ');
- if (auto result = svc->Start(); !result) {
+ if (auto result = svc->Start(); !result.ok()) {
LOG(ERROR) << "Could not start service '" << svc->name() << "' from keychord "
<< android::base::Join(keycodes, ' ') << ": " << result.error();
}
@@ -558,7 +558,7 @@
void SendLoadPersistentPropertiesMessage() {
auto init_message = InitMessage{};
init_message.set_load_persistent_properties(true);
- if (auto result = SendMessage(property_fd, init_message); !result) {
+ if (auto result = SendMessage(property_fd, init_message); !result.ok()) {
LOG(ERROR) << "Failed to send load persistent properties message: " << result.error();
}
}
@@ -566,7 +566,7 @@
void SendStopSendingMessagesMessage() {
auto init_message = InitMessage{};
init_message.set_stop_sending_messages(true);
- if (auto result = SendMessage(property_fd, init_message); !result) {
+ if (auto result = SendMessage(property_fd, init_message); !result.ok()) {
LOG(ERROR) << "Failed to send 'stop sending messages' message: " << result.error();
}
}
@@ -574,14 +574,14 @@
void SendStartSendingMessagesMessage() {
auto init_message = InitMessage{};
init_message.set_start_sending_messages(true);
- if (auto result = SendMessage(property_fd, init_message); !result) {
+ if (auto result = SendMessage(property_fd, init_message); !result.ok()) {
LOG(ERROR) << "Failed to send 'start sending messages' message: " << result.error();
}
}
static void HandlePropertyFd() {
auto message = ReadMessage(property_fd);
- if (!message) {
+ if (!message.ok()) {
LOG(ERROR) << "Could not read message from property service: " << message.error();
return;
}
@@ -636,7 +636,7 @@
// Set init and its forked children's oom_adj.
if (auto result =
WriteFile("/proc/1/oom_score_adj", StringPrintf("%d", DEFAULT_OOM_SCORE_ADJUST));
- !result) {
+ !result.ok()) {
LOG(ERROR) << "Unable to write " << DEFAULT_OOM_SCORE_ADJUST
<< " to /proc/1/oom_score_adj: " << result.error();
}
@@ -679,14 +679,14 @@
SelinuxRestoreContext();
Epoll epoll;
- if (auto result = epoll.Open(); !result) {
+ if (auto result = epoll.Open(); !result.ok()) {
PLOG(FATAL) << result.error();
}
InstallSignalFdHandler(&epoll);
StartPropertyService(&property_fd);
- if (auto result = epoll.RegisterHandler(property_fd, HandlePropertyFd); !result) {
+ if (auto result = epoll.RegisterHandler(property_fd, HandlePropertyFd); !result.ok()) {
LOG(FATAL) << "Could not register epoll handler for property fd: " << result.error();
}
@@ -797,7 +797,7 @@
}
auto pending_functions = epoll.Wait(epoll_timeout);
- if (!pending_functions) {
+ if (!pending_functions.ok()) {
LOG(ERROR) << pending_functions.error();
} else if (!pending_functions->empty()) {
// We always reap children before responding to the other pending functions. This is to