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/filesystem_copier_action.cc b/filesystem_copier_action.cc
index d557eba..4bfde99 100644
--- a/filesystem_copier_action.cc
+++ b/filesystem_copier_action.cc
@@ -79,7 +79,7 @@
LOG(INFO) << "filesystem copying skipped on resumed update.";
if (HasOutputPipe())
SetOutputObject(install_plan_);
- abort_action_completer.set_code(kErrorCodeSuccess);
+ abort_action_completer.set_code(ErrorCode::kSuccess);
return;
}
@@ -96,7 +96,7 @@
LOG(INFO) << "filesystem copying skipped on full update.";
if (HasOutputPipe())
SetOutputObject(install_plan_);
- abort_action_completer.set_code(kErrorCodeSuccess);
+ abort_action_completer.set_code(ErrorCode::kSuccess);
return;
}
@@ -169,7 +169,7 @@
}
if (cancelled_)
return;
- if (code == kErrorCodeSuccess && HasOutputPipe())
+ if (code == ErrorCode::kSuccess && HasOutputPipe())
SetOutputObject(install_plan_);
processor_->ActionComplete(this, code);
}
@@ -268,7 +268,7 @@
}
if (failed_ || cancelled_) {
if (!reading && !writing) {
- Cleanup(kErrorCodeError);
+ Cleanup(ErrorCode::kError);
}
return;
}
@@ -302,18 +302,18 @@
}
if (!reading && !writing) {
// We're done!
- ErrorCode code = kErrorCodeSuccess;
+ ErrorCode code = ErrorCode::kSuccess;
if (hasher_.Finalize()) {
LOG(INFO) << "Hash: " << hasher_.hash();
if (verify_hash_) {
if (copying_kernel_install_path_) {
if (install_plan_.kernel_hash != hasher_.raw_hash()) {
- code = kErrorCodeNewKernelVerificationError;
+ code = ErrorCode::kNewKernelVerificationError;
LOG(ERROR) << "New kernel verification failed.";
}
} else {
if (install_plan_.rootfs_hash != hasher_.raw_hash()) {
- code = kErrorCodeNewRootfsVerificationError;
+ code = ErrorCode::kNewRootfsVerificationError;
LOG(ERROR) << "New rootfs verification failed.";
}
}
@@ -326,7 +326,7 @@
}
} else {
LOG(ERROR) << "Unable to finalize the hash.";
- code = kErrorCodeError;
+ code = ErrorCode::kError;
}
Cleanup(code);
}