privetd: Remove empty device name checks Server allows to have empty name. Buffet and privet also has no requirement to have it not empty. BUG=brillo:989 CQ-DEPEND=CL:274924 TEST=`FEATURES=test emerge-gizmo privetd buffet` Change-Id: I02e141149d6eaf36a6c92676e68ab02b8287c724 Reviewed-on: https://chromium-review.googlesource.com/274883 Reviewed-by: Vitaly Buka <vitalybuka@chromium.org> Tested-by: Vitaly Buka <vitalybuka@chromium.org> Commit-Queue: Vitaly Buka <vitalybuka@chromium.org>
diff --git a/buffet/buffet_config.cc b/buffet/buffet_config.cc index bf8891e..dc3ae97 100644 --- a/buffet/buffet_config.cc +++ b/buffet/buffet_config.cc
@@ -128,6 +128,8 @@ if (store.GetString(config_keys::kBackupPollingPeriodMs, &polling_period_str)) CHECK(base::StringToUint64(polling_period_str, &backup_polling_period_ms_)); + // Empty name set by user or server is allowed, still we expect some + // meaningfull config value. store.GetString(config_keys::kName, &name_); CHECK(!name_.empty()); @@ -228,15 +230,6 @@ Commit(); } -bool BuffetConfig::Transaction::set_name(const std::string& name) { - if (name.empty()) { - LOG(ERROR) << "Invalid name: " << name; - return false; - } - config_->name_ = name; - return true; -} - bool BuffetConfig::Transaction::set_local_anonymous_access_role( const std::string& role) { if (!IsValidAccessRole(role)) {
diff --git a/buffet/buffet_config.h b/buffet/buffet_config.h index d755f08..43202a6 100644 --- a/buffet/buffet_config.h +++ b/buffet/buffet_config.h
@@ -56,7 +56,7 @@ void set_service_url(const std::string& url) { config_->service_url_ = url; } - bool set_name(const std::string& name); + void set_name(const std::string& name) { config_->name_ = name; } void set_description(const std::string& description) { config_->description_ = description; }
diff --git a/buffet/device_registration_info.cc b/buffet/device_registration_info.cc index 3dd5864..bd02b23 100644 --- a/buffet/device_registration_info.cc +++ b/buffet/device_registration_info.cc
@@ -669,11 +669,7 @@ const std::string& location, chromeos::ErrorPtr* error) { BuffetConfig::Transaction change{config_.get()}; - if (!change.set_name(name)) { - chromeos::Error::AddTo(error, FROM_HERE, kErrorDomainBuffet, - "invalid_parameter", "Empty device name"); - return false; - } + change.set_name(name); change.set_description(description); change.set_location(location); change.Commit();