From: Kefu Chai Date: Sun, 29 Mar 2026 11:39:40 +0000 (+0800) Subject: crimson/osd: make early_config_t::to_ptr_vector private X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ada944b7271ec1403d116b356d8504c1a9bc50f5;p=ceph.git crimson/osd: make early_config_t::to_ptr_vector private 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 --- diff --git a/src/crimson/osd/main_config_bootstrap_helpers.h b/src/crimson/osd/main_config_bootstrap_helpers.h index 6e993a58cf00..8d33ea67aeca 100644 --- a/src/crimson/osd/main_config_bootstrap_helpers.h +++ b/src/crimson/osd/main_config_bootstrap_helpers.h @@ -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 &in) { + std::vector get_early_args() { + return to_ptr_vector(early_args); + } + + std::vector 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 to_ptr_vector( + const std::vector &in) { std::vector ret; ret.reserve(in.size()); std::transform( @@ -46,13 +56,7 @@ struct early_config_t { return ret; } - std::vector get_early_args() { - return to_ptr_vector(early_args); - } - - std::vector get_ceph_args() { - return to_ptr_vector(ceph_args); - } +public: void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl);