From 6e68f29a755d3efb4231e02e55b1353979a03503 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Tue, 3 Jan 2023 15:43:37 -0600 Subject: [PATCH] Update: The f_file_mode_from_string() replace parameter should be optional. This change does not break ABI. This change does not break API, except for parameter error when replace is NULL. --- level_0/f_file/c/file.c | 6 ++++-- level_0/f_file/c/file.h | 4 +++- level_0/f_file/tests/unit/c/test-file-mode_from_string.c | 16 ++++++++-------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/level_0/f_file/c/file.c b/level_0/f_file/c/file.c index 53bf5cb..1109f56 100644 --- a/level_0/f_file/c/file.c +++ b/level_0/f_file/c/file.c @@ -920,7 +920,6 @@ extern "C" { f_status_t f_file_mode_from_string(const f_string_static_t code, const mode_t umask, f_file_mode_t * const mode, uint8_t * const replace) { #ifndef _di_level_0_parameter_checking_ if (!mode) return F_status_set_error(F_parameter); - if (!replace) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!code.used) return F_data_not; @@ -1269,7 +1268,10 @@ extern "C" { if (syntax) { *mode = mode_result; - *replace = replace_result; + + if (replace) { + *replace = replace_result; + } return F_none; } diff --git a/level_0/f_file/c/file.h b/level_0/f_file/c/file.h index 40442fa..6fb1206 100644 --- a/level_0/f_file/c/file.h +++ b/level_0/f_file/c/file.h @@ -1150,7 +1150,7 @@ extern "C" { * * See the f_file_mode_t documentation for details. * @param replace - * The determined modes that are to be replaced, such as: F_file_mode_t_replace_owner_d. + * (optional) The determined modes that are to be replaced, such as: F_file_mode_t_replace_owner_d. * This uses bitwise data. * * The flags F_file_mode_t_replace_* are used to designate which mask bits are to be replaced. @@ -1159,6 +1159,8 @@ extern "C" { * * Replacements replace the entire existing mode values where as "add" and "subtract" add or subtract modes, respectively, to the existing mode values. * + * Set to NULL to not use. + * * @return * F_none on success. * diff --git a/level_0/f_file/tests/unit/c/test-file-mode_from_string.c b/level_0/f_file/tests/unit/c/test-file-mode_from_string.c index 0a084d1..27e0bc1 100644 --- a/level_0/f_file/tests/unit/c/test-file-mode_from_string.c +++ b/level_0/f_file/tests/unit/c/test-file-mode_from_string.c @@ -203,14 +203,6 @@ void test__f_file_mode_from_string__parameter_checking(void **state) { } { - f_file_mode_t mode_file = f_file_mode_t_initialize; - - const f_status_t status = f_file_mode_from_string(f_string_empty_s, 0, &mode_file, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - } - - { uint8_t replace = 0; const f_status_t status = f_file_mode_from_string(f_string_empty_s, 0, 0, &replace); @@ -229,6 +221,14 @@ void test__f_file_mode_from_string__returns_data_not(void **state) { assert_int_equal(F_status_set_fine(status), F_data_not); } + + { + f_file_mode_t mode_file = f_file_mode_t_initialize; + + const f_status_t status = f_file_mode_from_string(f_string_empty_s, 0, &mode_file, 0); + + assert_int_equal(F_status_set_fine(status), F_data_not); + } } void test__f_file_mode_from_string__works_basic_alphabet(void **state) { -- 1.8.3.1