@@ -71,7 +71,7 @@ RMW_WARN_UNUSED
7171rmw_init_options_t
7272rmw_get_zero_initialized_init_options (void );
7373
74- /// Initialize given init_options with the default values and implementation specific values.
74+ /// Initialize given init options with the default values and implementation specific values.
7575/**
7676 * The given allocator is used, if required, during setup of the init options,
7777 * but is also used during initialization.
@@ -80,6 +80,13 @@ rmw_get_zero_initialized_init_options(void);
8080 *
8181 * The `impl` pointer should not be changed manually.
8282 *
83+ * \pre The given init options must be zero initialized.
84+ *
85+ * \post If initialization fails, init options will remain zero initialized.
86+ *
87+ * \remark Giving an already initialized init options will result
88+ * in a failure with return code `RMW_RET_INVALID_ARGUMENT`.
89+ *
8390 * <hr>
8491 * Attribute | Adherence
8592 * ------------------ | -------------
@@ -93,7 +100,6 @@ rmw_get_zero_initialized_init_options(void);
93100 * \param[inout] init_options object to be setup
94101 * \param[in] allocator to be used during setup and during initialization
95102 * \return `RMW_RET_OK` if setup is successful, or
96- * \return `RMW_RET_INVALID_ARGUMENT` if init_options has already be initialized, or
97103 * \return `RMW_RET_INVALID_ARGUMENT` if any arguments are invalid, or
98104 * \return `RMW_RET_BAD_ALLOC` if allocating memory failed, or
99105 * \return `RMW_RET_ERROR` if an unspecified error occurs.
@@ -108,11 +114,16 @@ rmw_init_options_init(rmw_init_options_t * init_options, rcutils_allocator_t all
108114 * The allocator from the source is used for any allocations and stored in the
109115 * destination.
110116 *
111- * The destination should either be zero initialized with
112- * `rmw_get_zero_initialized_init_options()` or should have had
113- * `rmw_init_options_fini()` called on it.
114- * Giving an already initialized init options for the destination will result
115- * in a failure with return code `RMW_RET_INVALID_ARGUMENT`.
117+ * \pre The source init options must have been initialized
118+ * i.e. had `rmw_init_options_init()` called on.
119+ * \pre The destination init options must be zero initialized.
120+ *
121+ * \post If copy fails, destination init options will remain zero initialized.
122+ *
123+ * \remark Giving an zero initialized init options as a source will result
124+ * in a failure with return code `RMW_RET_INVALID_ARGUMENT`.
125+ * \remark Giving an already initialized init options for the destination will result
126+ * in a failure with return code `RMW_RET_INVALID_ARGUMENT`.
116127 *
117128 * <hr>
118129 * Attribute | Adherence
@@ -129,7 +140,6 @@ rmw_init_options_init(rmw_init_options_t * init_options, rcutils_allocator_t all
129140 * \return `RMW_RET_OK` if the copy is successful, or
130141 * \return `RMW_RET_INCORRECT_RMW_IMPLEMENTATION` if the implementation
131142 * identifier for src does not match the implementation of this function, or
132- * \return `RMW_RET_INVALID_ARGUMENT` if the dst has already be initialized, or
133143 * \return `RMW_RET_INVALID_ARGUMENT` if any arguments are invalid, or
134144 * \return `RMW_RET_BAD_ALLOC` if allocating memory failed, or
135145 * \return `RMW_RET_ERROR` if an unspecified error occurs.
@@ -139,10 +149,19 @@ RMW_WARN_UNUSED
139149rmw_ret_t
140150rmw_init_options_copy (const rmw_init_options_t * src , rmw_init_options_t * dst );
141151
142- /// Finalize the given init_options .
152+ /// Finalize the given init options .
143153/**
144- * The given init_options must be non-`NULL` and valid, i.e. had
145- * `rmw_init_options_init()` called on it but not this function yet.
154+ * This function will return early if a logical error, such as `RMW_RET_INVALID_ARGUMENT`
155+ * or `RMW_RET_INCORRECT_RMW_IMPLEMENTATION`, ensues, leaving the given init options
156+ * unchanged.
157+ * Otherwise, it will proceed despite errors, freeing as much resources as it can and zero
158+ * initializing the given init options.
159+ *
160+ * \pre The given init options must have been initialized
161+ * i.e. had `rmw_init_options_init()` called on.
162+ *
163+ * \remarks If init options are zero initialized,
164+ * then `RMW_RET_INVALID_ARGUMENT` is returned.
146165 *
147166 * <hr>
148167 * Attribute | Adherence
@@ -154,9 +173,11 @@ rmw_init_options_copy(const rmw_init_options_t * src, rmw_init_options_t * dst);
154173 *
155174 * This should be defined by the rmw implementation.
156175 *
157- * \param[inout] init_options object to be setup
158- * \return `RMW_RET_OK` if setup is successful, or
176+ * \param[inout] init_options object to finalized
177+ * \return `RMW_RET_OK` if finalization is successful, or
159178 * \return `RMW_RET_INVALID_ARGUMENT` if any arguments are invalid, or
179+ * \return `RMW_RET_INCORRECT_RMW_IMPLEMENTATION` if the implementation
180+ * identifier does not match the implementation of this function, or
160181 * \return `RMW_RET_ERROR` if an unspecified error occurs.
161182 */
162183RMW_PUBLIC
0 commit comments