]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: pre-declare RBDClient to avoid a bunch of casts
authorJosh Durgin <josh.durgin@dreamhost.com>
Wed, 26 Jan 2011 22:46:04 +0000 (14:46 -0800)
committerYehuda Sadeh <yehuda.sadeh@dreamhost.com>
Mon, 7 Feb 2011 22:41:57 +0000 (14:41 -0800)
src/include/librbd.hpp
src/librbd.cc

index 859795342d6137b2ed8965f1afa713018d9453c9..20b7a5422126d2b703782b5f9729b968da5d6f72 100644 (file)
@@ -24,9 +24,8 @@
 #include "librados.hpp"
 #include "librbd.h"
 
-class RBD;
-
 namespace librbd {
+  class RBDClient;
   typedef void *pool_t;
 #if 0 // for IO
   typedef void *completion_t;
@@ -48,7 +47,7 @@ namespace librbd {
 
 class RBD
 {
-  void *client;
+  RBDClient *client;
 
 public:
   RBD() {}
index 4691c2c9232408bda662aad54f4d7f8c4ca77e56..74f5fadeda53a0445156267856ab3ab37bcd8eb7 100644 (file)
@@ -832,12 +832,12 @@ int librbd::RBDClient::open_pools(const char *pool_name, PoolCtx *ctx)
 int librbd::RBD::initialize(int argc, const char *argv[])
 {
   client = new RBDClient();
-  return ((librbd::RBDClient *)client)->initialize(argc, argv);
+  return client->initialize(argc, argv);
 }
 
 void librbd::RBD::shutdown()
 {
-  ((librbd::RBDClient *)client)->shutdown();
+  client->shutdown();
   delete (librbd::RBDClient *)client;
 }
 
@@ -847,7 +847,7 @@ int librbd::RBD::open_pool(const char *pool_name, pool_t *pool)
   if (!ctx)
     return -ENOMEM;
 
-  int ret = ((librbd::RBDClient *)client)->open_pools(pool_name, ctx);
+  int ret = client->open_pools(pool_name, ctx);
   if (ret < 0)
     return ret;
 
@@ -860,7 +860,7 @@ int librbd::RBD::close_pool(pool_t pool)
 {
   PoolCtx *ctx = (PoolCtx *)pool;
 
-  ((librbd::RBDClient *)client)->close_pools(ctx);
+  client->close_pools(ctx);
   delete ctx;
   
   return 0; 
@@ -871,7 +871,7 @@ int librbd::RBD::create(pool_t pool, const char *name, size_t size)
   string md_oid = name;
   md_oid += RBD_SUFFIX;
   int order = 0;
-  int r = ((librbd::RBDClient *)client)->do_create(ctx->md, md_oid, name, size, &order);
+  int r = client->do_create(ctx->md, md_oid, name, size, &order);
   return r;
 }
 
@@ -880,7 +880,7 @@ int librbd::RBD::remove(pool_t pool, const char *name)
   PoolCtx *ctx = (PoolCtx *)pool;
   string md_oid = name;
   md_oid += RBD_SUFFIX;
-  int r = ((librbd::RBDClient *)client)->do_delete(ctx, md_oid, name);
+  int r = client->do_delete(ctx, md_oid, name);
   return r;
 }
 
@@ -889,7 +889,7 @@ int librbd::RBD::resize(pool_t pool, const char *name, size_t size)
   PoolCtx *ctx = (PoolCtx *)pool;
   string md_oid = name;
   md_oid += RBD_SUFFIX;
-  int r = ((librbd::RBDClient *)client)->do_resize(ctx, md_oid, name, size);
+  int r = client->do_resize(ctx, md_oid, name, size);
   return r;
 }
 
@@ -898,35 +898,35 @@ int librbd::RBD::stat(pool_t pool, const char *name, image_info_t& info)
   PoolCtx *ctx = (PoolCtx *)pool;
   string md_oid = name;
   md_oid += RBD_SUFFIX;
-  int r = ((librbd::RBDClient *)client)->do_info(ctx, md_oid, info);
+  int r = client->do_info(ctx, md_oid, info);
   return r;
 }
 
 int librbd::RBD::list(pool_t pool, std::vector<string>& names)
 {
   PoolCtx *ctx = (PoolCtx *)pool;
-  int r = ((librbd::RBDClient *)client)->do_list(ctx, names);
+  int r = client->do_list(ctx, names);
   return r;
 }
 
 int librbd::RBD::create_snap(pool_t pool, const char *image_name, const char *snap_name)
 {
   PoolCtx *ctx = (PoolCtx *)pool;
-  int r = ((librbd::RBDClient *)client)->do_create_snap(ctx, image_name, snap_name);
+  int r = client->do_create_snap(ctx, image_name, snap_name);
   return r;
 }
 
 int librbd::RBD::remove_snap(pool_t pool, const char *image_name, const char *snap_name)
 {
   PoolCtx *ctx = (PoolCtx *)pool;
-  int r = ((librbd::RBDClient *)client)->do_remove_snap(ctx, image_name, snap_name);
+  int r = client->do_remove_snap(ctx, image_name, snap_name);
   return r;
 }
 
 int librbd::RBD::rollback_snap(pool_t pool, const char *image_name, const char *snap_name)
 {
   PoolCtx *ctx = (PoolCtx *)pool;
-  int r = ((librbd::RBDClient *)client)->do_rollback_snap(ctx, image_name, snap_name);
+  int r = client->do_rollback_snap(ctx, image_name, snap_name);
   return r;
 }
 
@@ -935,7 +935,7 @@ int librbd::RBD::list_snaps(pool_t pool, const char* image_name, std::vector<lib
   PoolCtx *ctx = (PoolCtx *)pool;
   string md_oid = image_name;
   md_oid += RBD_SUFFIX;
-  int r = ((librbd::RBDClient *)client)->do_list_snaps(ctx, md_oid, snaps);
+  int r = client->do_list_snaps(ctx, md_oid, snaps);
   return r;
 }