]> git.ipfire.org Git - thirdparty/FORT-validator.git/commitdiff
Change rsync.priority's config data type to uint
authorAlberto Leiva Popper <ydahhrk@gmail.com>
Thu, 29 Jun 2023 20:47:16 +0000 (14:47 -0600)
committerAlberto Leiva Popper <ydahhrk@gmail.com>
Thu, 29 Jun 2023 20:47:16 +0000 (14:47 -0600)
It was using uint32, even though it was declared as an unsigned int.

This orphans uint32, so purged.

src/Makefile.am
src/config.c
src/config/string_array.c
src/config/string_array.h
src/config/uint.c
src/config/uint.h
src/config/uint32.c [deleted file]
src/config/uint32.h [deleted file]

index 2dc0519dd7f7fa8955a54425a6873f71fce2436f..120f4385a6005d67906268f622dd643f8aad0253 100644 (file)
@@ -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
index 7900c43803397b15eab241f8108b60cb61114e9b..ab103a2dc111cd67eec51bb660ee4416991a65ef 100644 (file)
@@ -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 = &gt_uint32, /* TODO (#78) this is not u32 */
+               .type = &gt_uint,
                .offset = offsetof(struct rpki_config, rsync.priority),
                .doc = "Priority of execution to fetch repositories files, a higher value means higher priority",
                .min = 0,
index f61484a9250c34ea160c641ce1e47fe922922da9..fde9393d95cf6f79aa676365ae119fcafdcd8a96 100644 (file)
@@ -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;
 }
index 90bbf994ac7ced9de13050e8b3d2ab415e7fc901..65f9c9e107cf65eedd611a48c49ddb7ca71d0f36 100644 (file)
@@ -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_ */
index 6eba6524094c44a952cc57ac7b6bb988537670cf..c3dad8584e5a76defc048121a56d58c06ea2dd3c 100644 (file)
@@ -6,13 +6,13 @@
 #include <string.h>
 #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;
index 61c793588abd2f952c29cd8ccf6cec153cdf3591..4e1b619c37f40321503a7cdfd7f993bbbe0187bd 100644 (file)
@@ -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 (file)
index cbd8259..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-#include "config/uint32.h"
-
-#include <getopt.h>
-#include <errno.h>
-#include <stdlib.h>
-
-#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 (file)
index 7878e4a..0000000
+++ /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_ */