From 717c5ddae44fe86747d1545f64901163b1619bf8 Mon Sep 17 00:00:00 2001 From: Ronen Friedman Date: Sun, 21 Feb 2021 14:21:06 +0200 Subject: [PATCH] tools/cephfs-mirror: fix a dangling pointer MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit stringify(snap_id) is ephemeral: tools/cephfs_mirror/PeerReplayer.cc:916:62: warning: object backing the pointer will be destroyed at the end of the full-expression   snap_metadata snap_meta[] = {{PRIMARY_SNAP_ID_KEY.c_str(), stringify(snap_id).c_str()}}; Signed-off-by: Ronen Friedman --- src/tools/cephfs_mirror/PeerReplayer.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tools/cephfs_mirror/PeerReplayer.cc b/src/tools/cephfs_mirror/PeerReplayer.cc index 49c4cbef59fd5..b0a90f69cfdf3 100644 --- a/src/tools/cephfs_mirror/PeerReplayer.cc +++ b/src/tools/cephfs_mirror/PeerReplayer.cc @@ -913,7 +913,8 @@ int PeerReplayer::synchronize(const std::string &dir_path, uint64_t snap_id, return r; } - snap_metadata snap_meta[] = {{PRIMARY_SNAP_ID_KEY.c_str(), stringify(snap_id).c_str()}}; + auto snap_id_str{stringify(snap_id)}; + snap_metadata snap_meta[] = {{PRIMARY_SNAP_ID_KEY.c_str(), snap_id_str.c_str()}}; r = ceph_mksnap(m_remote_mount, dir_path.c_str(), snap_name.c_str(), 0755, snap_meta, 1); if (r < 0) { -- 2.39.5