summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_conf.h
diff options
context:
space:
mode:
authorAndrew Clayton <a.clayton@nginx.com>2024-04-16 19:22:59 +0100
committerAndrew Clayton <a.clayton@nginx.com>2024-04-25 15:14:50 +0100
commite5bc299d7a55a66e1ecf54d35dcdd9448c49f3d4 (patch)
treece39c4cc8a274bf5bfb2b821c04077aad442c4d1 /src/nxt_conf.h
parent3fbca6ca672d40964812f5fe08b08c2dbb232cdd (diff)
downloadunit-e5bc299d7a55a66e1ecf54d35dcdd9448c49f3d4.tar.gz
unit-e5bc299d7a55a66e1ecf54d35dcdd9448c49f3d4.tar.bz2
configuration: Constify numerous pointers
Mark numerous function argument pointers as 'const' in the configuration sub-system. This also does the same with a few functions in src/nxt_conf_validation.c that are required to accomplish the below, attacking the rest is an exercise for another day... While this is a worthwhile hardening exercise in its own right, the main impetus for this is to 'constify' some local function variables which are currently defined with 'static' storage class and turn them into 'static const', which will be done in a subsequent patch. Reviewed-by: Zhidao HONG <z.hong@f5.com> Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
Diffstat (limited to 'src/nxt_conf.h')
-rw-r--r--src/nxt_conf.h59
1 files changed, 32 insertions, 27 deletions
diff --git a/src/nxt_conf.h b/src/nxt_conf.h
index 626b6d4d..d1a475e5 100644
--- a/src/nxt_conf.h
+++ b/src/nxt_conf.h
@@ -79,27 +79,28 @@ typedef struct {
} nxt_conf_validation_t;
-NXT_EXPORT nxt_uint_t nxt_conf_type(nxt_conf_value_t *value);
+NXT_EXPORT nxt_uint_t nxt_conf_type(const nxt_conf_value_t *value);
NXT_EXPORT nxt_conf_value_t *nxt_conf_get_path(nxt_conf_value_t *value,
- nxt_str_t *path);
-NXT_EXPORT nxt_conf_value_t *nxt_conf_get_object_member(nxt_conf_value_t *value,
- nxt_str_t *name, uint32_t *index);
+ const nxt_str_t *path);
+NXT_EXPORT nxt_conf_value_t *nxt_conf_get_object_member(
+ const nxt_conf_value_t *value, const nxt_str_t *name, uint32_t *index);
NXT_EXPORT nxt_conf_value_t *nxt_conf_next_object_member(
- nxt_conf_value_t *value, nxt_str_t *name, uint32_t *next);
-NXT_EXPORT nxt_conf_value_t *nxt_conf_get_array_element(nxt_conf_value_t *value,
- uint32_t index);
+ const nxt_conf_value_t *value, nxt_str_t *name, uint32_t *next);
+NXT_EXPORT nxt_conf_value_t *nxt_conf_get_array_element(
+ const nxt_conf_value_t *value, uint32_t index);
NXT_EXPORT nxt_conf_value_t *nxt_conf_get_array_element_or_itself(
nxt_conf_value_t *value, uint32_t index);
-NXT_EXPORT nxt_int_t nxt_conf_map_object(nxt_mp_t *mp, nxt_conf_value_t *value,
- nxt_conf_map_t *map, nxt_uint_t n, void *data);
+NXT_EXPORT nxt_int_t nxt_conf_map_object(nxt_mp_t *mp,
+ const nxt_conf_value_t *value, const nxt_conf_map_t *map, nxt_uint_t n,
+ void *data);
nxt_conf_op_ret_t nxt_conf_op_compile(nxt_mp_t *mp, nxt_conf_op_t **ops,
- nxt_conf_value_t *root, nxt_str_t *path, nxt_conf_value_t *value,
+ const nxt_conf_value_t *root, const nxt_str_t *path, nxt_conf_value_t *value,
nxt_bool_t add);
nxt_conf_value_t *nxt_conf_clone(nxt_mp_t *mp, nxt_conf_op_t *op,
- nxt_conf_value_t *value);
+ const nxt_conf_value_t *value);
nxt_conf_value_t *nxt_conf_json_parse(nxt_mp_t *mp, u_char *start, u_char *end,
nxt_conf_json_error_t *error);
@@ -119,37 +120,41 @@ nxt_int_t nxt_conf_validate(nxt_conf_validation_t *vldt);
NXT_EXPORT void nxt_conf_get_string(nxt_conf_value_t *value, nxt_str_t *str);
NXT_EXPORT nxt_str_t *nxt_conf_get_string_dup(nxt_conf_value_t *value,
nxt_mp_t *mp, nxt_str_t *str);
-NXT_EXPORT void nxt_conf_set_string(nxt_conf_value_t *value, nxt_str_t *str);
+NXT_EXPORT void nxt_conf_set_string(nxt_conf_value_t *value,
+ const nxt_str_t *str);
NXT_EXPORT nxt_int_t nxt_conf_set_string_dup(nxt_conf_value_t *value,
nxt_mp_t *mp, const nxt_str_t *str);
NXT_EXPORT double nxt_conf_get_number(nxt_conf_value_t *value);
NXT_EXPORT uint8_t nxt_conf_get_boolean(nxt_conf_value_t *value);
// FIXME reimplement and reorder functions below
-NXT_EXPORT nxt_uint_t nxt_conf_object_members_count(nxt_conf_value_t *value);
+NXT_EXPORT nxt_uint_t nxt_conf_object_members_count(
+ const nxt_conf_value_t *value);
nxt_conf_value_t *nxt_conf_create_object(nxt_mp_t *mp, nxt_uint_t count);
-void nxt_conf_set_member(nxt_conf_value_t *object, nxt_str_t *name,
+void nxt_conf_set_member(nxt_conf_value_t *object, const nxt_str_t *name,
const nxt_conf_value_t *value, uint32_t index);
nxt_int_t nxt_conf_set_member_dup(nxt_conf_value_t *object, nxt_mp_t *mp,
- nxt_str_t *name, nxt_conf_value_t *value, uint32_t index);
-void nxt_conf_set_member_string(nxt_conf_value_t *object, nxt_str_t *name,
- nxt_str_t *value, uint32_t index);
-nxt_int_t nxt_conf_set_member_string_dup(nxt_conf_value_t *object, nxt_mp_t *mp,
- nxt_str_t *name, nxt_str_t *value, uint32_t index);
-void nxt_conf_set_member_integer(nxt_conf_value_t *object, nxt_str_t *name,
- int64_t value, uint32_t index);
-void nxt_conf_set_member_null(nxt_conf_value_t *object, nxt_str_t *name,
+ const nxt_str_t *name, const nxt_conf_value_t *value, uint32_t index);
+void nxt_conf_set_member_string(nxt_conf_value_t *object,
+ const nxt_str_t *name, const nxt_str_t *value, uint32_t index);
+nxt_int_t nxt_conf_set_member_string_dup(nxt_conf_value_t *object,
+ nxt_mp_t *mp, const nxt_str_t *name, const nxt_str_t *value,
+ uint32_t index);
+void nxt_conf_set_member_integer(nxt_conf_value_t *object,
+ const nxt_str_t *name, int64_t value, uint32_t index);
+void nxt_conf_set_member_null(nxt_conf_value_t *object, const nxt_str_t *name,
uint32_t index);
nxt_conf_value_t *nxt_conf_create_array(nxt_mp_t *mp, nxt_uint_t count);
void nxt_conf_set_element(nxt_conf_value_t *array, nxt_uint_t index,
const nxt_conf_value_t *value);
-nxt_int_t nxt_conf_set_element_string_dup(nxt_conf_value_t *array, nxt_mp_t *mp,
- nxt_uint_t index, nxt_str_t *value);
-NXT_EXPORT nxt_uint_t nxt_conf_array_elements_count(nxt_conf_value_t *value);
+nxt_int_t nxt_conf_set_element_string_dup(nxt_conf_value_t *array,
+ nxt_mp_t *mp, nxt_uint_t index, const nxt_str_t *value);
+NXT_EXPORT nxt_uint_t nxt_conf_array_elements_count(
+ const nxt_conf_value_t *value);
NXT_EXPORT nxt_uint_t nxt_conf_array_elements_count_or_1(
- nxt_conf_value_t *value);
-void nxt_conf_array_qsort(nxt_conf_value_t *value,
+ const nxt_conf_value_t *value);
+void nxt_conf_array_qsort(const nxt_conf_value_t *value,
int (*compare)(const void *, const void *));