From bfcf4374ed78e20394edb76b54e20bea4887b5cf Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 14 Nov 2022 11:24:12 -0800 Subject: [PATCH] init: Document which class Service members are not modified It is nontrivial to derive from the implementation of class Service which members are not modified. Hence this CL that documents this by declaring these members 'const'. Change-Id: I27b907a1c7044376d5c5393a29050c66cbdab7bf Signed-off-by: Bart Van Assche --- init/service.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/init/service.h b/init/service.h index b2c9909ed..e7211ec7b 100644 --- a/init/service.h +++ b/init/service.h @@ -143,7 +143,7 @@ class Service { flags_ &= ~SVC_ONESHOT; } } - Subcontext* subcontext() const { return subcontext_; } + const Subcontext* subcontext() const { return subcontext_; } const std::string& filename() const { return filename_; } void set_filename(const std::string& name) { filename_ = name; } @@ -162,7 +162,7 @@ class Service { static std::chrono::time_point exec_service_started_; static pid_t exec_service_pid_; - std::string name_; + const std::string name_; std::set classnames_; unsigned flags_; @@ -186,7 +186,7 @@ class Service { // Environment variables that only get applied to the next run. std::vector> once_environment_vars_; - Subcontext* subcontext_; + const Subcontext* const subcontext_; Action onrestart_; // Commands to execute on restart. std::vector writepid_files_; @@ -220,7 +220,7 @@ class Service { bool updatable_ = false; - std::vector args_; + const std::vector args_; std::vector> reap_callbacks_;