]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Fix interface of RGWSI_Zone::find_zone
authorAdam C. Emerson <aemerson@redhat.com>
Thu, 30 Jun 2022 17:44:24 +0000 (13:44 -0400)
committerAdam C. Emerson <aemerson@redhat.com>
Sun, 17 Jul 2022 04:42:55 +0000 (00:42 -0400)
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 <aemerson@redhat.com>
src/rgw/rgw_admin.cc
src/rgw/rgw_data_sync.cc
src/rgw/rgw_rest_s3.cc
src/rgw/services/svc_zone.cc
src/rgw/services/svc_zone.h

index 19cf667ecf4af7a27a65b614f8bd8fdb709f6e37..eb1b8f8093966157bc7d1dd90f36f6e736e1d796 100644 (file)
@@ -2274,7 +2274,7 @@ static void get_data_sync_status(const rgw_zone_id& source_zone, list<string>& s
 
   RGWZone *sz;
 
-  if (!static_cast<rgw::sal::RadosStore*>(store)->svc()->zone->find_zone(source_zone, &sz)) {
+  if (!(sz = static_cast<rgw::sal::RadosStore*>(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<rgw::sal::RadosStore*>(store)->svc()->zone->find_zone(source_id, &sz)) {
+    if ((sz = static_cast<rgw::sal::RadosStore*>(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<rgw::sal::RadosStore*>(store)->svc()->zone->find_zone(s, &zone)) {
+  if ((zone = static_cast<rgw::sal::RadosStore*>(store)->svc()->zone->find_zone(s))) {
     return rgw_zone_id(s);
   }
   if (static_cast<rgw::sal::RadosStore*>(store)->svc()->zone->find_zone_id_by_name(s, &result)) {
@@ -3263,7 +3263,7 @@ class JSONFormatter_PrettyZone : public JSONFormatter {
       auto zone_id = *(static_cast<const rgw_zone_id *>(pval));
       string zone_name;
       RGWZone *zone;
-      if (static_cast<rgw::sal::RadosStore*>(store)->svc()->zone->find_zone(zone_id, &zone)) {
+      if ((zone = static_cast<rgw::sal::RadosStore*>(store)->svc()->zone->find_zone(zone_id))) {
         zone_name = zone->name;
       } else {
         cerr << "WARNING: cannot find zone name for id=" << zone_id << std::endl;
index ecc7a9596ae82d128d54246c61a8dc69c9c3c031..2662a9ab0751fd3e9164784dc8bfbe59fb3bd745 100644 (file)
@@ -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();
   }
 
index 4f90abb914a4d7ddea3466f4d00afd0bf0dcd975..b2a40fd2bd5cbc0039f59b4f27767e3b3fce0f8f 100644 (file)
@@ -1074,7 +1074,7 @@ struct ReplicationConfiguration {
 
       for (auto& id : zone_ids) {
        RGWZone *zone;
-       if (static_cast<rgw::sal::RadosStore*>(store)->svc()->zone->find_zone(id, &zone)) {
+       if ((zone = static_cast<rgw::sal::RadosStore*>(store)->svc()->zone->find_zone(id))) {
          names.emplace_back(zone->name);
        }
       }
index f314ea79c0c40e6ec438bd1ebeb04d016255b57d..0f8ddcf5f539fdbad1f1aca6d9a9c7aca5c3a806 100644 (file)
@@ -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) {
index 175fbc2c4a0e415b5656a7fc11629acfbab572b7..3e7e91e4d3ade64caefa73ce4496b22f71f68dc9 100644 (file)
@@ -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);