From 954c384d0fe9cb5ef0c73c55083cf97684278f97 Mon Sep 17 00:00:00 2001 From: Damian Pietruchowski Date: Wed, 5 Jul 2017 18:10:24 +0200 Subject: [PATCH] Unnecessary uses of strcmp() in StepParsePreload Change-Id: Ia2d6b3ff6d4fe6a3b14f9f1136b9914d6c1b6bb6 Signed-off-by: Damian Pietruchowski --- src/common/step/configuration/step_parse_preload.cc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/common/step/configuration/step_parse_preload.cc b/src/common/step/configuration/step_parse_preload.cc index 7500b37..c81ba20 100644 --- a/src/common/step/configuration/step_parse_preload.cc +++ b/src/common/step/configuration/step_parse_preload.cc @@ -75,20 +75,24 @@ ci::Step::Status StepParsePreload::process() { context_->manifest_data.get()->removable = strdup("true"); } - if ((strcmp(context_->manifest_data.get()->readonly, "true") == 0) && - (strcmp(context_->manifest_data.get()->preload, "true") != 0)) { + bool is_readonly = + (strcmp(context_->manifest_data.get()->readonly, "true") == 0); + bool is_preload = + (strcmp(context_->manifest_data.get()->preload, "true") == 0); + bool is_removable = + (strcmp(context_->manifest_data.get()->removable, "true") == 0); + + if (is_readonly && !is_preload) { LOG(ERROR) << "invalid preload attribute, readonly but not preload!"; return Status::MANIFEST_ERROR; } - if ((strcmp(context_->manifest_data.get()->readonly, "true") == 0) && - (strcmp(context_->manifest_data.get()->removable, "false") != 0)) { + if (is_readonly && is_removable) { LOG(ERROR) << "invalid preload attribute, readonly but removable!"; return Status::MANIFEST_ERROR; } - if ((strcmp(context_->manifest_data.get()->preload, "false") == 0) && - (strcmp(context_->manifest_data.get()->removable, "false") == 0)) { + if (!is_preload && !is_removable) { LOG(ERROR) << "invalid preload attribute, no preload but not removable!"; return Status::MANIFEST_ERROR; } -- 2.7.4