shill: KeyFileStore: assume |path_| is non-empty
|path_| is non-empty by construction. So remove code
in other methods, which tests whether or not path_
is empty.
While we're at it, mark |path_| as a const member.
BUG=None
TEST="USE='asan clang' FEATURES=test emerge-samus shill"
Change-Id: I57717404ca831f379751316ea6af45196c44e21b
Reviewed-on: https://chromium-review.googlesource.com/295929
Commit-Ready: mukesh agrawal <quiche@chromium.org>
Tested-by: mukesh agrawal <quiche@chromium.org>
Reviewed-by: mukesh agrawal <quiche@chromium.org>
diff --git a/key_file_store.cc b/key_file_store.cc
index afdc91d..64eb311 100644
--- a/key_file_store.cc
+++ b/key_file_store.cc
@@ -81,7 +81,6 @@
}
bool KeyFileStore::Open() {
- CHECK(!path_.empty());
CHECK(!key_file_);
crypto_.Init();
key_file_ = g_key_file_new();
@@ -117,11 +116,7 @@
gchar* data = g_key_file_to_data(key_file_, &length, &error);
bool success = true;
- if (path_.empty()) {
- LOG(ERROR) << "Empty key file path.";
- success = false;
- }
- if (success && (!data || error)) {
+ if (!data || error) {
LOG(ERROR) << "Failed to convert key file to string: "
<< ConvertErrorToMessage(error);
success = false;
@@ -139,10 +134,6 @@
bool KeyFileStore::MarkAsCorrupted() {
LOG(INFO) << "In " << __func__ << " for " << path_.value();
- if (path_.empty()) {
- LOG(ERROR) << "Empty key file path.";
- return false;
- }
string corrupted_path = path_.value() + kCorruptSuffix;
int ret = rename(path_.value().c_str(), corrupted_path.c_str());
if (ret != 0) {