From bb311892b58a931dff8215f1f037b91ee8ef31c4 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Tue, 19 Sep 2017 14:47:49 +0900 Subject: [PATCH] Remove unused code --- repmgr-action-standby.c | 140 ---------------------------------------- 1 file changed, 140 deletions(-) diff --git a/repmgr-action-standby.c b/repmgr-action-standby.c index ecf6c76d..903dff7b 100644 --- a/repmgr-action-standby.c +++ b/repmgr-action-standby.c @@ -102,7 +102,6 @@ static bool write_recovery_file_line(FILE *recovery_file, char *recovery_file_pa static NodeStatus parse_node_status_is_shutdown_cleanly(const char *node_status_output, XLogRecPtr *checkPoint); static CheckStatus parse_node_check_archiver(const char *node_check_output, int *files, int *threshold); -static CheckStatus parse_node_check_replication_lag(const char *node_check_output, int *seconds, int *threshold); /* * STANDBY CLONE @@ -5282,145 +5281,6 @@ parse_node_check_archiver(const char *node_check_output, int *files, int *thresh -static CheckStatus -parse_node_check_replication_lag(const char *node_check_output, int *seconds, int *threshold) -{ - int options_len = 0; - char *options_string = NULL; - char *options_string_ptr = NULL; - - CheckStatus status = CHECK_STATUS_UNKNOWN; - - - /* - * Add parsed options to this list, then copy to an array to pass to - * getopt - */ - static ItemList option_argv = {NULL, NULL}; - - char *argv_item; - int c, - argc_item = 1; - - char **argv_array; - ItemListCell *cell; - - int optindex = 0; - - /* We're only interested in these options */ - static struct option long_options[] = - { - {"status", required_argument, NULL, 'S'}, - {"lag", required_argument, NULL, 'l'}, - {"threshold", required_argument, NULL, 't'}, - {NULL, 0, NULL, 0} - }; - - *seconds = 0; - *threshold = 0; - - /* Don't attempt to tokenise an empty string */ - if (!strlen(node_check_output)) - { - return status; - } - - options_len = strlen(node_check_output) + 1; - options_string = pg_malloc(options_len); - options_string_ptr = options_string; - - /* Copy the string before operating on it with strtok() */ - strncpy(options_string, node_check_output, options_len); - - /* Extract arguments into a list and keep a count of the total */ - while ((argv_item = strtok(options_string_ptr, " ")) != NULL) - { - item_list_append(&option_argv, argv_item); - - argc_item++; - - if (options_string_ptr != NULL) - options_string_ptr = NULL; - } - - /* - * Array of argument values to pass to getopt_long - this will need to - * include an empty string as the first value (normally this would be the - * program name) - */ - argv_array = pg_malloc0(sizeof(char *) * (argc_item + 2)); - - /* Insert a blank dummy program name at the start of the array */ - argv_array[0] = pg_malloc0(1); - - c = 1; - - /* - * Copy the previously extracted arguments from our list to the array - */ - for (cell = option_argv.head; cell; cell = cell->next) - { - int argv_len = strlen(cell->string) + 1; - - argv_array[c] = pg_malloc0(argv_len); - - strncpy(argv_array[c], cell->string, argv_len); - - c++; - } - - argv_array[c] = NULL; - - /* Reset getopt's optind variable */ - optind = 0; - - /* Prevent getopt from emitting errors */ - opterr = 0; - - while ((c = getopt_long(argc_item, argv_array, "l:S:t:", long_options, - &optindex)) != -1) - { - switch (c) - { - /* --files */ - case 'l': - *seconds = atoi(optarg); - break; - - case 't': - *threshold = atoi(optarg); - break; - - /* --status */ - case 'S': - { - if (strncmp(optarg, "OK", MAXLEN) == 0) - { - status = CHECK_STATUS_OK; - } - else if (strncmp(optarg, "WARNING", MAXLEN) == 0) - { - status = CHECK_STATUS_WARNING; - } - else if (strncmp(optarg, "CRITICAL", MAXLEN) == 0) - { - status = CHECK_STATUS_CRITICAL; - } - else if (strncmp(optarg, "UNKNOWN", MAXLEN) == 0) - { - status = CHECK_STATUS_UNKNOWN; - } - else - { - status = CHECK_STATUS_UNKNOWN; - } - } - break; - } - } - - return status; -} void