]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd: improve formatting and refactor ClassHandler.h a bit.
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Thu, 25 Jul 2019 09:28:26 +0000 (11:28 +0200)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Fri, 23 Aug 2019 23:18:34 +0000 (01:18 +0200)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/osd/ClassHandler.h

index c80c4c0c47bc67fb6bbce0ca91dc19c687b5120b..c70e9fbd25da99ed6dfe4ba24ec27f7acb7aa97f 100644 (file)
@@ -43,12 +43,9 @@ public:
   struct ClassFilter {
     ClassData *cls = nullptr;
     std::string name;
-    cls_cxx_filter_factory_t fn;
+    cls_cxx_filter_factory_t fn = nullptr;
 
     void unregister();
-
-    ClassFilter() : fn(0)
-    {}
   };
 
   struct ClassData {
@@ -58,11 +55,11 @@ public:
       CLASS_MISSING_DEPS,    // missing dependencies
       CLASS_INITIALIZING,    // calling init() right now
       CLASS_OPEN,            // initialized, usable
-    } status;
+    } status = CLASS_UNKNOWN;
 
     std::string name;
-    ClassHandler *handler;
-    void *handle;
+    ClassHandler *handler = nullptr;
+    void *handle = nullptr;
 
     bool whitelisted = false;
 
@@ -74,18 +71,16 @@ public:
 
     ClassMethod *_get_method(const char *mname);
 
-    ClassData() : status(CLASS_UNKNOWN), 
-                 handler(NULL),
-                 handle(NULL) {}
-    ~ClassData() { }
-
-    ClassMethod *register_method(const char *mname, int flags, cls_method_call_t func);
-    ClassMethod *register_cxx_method(const char *mname, int flags, cls_method_cxx_call_t func);
+    ClassMethod *register_method(const char *mname,
+                                 int flags,
+                                 cls_method_call_t func);
+    ClassMethod *register_cxx_method(const char *mname,
+                                     int flags,
+                                     cls_method_cxx_call_t func);
     void unregister_method(ClassMethod *method);
 
-    ClassFilter *register_cxx_filter(
-        const std::string &filter_name,
-        cls_cxx_filter_factory_t fn);
+    ClassFilter *register_cxx_filter(const std::string &filter_name,
+                                     cls_cxx_filter_factory_t fn);
     void unregister_filter(ClassFilter *method);
 
     ClassMethod *get_method(const char *mname) {
@@ -94,12 +89,10 @@ public:
     }
     int get_method_flags(const char *mname);
 
-    ClassFilter *get_filter(const std::string &filter_name)
-    {
+    ClassFilter *get_filter(const std::string &filter_name) {
       std::lock_guard l(handler->mutex);
-      std::map<std::string, ClassFilter>::iterator i = filters_map.find(filter_name);
-      if (i == filters_map.end()) {
-        return NULL;
+      if (auto i = filters_map.find(filter_name); i == filters_map.end()) {
+        return nullptr;
       } else {
         return &(i->second);
       }
@@ -118,7 +111,7 @@ private:
   ceph::mutex mutex = ceph::make_mutex("ClassHandler");
 
 public:
-  explicit ClassHandler(CephContext *cct_) : cct(cct_) {}
+  explicit ClassHandler(CephContext *cct) : cct(cct) {}
 
   int open_all_classes();
   int open_class(const std::string& cname, ClassData **pcls);