]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: make early_config_t::to_ptr_vector private
authorKefu Chai <k.chai@proxmox.com>
Sun, 29 Mar 2026 11:39:40 +0000 (19:39 +0800)
committerKefu Chai <k.chai@proxmox.com>
Tue, 31 Mar 2026 22:47:54 +0000 (06:47 +0800)
The helper is an implementation detail of get_early_args() and
get_ceph_args(). Making it private prevents callers from inadvertently
holding the returned const char* pointers past the lifetime of the
input vector. Also fix the truncated doc-comment ("must not outlive in").

Signed-off-by: Kefu Chai <k.chai@proxmox.com>
src/crimson/osd/main_config_bootstrap_helpers.h

index 6e993a58cf007b72622d0e24ce07054d52c3d084..8d33ea67aecae8af7eb62a76b9b83fcba60fdfa2 100644 (file)
@@ -35,8 +35,18 @@ struct early_config_t {
   std::string conf_file_list;
   CephInitParameters init_params{CEPH_ENTITY_TYPE_OSD};
 
-  /// Returned vector must not outlive in
-  auto to_ptr_vector(const std::vector<std::string> &in) {
+  std::vector<const char *> get_early_args() {
+    return to_ptr_vector(early_args);
+  }
+
+  std::vector<const char *> get_ceph_args() {
+    return to_ptr_vector(ceph_args);
+  }
+
+private:
+  /// Returned pointers are valid only as long as \p in is alive.
+  static std::vector<const char *> to_ptr_vector(
+    const std::vector<std::string> &in) {
     std::vector<const char *> ret;
     ret.reserve(in.size());
     std::transform(
@@ -46,13 +56,7 @@ struct early_config_t {
     return ret;
   }
 
-  std::vector<const char *> get_early_args() {
-    return to_ptr_vector(early_args);
-  }
-
-  std::vector<const char *> get_ceph_args() {
-    return to_ptr_vector(ceph_args);
-  }
+public:
 
   void encode(ceph::buffer::list& bl) const {
     ENCODE_START(1, 1, bl);