Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test/librados/snapshots.cc: Fix memory leak #12690

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/test/librados/snapshots.cc
Expand Up @@ -157,15 +157,13 @@ TEST_F(LibRadosSnapshotsPP, SnapCreateRemovePP) {
ASSERT_EQ(0, ioctx.remove("foo"));
ASSERT_EQ(0, ioctx.snap_create("snapbar"));

librados::ObjectWriteOperation *op = new librados::ObjectWriteOperation();
std::unique_ptr<librados::ObjectWriteOperation> op(new librados::ObjectWriteOperation());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might want to use make_unique<librados::ObjectWriteOperation>() .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tchaikov I can't find any examples existing in the code base?

$ ag --cpp --ignore ./src/boost/* "make_unique"
$

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad, it's a c++14 feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh... yes it is. I thought we must have had a "ceph version" for 11.

op->create(false);
op->remove();
ASSERT_EQ(0, ioctx.operate("foo", op));
ASSERT_EQ(0, ioctx.operate("foo", op.get()));

EXPECT_EQ(0, ioctx.snap_remove("snapfoo"));
EXPECT_EQ(0, ioctx.snap_remove("snapbar"));

delete op;
}

TEST_F(LibRadosSnapshotsSelfManaged, Snap) {
Expand Down Expand Up @@ -512,10 +510,10 @@ TEST_F(LibRadosSnapshotsSelfManagedPP, Bug11677) {
ASSERT_EQ(0, ioctx.selfmanaged_snap_set_write_ctx(my_snaps[0], my_snaps));
::std::reverse(my_snaps.begin(), my_snaps.end());

librados::ObjectWriteOperation *op = new librados::ObjectWriteOperation();
std::unique_ptr<librados::ObjectWriteOperation> op(new librados::ObjectWriteOperation());
op->assert_exists();
op->remove();
ASSERT_EQ(0, ioctx.operate("foo", op));
ASSERT_EQ(0, ioctx.operate("foo", op.get()));

ASSERT_EQ(0, ioctx.selfmanaged_snap_remove(my_snaps.back()));
my_snaps.pop_back();
Expand Down Expand Up @@ -877,10 +875,10 @@ TEST_F(LibRadosSnapshotsSelfManagedECPP, Bug11677) {
ASSERT_EQ(0, ioctx.selfmanaged_snap_set_write_ctx(my_snaps[0], my_snaps));
::std::reverse(my_snaps.begin(), my_snaps.end());

librados::ObjectWriteOperation *op = new librados::ObjectWriteOperation();
std::unique_ptr<librados::ObjectWriteOperation> op(new librados::ObjectWriteOperation());
op->assert_exists();
op->remove();
ASSERT_EQ(0, ioctx.operate("foo", op));
ASSERT_EQ(0, ioctx.operate("foo", op.get()));

ASSERT_EQ(0, ioctx.selfmanaged_snap_remove(my_snaps.back()));
my_snaps.pop_back();
Expand Down