From c6e09500c82fccec09527ec375f314cf24fdef8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20K=C3=A4stle?= <12514511+RincewindsHat@users.noreply.github.com> Date: Thu, 31 Oct 2024 14:21:55 +0100 Subject: negate: style + linter fixes diff --git a/plugins/negate.c b/plugins/negate.c index 82a5548..7e52fe6 100644 --- a/plugins/negate.c +++ b/plugins/negate.c @@ -41,10 +41,8 @@ const char *email = "devel@monitoring-plugins.org"; #include -/* char *command_line; */ - -static const char **process_arguments(int, char **); -static void validate_arguments(char **); +static const char **process_arguments(int /*argc*/, char ** /*argv*/); +static void validate_arguments(char ** /*command_line*/); static void print_help(void); void print_usage(void); static bool subst_text = false; @@ -57,18 +55,13 @@ static int state[4] = { }; int main(int argc, char **argv) { - int result = STATE_UNKNOWN; - char *sub; - char **command_line; - output chld_out, chld_err; - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); timeout_interval = DEFAULT_TIMEOUT; - command_line = (char **)process_arguments(argc, argv); + char **command_line = (char **)process_arguments(argc, argv); /* Set signal handling and alarm */ if (signal(SIGALRM, timeout_alarm_handler) == SIG_ERR) @@ -76,6 +69,10 @@ int main(int argc, char **argv) { (void)alarm((unsigned)timeout_interval); + int result = STATE_UNKNOWN; + output chld_out; + output chld_err; + /* catch when the command is quoted */ if (command_line[1] == NULL) { result = cmd_run(command_line[0], &chld_out, &chld_err, 0); @@ -92,6 +89,7 @@ int main(int argc, char **argv) { if (chld_out.lines == 0) die(max_state_alt(result, STATE_UNKNOWN), _("No data returned from command\n")); + char *sub; for (size_t i = 0; i < chld_out.lines; i++) { if (subst_text && result >= 0 && result <= 4 && result != state[result]) { /* Loop over each match found */ @@ -115,23 +113,21 @@ int main(int argc, char **argv) { /* process command-line arguments */ static const char **process_arguments(int argc, char **argv) { - int c; - bool permute = true; - - int option = 0; static struct option longopts[] = {{"help", no_argument, 0, 'h'}, {"version", no_argument, 0, 'V'}, {"timeout", required_argument, 0, 't'}, {"timeout-result", required_argument, 0, 'T'}, {"ok", required_argument, 0, 'o'}, {"warning", required_argument, 0, 'w'}, {"critical", required_argument, 0, 'c'}, {"unknown", required_argument, 0, 'u'}, {"substitute", no_argument, 0, 's'}, {0, 0, 0, 0}}; - while (1) { - c = getopt_long(argc, argv, "+hVt:T:o:w:c:u:s", longopts, &option); + bool permute = true; + while (true) { + int option = 0; + int option_char = getopt_long(argc, argv, "+hVt:T:o:w:c:u:s", longopts, &option); - if (c == -1 || c == EOF) + if (option_char == -1 || option_char == EOF) break; - switch (c) { + switch (option_char) { case '?': /* help */ usage5(); break; -- cgit v0.10-9-g596f