Change ErrorCode into an enum class.
This change is needed in order for us to be able to import ErrorCode
symbols from chromeos_update_engine into chromeos_update_manager.
Unfortunately, shifting from plain 'enum' into an 'enum class' means
that the compiler treats the new class as a distinct type from int,
which in turn means that plenty of seamless arithmetic/bitwise
operations we used for manipulating error code values throughout the
code needed to be retrofitted with static_cast operators.
In the future, we should consider imposing a proper abstraction on
update engine error codes that'll prevent mingling with value encoding
directly and prevent such nastiness. It'll also make things more
coherent (types, semantics) and safer.
BUG=chromium:358329
TEST=Unit tests.
Change-Id: Ie55fa566b764cdab6c4785d995fb6daee4cb32d3
Reviewed-on: https://chromium-review.googlesource.com/203209
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
diff --git a/postinstall_runner_action.cc b/postinstall_runner_action.cc
index 1b3af2f..cc8968b 100644
--- a/postinstall_runner_action.cc
+++ b/postinstall_runner_action.cc
@@ -67,7 +67,7 @@
if (utils::CreatePowerwashMarkerFile(powerwash_marker_file_)) {
powerwash_marker_created_ = true;
} else {
- completer.set_code(kErrorCodePostinstallPowerwashError);
+ completer.set_code(ErrorCode::kPostinstallPowerwashError);
return;
}
}
@@ -111,14 +111,14 @@
// This special return code means that we tried to update firmware,
// but couldn't because we booted from FW B, and we need to reboot
// to get back to FW A.
- completer.set_code(kErrorCodePostinstallBootedFromFirmwareB);
+ completer.set_code(ErrorCode::kPostinstallBootedFromFirmwareB);
}
if (return_code == 4) {
// This special return code means that we tried to update firmware,
// but couldn't because we booted from FW B, and we need to reboot
// to get back to FW A.
- completer.set_code(kErrorCodePostinstallFirmwareRONotUpdatable);
+ completer.set_code(ErrorCode::kPostinstallFirmwareRONotUpdatable);
}
return;
@@ -129,7 +129,7 @@
SetOutputObject(install_plan_);
}
- completer.set_code(kErrorCodeSuccess);
+ completer.set_code(ErrorCode::kSuccess);
}
void PostinstallRunnerAction::StaticCompletePostinstall(int return_code,