From: Florian Forster Date: Mon, 28 Nov 2016 21:23:24 +0000 (+0100) Subject: Even more renormalization. X-Git-Tag: collectd-5.7.0~8 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=6c17c8ccba745714c4d7cc10dc3ca57f2d0d293f;p=collectd.git Even more renormalization. --- diff --git a/src/utils_cmds.h b/src/utils_cmds.h index 205e89a0..26d5338d 100644 --- a/src/utils_cmds.h +++ b/src/utils_cmds.h @@ -32,44 +32,46 @@ #include typedef enum { - CMD_UNKNOWN = 0, - CMD_FLUSH = 1, - CMD_GETVAL = 2, - CMD_LISTVAL = 3, - CMD_PUTVAL = 4, + CMD_UNKNOWN = 0, + CMD_FLUSH = 1, + CMD_GETVAL = 2, + CMD_LISTVAL = 3, + CMD_PUTVAL = 4, } cmd_type_t; -#define CMD_TO_STRING(type) \ - ((type) == CMD_FLUSH) ? "FLUSH" \ - : ((type) == CMD_GETVAL) ? "GETVAL" \ - : ((type) == CMD_LISTVAL) ? "LISTVAL" \ - : ((type) == CMD_PUTVAL) ? "PUTVAL" \ - : "UNKNOWN" +#define CMD_TO_STRING(type) \ + ((type) == CMD_FLUSH) ? "FLUSH" : ((type) == CMD_GETVAL) \ + ? "GETVAL" \ + : ((type) == CMD_LISTVAL) \ + ? "LISTVAL" \ + : ((type) == CMD_PUTVAL) \ + ? "PUTVAL" \ + : "UNKNOWN" typedef struct { - double timeout; + double timeout; - char **plugins; - size_t plugins_num; - identifier_t *identifiers; - size_t identifiers_num; + char **plugins; + size_t plugins_num; + identifier_t *identifiers; + size_t identifiers_num; } cmd_flush_t; typedef struct { - char *raw_identifier; - identifier_t identifier; + char *raw_identifier; + identifier_t identifier; } cmd_getval_t; typedef struct { } cmd_listval_t; typedef struct { - /* The raw identifier as provided by the user. */ - char *raw_identifier; + /* The raw identifier as provided by the user. */ + char *raw_identifier; - /* An array of the fully parsed identifier and all value lists, and their - * options as provided by the user. */ - value_list_t *vl; - size_t vl_num; + /* An array of the fully parsed identifier and all value lists, and their + * options as provided by the user. */ + value_list_t *vl; + size_t vl_num; } cmd_putval_t; /* @@ -80,13 +82,13 @@ typedef struct { * The representation of a fully parsed command. */ typedef struct { - cmd_type_t type; - union { - cmd_flush_t flush; - cmd_getval_t getval; - cmd_listval_t listval; - cmd_putval_t putval; - } cmd; + cmd_type_t type; + union { + cmd_flush_t flush; + cmd_getval_t getval; + cmd_listval_t listval; + cmd_putval_t putval; + } cmd; } cmd_t; /* @@ -97,9 +99,9 @@ typedef struct { * Optional settings for tuning the parser behavior. */ typedef struct { - /* identifier_default_host: If non-NULL, the hostname is optional and will - * default to the specified value. */ - char *identifier_default_host; + /* identifier_default_host: If non-NULL, the hostname is optional and will + * default to the specified value. */ + char *identifier_default_host; } cmd_options_t; /* @@ -110,13 +112,13 @@ typedef struct { * Status codes describing the parse result. */ typedef enum { - CMD_OK = 0, - CMD_ERROR = -1, - CMD_PARSE_ERROR = -2, - CMD_UNKNOWN_COMMAND = -3, + CMD_OK = 0, + CMD_ERROR = -1, + CMD_PARSE_ERROR = -2, + CMD_UNKNOWN_COMMAND = -3, - /* Not necessarily fatal errors. */ - CMD_NO_OPTION = 1, + /* Not necessarily fatal errors. */ + CMD_NO_OPTION = 1, } cmd_status_t; /* @@ -129,8 +131,8 @@ typedef enum { * as the first argument. */ typedef struct { - void (*cb) (void *, cmd_status_t, const char *, va_list); - void *ud; + void (*cb)(void *, cmd_status_t, const char *, va_list); + void *ud; } cmd_error_handler_t; /* @@ -140,8 +142,8 @@ typedef struct { * DESCRIPTION * Reports an error via the specified error handler (if set). */ -void cmd_error (cmd_status_t status, cmd_error_handler_t *err, - const char *format, ...); +void cmd_error(cmd_status_t status, cmd_error_handler_t *err, + const char *format, ...); /* * NAME @@ -159,13 +161,13 @@ void cmd_error (cmd_status_t status, cmd_error_handler_t *err, * RETURN VALUE * CMD_OK on success or the respective error code otherwise. */ -cmd_status_t cmd_parse (char *buffer, cmd_t *ret_cmd, - const cmd_options_t *opts, cmd_error_handler_t *err); +cmd_status_t cmd_parse(char *buffer, cmd_t *ret_cmd, const cmd_options_t *opts, + cmd_error_handler_t *err); -cmd_status_t cmd_parsev (size_t argc, char **argv, cmd_t *ret_cmd, - const cmd_options_t *opts, cmd_error_handler_t *err); +cmd_status_t cmd_parsev(size_t argc, char **argv, cmd_t *ret_cmd, + const cmd_options_t *opts, cmd_error_handler_t *err); -void cmd_destroy (cmd_t *cmd); +void cmd_destroy(cmd_t *cmd); /* * NAME @@ -186,8 +188,8 @@ void cmd_destroy (cmd_t *cmd); * CMD_NO_OPTION if `field' does not represent an option at all (missing * equal sign). */ -cmd_status_t cmd_parse_option (char *field, - char **ret_key, char **ret_value, cmd_error_handler_t *err); +cmd_status_t cmd_parse_option(char *field, char **ret_key, char **ret_value, + cmd_error_handler_t *err); /* * NAME @@ -205,7 +207,7 @@ cmd_status_t cmd_parse_option (char *field, * `ap' Variable argument list providing the arguments for the format * string. */ -void cmd_error_fh (void *ud, cmd_status_t status, - const char *format, va_list ap); +void cmd_error_fh(void *ud, cmd_status_t status, const char *format, + va_list ap); #endif /* UTILS_CMDS_H */ diff --git a/src/utils_format_graphite_test.c b/src/utils_format_graphite_test.c index f349db1f..415a283e 100644 --- a/src/utils_format_graphite_test.c +++ b/src/utils_format_graphite_test.c @@ -26,9 +26,9 @@ #include "collectd.h" +#include "common.h" /* for STATIC_ARRAY_SIZE */ #include "testing.h" #include "utils_format_graphite.h" -#include "common.h" /* for STATIC_ARRAY_SIZE */ static data_set_t ds_single = { .type = "single", @@ -47,8 +47,7 @@ static data_set_t ds_double = { }; */ -DEF_TEST(metric_name) -{ +DEF_TEST(metric_name) { struct { char *plugin_instance; char *type_instance; @@ -57,105 +56,108 @@ DEF_TEST(metric_name) unsigned int flags; char *want_name; } cases[] = { - { - .want_name = "example@com.test.single", - }, - /* plugin and type instances */ - { - .plugin_instance = "foo", - .type_instance = "bar", - .want_name = "example@com.test-foo.single-bar", - }, - { - .plugin_instance = NULL, - .type_instance = "bar", - .want_name = "example@com.test.single-bar", - }, - { - .plugin_instance = "foo", - .type_instance = NULL, - .want_name = "example@com.test-foo.single", - }, - /* special chars */ - { - .plugin_instance = "foo (test)", - .type_instance = "test: \"hello\"", - .want_name = "example@com.test-foo@@test@.single-test@@@hello@", - }, - /* flag GRAPHITE_SEPARATE_INSTANCES */ - { - .plugin_instance = "foo", - .type_instance = "bar", - .flags = GRAPHITE_SEPARATE_INSTANCES, - .want_name = "example@com.test.foo.single.bar", - }, - /* flag GRAPHITE_ALWAYS_APPEND_DS */ - { - .plugin_instance = "foo", - .type_instance = "bar", - .flags = GRAPHITE_ALWAYS_APPEND_DS, - .want_name = "example@com.test-foo.single-bar.value", - }, - /* flag GRAPHITE_PRESERVE_SEPARATOR */ - { - .plugin_instance = "f.o.o", - .type_instance = "b.a.r", - .flags = 0, - .want_name = "example@com.test-f@o@o.single-b@a@r", - }, - { - .plugin_instance = "f.o.o", - .type_instance = "b.a.r", - .flags = GRAPHITE_PRESERVE_SEPARATOR, - .want_name = "example.com.test-f.o.o.single-b.a.r", - }, - /* prefix and suffix */ - { - .prefix = "foo.", - .suffix = ".bar", - .want_name = "foo.example@com.bar.test.single", - }, - { - .prefix = NULL, - .suffix = ".bar", - .want_name = "example@com.bar.test.single", - }, - { - .prefix = "foo.", - .suffix = NULL, - .want_name = "foo.example@com.test.single", - }, + { + .want_name = "example@com.test.single", + }, + /* plugin and type instances */ + { + .plugin_instance = "foo", + .type_instance = "bar", + .want_name = "example@com.test-foo.single-bar", + }, + { + .plugin_instance = NULL, + .type_instance = "bar", + .want_name = "example@com.test.single-bar", + }, + { + .plugin_instance = "foo", + .type_instance = NULL, + .want_name = "example@com.test-foo.single", + }, + /* special chars */ + { + .plugin_instance = "foo (test)", + .type_instance = "test: \"hello\"", + .want_name = "example@com.test-foo@@test@.single-test@@@hello@", + }, + /* flag GRAPHITE_SEPARATE_INSTANCES */ + { + .plugin_instance = "foo", + .type_instance = "bar", + .flags = GRAPHITE_SEPARATE_INSTANCES, + .want_name = "example@com.test.foo.single.bar", + }, + /* flag GRAPHITE_ALWAYS_APPEND_DS */ + { + .plugin_instance = "foo", + .type_instance = "bar", + .flags = GRAPHITE_ALWAYS_APPEND_DS, + .want_name = "example@com.test-foo.single-bar.value", + }, + /* flag GRAPHITE_PRESERVE_SEPARATOR */ + { + .plugin_instance = "f.o.o", + .type_instance = "b.a.r", + .flags = 0, + .want_name = "example@com.test-f@o@o.single-b@a@r", + }, + { + .plugin_instance = "f.o.o", + .type_instance = "b.a.r", + .flags = GRAPHITE_PRESERVE_SEPARATOR, + .want_name = "example.com.test-f.o.o.single-b.a.r", + }, + /* prefix and suffix */ + { + .prefix = "foo.", + .suffix = ".bar", + .want_name = "foo.example@com.bar.test.single", + }, + { + .prefix = NULL, + .suffix = ".bar", + .want_name = "example@com.bar.test.single", + }, + { + .prefix = "foo.", + .suffix = NULL, + .want_name = "foo.example@com.test.single", + }, }; for (size_t i = 0; i < STATIC_ARRAY_SIZE(cases); i++) { value_list_t vl = { - .values = &(value_t){.gauge = 42}, - .values_len = 1, - .time = TIME_T_TO_CDTIME_T_STATIC(1480063672), - .interval = TIME_T_TO_CDTIME_T_STATIC(10), - .host = "example.com", - .plugin = "test", - .type = "single", + .values = &(value_t){.gauge = 42}, + .values_len = 1, + .time = TIME_T_TO_CDTIME_T_STATIC(1480063672), + .interval = TIME_T_TO_CDTIME_T_STATIC(10), + .host = "example.com", + .plugin = "test", + .type = "single", }; char want[1024]; snprintf(want, sizeof(want), "%s 42 1480063672\r\n", cases[i].want_name); if (cases[i].plugin_instance != NULL) - sstrncpy (vl.plugin_instance, cases[i].plugin_instance, sizeof (vl.plugin_instance)); + sstrncpy(vl.plugin_instance, cases[i].plugin_instance, + sizeof(vl.plugin_instance)); if (cases[i].type_instance != NULL) - sstrncpy (vl.type_instance, cases[i].type_instance, sizeof (vl.type_instance)); + sstrncpy(vl.type_instance, cases[i].type_instance, + sizeof(vl.type_instance)); char got[1024]; - EXPECT_EQ_INT(0, format_graphite(got, sizeof(got), &ds_single, &vl, cases[i].prefix, cases[i].suffix, '@', cases[i].flags)); + EXPECT_EQ_INT(0, format_graphite(got, sizeof(got), &ds_single, &vl, + cases[i].prefix, cases[i].suffix, '@', + cases[i].flags)); EXPECT_EQ_STR(want, got); } return 0; } -int main (void) -{ +int main(void) { RUN_TEST(metric_name); END_TEST; diff --git a/src/utils_mount.c b/src/utils_mount.c index 660e0852..87f26df0 100644 --- a/src/utils_mount.c +++ b/src/utils_mount.c @@ -527,7 +527,7 @@ static cu_mount_t *cu_mount_gen_getmntent(void) { return (first); } /* static cu_mount_t *cu_mount_gen_getmntent (void) */ - /* #endif HAVE_TWO_GETMNTENT || HAVE_GEN_GETMNTENT || HAVE_SUN_GETMNTENT */ +/* #endif HAVE_TWO_GETMNTENT || HAVE_GEN_GETMNTENT || HAVE_SUN_GETMNTENT */ #elif HAVE_SEQ_GETMNTENT #warn "This version of `getmntent' hat not yet been implemented!"