]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
c_read_operations.cc: silence coverity with scope_guard
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Tue, 30 May 2017 10:27:57 +0000 (12:27 +0200)
committerKefu Chai <kchai@redhat.com>
Sat, 2 Sep 2017 04:27:16 +0000 (12:27 +0800)
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 <danny.al-gaaf@bisect.de>
src/test/librados/c_read_operations.cc

index 605fe4ff3ddc45e404785fa5ef10f661baf4155f..f5713302d82dc63a39b965e8d1816ddf5e624d1d 100644 (file)
@@ -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();