]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/PyModule: get_error_string() returns copy
authorMax Kellermann <max.kellermann@ionos.com>
Fri, 11 Oct 2024 10:32:11 +0000 (12:32 +0200)
committerMax Kellermann <max.kellermann@ionos.com>
Mon, 9 Dec 2024 07:20:51 +0000 (08:20 +0100)
The explanation from the previous commit about get_name() applies here
as well; but other than `module_name`, the `error_string` field is
mutable and does indeed need protection.  But still, returning a
reference is wrong, because the reference does not need protection;
the pointed-to value does.  This can be fixed easily by making the
method return a value instead of a reference.  The copy is made while
holding the lock.

Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
src/mgr/PyModule.h

index 3dd39a778656ca197ab5ddd47c78e7b0b6faa7c3..a47db3a47ef9bda2fc206d99297c7c0f201684a1 100644 (file)
@@ -163,7 +163,7 @@ public:
   const std::string &get_name() const {
     return module_name;
   }
-  const std::string &get_error_string() const {
+  std::string get_error_string() const {
     std::lock_guard l(lock) ; return error_string;
   }
   bool get_can_run() const {