From e04ba95ba72e16a5f24e15f0a69c34b0bfafdefe Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Wed, 16 Feb 2022 22:45:52 -0600 Subject: [PATCH] Progress: Continue mass converting to f_string_static_t and use const more. Continue on in the f_string_static_t refactoring. Also take care of adding "const" to the function parameters that pass pointers. --- level_0/f_account/c/account.c | 24 ++--- level_0/f_account/c/account.h | 16 +-- level_0/f_account/c/private-account.c | 2 +- level_0/f_account/c/private-account.h | 2 +- .../f_account/tests/unit/c/test-account-by_name.c | 22 +++- .../tests/unit/c/test-account-group_id_by_name.c | 21 +++- .../tests/unit/c/test-account-id_by_name.c | 21 +++- level_0/f_account/tests/unit/c/test-account.h | 4 +- level_0/f_capability/c/capability.c | 116 +++++++++++---------- level_0/f_capability/c/capability.h | 69 ++++++------ .../tests/unit/c/test-capability-file_get.c | 6 +- .../tests/unit/c/test-capability-file_set.c | 4 +- .../tests/unit/c/test-capability-from_name.c | 6 +- .../tests/unit/c/test-capability-from_text.c | 6 +- .../tests/unit/c/test-capability-mode_get_name.c | 4 +- .../f_capability/tests/unit/c/test-capability.h | 4 +- level_0/f_color/tests/unit/c/test-color.h | 4 +- level_0/f_console/tests/unit/c/test-console.h | 2 +- .../tests/unit/c/test-control_group.h | 2 +- .../f_conversion/tests/unit/c/test-conversion.h | 4 +- level_0/f_memory/tests/unit/c/test-memory.h | 2 +- .../f_type_array/tests/unit/c/test-type_array.h | 2 +- .../controller/c/controller/private-controller.c | 4 +- level_3/controller/c/rule/private-rule.c | 2 +- level_3/fake/c/private-make.c | 4 +- 25 files changed, 197 insertions(+), 156 deletions(-) diff --git a/level_0/f_account/c/account.c b/level_0/f_account/c/account.c index 5088951..9d67cd3 100644 --- a/level_0/f_account/c/account.c +++ b/level_0/f_account/c/account.c @@ -6,7 +6,7 @@ extern "C" { #endif #ifndef _di_f_account_by_id_ - f_status_t f_account_by_id(const uid_t id, f_account_t *account) { + f_status_t f_account_by_id(const uid_t id, f_account_t * const account) { #ifndef _di_level_0_parameter_checking_ if (!account) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -87,7 +87,7 @@ extern "C" { #endif // _di_f_account_by_id_ #ifndef _di_f_account_by_name_ - f_status_t f_account_by_name(const f_string_t name, f_account_t *account) { + f_status_t f_account_by_name(const f_string_static_t name, f_account_t * const account) { #ifndef _di_level_0_parameter_checking_ if (!account) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -117,7 +117,7 @@ extern "C" { errno = 0; char buffer[length]; - const int result = getpwnam_r(name, &password, buffer, length, &pointer); + const int result = getpwnam_r(name.string, &password, buffer, length, &pointer); if (result) { if (errno == EINTR) return F_status_set_error(F_interrupt); @@ -146,7 +146,7 @@ extern "C" { char buffer[F_account_pwd_length_fallback_second_d]; - const int result = getpwnam_r(name, &password, buffer, length, &pointer); + const int result = getpwnam_r(name.string, &password, buffer, length, &pointer); if (result) { if (errno == EINTR) return F_status_set_error(F_interrupt); @@ -168,7 +168,7 @@ extern "C" { #endif // _di_f_account_by_name_ #ifndef _di_f_account_group_id_by_name_ - f_status_t f_account_group_id_by_name(const f_string_t name, gid_t *id) { + f_status_t f_account_group_id_by_name(const f_string_static_t name, gid_t * const id) { #ifndef _di_level_0_parameter_checking_ if (!id) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -190,7 +190,7 @@ extern "C" { errno = 0; char buffer[length]; - int result = getgrnam_r(name, &group_data, buffer, length, &pointer); + int result = getgrnam_r(name.string, &group_data, buffer, length, &pointer); if (result) { if (errno == EINTR) return F_status_set_error(F_interrupt); @@ -221,7 +221,7 @@ extern "C" { char buffer[F_account_pwd_length_fallback_second_d]; - const int result = getgrnam_r(name, &group_data, buffer, length, &pointer); + const int result = getgrnam_r(name.string, &group_data, buffer, length, &pointer); if (result) { if (errno == EINTR) return F_status_set_error(F_interrupt); @@ -245,7 +245,7 @@ extern "C" { #endif // _di_f_account_group_id_by_name_ #ifndef _di_f_account_group_name_by_id_ - f_status_t f_account_group_name_by_id(const gid_t id, f_string_dynamic_t *name) { + f_status_t f_account_group_name_by_id(const gid_t id, f_string_dynamic_t * const name) { #ifndef _di_level_0_parameter_checking_ if (!name) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -342,7 +342,7 @@ extern "C" { #endif // _di_f_account_group_name_by_id_ #ifndef _di_f_account_id_by_name_ - f_status_t f_account_id_by_name(const f_string_t name, uid_t *id) { + f_status_t f_account_id_by_name(const f_string_static_t name, uid_t * const id) { #ifndef _di_level_0_parameter_checking_ if (!id) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -364,7 +364,7 @@ extern "C" { errno = 0; char buffer[length]; - const int result = getpwnam_r(name, &password, buffer, length, &pointer); + const int result = getpwnam_r(name.string, &password, buffer, length, &pointer); if (result) { if (errno == EINTR) return F_status_set_error(F_interrupt); @@ -395,7 +395,7 @@ extern "C" { char buffer[F_account_pwd_length_fallback_second_d]; - const int result = getpwnam_r(name, &password, buffer, length, &pointer); + const int result = getpwnam_r(name.string, &password, buffer, length, &pointer); if (result) { if (errno == EINTR) return F_status_set_error(F_interrupt); @@ -419,7 +419,7 @@ extern "C" { #endif // _di_f_account_id_by_name_ #ifndef _di_f_account_name_by_id_ - f_status_t f_account_name_by_id(const uid_t id, f_string_dynamic_t *name) { + f_status_t f_account_name_by_id(const uid_t id, f_string_dynamic_t * const name) { #ifndef _di_level_0_parameter_checking_ if (!name) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ diff --git a/level_0/f_account/c/account.h b/level_0/f_account/c/account.h index 7be1e31..e5b60d0 100644 --- a/level_0/f_account/c/account.h +++ b/level_0/f_account/c/account.h @@ -56,7 +56,7 @@ extern "C" { * @see getpwuid_r() */ #ifndef _di_f_account_by_id_ - extern f_status_t f_account_by_id(const uid_t id, f_account_t *account); + extern f_status_t f_account_by_id(const uid_t id, f_account_t * const account); #endif // _di_f_account_by_id_ /** @@ -84,7 +84,7 @@ extern "C" { * @see getpwnam_r() */ #ifndef _di_f_account_by_name_ - extern f_status_t f_account_by_name(const f_string_t name, f_account_t *account); + extern f_status_t f_account_by_name(const f_string_static_t name, f_account_t * const account); #endif // _di_f_account_by_name_ /** @@ -111,7 +111,7 @@ extern "C" { * @see getgrnam_r() */ #ifndef _di_f_account_group_id_by_name_ - extern f_status_t f_account_group_id_by_name(const f_string_t name, gid_t *id); + extern f_status_t f_account_group_id_by_name(const f_string_static_t name, gid_t * const id); #endif // _di_f_account_group_id_by_name_ /** @@ -121,7 +121,7 @@ extern "C" { * The id of the group. * @param name * This is replaced with by the group name. - * The name will be NULL terminated. + * The name will be NULL terminated after the name.used. * * @return * F_none on success. @@ -138,7 +138,7 @@ extern "C" { * @see getgrgid_r() */ #ifndef _di_f_account_group_name_by_id_ - extern f_status_t f_account_group_name_by_id(const gid_t id, f_string_dynamic_t *name); + extern f_status_t f_account_group_name_by_id(const gid_t id, f_string_dynamic_t * const name); #endif // _di_f_account_group_name_by_id_ /** @@ -165,7 +165,7 @@ extern "C" { * @see getpwnam_r() */ #ifndef _di_f_account_id_by_name_ - extern f_status_t f_account_id_by_name(const f_string_t name, uid_t *id); + extern f_status_t f_account_id_by_name(const f_string_static_t name, uid_t * const id); #endif // _di_f_account_id_by_name_ /** @@ -175,7 +175,7 @@ extern "C" { * The id of the user. * @param name * This is replaced with by the user name. - * The name will be NULL terminated. + * The name will be NULL terminated after the name.used. * * @return * F_none on success. @@ -192,7 +192,7 @@ extern "C" { * @see getpwuid_r() */ #ifndef _di_f_account_name_by_id_ - extern f_status_t f_account_name_by_id(const uid_t id, f_string_dynamic_t *name); + extern f_status_t f_account_name_by_id(const uid_t id, f_string_dynamic_t * const name); #endif // _di_f_account_name_by_id_ #ifdef __cplusplus diff --git a/level_0/f_account/c/private-account.c b/level_0/f_account/c/private-account.c index f0619c9..307d207 100644 --- a/level_0/f_account/c/private-account.c +++ b/level_0/f_account/c/private-account.c @@ -6,7 +6,7 @@ extern "C" { #endif #if !defined(_di_f_account_by_name_) || !defined(_di_f_account_by_id_) - f_status_t private_f_account_from_passwd(const struct passwd password, const f_array_length_t password_length, f_account_t *account) { + f_status_t private_f_account_from_passwd(const struct passwd password, const f_array_length_t password_length, f_account_t * const account) { f_status_t status = F_none; diff --git a/level_0/f_account/c/private-account.h b/level_0/f_account/c/private-account.h index 911efca..2ec37ff 100644 --- a/level_0/f_account/c/private-account.h +++ b/level_0/f_account/c/private-account.h @@ -39,7 +39,7 @@ extern "C" { * @see macro_f_string_dynamic_t_resize() */ #if !defined(_di_f_account_by_name_) || !defined(_di_f_account_by_id_) - extern f_status_t private_f_account_from_passwd(const struct passwd password, const f_array_length_t password_length, f_account_t *account) F_attribute_visibility_internal_d; + extern f_status_t private_f_account_from_passwd(const struct passwd password, const f_array_length_t password_length, f_account_t * const account) F_attribute_visibility_internal_d; #endif // !defined(_di_f_account_by_name_) || !defined(_di_f_account_by_id_) #ifdef __cplusplus diff --git a/level_0/f_account/tests/unit/c/test-account-by_name.c b/level_0/f_account/tests/unit/c/test-account-by_name.c index e1faebf..6fa4032 100644 --- a/level_0/f_account/tests/unit/c/test-account-by_name.c +++ b/level_0/f_account/tests/unit/c/test-account-by_name.c @@ -8,9 +8,13 @@ extern "C" { void test__f_account_by_name__fails(void **state) { const long size = 20; - char *name = "name"; f_account_t account = f_account_t_initialize; + f_string_t name_string = "name"; + f_string_static_t name = f_string_static_t_initialize; + name.string = name_string; + name.used = 4; + int errnos[] = { EINTR, EIO, @@ -49,9 +53,13 @@ void test__f_account_by_name__not_found(void **state) { const long size = 20; struct passwd password; - char *name = "name"; f_account_t account = f_account_t_initialize; + f_string_t name_string = "name"; + f_string_static_t name = f_string_static_t_initialize; + name.string = name_string; + name.used = 4; + { will_return(__wrap_sysconf, size); will_return(__wrap_getpwnam_r, false); @@ -69,7 +77,7 @@ void test__f_account_by_name__not_found(void **state) { #ifndef _di_level_0_parameter_checking_ void test__f_account_by_name__parameter_checking(void **state) { - const f_string_t name = f_string_t_initialize; + const f_string_static_t name = f_string_static_t_initialize; { const f_status_t status = f_account_by_name(name, 0); @@ -84,14 +92,18 @@ void test__f_account_by_name__works(void **state) { const long size = 20; struct passwd password; struct passwd pointer; - char *name = "name"; f_account_t account = f_account_t_initialize; + f_string_t name_string = "name"; + f_string_static_t name = f_string_static_t_initialize; + name.string = name_string; + name.used = 4; + password.pw_uid = 1; password.pw_gid = 2; password.pw_dir = "pw_dir"; password.pw_gecos = "pw_gecos"; - password.pw_name = name; + password.pw_name = name_string; password.pw_passwd = "pw_passwd"; password.pw_shell = "pw_shell"; diff --git a/level_0/f_account/tests/unit/c/test-account-group_id_by_name.c b/level_0/f_account/tests/unit/c/test-account-group_id_by_name.c index 954e5b3..0e91d95 100644 --- a/level_0/f_account/tests/unit/c/test-account-group_id_by_name.c +++ b/level_0/f_account/tests/unit/c/test-account-group_id_by_name.c @@ -8,9 +8,13 @@ extern "C" { void test__f_account_group_id_by_name__fails(void **state) { const long size = 20; - char *name = "name"; gid_t gid = 0; + f_string_t name_string = "name"; + f_string_static_t name = f_string_static_t_initialize; + name.string = name_string; + name.used = 4; + int errnos[] = { EINTR, EIO, @@ -47,9 +51,13 @@ void test__f_account_group_id_by_name__not_found(void **state) { const long size = 20; struct group group_data; - char *name = "name"; gid_t gid = 0; + f_string_t name_string = "name"; + f_string_static_t name = f_string_static_t_initialize; + name.string = name_string; + name.used = 4; + { will_return(__wrap_sysconf, size); will_return(__wrap_getgrnam_r, false); @@ -65,7 +73,7 @@ void test__f_account_group_id_by_name__not_found(void **state) { #ifndef _di_level_0_parameter_checking_ void test__f_account_group_id_by_name__parameter_checking(void **state) { - const f_string_t name = f_string_t_initialize; + const f_string_static_t name = f_string_static_t_initialize; { const f_status_t status = f_account_group_id_by_name(name, 0); @@ -83,6 +91,8 @@ void test__f_account_group_id_by_name__works(void **state) { char *pointers[] = { "gr_mem", 0 }; gid_t gid = 0; + f_string_static_t name = f_string_static_t_initialize; + group_data.gr_gid = 1; group_data.gr_name = "gr_name"; group_data.gr_passwd = "gr_passwd"; @@ -94,7 +104,10 @@ void test__f_account_group_id_by_name__works(void **state) { will_return(__wrap_getgrnam_r, &group_data); will_return(__wrap_getgrnam_r, &pointer); - const f_status_t status = f_account_group_id_by_name(group_data.gr_name, &gid); + name.string = group_data.gr_name; + name.used = strlen(group_data.gr_name); + + const f_status_t status = f_account_group_id_by_name(name, &gid); assert_int_equal(status, F_none); assert_int_equal(gid, group_data.gr_gid); diff --git a/level_0/f_account/tests/unit/c/test-account-id_by_name.c b/level_0/f_account/tests/unit/c/test-account-id_by_name.c index eeea2ae..cb4998c 100644 --- a/level_0/f_account/tests/unit/c/test-account-id_by_name.c +++ b/level_0/f_account/tests/unit/c/test-account-id_by_name.c @@ -8,9 +8,13 @@ extern "C" { void test__f_account_id_by_name__fails(void **state) { const long size = 20; - char *name = "name"; uid_t uid = 0; + f_string_t name_string = "name"; + f_string_static_t name = f_string_static_t_initialize; + name.string = name_string; + name.used = 4; + int errnos[] = { EINTR, EIO, @@ -47,9 +51,13 @@ void test__f_account_id_by_name__not_found(void **state) { const long size = 20; struct passwd password; - char *name = "name"; uid_t uid = 0; + f_string_t name_string = "name"; + f_string_static_t name = f_string_static_t_initialize; + name.string = name_string; + name.used = 4; + { will_return(__wrap_sysconf, size); will_return(__wrap_getpwnam_r, false); @@ -65,7 +73,7 @@ void test__f_account_id_by_name__not_found(void **state) { #ifndef _di_level_0_parameter_checking_ void test__f_account_id_by_name__parameter_checking(void **state) { - const f_string_t name = f_string_t_initialize; + const f_string_static_t name = f_string_static_t_initialize; { const f_status_t status = f_account_id_by_name(name, 0); @@ -82,6 +90,8 @@ void test__f_account_id_by_name__works(void **state) { struct passwd pointer; uid_t uid = 0; + f_string_static_t name = f_string_static_t_initialize; + password.pw_uid = 1; password.pw_gid = 2; password.pw_dir = "pw_dir"; @@ -96,7 +106,10 @@ void test__f_account_id_by_name__works(void **state) { will_return(__wrap_getpwnam_r, &password); will_return(__wrap_getpwnam_r, &pointer); - const f_status_t status = f_account_id_by_name(password.pw_name, &uid); + name.string = password.pw_name; + name.used = strlen(password.pw_name); + + const f_status_t status = f_account_id_by_name(name, &uid); assert_int_equal(status, F_none); assert_int_equal(uid, password.pw_uid); diff --git a/level_0/f_account/tests/unit/c/test-account.h b/level_0/f_account/tests/unit/c/test-account.h index 369a2a8..6e4e8db 100644 --- a/level_0/f_account/tests/unit/c/test-account.h +++ b/level_0/f_account/tests/unit/c/test-account.h @@ -22,10 +22,10 @@ // FLL-0 includes. #include -// mock includes. +// Mock includes. #include "mock-account.h" -// test includes. +// Test includes. #include "test-account-by_id.h" #include "test-account-by_name.h" #include "test-account-group_id_by_name.h" diff --git a/level_0/f_capability/c/capability.c b/level_0/f_capability/c/capability.c index e56864a..2240ca4 100644 --- a/level_0/f_capability/c/capability.c +++ b/level_0/f_capability/c/capability.c @@ -7,7 +7,7 @@ extern "C" { #if defined(_di_libcap_) || defined(_libcap_legacy_only_) #ifndef _di_f_capability_ambient_get_ - f_status_t f_capability_ambient_get(const f_capability_value_t value, int *ambient) { + f_status_t f_capability_ambient_get(const f_capability_value_t value, int * const ambient) { #ifndef _di_level_0_parameter_checking_ if (!ambient) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -33,7 +33,7 @@ extern "C" { #ifdef _di_libcap_ #ifndef _di_f_capability_clear_ - f_status_t f_capability_clear(f_capability_t *capability) { + f_status_t f_capability_clear(f_capability_t * const capability) { #ifndef _di_level_0_parameter_checking_ if (!capability) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -43,7 +43,7 @@ extern "C" { #endif // _di_f_capability_clear_ #ifndef _di_f_capability_clear_flag_ - f_status_t f_capability_clear_flag(const f_capability_flag_t flag, f_capability_t *capability) { + f_status_t f_capability_clear_flag(const f_capability_flag_t flag, f_capability_t * const capability) { #ifndef _di_level_0_parameter_checking_ if (!capability) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -53,13 +53,13 @@ extern "C" { #endif // _di_f_capability_clear_flag_ #ifndef _di_f_capability_compare_ - f_status_t f_capability_compare(const f_capability_t capability1, const f_capability_t capability2, int *flags) { + f_status_t f_capability_compare(const f_capability_t capability1, const f_capability_t capability2, int * const flags) { return F_status_set_error(F_implemented_not); } #endif // _di_f_capability_compare_ #ifndef _di_f_capability_copy_ - f_status_t f_capability_copy(const f_capability_t source, f_capability_t *destination) { + f_status_t f_capability_copy(const f_capability_t source, f_capability_t * const destination) { #ifndef _di_level_0_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -69,7 +69,7 @@ extern "C" { #endif // _di_f_capability_copy_ #ifndef _di_f_capability_copy_external_ - f_status_t f_capability_copy_external(const f_capability_t capability, const ssize_t max, void *external, ssize_t *size) { + f_status_t f_capability_copy_external(const f_capability_t capability, const ssize_t max, void * const external, ssize_t * const size) { #ifndef _di_level_0_parameter_checking_ if (!external) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -79,7 +79,7 @@ extern "C" { #endif // _di_f_capability_copy_external_ #ifndef _di_f_capability_copy_internal_ - f_status_t f_capability_copy_internal(const void *external, f_capability_t *capability) { + f_status_t f_capability_copy_internal(const void *external, f_capability_t * const capability) { #ifndef _di_level_0_parameter_checking_ if (!external) return F_status_set_error(F_parameter); if (!capability) return F_status_set_error(F_parameter); @@ -100,7 +100,7 @@ extern "C" { #endif // _di_f_capability_delete_ #ifndef _di_f_capability_file_descriptor_get_ - f_status_t f_capability_file_descriptor_get(const int descriptor, f_capability_t *capability) { + f_status_t f_capability_file_descriptor_get(const int descriptor, f_capability_t * const capability) { #ifndef _di_level_0_parameter_checking_ if (!capability) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -116,7 +116,7 @@ extern "C" { #endif // _di_f_capability_file_descriptor_set_ #ifndef _di_f_capability_file_get_ - f_status_t f_capability_file_get(const f_string_t path, f_capability_t *capability) { + f_status_t f_capability_file_get(const f_string_static_t path, f_capability_t * const capability) { #ifndef _di_level_0_parameter_checking_ if (!capability) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -126,13 +126,13 @@ extern "C" { #endif // _di_f_capability_file_get_ #ifndef _di_f_capability_file_set_ - f_status_t f_capability_file_set(const f_string_t path, const f_capability_t capability) { + f_status_t f_capability_file_set(const f_string_static_t path, const f_capability_t capability) { return F_status_set_error(F_implemented_not); } #endif // _di_f_capability_file_set_ #ifndef _di_f_capability_flag_get_ - f_status_t f_capability_flag_get(const f_capability_t capability, const f_capability_value_t code, const f_capability_flag_t flag, f_capability_flag_value_t *enabled) { + f_status_t f_capability_flag_get(const f_capability_t capability, const f_capability_value_t code, const f_capability_flag_t flag, f_capability_flag_value_t * const enabled) { #ifndef _di_level_0_parameter_checking_ if (!enabled) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -142,7 +142,7 @@ extern "C" { #endif // _di_f_capability_flag_get_ #ifndef _di_f_capability_flag_set_ - f_status_t f_capability_flag_set(const f_capability_flag_t flag, const f_capability_flag_value_t enabled, const f_int32s_t codes, f_capability_t *capability) { + f_status_t f_capability_flag_set(const f_capability_flag_t flag, const f_capability_flag_value_t enabled, const f_int32s_t codes, f_capability_t * const capability) { #ifndef _di_level_0_parameter_checking_ if (!capability) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -152,7 +152,7 @@ extern "C" { #endif // _di_f_capability_flag_set_ #ifndef _di_f_capability_from_name_ - f_status_t f_capability_from_name(const f_string_t name, f_capability_value_t *code) { + f_status_t f_capability_from_name(const f_string_static_t name, f_capability_value_t * const code) { #ifndef _di_level_0_parameter_checking_ if (!code) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -162,7 +162,7 @@ extern "C" { #endif // _di_f_capability_from_name_ #ifndef _di_f_capability_from_text_ - f_status_t f_capability_from_text(const f_string_t text, f_capability_t *capability) { + f_status_t f_capability_from_text(const f_string_static_t text, f_capability_t * const capability) { #ifndef _di_level_0_parameter_checking_ if (!capability) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -186,7 +186,7 @@ extern "C" { #ifdef _di_libcap_ #ifndef _di_f_capability_initialize_ - f_status_t f_capability_initialize(f_capability_t *capability) { + f_status_t f_capability_initialize(f_capability_t * const capability) { #ifndef _di_level_0_parameter_checking_ if (!capability) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -200,7 +200,7 @@ extern "C" { #if defined(_di_libcap_) || defined(_libcap_legacy_only_) #ifndef _di_f_capability_mode_get_ - f_status_t f_capability_mode_get(f_capability_mode_t *mode) { + f_status_t f_capability_mode_get(f_capability_mode_t * const mode) { #ifndef _di_level_0_parameter_checking_ if (!mode) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -210,7 +210,7 @@ extern "C" { #endif // _di_f_capability_mode_get_ #ifndef _di_f_capability_mode_get_name_ - f_status_t f_capability_mode_get_name(const f_capability_mode_t mode, f_string_constant_t *name) { + f_status_t f_capability_mode_get_name(const f_capability_mode_t mode, f_string_static_t * const name) { #ifndef _di_level_0_parameter_checking_ if (!name) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -226,7 +226,7 @@ extern "C" { #endif // _di_f_capability_mode_set_ #ifndef _di_f_capability_owner_get_ - f_status_t f_capability_owner_get(const f_capability_t capability, uid_t *id_user) { + f_status_t f_capability_owner_get(const f_capability_t capability, uid_t * const id_user) { #ifndef _di_level_0_parameter_checking_ if (!id_user) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -246,7 +246,7 @@ extern "C" { #ifdef _di_libcap_ #ifndef _di_f_capability_process_bound_drop_ - f_status_t f_capability_process_bound_drop(f_capability_value_t code, int *bound) { + f_status_t f_capability_process_bound_drop(f_capability_value_t code, int * const bound) { #ifndef _di_level_0_parameter_checking_ if (!bound) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -256,7 +256,7 @@ extern "C" { #endif // _di_f_capability_process_bound_drop_ #ifndef _di_f_capability_process_bound_get_ - f_status_t f_capability_process_bound_get(f_capability_value_t code, int *bound) { + f_status_t f_capability_process_bound_get(f_capability_value_t code, int * const bound) { #ifndef _di_level_0_parameter_checking_ if (!bound) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -266,7 +266,7 @@ extern "C" { #endif // _di_f_capability_process_bound_get_ #ifndef _di_f_capability_process_get_ - f_status_t f_capability_process_get(f_capability_t *capability) { + f_status_t f_capability_process_get(f_capability_t * const capability) { #ifndef _di_level_0_parameter_checking_ if (!capability) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -276,7 +276,7 @@ extern "C" { #endif // _di_f_capability_process_get_ #ifndef _di_f_capability_process_get_by_id_ - f_status_t f_capability_process_get_by_id(const pid_t id, f_capability_t *capability) { + f_status_t f_capability_process_get_by_id(const pid_t id, f_capability_t * const capability) { #ifndef _di_level_0_parameter_checking_ if (!capability) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -296,7 +296,7 @@ extern "C" { #if defined(_di_libcap_) || defined(_libcap_legacy_only_) #ifndef _di_f_capability_security_bits_get_ - f_status_t f_capability_security_bits_get(f_capability_bits_t *bits) { + f_status_t f_capability_security_bits_get(f_capability_bits_t * const bits) { #ifndef _di_level_0_parameter_checking_ if (!bits) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -316,7 +316,7 @@ extern "C" { #ifdef _di_libcap_ #ifndef _di_f_capability_size_ - f_status_t f_capability_size(const f_capability_t capability, ssize_t *size) { + f_status_t f_capability_size(const f_capability_t capability, ssize_t * const size) { #ifndef _di_level_0_parameter_checking_ if (!size) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -352,7 +352,7 @@ extern "C" { #endif // _di_f_capability_supported_code_ #ifndef _di_f_capability_to_name_ - f_status_t f_capability_to_name(const int code, f_string_dynamic_t *name) { + f_status_t f_capability_to_name(const int code, f_string_dynamic_t * const name) { #ifndef _di_level_0_parameter_checking_ if (!name) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -362,7 +362,7 @@ extern "C" { #endif // _di_f_capability_to_name_ #ifndef _di_f_capability_to_text_ - f_status_t f_capability_to_text(const f_capability_t capability, f_string_dynamic_t *text) { + f_status_t f_capability_to_text(const f_capability_t capability, f_string_dynamic_t * const text) { #ifndef _di_level_0_parameter_checking_ if (!text) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -386,7 +386,7 @@ extern "C" { #if !defined(_di_libcap_) && !defined(_libcap_legacy_only_) #ifndef _di_f_capability_ambient_get_ - f_status_t f_capability_ambient_get(const f_capability_value_t value, int *ambient) { + f_status_t f_capability_ambient_get(const f_capability_value_t value, int * const ambient) { #ifndef _di_level_0_parameter_checking_ if (!ambient) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -438,7 +438,7 @@ extern "C" { #ifndef _di_libcap_ #ifndef _di_f_capability_clear_ - f_status_t f_capability_clear(f_capability_t *capability) { + f_status_t f_capability_clear(f_capability_t * const capability) { #ifndef _di_level_0_parameter_checking_ if (!capability) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -456,7 +456,7 @@ extern "C" { #endif // _di_f_capability_clear_ #ifndef _di_f_capability_clear_flag_ - f_status_t f_capability_clear_flag(const f_capability_flag_t flag, f_capability_t *capability) { + f_status_t f_capability_clear_flag(const f_capability_flag_t flag, f_capability_t * const capability) { #ifndef _di_level_0_parameter_checking_ if (!capability) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -472,7 +472,7 @@ extern "C" { #endif // _di_f_capability_clear_flag_ #ifndef _di_f_capability_compare_ - f_status_t f_capability_compare(const f_capability_t capability1, const f_capability_t capability2, int *flags) { + f_status_t f_capability_compare(const f_capability_t capability1, const f_capability_t capability2, int * const flags) { if (flags) { *flags = 0; @@ -499,7 +499,7 @@ extern "C" { #endif // _di_f_capability_compare_ #ifndef _di_f_capability_copy_ - f_status_t f_capability_copy(const f_capability_t source, f_capability_t *destination) { + f_status_t f_capability_copy(const f_capability_t source, f_capability_t * const destination) { #ifndef _di_level_0_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -518,7 +518,7 @@ extern "C" { #endif // _di_f_capability_copy_ #ifndef _di_f_capability_copy_external_ - f_status_t f_capability_copy_external(const f_capability_t capability, const ssize_t max, void *external, ssize_t *size) { + f_status_t f_capability_copy_external(const f_capability_t capability, const ssize_t max, void * const external, ssize_t * const size) { #ifndef _di_level_0_parameter_checking_ if (!external) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -540,7 +540,7 @@ extern "C" { #endif // _di_f_capability_copy_external_ #ifndef _di_f_capability_copy_internal_ - f_status_t f_capability_copy_internal(const void *external, f_capability_t *capability) { + f_status_t f_capability_copy_internal(const void * const external, f_capability_t * const capability) { #ifndef _di_level_0_parameter_checking_ if (!external) return F_status_set_error(F_parameter); if (!capability) return F_status_set_error(F_parameter); @@ -561,7 +561,7 @@ extern "C" { #endif // _di_f_capability_copy_internal_ #ifndef _di_f_capability_delete_ - f_status_t f_capability_delete(f_capability_t *capability) { + f_status_t f_capability_delete(f_capability_t * const capability) { #ifndef _di_level_0_parameter_checking_ if (!capability) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -580,7 +580,7 @@ extern "C" { #endif // _di_f_capability_delete_ #ifndef _di_f_capability_file_descriptor_get_ - f_status_t f_capability_file_descriptor_get(const int descriptor, f_capability_t *capability) { + f_status_t f_capability_file_descriptor_get(const int descriptor, f_capability_t * const capability) { #ifndef _di_level_0_parameter_checking_ if (!capability) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -627,12 +627,12 @@ extern "C" { #endif // _di_f_capability_file_descriptor_set_ #ifndef _di_f_capability_file_get_ - f_status_t f_capability_file_get(const f_string_t path, f_capability_t *capability) { + f_status_t f_capability_file_get(const f_string_static_t path, f_capability_t * const capability) { #ifndef _di_level_0_parameter_checking_ if (!capability) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - *capability = cap_get_file(path); + *capability = cap_get_file(path.string); if (*capability) { return F_none; @@ -652,9 +652,9 @@ extern "C" { #endif // _di_f_capability_file_get_ #ifndef _di_f_capability_file_set_ - f_status_t f_capability_file_set(const f_string_t path, const f_capability_t capability) { + f_status_t f_capability_file_set(const f_string_static_t path, const f_capability_t capability) { - const int result = cap_set_file(path, capability); + const int result = cap_set_file(path.string, capability); if (result == -1) { if (errno == EACCES) return F_status_set_error(F_access_denied); @@ -674,7 +674,7 @@ extern "C" { #endif // _di_f_capability_file_set_ #ifndef _di_f_capability_flag_get_ - f_status_t f_capability_flag_get(const f_capability_t capability, const f_capability_value_t code, const f_capability_flag_t flag, f_capability_flag_value_t *enabled) { + f_status_t f_capability_flag_get(const f_capability_t capability, const f_capability_value_t code, const f_capability_flag_t flag, f_capability_flag_value_t * const enabled) { #ifndef _di_level_0_parameter_checking_ if (!enabled) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -690,7 +690,7 @@ extern "C" { #endif // _di_f_capability_flag_get_ #ifndef _di_f_capability_flag_set_ - f_status_t f_capability_flag_set(const f_capability_flag_t flag, const f_capability_flag_value_t enabled, const f_int32s_t codes, f_capability_t *capability) { + f_status_t f_capability_flag_set(const f_capability_flag_t flag, const f_capability_flag_value_t enabled, const f_int32s_t codes, f_capability_t * const capability) { #ifndef _di_level_0_parameter_checking_ if (!capability) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -706,12 +706,12 @@ extern "C" { #endif // _di_f_capability_flag_set_ #ifndef _di_f_capability_from_name_ - f_status_t f_capability_from_name(const f_string_t name, f_capability_value_t *code) { + f_status_t f_capability_from_name(const f_string_static_t name, f_capability_value_t * const code) { #ifndef _di_level_0_parameter_checking_ if (!code) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (cap_from_name(name, code) == -1) { + if (cap_from_name(name.string, code) == -1) { if (errno == EINVAL) return F_status_set_error(F_parameter); if (errno == ENOMEM) return F_status_set_error(F_memory_not); @@ -723,12 +723,12 @@ extern "C" { #endif // _di_f_capability_from_name_ #ifndef _di_f_capability_from_text_ - f_status_t f_capability_from_text(const f_string_t text, f_capability_t *capability) { + f_status_t f_capability_from_text(const f_string_static_t text, f_capability_t * const capability) { #ifndef _di_level_0_parameter_checking_ if (!capability) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - *capability = cap_from_text(text); + *capability = cap_from_text(text.string); if (*capability) { return F_none; @@ -765,7 +765,7 @@ extern "C" { #ifndef _di_libcap_ #ifndef _di_f_capability_initialize_ - f_status_t f_capability_initialize(f_capability_t *capability) { + f_status_t f_capability_initialize(f_capability_t * const capability) { #ifndef _di_level_0_parameter_checking_ if (!capability) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -800,13 +800,15 @@ extern "C" { #endif // _di_f_capability_mode_get_ #ifndef _di_f_capability_mode_get_name_ - f_status_t f_capability_mode_get_name(const f_capability_mode_t mode, f_string_constant_t *name) { + f_status_t f_capability_mode_get_name(const f_capability_mode_t mode, f_string_static_t * const name) { #ifndef _di_level_0_parameter_checking_ if (!mode) return F_status_set_error(F_parameter); if (!name) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - *name = cap_mode_name(mode); + name.string = cap_mode_name(mode); + name.used = strnlen(name.string, F_string_t_size_d); + name.size = 0; return F_none; } @@ -828,7 +830,7 @@ extern "C" { #endif // _di_f_capability_mode_set_ #ifndef _di_f_capability_owner_get_ - f_status_t f_capability_owner_get(const f_capability_t capability, uid_t *id_user) { + f_status_t f_capability_owner_get(const f_capability_t capability, uid_t * const id_user) { #ifndef _di_level_0_parameter_checking_ if (!id_user) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -864,7 +866,7 @@ extern "C" { #ifndef _di_libcap_ #ifndef _di_f_capability_process_bound_drop_ - f_status_t f_capability_process_bound_drop(f_capability_value_t value, int *bound) { + f_status_t f_capability_process_bound_drop(f_capability_value_t value, int * const bound) { #ifndef _di_level_0_parameter_checking_ if (!bound) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -884,7 +886,7 @@ extern "C" { #endif // _di_f_capability_process_bound_drop_ #ifndef _di_f_capability_process_bound_get_ - f_status_t f_capability_process_bound_get(f_capability_value_t value, int *bound) { + f_status_t f_capability_process_bound_get(f_capability_value_t value, int * const bound) { #ifndef _di_level_0_parameter_checking_ if (!bound) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -900,7 +902,7 @@ extern "C" { #endif // _di_f_capability_process_bound_get_ #ifndef _di_f_capability_process_get_ - f_status_t f_capability_process_get(f_capability_t *capability) { + f_status_t f_capability_process_get(f_capability_t * const capability) { #ifndef _di_level_0_parameter_checking_ if (!capability) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -919,7 +921,7 @@ extern "C" { #endif // _di_f_capability_process_get_ #ifndef _di_f_capability_process_get_by_id_ - f_status_t f_capability_process_get_by_id(const pid_t id, f_capability_t *capability) { + f_status_t f_capability_process_get_by_id(const pid_t id, f_capability_t * const capability) { #ifndef _di_level_0_parameter_checking_ if (!capability) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -954,7 +956,7 @@ extern "C" { #if !defined(_di_libcap_) && !defined(_libcap_legacy_only_) #ifndef _di_f_capability_security_bits_get_ - f_status_t f_capability_security_bits_get(f_capability_bits_t *bits) { + f_status_t f_capability_security_bits_get(f_capability_bits_t * const bits) { #ifndef _di_level_0_parameter_checking_ if (!bits) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -985,7 +987,7 @@ extern "C" { #ifndef _di_libcap_ #ifndef _di_f_capability_size_ - f_status_t f_capability_size(const f_capability_t capability, ssize_t *size) { + f_status_t f_capability_size(const f_capability_t capability, ssize_t * const size) { #ifndef _di_level_0_parameter_checking_ if (!size) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -1041,7 +1043,7 @@ extern "C" { #endif // _di_f_capability_supported_code_ #ifndef _di_f_capability_to_name_ - f_status_t f_capability_to_name(const int code, f_string_dynamic_t *name) { + f_status_t f_capability_to_name(const int code, f_string_dynamic_t * const name) { #ifndef _di_level_0_parameter_checking_ if (!name) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -1082,7 +1084,7 @@ extern "C" { #endif // _di_f_capability_to_name_ #ifndef _di_f_capability_to_text_ - f_status_t f_capability_to_text(const f_capability_t capability, f_string_dynamic_t *text) { + f_status_t f_capability_to_text(const f_capability_t capability, f_string_dynamic_t * const text) { #ifndef _di_level_0_parameter_checking_ if (!text) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ diff --git a/level_0/f_capability/c/capability.h b/level_0/f_capability/c/capability.h index 60c3fa5..d9ce645 100644 --- a/level_0/f_capability/c/capability.h +++ b/level_0/f_capability/c/capability.h @@ -68,7 +68,7 @@ extern "C" { * @see cap_set_ambient() */ #ifndef _di_f_capability_ambient_get_ - extern f_status_t f_capability_ambient_get(const f_capability_value_t value, int *ambient); + extern f_status_t f_capability_ambient_get(const f_capability_value_t value, int * const ambient); #endif // _di_f_capability_ambient_get_ /** @@ -131,7 +131,7 @@ extern "C" { * @see cap_clear() */ #ifndef _di_f_capability_clear_ - extern f_status_t f_capability_clear(f_capability_t *capability); + extern f_status_t f_capability_clear(f_capability_t * const capability); #endif // _di_f_capability_clear_ /** @@ -154,7 +154,7 @@ extern "C" { * @see cap_clear_flag() */ #ifndef _di_f_capability_clear_flag_ - extern f_status_t f_capability_clear_flag(const f_capability_flag_t flag, f_capability_t *capability); + extern f_status_t f_capability_clear_flag(const f_capability_flag_t flag, f_capability_t * const capability); #endif // _di_f_capability_clear_flag_ /** @@ -180,7 +180,7 @@ extern "C" { * @see cap_compare() */ #ifndef _di_f_capability_compare_ - extern f_status_t f_capability_compare(const f_capability_t capability1, const f_capability_t capability2, int *flags); + extern f_status_t f_capability_compare(const f_capability_t capability1, const f_capability_t capability2, int * const flags); #endif // _di_f_capability_compare_ /** @@ -204,7 +204,7 @@ extern "C" { * @see cap_dup() */ #ifndef _di_f_capability_copy_ - extern f_status_t f_capability_copy(const f_capability_t source, f_capability_t *destination); + extern f_status_t f_capability_copy(const f_capability_t source, f_capability_t * const destination); #endif // _di_f_capability_copy_ /** @@ -233,7 +233,7 @@ extern "C" { * @see cap_copy_ext() */ #ifndef _di_f_capability_copy_external_ - extern f_status_t f_capability_copy_external(const f_capability_t capability, const ssize_t max, void *external, ssize_t *size); + extern f_status_t f_capability_copy_external(const f_capability_t capability, const ssize_t max, void * const external, ssize_t * const size); #endif // _di_f_capability_copy_external_ /** @@ -258,7 +258,7 @@ extern "C" { * @see cap_copy_int() */ #ifndef _di_f_capability_copy_internal_ - extern f_status_t f_capability_copy_internal(const void *external, f_capability_t *capability); + extern f_status_t f_capability_copy_internal(const void * const external, f_capability_t * const capability); #endif // _di_f_capability_copy_internal_ /** @@ -280,7 +280,7 @@ extern "C" { * @see cap_free() */ #ifndef _di_f_capability_delete_ - extern f_status_t f_capability_delete(f_capability_t *capability); + extern f_status_t f_capability_delete(f_capability_t * const capability); #endif // _di_f_capability_delete_ /** @@ -311,7 +311,7 @@ extern "C" { * @see cap_get_fd() */ #ifndef _di_f_capability_file_descriptor_get_ - extern f_status_t f_capability_file_descriptor_get(const int descriptor, f_capability_t *capability); + extern f_status_t f_capability_file_descriptor_get(const int descriptor, f_capability_t * const capability); #endif // _di_f_capability_file_descriptor_get_ /** @@ -372,7 +372,7 @@ extern "C" { * @see cap_get_file() */ #ifndef _di_f_capability_file_get_ - extern f_status_t f_capability_file_get(const f_string_t path, f_capability_t *capability); + extern f_status_t f_capability_file_get(const f_string_static_t path, f_capability_t * const capability); #endif // _di_f_capability_file_get_ /** @@ -402,7 +402,7 @@ extern "C" { * @see cap_set_file() */ #ifndef _di_f_capability_file_set_ - extern f_status_t f_capability_file_set(const f_string_t path, const f_capability_t capability); + extern f_status_t f_capability_file_set(const f_string_static_t path, const f_capability_t capability); #endif // _di_f_capability_file_set_ /** @@ -429,7 +429,7 @@ extern "C" { * @see cap_get_flag() */ #ifndef _di_f_capability_flag_get_ - extern f_status_t f_capability_flag_get(const f_capability_t capability, const f_capability_value_t code, const f_capability_flag_t flag, f_capability_flag_value_t *enabled); + extern f_status_t f_capability_flag_get(const f_capability_t capability, const f_capability_value_t code, const f_capability_flag_t flag, f_capability_flag_value_t * const enabled); #endif // _di_f_capability_flag_get /** @@ -456,7 +456,7 @@ extern "C" { * @see cap_set_flag() */ #ifndef _di_f_capability_flag_set_ - extern f_status_t f_capability_flag_set(const f_capability_flag_t flag, const f_capability_flag_value_t enabled, const f_int32s_t codes, f_capability_t *capability); + extern f_status_t f_capability_flag_set(const f_capability_flag_t flag, const f_capability_flag_value_t enabled, const f_int32s_t codes, f_capability_t * const capability); #endif // _di_f_capability_flag_set_ /** @@ -480,17 +480,18 @@ extern "C" { * @see cap_from_name() */ #ifndef _di_f_capability_from_name_ - extern f_status_t f_capability_from_name(const f_string_t name, f_capability_value_t *code); + extern f_status_t f_capability_from_name(const f_string_static_t name, f_capability_value_t * const code); #endif // _di_f_capability_from_name_ /** * Get the capability represented by the given string. * * @param text - * The human-readable NULL terminated string representing the capabilities (such as "cap_chown+ep"). + * The human-readable string representing the capabilities (such as "cap_chown+ep"). + * This must be a NULL terminated string. * @param capability * The determined capabilities. - * This must be freed via f_capability_delete() when finished with. + * This must be freed via f_capability_delete(). * * @return * F_none on success. @@ -504,7 +505,7 @@ extern "C" { * @see cap_from_text() */ #ifndef _di_f_capability_from_text_ - extern f_status_t f_capability_from_text(const f_string_t text, f_capability_t *capability); + extern f_status_t f_capability_from_text(const f_string_static_t text, f_capability_t * const capability); #endif // _di_f_capability_from_text_ /** @@ -558,7 +559,7 @@ extern "C" { * @see cap_init() */ #ifndef _di_f_capability_initialize_ - extern f_status_t f_capability_initialize(f_capability_t *capability); + extern f_status_t f_capability_initialize(f_capability_t * const capability); #endif // _di_f_capability_initialize_ /** @@ -577,7 +578,7 @@ extern "C" { * @see cap_get_mode() */ #ifndef _di_f_capability_mode_get_ - extern f_status_t f_capability_mode_get(f_capability_mode_t *mode); + extern f_status_t f_capability_mode_get(f_capability_mode_t * const mode); #endif // _di_f_capability_mode_get_ /** @@ -587,8 +588,7 @@ extern "C" { * The capability mode. * @param name * The name of the mode. - * This is a NULL terminated string. - * This is not an allocated string. + * This is NULL terminated after the name.used. * * @return * F_none on success. @@ -600,7 +600,7 @@ extern "C" { * @see cap_get_mode() */ #ifndef _di_f_capability_mode_get_name_ - extern f_status_t f_capability_mode_get_name(const f_capability_mode_t mode, f_string_constant_t *name); + extern f_status_t f_capability_mode_get_name(const f_capability_mode_t mode, f_string_static_t * const name); #endif // _di_f_capability_mode_get_name_ /** @@ -643,7 +643,7 @@ extern "C" { * @see cap_get_owner() */ #ifndef _di_f_capability_owner_get_ - extern f_status_t f_capability_owner_get(const f_capability_t capability, uid_t *id_user); + extern f_status_t f_capability_owner_get(const f_capability_t capability, uid_t * const id_user); #endif // _di_f_capability_owner_get_ /** @@ -704,7 +704,7 @@ extern "C" { * @see cap_drop_bound() */ #ifndef _di_f_capability_process_bound_drop_ - extern f_status_t f_capability_process_bound_drop(f_capability_value_t value, int *bound); + extern f_status_t f_capability_process_bound_drop(f_capability_value_t value, int * const bound); #endif // _di_f_capability_process_bound_drop_ /** @@ -727,7 +727,7 @@ extern "C" { * @see cap_get_bound() */ #ifndef _di_f_capability_process_bound_get_ - extern f_status_t f_capability_process_bound_get(f_capability_value_t value, int *bound); + extern f_status_t f_capability_process_bound_get(f_capability_value_t value, int * const bound); #endif // _di_f_capability_process_bound_get_ /** @@ -748,7 +748,7 @@ extern "C" { * @see cap_get_proc() */ #ifndef _di_f_capability_process_get_ - extern f_status_t f_capability_process_get(f_capability_t *capability); + extern f_status_t f_capability_process_get(f_capability_t * const capability); #endif // _di_f_capability_process_get_ /** @@ -772,7 +772,7 @@ extern "C" { * @see cap_get_pid() */ #ifndef _di_f_capability_process_get_by_id_ - extern f_status_t f_capability_process_get_by_id(const pid_t id, f_capability_t *capability); + extern f_status_t f_capability_process_get_by_id(const pid_t id, f_capability_t * const capability); #endif // _di_f_capability_process_get_by_id_ /** @@ -813,7 +813,7 @@ extern "C" { * @see cap_get_secbits() */ #ifndef _di_f_capability_security_bits_get_ - extern f_status_t f_capability_security_bits_get(f_capability_bits_t *bits); + extern f_status_t f_capability_security_bits_get(f_capability_bits_t * const bits); #endif // _di_f_capability_security_bits_get_ /** @@ -859,7 +859,7 @@ extern "C" { * @see cap_size() */ #ifndef _di_f_capability_size_ - extern f_status_t f_capability_size(const f_capability_t capability, ssize_t *size); + extern f_status_t f_capability_size(const f_capability_t capability, ssize_t * const size); #endif // _di_f_capability_size_ /** @@ -913,7 +913,7 @@ extern "C" { * @param name * The determined name. * The name is appended into this variable. - * This is not NULL terminated. + * This is NULL terminated after the name.used. * * @return * F_none on success. @@ -933,18 +933,19 @@ extern "C" { * @see f_string_dynamic_resize() */ #ifndef _di_f_capability_to_name_ - extern f_status_t f_capability_to_name(const f_capability_value_t code, f_string_dynamic_t *name); + extern f_status_t f_capability_to_name(const f_capability_value_t code, f_string_dynamic_t * const name); #endif // _di_f_capability_to_name_ /** - * Convert the capability to a human-readable NULL terminated string. + * Convert the capability to a human-readable string. * * This will append the string to text. * * @param capability * The capability code. * @param text - * The determined human-readable NULL terminated string. + * The determined human-readable string. + * This is NULL terminated after the text.used. * * @return * F_none on success. @@ -964,7 +965,7 @@ extern "C" { * @see f_string_dynamic_resize() */ #ifndef _di_f_capability_to_text_ - extern f_status_t f_capability_to_text(const f_capability_t capability, f_string_dynamic_t *text); + extern f_status_t f_capability_to_text(const f_capability_t capability, f_string_dynamic_t * const text); #endif // _di_f_capability_to_text_ /** diff --git a/level_0/f_capability/tests/unit/c/test-capability-file_get.c b/level_0/f_capability/tests/unit/c/test-capability-file_get.c index e02a9a6..2c72f78 100644 --- a/level_0/f_capability/tests/unit/c/test-capability-file_get.c +++ b/level_0/f_capability/tests/unit/c/test-capability-file_get.c @@ -8,7 +8,7 @@ extern "C" { void test__f_capability_file_get__fails(void **state) { #if !defined(_di_libcap_) - const f_string_t path = f_string_t_initialize; + const f_string_static_t path = f_string_static_t_initialize; f_capability_t capability = f_capability_t_initialize; int errnos[] = { @@ -50,7 +50,7 @@ void test__f_capability_file_get__fails(void **state) { #ifndef _di_level_0_parameter_checking_ void test__f_capability_file_get__parameter_checking(void **state) { - const f_string_t path = f_string_t_initialize; + const f_string_static_t path = f_string_static_t_initialize; { const f_status_t status = f_capability_file_get(path, 0); @@ -62,7 +62,7 @@ void test__f_capability_file_get__fails(void **state) { void test__f_capability_file_get__works(void **state) { - const f_string_t path = f_string_t_initialize; + const f_string_static_t path = f_string_static_t_initialize; f_capability_t capability = f_capability_t_initialize; #if defined(_di_libcap_) diff --git a/level_0/f_capability/tests/unit/c/test-capability-file_set.c b/level_0/f_capability/tests/unit/c/test-capability-file_set.c index 25ca069..a1bb9dc 100644 --- a/level_0/f_capability/tests/unit/c/test-capability-file_set.c +++ b/level_0/f_capability/tests/unit/c/test-capability-file_set.c @@ -8,7 +8,7 @@ extern "C" { void test__f_capability_file_set__fails(void **state) { #if !defined(_di_libcap_) - const f_string_t path = f_string_t_initialize; + const f_string_static_t path = f_string_static_t_initialize; f_capability_t capability = f_capability_t_initialize; int errnos[] = { @@ -49,7 +49,7 @@ void test__f_capability_file_set__fails(void **state) { void test__f_capability_file_set__works(void **state) { - const f_string_t path = f_string_t_initialize; + const f_string_static_t path = f_string_static_t_initialize; f_capability_t capability = f_capability_t_initialize; #if defined(_di_libcap_) diff --git a/level_0/f_capability/tests/unit/c/test-capability-from_name.c b/level_0/f_capability/tests/unit/c/test-capability-from_name.c index 73ba3df..c0e7eb8 100644 --- a/level_0/f_capability/tests/unit/c/test-capability-from_name.c +++ b/level_0/f_capability/tests/unit/c/test-capability-from_name.c @@ -8,7 +8,7 @@ extern "C" { void test__f_capability_from_name__fails(void **state) { #if !defined(_di_libcap_) - const f_string_t name = f_string_t_initialize; + const f_string_static_t name = f_string_static_t_initialize; f_capability_value_t capability_value = f_capability_value_t_initialize; int errnos[] = { @@ -38,7 +38,7 @@ void test__f_capability_from_name__fails(void **state) { #ifndef _di_level_0_parameter_checking_ void test__f_capability_from_name__parameter_checking(void **state) { - const f_string_t name = f_string_t_initialize; + const f_string_static_t name = f_string_static_t_initialize; { const f_status_t status = f_capability_from_name(name, 0); @@ -50,7 +50,7 @@ void test__f_capability_from_name__fails(void **state) { void test__f_capability_from_name__works(void **state) { - const f_string_t name = f_string_t_initialize; + const f_string_static_t name = f_string_static_t_initialize; f_capability_value_t capability_value = f_capability_value_t_initialize; #if defined(_di_libcap_) diff --git a/level_0/f_capability/tests/unit/c/test-capability-from_text.c b/level_0/f_capability/tests/unit/c/test-capability-from_text.c index 672dbc0..e9b48c6 100644 --- a/level_0/f_capability/tests/unit/c/test-capability-from_text.c +++ b/level_0/f_capability/tests/unit/c/test-capability-from_text.c @@ -8,7 +8,7 @@ extern "C" { void test__f_capability_from_text__fails(void **state) { #if !defined(_di_libcap_) - const f_string_t text = f_string_t_initialize; + const f_string_static_t text = f_string_static_t_initialize; f_capability_t capability = f_capability_t_initialize; int errnos[] = { @@ -38,7 +38,7 @@ void test__f_capability_from_text__fails(void **state) { #ifndef _di_level_0_parameter_checking_ void test__f_capability_from_text__parameter_checking(void **state) { - const f_string_t text = f_string_t_initialize; + const f_string_static_t text = f_string_static_t_initialize; { const f_status_t status = f_capability_from_text(text, 0); @@ -50,7 +50,7 @@ void test__f_capability_from_text__fails(void **state) { void test__f_capability_from_text__works(void **state) { - const f_string_t text = f_string_t_initialize; + const f_string_static_t text = f_string_static_t_initialize; f_capability_t capability = f_capability_t_initialize; #if defined(_di_libcap_) diff --git a/level_0/f_capability/tests/unit/c/test-capability-mode_get_name.c b/level_0/f_capability/tests/unit/c/test-capability-mode_get_name.c index 78a0b3b..a9d1443 100644 --- a/level_0/f_capability/tests/unit/c/test-capability-mode_get_name.c +++ b/level_0/f_capability/tests/unit/c/test-capability-mode_get_name.c @@ -21,7 +21,7 @@ extern "C" { void test__f_capability_mode_get_name__works(void **state) { const f_capability_mode_t mode = f_capability_mode_t_initialize; - f_string_constant_t constant = f_string_constant_t_initialize; + f_string_static_t name = f_string_static_t_initialize; #if defined(_di_libcap_) || defined(_libcap_legacy_only_) printf("[ WARN ] f_capability_mode_get_name() is not implemented and cannot be fully tested.\n"); @@ -30,7 +30,7 @@ void test__f_capability_mode_get_name__works(void **state) { #endif // defined(_di_libcap_) || defined(_libcap_legacy_only_) { - const f_status_t status = f_capability_mode_get_name(mode, &constant); + const f_status_t status = f_capability_mode_get_name(mode, &name); #if defined(_di_libcap_) || defined(_libcap_legacy_only_) assert_int_equal(F_status_set_fine(status), F_implemented_not); diff --git a/level_0/f_capability/tests/unit/c/test-capability.h b/level_0/f_capability/tests/unit/c/test-capability.h index 1d3b9f3..6278aea 100644 --- a/level_0/f_capability/tests/unit/c/test-capability.h +++ b/level_0/f_capability/tests/unit/c/test-capability.h @@ -22,10 +22,10 @@ // FLL-0 includes. #include -// mock includes. +// Mock includes. #include "mock-capability.h" -// test includes. +// Test includes. #include "test-capability-ambient_get.h" #include "test-capability-ambient_reset.h" #include "test-capability-ambient_set.h" diff --git a/level_0/f_color/tests/unit/c/test-color.h b/level_0/f_color/tests/unit/c/test-color.h index 865daa5..d83c8e9 100644 --- a/level_0/f_color/tests/unit/c/test-color.h +++ b/level_0/f_color/tests/unit/c/test-color.h @@ -22,10 +22,10 @@ // FLL-0 includes. #include -// mock includes. +// Mock includes. #include "mock-color.h" -// test includes. +// Test includes. #include "test-color-load_context.h" #include "test-color-save_1.h" #include "test-color-save_2.h" diff --git a/level_0/f_console/tests/unit/c/test-console.h b/level_0/f_console/tests/unit/c/test-console.h index 028e2ee..8ae1c4f 100644 --- a/level_0/f_console/tests/unit/c/test-console.h +++ b/level_0/f_console/tests/unit/c/test-console.h @@ -22,7 +22,7 @@ // FLL-0 includes. #include -// test includes. +// Test includes. #include "test-console-identify.h" #include "test-console-environment_process.h" #include "test-console-parameter_prioritize_left.h" diff --git a/level_0/f_control_group/tests/unit/c/test-control_group.h b/level_0/f_control_group/tests/unit/c/test-control_group.h index 29e0261..f60f43c 100644 --- a/level_0/f_control_group/tests/unit/c/test-control_group.h +++ b/level_0/f_control_group/tests/unit/c/test-control_group.h @@ -22,7 +22,7 @@ // FLL-0 includes. #include -// test includes. +// Test includes. #include "test-control_group-copy.h" #ifdef __cplusplus diff --git a/level_0/f_conversion/tests/unit/c/test-conversion.h b/level_0/f_conversion/tests/unit/c/test-conversion.h index 1cff4e4..0164c8d 100644 --- a/level_0/f_conversion/tests/unit/c/test-conversion.h +++ b/level_0/f_conversion/tests/unit/c/test-conversion.h @@ -22,10 +22,10 @@ // FLL-0 includes. #include -// mock includes. +// Mock includes. #include "mock-conversion.h" -// test includes. +// Test includes. #include "test-conversion-character_is_binary.h" #include "test-conversion-character_is_decimal.h" #include "test-conversion-character_is_duodecimal.h" diff --git a/level_0/f_memory/tests/unit/c/test-memory.h b/level_0/f_memory/tests/unit/c/test-memory.h index 54ff21a..880da15 100644 --- a/level_0/f_memory/tests/unit/c/test-memory.h +++ b/level_0/f_memory/tests/unit/c/test-memory.h @@ -22,7 +22,7 @@ // FLL-0 includes. #include -// test includes. +// Test includes. #include "test-memory-adjust.h" #include "test-memory-delete.h" #include "test-memory-destroy.h" diff --git a/level_0/f_type_array/tests/unit/c/test-type_array.h b/level_0/f_type_array/tests/unit/c/test-type_array.h index aedad9c..3299059 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array.h @@ -24,7 +24,7 @@ #include #include -// test includes. +// Test includes. #include "test-type_array-array_lengths_adjust.h" #include "test-type_array-array_lengths_append.h" #include "test-type_array-array_lengths_decimate_by.h" diff --git a/level_3/controller/c/controller/private-controller.c b/level_3/controller/c/controller/private-controller.c index 273c5d2..68917dd 100644 --- a/level_3/controller/c/controller/private-controller.c +++ b/level_3/controller/c/controller/private-controller.c @@ -335,7 +335,7 @@ extern "C" { status = controller_dynamic_rip_nulless_terminated(buffer, range, &cache->action.generic); if (F_status_is_error(status)) return status; - status = f_account_id_by_name(cache->action.generic.string, id); + status = f_account_id_by_name(cache->action.generic, id); if (F_status_is_error(status)) return status; if (status == F_exist_not) { @@ -370,7 +370,7 @@ extern "C" { status = controller_dynamic_rip_nulless_terminated(buffer, range, &cache->action.generic); if (F_status_is_error(status)) return status; - status = f_account_group_id_by_name(cache->action.generic.string, id); + status = f_account_group_id_by_name(cache->action.generic, id); if (F_status_is_error(status)) return status; if (status == F_exist_not) { diff --git a/level_3/controller/c/rule/private-rule.c b/level_3/controller/c/rule/private-rule.c index f39808e..21c98f3 100644 --- a/level_3/controller/c/rule/private-rule.c +++ b/level_3/controller/c/rule/private-rule.c @@ -4729,7 +4729,7 @@ extern "C" { } } - status = f_capability_from_text(cache->action.generic.string, &rule->capability); + status = f_capability_from_text(cache->action.generic, &rule->capability); if (F_status_is_error(status) && F_status_set_fine(status) != F_supported_not) { if (F_status_set_fine(status) == F_memory_not) { diff --git a/level_3/fake/c/private-make.c b/level_3/fake/c/private-make.c index db59bf1..464ad45 100644 --- a/level_3/fake/c/private-make.c +++ b/level_3/fake/c/private-make.c @@ -60,7 +60,7 @@ extern "C" { status = F_status_set_fine(status); if (status == F_number) { - status = f_account_group_id_by_name(buffer.string, id); + status = f_account_group_id_by_name(buffer, id); if (F_status_is_error(status)) { fll_error_print(print, F_status_set_fine(status), "f_account_group_id_by_name", F_true); @@ -151,7 +151,7 @@ extern "C" { status = F_status_set_fine(status); if (status == F_number) { - status = f_account_id_by_name(buffer.string, id); + status = f_account_id_by_name(buffer, id); if (F_status_is_error(status)) { fll_error_print(print, status, "f_account_id_by_name", F_true); -- 1.8.3.1