This was the original intent, but buf==NULL wasn't documented
and only half-way implemented.
Signed-off-by: Sage Weil <sage@redhat.com>
* If len is too short to fit all the pool name entries we need, we will fill
* as much as we can.
*
+ * Buf may be null to determine the buffer size needed to list all pools.
+ *
* @param cluster cluster handle
* @param buf output buffer
* @param len output buffer length
break;
const char* pool = i->second.c_str();
tracepoint(librados, rados_pool_list_pool, pool);
- strncat(b, pool, rl);
+ if (b) {
+ strncat(b, pool, rl);
+ b += rl;
+ }
needed += rl;
len -= rl;
- b += rl;
}
for (; i != p_end; ++i) {
int rl = i->second.length() + 1;
ASSERT_EQ("", create_one_pool(pool_name, &cluster));
ASSERT_LT(rados_pool_list(cluster, buf, POOL_LIST_BUF_SZ), POOL_LIST_BUF_SZ);
+ // we can pass a null buffer too.
+ ASSERT_LT(rados_pool_list(cluster, NULL, POOL_LIST_BUF_SZ), POOL_LIST_BUF_SZ);
+
bool found_pool = false;
while (buf[0] != '\0') {
if ((found_pool == false) && (strcmp(buf, pool_name.c_str()) == 0)) {