]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librados: fix rados_ioctx_pool_requires_alignment2()
authorKefu Chai <kchai@redhat.com>
Mon, 18 Jan 2016 05:06:27 +0000 (13:06 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 18 Jan 2016 07:30:59 +0000 (15:30 +0800)
we can not cast an "int *" pointer to a "bool *" and assign a bool
to it in hope to update the integer pointed by the "int *" with
1 or 0 according to the assigned boolean. because, the existing
value pointed by the "int *" pointer could be any value, if it's
non-zero, say, 0x12345678, after casting to "bool *", and assigning it
to "false", the variable would be 0x12345600. only the least
significant 8 bits are reset. so after resetting the variable pointed
by the "int *" pointer after reset it using "bool *", it still "true"!

Introduced-by: 1f85545
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/librados/librados.cc

index 90a89c0f38d207bf49292c762449fa37a481ae0b..ed256dbc6497ba0166d886de546d0310791517fb 100644 (file)
@@ -3186,10 +3186,13 @@ extern "C" int rados_ioctx_pool_requires_alignment2(rados_ioctx_t io,
 {
   tracepoint(librados, rados_ioctx_pool_requires_alignment_enter2, io);
   librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io;
+  bool requires_alignment;
   int retval = ctx->client->pool_requires_alignment2(ctx->get_id(), 
-       (bool *)requires);
+       &requires_alignment);
   tracepoint(librados, rados_ioctx_pool_requires_alignment_exit2, retval, 
-       *requires);
+       requires_alignment);
+  if (requires)
+    *requires = requires_alignment;
   return retval;
 }