From 8162d65e27f1e9a4761e8f20151616010b64efcc Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Tue, 30 May 2017 12:27:57 +0200 Subject: [PATCH] c_read_operations.cc: silence coverity with scope_guard CID 1219593 (#1 of 1): Resource leak (RESOURCE_LEAK) leaked_storage: Variable completion going out of scope leaks the storage it points to. Signed-off-by: Danny Al-Gaaf --- src/test/librados/c_read_operations.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/librados/c_read_operations.cc b/src/test/librados/c_read_operations.cc index 605fe4ff3dd..f5713302d82 100644 --- a/src/test/librados/c_read_operations.cc +++ b/src/test/librados/c_read_operations.cc @@ -8,6 +8,7 @@ #include "include/rados/librados.h" #include "test/librados/test.h" #include "test/librados/TestCase.h" +#include "include/scope_guard.h" const char *data = "testdata"; const char *obj = "testobj"; @@ -158,10 +159,10 @@ TEST_F(CReadOpsTest, AssertExists) { rados_completion_t completion; ASSERT_EQ(0, rados_aio_create_completion(NULL, NULL, NULL, &completion)); + auto sg = make_scope_guard([&] { rados_aio_release(completion); }); ASSERT_EQ(0, rados_aio_read_op_operate(op, ioctx, completion, obj, 0)); rados_aio_wait_for_complete(completion); ASSERT_EQ(-ENOENT, rados_aio_get_return_value(completion)); - rados_aio_release(completion); rados_release_read_op(op); write_object(); -- 2.39.5