From 6a5db033ad9cd82142f90f13897ff087c7e1c116 Mon Sep 17 00:00:00 2001 From: "Adam C. Emerson" Date: Thu, 30 Jun 2022 13:44:24 -0400 Subject: [PATCH] rgw: Fix interface of RGWSI_Zone::find_zone Since nullable pointers are nullable, it makes no sense to return a bool and take a nullable pointer out parameter. Just return the pointer. Signed-off-by: Adam C. Emerson --- src/rgw/rgw_admin.cc | 8 ++++---- src/rgw/rgw_data_sync.cc | 4 ++-- src/rgw/rgw_rest_s3.cc | 2 +- src/rgw/services/svc_zone.cc | 7 +++---- src/rgw/services/svc_zone.h | 2 +- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 19cf667ecf4af..eb1b8f8093966 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -2274,7 +2274,7 @@ static void get_data_sync_status(const rgw_zone_id& source_zone, list& s RGWZone *sz; - if (!static_cast(store)->svc()->zone->find_zone(source_zone, &sz)) { + if (!(sz = static_cast(store)->svc()->zone->find_zone(source_zone))) { push_ss(ss, status, tab) << string("zone not found"); flush_ss(ss, status); return; @@ -2489,7 +2489,7 @@ static void sync_status(Formatter *formatter) string source_str = "source: "; string s = source_str + source_id.id; RGWZone *sz; - if (static_cast(store)->svc()->zone->find_zone(source_id, &sz)) { + if ((sz = static_cast(store)->svc()->zone->find_zone(source_id))) { s += string(" (") + sz->name + ")"; } data_status.push_back(s); @@ -2673,7 +2673,7 @@ static rgw_zone_id resolve_zone_id(const string& s) rgw_zone_id result; RGWZone *zone; - if (static_cast(store)->svc()->zone->find_zone(s, &zone)) { + if ((zone = static_cast(store)->svc()->zone->find_zone(s))) { return rgw_zone_id(s); } if (static_cast(store)->svc()->zone->find_zone_id_by_name(s, &result)) { @@ -3263,7 +3263,7 @@ class JSONFormatter_PrettyZone : public JSONFormatter { auto zone_id = *(static_cast(pval)); string zone_name; RGWZone *zone; - if (static_cast(store)->svc()->zone->find_zone(zone_id, &zone)) { + if ((zone = static_cast(store)->svc()->zone->find_zone(zone_id))) { zone_name = zone->name; } else { cerr << "WARNING: cannot find zone name for id=" << zone_id << std::endl; diff --git a/src/rgw/rgw_data_sync.cc b/src/rgw/rgw_data_sync.cc index ecc7a9596ae82..2662a9ab0751f 100644 --- a/src/rgw/rgw_data_sync.cc +++ b/src/rgw/rgw_data_sync.cc @@ -2636,7 +2636,7 @@ int RGWDataSyncStatusManager::init(const DoutPrefixProvider *dpp) { RGWZone *zone_def; - if (!store->svc()->zone->find_zone(source_zone, &zone_def)) { + if (!(zone_def = store->svc()->zone->find_zone(source_zone))) { ldpp_dout(this, 0) << "ERROR: failed to find zone config info for zone=" << source_zone << dendl; return -EIO; } @@ -2647,7 +2647,7 @@ int RGWDataSyncStatusManager::init(const DoutPrefixProvider *dpp) const RGWZoneParams& zone_params = store->svc()->zone->get_zone_params(); - if (sync_module == nullptr) { + if (sync_module == nullptr) { sync_module = store->get_sync_module(); } diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 4f90abb914a4d..b2a40fd2bd5cb 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -1074,7 +1074,7 @@ struct ReplicationConfiguration { for (auto& id : zone_ids) { RGWZone *zone; - if (static_cast(store)->svc()->zone->find_zone(id, &zone)) { + if ((zone = static_cast(store)->svc()->zone->find_zone(id))) { names.emplace_back(zone->name); } } diff --git a/src/rgw/services/svc_zone.cc b/src/rgw/services/svc_zone.cc index f314ea79c0c40..0f8ddcf5f539f 100644 --- a/src/rgw/services/svc_zone.cc +++ b/src/rgw/services/svc_zone.cc @@ -1010,14 +1010,13 @@ const string& RGWSI_Zone::zone_name() const return get_zone_params().get_name(); } -bool RGWSI_Zone::find_zone(const rgw_zone_id& id, RGWZone **zone) +RGWZone* RGWSI_Zone::find_zone(const rgw_zone_id& id) { auto iter = zone_by_id.find(id); if (iter == zone_by_id.end()) { - return false; + return nullptr; } - *zone = &(iter->second); - return true; + return &(iter->second); } RGWRESTConn *RGWSI_Zone::get_zone_conn(const rgw_zone_id& zone_id) { diff --git a/src/rgw/services/svc_zone.h b/src/rgw/services/svc_zone.h index 175fbc2c4a0e4..3e7e91e4d3ade 100644 --- a/src/rgw/services/svc_zone.h +++ b/src/rgw/services/svc_zone.h @@ -129,7 +129,7 @@ public: return zone_data_notify_to_map; } - bool find_zone(const rgw_zone_id& id, RGWZone **zone); + RGWZone* find_zone(const rgw_zone_id& id); RGWRESTConn *get_zone_conn(const rgw_zone_id& zone_id); RGWRESTConn *get_zone_conn_by_name(const std::string& name); -- 2.39.5