]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: trivial cleanups
authorYehuda Sadeh <yehuda@redhat.com>
Fri, 26 Apr 2019 18:30:43 +0000 (11:30 -0700)
committerCasey Bodley <cbodley@redhat.com>
Mon, 29 Jul 2019 19:20:47 +0000 (15:20 -0400)
in rgw_user.cc

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_user.cc
src/rgw/rgw_user.h

index ba65666642db67a974c50e06367f6f1194a16573..171a5bd9440a3544f62e5efd107c7f9c12e1de18 100644 (file)
@@ -470,24 +470,14 @@ static void dump_user_info(Formatter *f, RGWUserInfo &info,
 
 RGWAccessKeyPool::RGWAccessKeyPool(RGWUser* usr)
 {
-  user = usr;
-  swift_keys = NULL;
-  access_keys = NULL;
-
-  if (!user) {
-    keys_allowed = false;
-    store = NULL;
+  if (!usr) {
     return;
   }
 
-  keys_allowed = true;
+  user = usr;
 
   store = user->get_store();
-}
-
-RGWAccessKeyPool::~RGWAccessKeyPool()
-{
-
+  user_ctl = user->get_user_ctl();
 }
 
 int RGWAccessKeyPool::init(RGWUserAdminOpState& op_state)
@@ -996,18 +986,15 @@ int RGWAccessKeyPool::remove_subuser_keys(RGWUserAdminOpState& op_state,
 
 RGWSubUserPool::RGWSubUserPool(RGWUser *usr)
 {
-  subusers_allowed = (usr != NULL);
-  if (usr)
-    store = usr->get_store();
-  else
-    store = NULL;
-  user = usr;
-  subuser_map = NULL;
-}
+  if (!usr) {
+    return;
+  }
 
-RGWSubUserPool::~RGWSubUserPool()
-{
+  user = usr;
 
+  subusers_allowed = true;
+  store = user->get_store();
+  user_ctl = user->get_user_ctl();
 }
 
 int RGWSubUserPool::init(RGWUserAdminOpState& op_state)
@@ -1299,14 +1286,11 @@ int RGWSubUserPool::modify(RGWUserAdminOpState& op_state, std::string *err_msg,
 
 RGWUserCapPool::RGWUserCapPool(RGWUser *usr)
 {
+  if (!usr) {
+    return;
+  }
   user = usr;
-  caps = NULL;
-  caps_allowed = (user != NULL);
-}
-
-RGWUserCapPool::~RGWUserCapPool()
-{
-
+  caps_allowed = true;
 }
 
 int RGWUserCapPool::init(RGWUserAdminOpState& op_state)
@@ -1414,7 +1398,7 @@ int RGWUserCapPool::remove(RGWUserAdminOpState& op_state, std::string *err_msg,
   return 0;
 }
 
-RGWUser::RGWUser() : store(NULL), info_stored(false), caps(this), keys(this), subusers(this)
+RGWUser::RGWUser() : caps(this), keys(this), subusers(this)
 {
   init_default();
 }
@@ -1433,10 +1417,6 @@ int RGWUser::init(RGWRados *storage, RGWUserAdminOpState& op_state)
   return 0;
 }
 
-RGWUser::~RGWUser()
-{
-}
-
 void RGWUser::init_default()
 {
   // use anonymous user info as a placeholder
@@ -1453,6 +1433,7 @@ int RGWUser::init_storage(RGWRados *storage)
   }
 
   store = storage;
+  user_ctl = *store->ctl.user;
 
   clear_populated();
 
index 16889fbdfbb3d099ec9762ca8c0929f979dd238b..b69a74c07f1b96dd9503c2d92b736ffca2f48c9d 100644 (file)
@@ -543,17 +543,18 @@ class RGWUser;
 
 class RGWAccessKeyPool
 {
-  RGWUser *user;
+  RGWUser *user{nullptr};
 
   std::map<std::string, int, ltstr_nocase> key_type_map;
   rgw_user user_id;
-  RGWRados *store;
+  RGWRados *store{nullptr};
+  RGWUserCtl *user_ctl{nullptr};
 
-  map<std::string, RGWAccessKey> *swift_keys;
-  map<std::string, RGWAccessKey> *access_keys;
+  map<std::string, RGWAccessKey> *swift_keys{nullptr};
+  map<std::string, RGWAccessKey> *access_keys{nullptr};
 
   // we don't want to allow keys for the anonymous user or a null user
-  bool keys_allowed;
+  bool keys_allowed{false};
 
 private:
   int create_key(RGWUserAdminOpState& op_state, std::string *err_msg = NULL);
@@ -573,7 +574,6 @@ private:
   int remove(RGWUserAdminOpState& op_state, std::string *err_msg, bool defer_save);
 public:
   explicit RGWAccessKeyPool(RGWUser* usr);
-  ~RGWAccessKeyPool();
 
   int init(RGWUserAdminOpState& op_state);
 
@@ -587,13 +587,14 @@ public:
 
 class RGWSubUserPool
 {
-  RGWUser *user;
+  RGWUser *user{nullptr};
 
   rgw_user user_id;
-  RGWRados *store;
-  bool subusers_allowed;
+  RGWRados *store{nullptr};
+  RGWUserCtl *user_ctl{nullptr};
+  bool subusers_allowed{false};
 
-  map<string, RGWSubUser> *subuser_map;
+  map<string, RGWSubUser> *subuser_map{nullptr};
 
 private:
   int check_op(RGWUserAdminOpState& op_state, std::string *err_msg = NULL);
@@ -608,7 +609,6 @@ private:
   int modify(RGWUserAdminOpState& op_state, std::string *err_msg, bool defer_save);
 public:
   explicit RGWSubUserPool(RGWUser *user);
-  ~RGWSubUserPool();
 
   bool exists(std::string subuser);
   int init(RGWUserAdminOpState& op_state);
@@ -623,9 +623,9 @@ public:
 
 class RGWUserCapPool
 {
-  RGWUserCaps *caps;
-  bool caps_allowed;
-  RGWUser *user;
+  RGWUserCaps *caps{false};
+  bool caps_allowed{false};
+  RGWUser *user{false};
 
 private:
   int add(RGWUserAdminOpState& op_state, std::string *err_msg, bool defer_save);
@@ -633,7 +633,6 @@ private:
 
 public:
   explicit RGWUserCapPool(RGWUser *user);
-  ~RGWUserCapPool();
 
   int init(RGWUserAdminOpState& op_state);
 
@@ -649,10 +648,11 @@ class RGWUser
 
 private:
   RGWUserInfo old_info;
-  RGWRados *store;
+  RGWRados *store{nullptr};
+  RGWUserCtl *user_ctl{nullptr};
 
   rgw_user user_id;
-  bool info_stored;
+  bool info_stored{false};
 
   void set_populated() { info_stored = true; }
   void clear_populated() { info_stored = false; }
@@ -672,7 +672,6 @@ private:
 
 public:
   RGWUser();
-  ~RGWUser();
 
   int init(RGWRados *storage, RGWUserAdminOpState& op_state);
 
@@ -681,6 +680,7 @@ public:
   int init_members(RGWUserAdminOpState& op_state);
 
   RGWRados *get_store() { return store; }
+  RGWUserCtl *get_user_ctl() { return user_ctl; }
 
   /* API Contracted Members */
   RGWUserCapPool caps;