From: Kefu Chai Date: Mon, 18 Jan 2016 05:06:27 +0000 (+0800) Subject: librados: fix rados_ioctx_pool_requires_alignment2() X-Git-Tag: v10.0.4~193^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8aa068d4a6e056fa1f2dbffc4205a64222c5867d;p=ceph.git librados: fix rados_ioctx_pool_requires_alignment2() 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 --- diff --git a/src/librados/librados.cc b/src/librados/librados.cc index 90a89c0f38d2..ed256dbc6497 100644 --- a/src/librados/librados.cc +++ b/src/librados/librados.cc @@ -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; }