From: Alberto Leiva Popper Date: Thu, 29 Jun 2023 20:47:16 +0000 (-0600) Subject: Change rsync.priority's config data type to uint X-Git-Tag: 1.6.0~80^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c01e2e932e30ddbc25c4ab65bc1f2b5674667590;p=thirdparty%2FFORT-validator.git Change rsync.priority's config data type to uint It was using uint32, even though it was declared as an unsigned int. This orphans uint32, so purged. --- diff --git a/src/Makefile.am b/src/Makefile.am index 2dc0519d..120f4385 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -60,7 +60,6 @@ fort_SOURCES += config/str.c config/str.h fort_SOURCES += config/string_array.h config/string_array.c fort_SOURCES += config/types.h fort_SOURCES += config/uint.c config/uint.h -fort_SOURCES += config/uint32.c config/uint32.h fort_SOURCES += config/work_offline.c config/work_offline.h fort_SOURCES += crypto/base64.h crypto/base64.c diff --git a/src/config.c b/src/config.c index 7900c438..ab103a2d 100644 --- a/src/config.c +++ b/src/config.c @@ -21,7 +21,6 @@ #include "config/init_tals.h" #include "config/str.h" #include "config/uint.h" -#include "config/uint32.h" #include "config/work_offline.h" /** @@ -440,7 +439,7 @@ static const struct option_field options[] = { }, { .id = 3001, .name = "rsync.priority", - .type = >_uint32, /* TODO (#78) this is not u32 */ + .type = >_uint, .offset = offsetof(struct rpki_config, rsync.priority), .doc = "Priority of execution to fetch repositories files, a higher value means higher priority", .min = 0, diff --git a/src/config/string_array.c b/src/config/string_array.c index f61484a9..fde9393d 100644 --- a/src/config/string_array.c +++ b/src/config/string_array.c @@ -28,19 +28,15 @@ string_array_init(struct string_array *array, char const *const *values, array->array[i] = pstrdup(values[i]); } -void -string_array_cleanup(struct string_array *array) +static void +__string_array_free(struct string_array *array) { size_t i; + for (i = 0; i < array->length; i++) free(array->array[i]); free(array->array); -} -static void -__string_array_free(struct string_array *array) -{ - string_array_cleanup(array); array->array = NULL; array->length = 0; } diff --git a/src/config/string_array.h b/src/config/string_array.h index 90bbf994..65f9c9e1 100644 --- a/src/config/string_array.h +++ b/src/config/string_array.h @@ -13,6 +13,5 @@ struct string_array { extern const struct global_type gt_string_array; void string_array_init(struct string_array *, char const *const *, size_t); -void string_array_cleanup(struct string_array *); #endif /* SRC_CONFIG_STRING_ARRAY_H_ */ diff --git a/src/config/uint.c b/src/config/uint.c index 6eba6524..c3dad858 100644 --- a/src/config/uint.c +++ b/src/config/uint.c @@ -6,13 +6,13 @@ #include #include "log.h" -void +static void print_uint(struct option_field const *field, void *value) { pr_op_info("%s: %u", field->name, *((unsigned int *) value)); } -int +static int parse_argv_uint(struct option_field const *field, char const *str, void *result) { @@ -46,7 +46,7 @@ parse_argv_uint(struct option_field const *field, char const *str, return 0; } -int +static int parse_json_uint(struct option_field const *opt, json_t *json, void *result) { json_int_t value; diff --git a/src/config/uint.h b/src/config/uint.h index 61c79358..4e1b619c 100644 --- a/src/config/uint.h +++ b/src/config/uint.h @@ -5,8 +5,4 @@ extern const struct global_type gt_uint; -void print_uint(struct option_field const *, void *); -int parse_argv_uint(struct option_field const *, char const *, void *); -int parse_json_uint(struct option_field const *, struct json_t *, void *); - #endif /* SRC_CONFIG_UINT_H_ */ diff --git a/src/config/uint32.c b/src/config/uint32.c deleted file mode 100644 index cbd82592..00000000 --- a/src/config/uint32.c +++ /dev/null @@ -1,54 +0,0 @@ -#include "config/uint32.h" - -#include -#include -#include - -#include "log.h" -#include "config/uint.h" - -void -print_uint32(struct option_field const *field, void *value) -{ - pr_op_info("%s: %u", field->name, *((uint32_t *) value)); -} - -int -parse_argv_uint32(struct option_field const *field, char const *str, - void *result) -{ - unsigned int tmp; - int error; - - error = parse_argv_uint(field, str, &tmp); - if (error) - return error; - - /* Range already validated (from field->min and field->max). */ - *((uint32_t *) result) = tmp; - return 0; -} - -int -parse_json_uint32(struct option_field const *opt, json_t *json, void *result) -{ - unsigned int tmp; - int error; - - error = parse_json_uint(opt, json, &tmp); - if (error) - return error; - - /* Range already validated (from opt->min and opt->max). */ - *((uint32_t *) result) = tmp; - return 0; -} - -const struct global_type gt_uint32 = { - .has_arg = required_argument, - .size = sizeof(uint32_t), - .print = print_uint32, - .parse.argv = parse_argv_uint32, - .parse.json = parse_json_uint32, - .arg_doc = "<32-bit unsigned integer>", -}; diff --git a/src/config/uint32.h b/src/config/uint32.h deleted file mode 100644 index 7878e4a0..00000000 --- a/src/config/uint32.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef SRC_CONFIG_UINT32_H_ -#define SRC_CONFIG_UINT32_H_ - -#include "config/types.h" - -extern const struct global_type gt_uint32; - -void print_uint32(struct option_field const *, void *); -int parse_argv_uint32(struct option_field const *, char const *, void *); -int parse_json_uint32(struct option_field const *, json_t *, void *); - -#endif /* SRC_CONFIG_UINT32_H_ */