From 2f29f45e10364f50f70a8d3fce9f1fe965527a68 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Wed, 18 Oct 2023 16:12:41 +0200 Subject: check_by_ssh: Use C99 booleans diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c index 1ad547e..1f5f72d 100644 --- a/plugins/check_by_ssh.c +++ b/plugins/check_by_ssh.c @@ -50,7 +50,7 @@ unsigned int services = 0; int skip_stdout = 0; int skip_stderr = 0; int warn_on_stderr = 0; -bool unknown_timeout = FALSE; +bool unknown_timeout = false; char *remotecmd = NULL; char **commargv = NULL; int commargc = 0; @@ -58,8 +58,8 @@ char *hostname = NULL; char *outputfile = NULL; char *host_shortname = NULL; char **service; -int passive = FALSE; -int verbose = FALSE; +bool passive = false; +bool verbose = false; int main (int argc, char **argv) @@ -235,7 +235,7 @@ process_arguments (int argc, char **argv) print_help (); exit (STATE_UNKNOWN); case 'v': /* help */ - verbose = TRUE; + verbose = true; break; case 't': /* timeout period */ if (!is_integer (optarg)) @@ -244,7 +244,7 @@ process_arguments (int argc, char **argv) timeout_interval = atoi (optarg); break; case 'U': - unknown_timeout = TRUE; + unknown_timeout = true; break; case 'H': /* host */ hostname = optarg; @@ -257,7 +257,7 @@ process_arguments (int argc, char **argv) break; case 'O': /* output file */ outputfile = optarg; - passive = TRUE; + passive = true; break; case 's': /* description of service to check */ p1 = optarg; -- cgit v0.10-9-g596f From bafe2c2ceb522f74f22104c8cebe62b177ff46e4 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Wed, 18 Oct 2023 16:14:01 +0200 Subject: check_dig: Use C99 booleans diff --git a/plugins/check_dig.c b/plugins/check_dig.c index 5d85ae2..be7a610 100644 --- a/plugins/check_dig.c +++ b/plugins/check_dig.c @@ -56,7 +56,7 @@ char *expected_address = NULL; char *dns_server = NULL; char *dig_args = ""; char *query_transport = ""; -int verbose = FALSE; +bool verbose = false; int server_port = DEFAULT_PORT; int number_tries = DEFAULT_TRIES; double warning_interval = UNDEFINED; @@ -176,11 +176,11 @@ main (int argc, char **argv) state_text (result), elapsed_time, msg ? msg : _("Probably a non-existent host/domain"), fperfdata("time", elapsed_time, "s", - (warning_interval>UNDEFINED?TRUE:FALSE), + (warning_interval>UNDEFINED ? true:false), warning_interval, - (critical_interval>UNDEFINED?TRUE:FALSE), + (critical_interval>UNDEFINED ? true:false), critical_interval, - TRUE, 0, FALSE, 0)); + true, 0, false, 0)); return result; } @@ -270,7 +270,7 @@ process_arguments (int argc, char **argv) dig_args = strdup(optarg); break; case 'v': /* verbose */ - verbose = TRUE; + verbose = true; break; case 'T': record_type = optarg; -- cgit v0.10-9-g596f From b6796d9172717a7dd718522b8f461a1452372a96 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Wed, 18 Oct 2023 16:16:44 +0200 Subject: check_disk: Use C99 booleans diff --git a/plugins/check_disk.c b/plugins/check_disk.c index 2f066c7..a4180ca 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c @@ -135,12 +135,12 @@ char *exclude_device; char *units; uintmax_t mult = 1024 * 1024; int verbose = 0; -int erronly = FALSE; -int display_mntp = FALSE; -int exact_match = FALSE; +bool erronly = false; +bool display_mntp = false; +bool exact_match = false; bool ignore_missing = false; -int freespace_ignore_reserved = FALSE; -int display_inodes_perfdata = FALSE; +bool freespace_ignore_reserved = false; +bool display_inodes_perfdata = false; char *warn_freespace_units = NULL; char *crit_freespace_units = NULL; char *warn_freespace_percent = NULL; @@ -153,7 +153,7 @@ char *warn_usedinodes_percent = NULL; char *crit_usedinodes_percent = NULL; char *warn_freeinodes_percent = NULL; char *crit_freeinodes_percent = NULL; -int path_selected = FALSE; +bool path_selected = false; bool path_ignored = false; char *group = NULL; struct stat *stat_buf; @@ -205,7 +205,7 @@ main (int argc, char **argv) /* If a list of paths has not been selected, find entire mount list and create list of paths */ - if (path_selected == FALSE && path_ignored == false) { + if (path_selected == false && path_ignored == false) { for (me = mount_list; me; me = me->me_next) { if (! (path = np_find_parameter(path_select_list, me->me_mountdir))) { path = np_add_parameter(&path_select_list, me->me_mountdir); @@ -396,10 +396,10 @@ main (int argc, char **argv) perfdata_uint64 ( (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir, path->dused_units * mult, "B", - (warning_high_tide == UINT64_MAX ? FALSE : TRUE), warning_high_tide, - (critical_high_tide == UINT64_MAX ? FALSE : TRUE), critical_high_tide, - TRUE, 0, - TRUE, path->dtotal_units * mult)); + (warning_high_tide == UINT64_MAX ? false : true), warning_high_tide, + (critical_high_tide == UINT64_MAX ? false : true), critical_high_tide, + true, 0, + true, path->dtotal_units * mult)); if (display_inodes_perfdata) { /* *_high_tide must be reinitialized at each run */ @@ -418,10 +418,10 @@ main (int argc, char **argv) xasprintf (&perf, "%s %s", perf, perfdata_uint64 (perf_ilabel, path->inodes_used, "", - (warning_high_tide != UINT64_MAX ? TRUE : FALSE), warning_high_tide, - (critical_high_tide != UINT64_MAX ? TRUE : FALSE), critical_high_tide, - TRUE, 0, - TRUE, path->inodes_total)); + (warning_high_tide != UINT64_MAX ? true : false), warning_high_tide, + (critical_high_tide != UINT64_MAX ? true : false), critical_high_tide, + true, 0, + true, path->inodes_total)); } if (disk_result==STATE_OK && erronly && !verbose) @@ -710,7 +710,7 @@ process_arguments (int argc, char **argv) mount_list = read_file_system_list (0); np_set_best_match(se, mount_list, exact_match); - path_selected = TRUE; + path_selected = true; break; case 'x': /* exclude path or partition */ np_add_name(&dp_exclude_list, optarg); @@ -734,18 +734,18 @@ process_arguments (int argc, char **argv) break; case 'q': /* TODO: this function should eventually go away (removed 2007-09-20) */ /* verbose--; **replaced by line below**. -q was only a broken way of implementing -e */ - erronly = TRUE; + erronly = true; break; case 'e': - erronly = TRUE; + erronly = true; break; case 'E': if (path_selected) die (STATE_UNKNOWN, "DISK %s: %s", _("UNKNOWN"), _("Must set -E before selecting paths\n")); - exact_match = TRUE; + exact_match = true; break; case 'f': - freespace_ignore_reserved = TRUE; + freespace_ignore_reserved = true; break; case 'g': if (path_selected) @@ -817,7 +817,7 @@ process_arguments (int argc, char **argv) for (me = mount_list; me; me = me->me_next) { if (np_regex_match_mount_entry(me, &re)) { - fnd = TRUE; + fnd = true; if (verbose >= 3) printf("%s %s matching expression %s\n", me->me_devname, me->me_mountdir, optarg); @@ -832,24 +832,24 @@ process_arguments (int argc, char **argv) if (!fnd && ignore_missing == true) { path_ignored = true; - /* path_selected = TRUE;*/ + /* path_selected = true;*/ break; } else if (!fnd) die (STATE_UNKNOWN, "DISK %s: %s - %s\n",_("UNKNOWN"), _("Regular expression did not match any path or disk"), optarg); - fnd = FALSE; - path_selected = TRUE; + fnd = false; + path_selected = true; np_set_best_match(path_select_list, mount_list, exact_match); cflags = default_cflags; break; case 'M': /* display mountpoint */ - display_mntp = TRUE; + display_mntp = true; break; case 'C': /* add all mount entries to path_select list if no partitions have been explicitly defined using -p */ - if (path_selected == FALSE) { + if (path_selected == false) { struct parameter_list *path; for (me = mount_list; me; me = me->me_next) { if (! (path = np_find_parameter(path_select_list, me->me_mountdir))) @@ -872,7 +872,7 @@ process_arguments (int argc, char **argv) warn_freeinodes_percent = NULL; crit_freeinodes_percent = NULL; - path_selected = FALSE; + path_selected = false; group = NULL; break; case 'V': /* version */ @@ -896,7 +896,7 @@ process_arguments (int argc, char **argv) if (argc > c) { se = np_add_parameter(&path_select_list, strdup(argv[c++])); - path_selected = TRUE; + path_selected = true; set_all_thresholds(se); } @@ -905,7 +905,7 @@ process_arguments (int argc, char **argv) mult = (uintmax_t)1024 * 1024; } - return TRUE; + return true; } -- cgit v0.10-9-g596f From a964f87d144b58196838148e7e0806db7e3ae870 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Wed, 18 Oct 2023 16:22:45 +0200 Subject: check_dns: Use C99 booleans diff --git a/plugins/check_dns.c b/plugins/check_dns.c index 7ffce98..7dcec38 100644 --- a/plugins/check_dns.c +++ b/plugins/check_dns.c @@ -41,8 +41,8 @@ const char *email = "devel@monitoring-plugins.org"; int process_arguments (int, char **); int validate_arguments (void); -int error_scan (char *, int *); -int ip_match_cidr(const char *, const char *); +int error_scan (char *, bool *); +bool ip_match_cidr(const char *, const char *); unsigned long ip2long(const char *); void print_help (void); void print_usage (void); @@ -51,13 +51,13 @@ void print_usage (void); char query_address[ADDRESS_LENGTH] = ""; char dns_server[ADDRESS_LENGTH] = ""; char ptr_server[ADDRESS_LENGTH] = ""; -int verbose = FALSE; +bool verbose = false; char **expected_address = NULL; int expected_address_cnt = 0; -int expect_nxdomain = FALSE; +bool expect_nxdomain = false; -int expect_authority = FALSE; -int all_match = FALSE; +bool expect_authority = false; +bool all_match = false; thresholds *time_thresholds = NULL; static int @@ -80,15 +80,15 @@ main (int argc, char **argv) int n_addresses = 0; char *msg = NULL; char *temp_buffer = NULL; - int non_authoritative = FALSE; + bool non_authoritative = false; int result = STATE_UNKNOWN; double elapsed_time; long microsec; struct timeval tv; - int parse_address = FALSE; /* This flag scans for Address: but only after Name: */ + bool parse_address = false; /* This flag scans for Address: but only after Name: */ output chld_out, chld_err; size_t i; - int is_nxdomain = FALSE; + int is_nxdomain = false; setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); @@ -164,8 +164,8 @@ main (int argc, char **argv) /* the server is responding, we just got the host name... */ if (strstr (chld_out.line[i], "Name:")) - parse_address = TRUE; - else if (parse_address == TRUE && (strstr (chld_out.line[i], "Address:") || + parse_address = true; + else if (parse_address && (strstr (chld_out.line[i], "Address:") || strstr (chld_out.line[i], "Addresses:"))) { temp_buffer = index (chld_out.line[i], ':'); temp_buffer++; @@ -184,7 +184,7 @@ main (int argc, char **argv) addresses[n_addresses++] = strdup(temp_buffer); } else if (strstr (chld_out.line[i], _("Non-authoritative answer:"))) { - non_authoritative = TRUE; + non_authoritative = true; } @@ -298,21 +298,21 @@ main (int argc, char **argv) printf (_(". %s returns %s"), query_address, address); if ((time_thresholds->warning != NULL) && (time_thresholds->critical != NULL)) { printf ("|%s\n", fperfdata ("time", elapsed_time, "s", - TRUE, time_thresholds->warning->end, - TRUE, time_thresholds->critical->end, - TRUE, 0, FALSE, 0)); + true, time_thresholds->warning->end, + true, time_thresholds->critical->end, + true, 0, false, 0)); } else if ((time_thresholds->warning == NULL) && (time_thresholds->critical != NULL)) { printf ("|%s\n", fperfdata ("time", elapsed_time, "s", - FALSE, 0, - TRUE, time_thresholds->critical->end, - TRUE, 0, FALSE, 0)); + false, 0, + true, time_thresholds->critical->end, + true, 0, false, 0)); } else if ((time_thresholds->warning != NULL) && (time_thresholds->critical == NULL)) { printf ("|%s\n", fperfdata ("time", elapsed_time, "s", - TRUE, time_thresholds->warning->end, - FALSE, 0, - TRUE, 0, FALSE, 0)); + true, time_thresholds->warning->end, + false, 0, + true, 0, false, 0)); } else - printf ("|%s\n", fperfdata ("time", elapsed_time, "s", FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0)); + printf ("|%s\n", fperfdata ("time", elapsed_time, "s", false, 0, false, 0, true, 0, false, 0)); } else if (result == STATE_WARNING) printf (_("DNS WARNING - %s\n"), @@ -327,15 +327,14 @@ main (int argc, char **argv) return result; } -int -ip_match_cidr(const char *addr, const char *cidr_ro) -{ +bool ip_match_cidr(const char *addr, const char *cidr_ro) { char *subnet, *mask_c, *cidr = strdup(cidr_ro); int mask; subnet = strtok(cidr, "/"); mask_c = strtok(NULL, "\0"); - if (!subnet || !mask_c) - return FALSE; + if (!subnet || !mask_c) { + return false; + } mask = atoi(mask_c); /* https://www.cryptobells.com/verifying-ips-in-a-subnet-in-php/ */ @@ -355,14 +354,14 @@ ip2long(const char* src) { } int -error_scan (char *input_buffer, int *is_nxdomain) +error_scan (char *input_buffer, bool *is_nxdomain) { const int nxdomain = strstr (input_buffer, "Non-existent") || strstr (input_buffer, "** server can't find") || strstr (input_buffer, "** Can't find") || strstr (input_buffer, "NXDOMAIN"); - if (nxdomain) *is_nxdomain = TRUE; + if (nxdomain) *is_nxdomain = true; /* the DNS lookup timed out */ if (strstr (input_buffer, _("Note: nslookup is deprecated and may be removed from future releases.")) || @@ -461,7 +460,7 @@ process_arguments (int argc, char **argv) print_revision (progname, NP_VERSION); exit (STATE_UNKNOWN); case 'v': /* version */ - verbose = TRUE; + verbose = true; break; case 't': /* timeout period */ timeout_interval = atoi (optarg); @@ -508,13 +507,13 @@ process_arguments (int argc, char **argv) } break; case 'n': /* expect NXDOMAIN */ - expect_nxdomain = TRUE; + expect_nxdomain = true; break; case 'A': /* expect authority */ - expect_authority = TRUE; + expect_authority = true; break; case 'L': /* all must match */ - all_match = TRUE; + all_match = true; break; case 'w': warning = optarg; -- cgit v0.10-9-g596f From 4a6c5ecc942e8f12a6b39fc39a3030eb56ce13f2 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Wed, 18 Oct 2023 16:27:28 +0200 Subject: check_fping: Use C99 booleans diff --git a/plugins/check_fping.c b/plugins/check_fping.c index 23a9e99..70d6f9f 100644 --- a/plugins/check_fping.c +++ b/plugins/check_fping.c @@ -59,16 +59,16 @@ int packet_size = PACKET_SIZE; int packet_count = PACKET_COUNT; int target_timeout = 0; int packet_interval = 0; -int verbose = FALSE; +bool verbose = false; int cpl; int wpl; double crta; double wrta; -int cpl_p = FALSE; -int wpl_p = FALSE; -bool alive_p = FALSE; -int crta_p = FALSE; -int wrta_p = FALSE; +bool cpl_p = false; +bool wpl_p = false; +bool alive_p = false; +bool crta_p = false; +bool wrta_p = false; int main (int argc, char **argv) @@ -194,8 +194,8 @@ int textscan (char *buf) { _("FPING %s - %s (rta=%f ms)|%s\n"), state_text (STATE_OK), server_name,rta, /* No loss since we only waited for the first reply - perfdata ("loss", (long int)loss, "%", wpl_p, wpl, cpl_p, cpl, TRUE, 0, TRUE, 100), */ - fperfdata ("rta", rta/1.0e3, "s", wrta_p, wrta/1.0e3, crta_p, crta/1.0e3, TRUE, 0, FALSE, 0)); + perfdata ("loss", (long int)loss, "%", wpl_p, wpl, cpl_p, cpl, true, 0, true, 100), */ + fperfdata ("rta", rta/1.0e3, "s", wrta_p, wrta/1.0e3, crta_p, crta/1.0e3, true, 0, false, 0)); } if (strstr (buf, "not found")) { @@ -228,21 +228,21 @@ int textscan (char *buf) { rtastr = 1 + index (rtastr, '/'); loss = strtod (losstr, NULL); rta = strtod (rtastr, NULL); - if (cpl_p == TRUE && loss > cpl) + if (cpl_p && loss > cpl) status = STATE_CRITICAL; - else if (crta_p == TRUE && rta > crta) + else if (crta_p && rta > crta) status = STATE_CRITICAL; - else if (wpl_p == TRUE && loss > wpl) + else if (wpl_p && loss > wpl) status = STATE_WARNING; - else if (wrta_p == TRUE && rta > wrta) + else if (wrta_p && rta > wrta) status = STATE_WARNING; else status = STATE_OK; die (status, _("FPING %s - %s (loss=%.0f%%, rta=%f ms)|%s %s\n"), state_text (status), server_name, loss, rta, - perfdata ("loss", (long int)loss, "%", wpl_p, wpl, cpl_p, cpl, TRUE, 0, TRUE, 100), - fperfdata ("rta", rta/1.0e3, "s", wrta_p, wrta/1.0e3, crta_p, crta/1.0e3, TRUE, 0, FALSE, 0)); + perfdata ("loss", (long int)loss, "%", wpl_p, wpl, cpl_p, cpl, true, 0, true, 100), + fperfdata ("rta", rta/1.0e3, "s", wrta_p, wrta/1.0e3, crta_p, crta/1.0e3, true, 0, false, 0)); } else if(strstr (buf, "xmt/rcv/%loss") ) { @@ -258,16 +258,16 @@ int textscan (char *buf) { loss = strtod (losstr, NULL); if (atoi(losstr) == 100) status = STATE_CRITICAL; - else if (cpl_p == TRUE && loss > cpl) + else if (cpl_p && loss > cpl) status = STATE_CRITICAL; - else if (wpl_p == TRUE && loss > wpl) + else if (wpl_p && loss > wpl) status = STATE_WARNING; else status = STATE_OK; /* loss=%.0f%%;%d;%d;0;100 */ die (status, _("FPING %s - %s (loss=%.0f%% )|%s\n"), state_text (status), server_name, loss , - perfdata ("loss", (long int)loss, "%", wpl_p, wpl, cpl_p, cpl, TRUE, 0, TRUE, 100)); + perfdata ("loss", (long int)loss, "%", wpl_p, wpl, cpl_p, cpl, true, 0, true, 100)); } else { @@ -329,7 +329,7 @@ process_arguments (int argc, char **argv) case '?': /* print short usage statement if args not parsable */ usage5 (); case 'a': /* host alive mode */ - alive_p = TRUE; + alive_p = true; break; case 'h': /* help */ print_help (); @@ -338,16 +338,16 @@ process_arguments (int argc, char **argv) print_revision (progname, NP_VERSION); exit (STATE_UNKNOWN); case 'v': /* verbose mode */ - verbose = TRUE; + verbose = true; break; case 'H': /* hostname */ - if (is_host (optarg) == FALSE) { + if (is_host (optarg) == false) { usage2 (_("Invalid hostname/address"), optarg); } server_name = strscpy (server_name, optarg); break; case 'S': /* sourceip */ - if (is_host (optarg) == FALSE) { + if (is_host (optarg) == false) { usage2 (_("Invalid hostname/address"), optarg); } sourceip = strscpy (sourceip, optarg); @@ -369,12 +369,12 @@ process_arguments (int argc, char **argv) get_threshold (optarg, rv); if (rv[RTA]) { crta = strtod (rv[RTA], NULL); - crta_p = TRUE; + crta_p = true; rv[RTA] = NULL; } if (rv[PL]) { cpl = atoi (rv[PL]); - cpl_p = TRUE; + cpl_p = true; rv[PL] = NULL; } break; @@ -382,12 +382,12 @@ process_arguments (int argc, char **argv) get_threshold (optarg, rv); if (rv[RTA]) { wrta = strtod (rv[RTA], NULL); - wrta_p = TRUE; + wrta_p = true; rv[RTA] = NULL; } if (rv[PL]) { wpl = atoi (rv[PL]); - wpl_p = TRUE; + wpl_p = true; rv[PL] = NULL; } break; -- cgit v0.10-9-g596f From 7ef12f5510bc72bbb010f7c7cd2581ac0d8f0845 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Wed, 18 Oct 2023 16:30:59 +0200 Subject: check_game: Use C99 booleans diff --git a/plugins/check_game.c b/plugins/check_game.c index a534b69..ca12697 100644 --- a/plugins/check_game.c +++ b/plugins/check_game.c @@ -53,7 +53,7 @@ char *server_ip; char *game_type; int port = 0; -int verbose; +bool verbose = false; int qstat_game_players_max = -1; int qstat_game_players = -1; @@ -90,7 +90,7 @@ main (int argc, char **argv) if (port) xasprintf (&command_line, "%s:%-d", command_line, port); - if (verbose > 0) + if (verbose) printf ("%s\n", command_line); /* run the command. historically, this plugin ignores output on stderr, @@ -142,11 +142,11 @@ main (int argc, char **argv) ret[qstat_map_field], ret[qstat_ping_field], perfdata ("players", atol(ret[qstat_game_players]), "", - FALSE, 0, FALSE, 0, - TRUE, 0, TRUE, atol(ret[qstat_game_players_max])), + false, 0, false, 0, + true, 0, true, atol(ret[qstat_game_players_max])), fperfdata ("ping", strtod(ret[qstat_ping_field], NULL), "", - FALSE, 0, FALSE, 0, - TRUE, 0, FALSE, 0)); + false, 0, false, 0, + true, 0, false, 0)); } return result; @@ -201,7 +201,7 @@ process_arguments (int argc, char **argv) print_revision (progname, NP_VERSION); exit (STATE_UNKNOWN); case 'v': /* version */ - verbose = TRUE; + verbose = true; break; case 't': /* timeout period */ timeout_interval = atoi (optarg); -- cgit v0.10-9-g596f From 58123356d562a29345b1145ec3cd78e7f458fb00 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Wed, 18 Oct 2023 16:33:39 +0200 Subject: check_ide_smart: Use C99 booleans diff --git a/plugins/check_ide_smart.c b/plugins/check_ide_smart.c index 0160d98..3872e34 100644 --- a/plugins/check_ide_smart.c +++ b/plugins/check_ide_smart.c @@ -73,10 +73,6 @@ void print_usage (void); #define NR_ATTRIBUTES 30 -#ifndef TRUE -#define TRUE 1 -#endif /* */ - #define PREFAILURE 2 #define ADVISORY 1 #define OPERATIONAL 0 @@ -169,9 +165,9 @@ int smart_read_values (int, values_t *); int nagios (values_t *, thresholds_t *); void print_value (value_t *, threshold_t *); void print_values (values_t *, thresholds_t *); -int smart_cmd_simple (int, enum SmartCommand, __u8, char); +int smart_cmd_simple (int, enum SmartCommand, __u8, bool); int smart_read_thresholds (int, thresholds_t *); -int verbose = FALSE; +bool verbose = false; int main (int argc, char *argv[]) @@ -203,7 +199,7 @@ main (int argc, char *argv[]) bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); - while (1) { + while (true) { o = getopt_long (argc, argv, "+d:iq10nhVv", longopts, &longindex); @@ -229,7 +225,7 @@ main (int argc, char *argv[]) fprintf (stderr, "%s\n", _("default and will be removed from future releases.")); break; case 'v': /* verbose */ - verbose = TRUE; + verbose = true; break; case 'h': print_help (); @@ -258,7 +254,7 @@ main (int argc, char *argv[]) return STATE_CRITICAL; } - if (smart_cmd_simple (fd, SMART_CMD_ENABLE, 0, FALSE)) { + if (smart_cmd_simple (fd, SMART_CMD_ENABLE, 0, false)) { printf (_("CRITICAL - SMART_CMD_ENABLE\n")); return STATE_CRITICAL; } @@ -447,9 +443,7 @@ print_values (values_t * p, thresholds_t * t) } -int -smart_cmd_simple (int fd, enum SmartCommand command, __u8 val0, char show_error) -{ +int smart_cmd_simple (int fd, enum SmartCommand command, __u8 val0, bool show_error) { int e = STATE_UNKNOWN; #ifdef __linux__ __u8 args[4]; -- cgit v0.10-9-g596f From 82f391085d46d207870864c7ab6332914bdd3681 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Wed, 18 Oct 2023 16:35:56 +0200 Subject: check_ldap: Use C99 booleans diff --git a/plugins/check_ldap.c b/plugins/check_ldap.c index 15113b1..868ffc1 100644 --- a/plugins/check_ldap.c +++ b/plugins/check_ldap.c @@ -71,9 +71,9 @@ thresholds *entries_thresholds = NULL; struct timeval tv; char* warn_entries = NULL; char* crit_entries = NULL; -int starttls = FALSE; -int ssl_on_connect = FALSE; -int verbose = 0; +bool starttls = false; +bool ssl_on_connect = false; +bool verbose = false; /* for ldap tls */ @@ -115,7 +115,7 @@ main (int argc, char *argv[]) usage4 (_("Could not parse arguments")); if (strstr(argv[0],"check_ldaps") && ! starttls && ! ssl_on_connect) - starttls = TRUE; + starttls = true; /* initialize alarm signal handling */ signal (SIGALRM, socket_timeout_alarm_handler); @@ -253,11 +253,11 @@ main (int argc, char *argv[]) fperfdata ("time", elapsed_time, "s", (int)warn_time, warn_time, (int)crit_time, crit_time, - TRUE, 0, FALSE, 0), + true, 0, false, 0), sperfdata ("entries", (double)num_entries, "", warn_entries, crit_entries, - TRUE, 0.0, FALSE, 0.0)); + true, 0.0, false, 0.0)); } else { printf (_("LDAP %s - %.3f seconds response time|%s\n"), state_text (status), @@ -265,7 +265,7 @@ main (int argc, char *argv[]) fperfdata ("time", elapsed_time, "s", (int)warn_time, warn_time, (int)crit_time, crit_time, - TRUE, 0, FALSE, 0)); + true, 0, false, 0)); } return status; @@ -313,7 +313,7 @@ process_arguments (int argc, char **argv) strcpy (argv[c], "-t"); } - while (1) { + while (true) { c = getopt_long (argc, argv, "hvV234TS6t:c:w:H:b:p:a:D:P:C:W:", longopts, &option); if (c == -1 || c == EOF) @@ -374,17 +374,17 @@ process_arguments (int argc, char **argv) address_family = AF_INET; break; case 'v': - verbose++; + verbose = true; break; case 'T': if (! ssl_on_connect) - starttls = TRUE; + starttls = true; else usage_va(_("%s cannot be combined with %s"), "-T/--starttls", "-S/--ssl"); break; case 'S': if (! starttls) { - ssl_on_connect = TRUE; + ssl_on_connect = true; if (ld_port == -1) ld_port = LDAPS_PORT; } else -- cgit v0.10-9-g596f From 790374c3b163003f85cf2122d437828e70b1d871 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Wed, 18 Oct 2023 16:37:36 +0200 Subject: check_mrtg: Use C99 booleans diff --git a/plugins/check_mrtg.c b/plugins/check_mrtg.c index 1fda549..826b77e 100644 --- a/plugins/check_mrtg.c +++ b/plugins/check_mrtg.c @@ -43,7 +43,7 @@ void print_usage (void); char *log_file = NULL; int expire_minutes = 0; -int use_average = TRUE; +bool use_average = true; int variable_number = -1; unsigned long value_warning_threshold = 0L; unsigned long value_critical_threshold = 0L; @@ -138,7 +138,7 @@ main (int argc, char **argv) } /* else check the incoming/outgoing rates */ - if (use_average == TRUE) + if (use_average) rate = average_value_rate; else rate = maximum_value_rate; @@ -149,7 +149,7 @@ main (int argc, char **argv) result = STATE_WARNING; printf("%s. %s = %lu %s|%s\n", - (use_average == TRUE) ? _("Avg") : _("Max"), + (use_average) ? _("Avg") : _("Max"), label, rate, units, perfdata(label, (long) rate, units, (int) value_warning_threshold, (long) value_warning_threshold, @@ -211,9 +211,9 @@ process_arguments (int argc, char **argv) break; case 'a': /* port */ if (!strcmp (optarg, "MAX")) - use_average = FALSE; + use_average = false; else - use_average = TRUE; + use_average = true; break; case 'v': variable_number = atoi (optarg); @@ -258,11 +258,11 @@ process_arguments (int argc, char **argv) } if (argc > c && strcmp (argv[c], "MAX") == 0) { - use_average = FALSE; + use_average = false; c++; } else if (argc > c && strcmp (argv[c], "AVG") == 0) { - use_average = TRUE; + use_average = true; c++; } -- cgit v0.10-9-g596f From 45893377bd70fd93928d015dc1f20cd19a17c6d3 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Wed, 18 Oct 2023 16:39:13 +0200 Subject: check_mrtgtraf: Use C99 booleans diff --git a/plugins/check_mrtgtraf.c b/plugins/check_mrtgtraf.c index eb66f62..bd25d47 100644 --- a/plugins/check_mrtgtraf.c +++ b/plugins/check_mrtgtraf.c @@ -43,7 +43,7 @@ void print_usage(void); char *log_file = NULL; int expire_minutes = -1; -int use_average = TRUE; +bool use_average = true; unsigned long incoming_warning_threshold = 0L; unsigned long incoming_critical_threshold = 0L; unsigned long outgoing_warning_threshold = 0L; @@ -137,7 +137,7 @@ main (int argc, char **argv) (int) ((current_time - timestamp) / 60)); /* else check the incoming/outgoing rates */ - if (use_average == TRUE) { + if (use_average) { incoming_rate = average_incoming_rate; outgoing_rate = average_outgoing_rate; } @@ -192,17 +192,17 @@ main (int argc, char **argv) } xasprintf (&error_message, _("%s. In = %0.1f %s/s, %s. Out = %0.1f %s/s|%s %s\n"), - (use_average == TRUE) ? _("Avg") : _("Max"), adjusted_incoming_rate, - incoming_speed_rating, (use_average == TRUE) ? _("Avg") : _("Max"), + (use_average) ? _("Avg") : _("Max"), adjusted_incoming_rate, + incoming_speed_rating, (use_average) ? _("Avg") : _("Max"), adjusted_outgoing_rate, outgoing_speed_rating, fperfdata("in", adjusted_incoming_rate, incoming_speed_rating, (int)incoming_warning_threshold, incoming_warning_threshold, (int)incoming_critical_threshold, incoming_critical_threshold, - TRUE, 0, FALSE, 0), + true, 0, false, 0), fperfdata("out", adjusted_outgoing_rate, outgoing_speed_rating, (int)outgoing_warning_threshold, outgoing_warning_threshold, (int)outgoing_critical_threshold, outgoing_critical_threshold, - TRUE, 0, FALSE, 0)); + true, 0, false, 0)); printf (_("Traffic %s - %s\n"), state_text(result), error_message); @@ -256,9 +256,9 @@ process_arguments (int argc, char **argv) break; case 'a': /* aggregation (AVE or MAX) */ if (!strcmp (optarg, "MAX")) - use_average = FALSE; + use_average = false; else - use_average = TRUE; + use_average = true; break; case 'c': /* warning threshold */ sscanf (optarg, "%lu,%lu", &incoming_critical_threshold, @@ -289,11 +289,11 @@ process_arguments (int argc, char **argv) } if (argc > c && strcmp (argv[c], "MAX") == 0) { - use_average = FALSE; + use_average = false; c++; } else if (argc > c && strcmp (argv[c], "AVG") == 0) { - use_average = TRUE; + use_average = true; c++; } -- cgit v0.10-9-g596f From 0b389d636e6c560f2ac22f27db6d18ebb09b474e Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Wed, 18 Oct 2023 16:40:51 +0200 Subject: check_mysql: Use C99 booleans diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c index 7d85554..6a7daf1 100644 --- a/plugins/check_mysql.c +++ b/plugins/check_mysql.c @@ -113,7 +113,7 @@ main (int argc, char **argv) char slaveresult[SLAVERESULTSIZE] = { 0 }; char* perf; - perf = strdup (""); + perf = strdup (""); setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); @@ -193,14 +193,14 @@ main (int argc, char **argv) for(i = 0; i < LENGTH_METRIC_UNIT; i++) { if (strcmp(row[0], metric_unit[i]) == 0) { xasprintf(&perf, "%s%s ", perf, perfdata(metric_unit[i], - atol(row[1]), "", FALSE, 0, FALSE, 0, FALSE, 0, FALSE, 0)); + atol(row[1]), "", false, 0, false, 0, false, 0, false, 0)); continue; } } for(i = 0; i < LENGTH_METRIC_COUNTER; i++) { if (strcmp(row[0], metric_counter[i]) == 0) { xasprintf(&perf, "%s%s ", perf, perfdata(metric_counter[i], - atol(row[1]), "c", FALSE, 0, FALSE, 0, FALSE, 0, FALSE, 0)); + atol(row[1]), "c", false, 0, false, 0, false, 0, false, 0)); continue; } } @@ -322,10 +322,10 @@ main (int argc, char **argv) status = get_status(value, my_threshold); xasprintf (&perf, "%s %s", perf, fperfdata ("seconds behind master", value, "s", - TRUE, (double) warning_time, - TRUE, (double) critical_time, - FALSE, 0, - FALSE, 0)); + true, (double) warning_time, + true, (double) critical_time, + false, 0, + false, 0)); if (status == STATE_WARNING) { printf("SLOW_SLAVE %s: %s|%s\n", _("WARNING"), slaveresult, perf); -- cgit v0.10-9-g596f From 6fc6e86994a678ee6fb0fdcf3976cf8b1944ada2 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Wed, 18 Oct 2023 16:48:05 +0200 Subject: check_mysql_query: Use C99 booleans diff --git a/plugins/check_mysql_query.c b/plugins/check_mysql_query.c index ac2fb15..842b7a2 100644 --- a/plugins/check_mysql_query.c +++ b/plugins/check_mysql_query.c @@ -162,10 +162,10 @@ main (int argc, char **argv) } printf(_("'%s' returned %f | %s"), sql_query, value, fperfdata("result", value, "", - my_thresholds->warning?TRUE:FALSE, my_thresholds->warning?my_thresholds->warning->end:0, - my_thresholds->critical?TRUE:FALSE, my_thresholds->critical?my_thresholds->critical->end:0, - FALSE, 0, - FALSE, 0) + my_thresholds->warning?true:false, my_thresholds->warning?my_thresholds->warning->end:0, + my_thresholds->critical?true:false, my_thresholds->critical?my_thresholds->critical->end:0, + false, 0, + false, 0) ); printf("\n"); -- cgit v0.10-9-g596f From ee80cc259190563ddb29eb780e13eb038a4ff680 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Wed, 18 Oct 2023 16:54:33 +0200 Subject: check_dns: Another C99 boolean diff --git a/plugins/check_dns.c b/plugins/check_dns.c index 7dcec38..82dc264 100644 --- a/plugins/check_dns.c +++ b/plugins/check_dns.c @@ -88,7 +88,7 @@ main (int argc, char **argv) bool parse_address = false; /* This flag scans for Address: but only after Name: */ output chld_out, chld_err; size_t i; - int is_nxdomain = false; + bool is_nxdomain = false; setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); -- cgit v0.10-9-g596f From 1ba64fb56683c7418d4d87565cdd52421edbb8c6 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Wed, 18 Oct 2023 16:54:48 +0200 Subject: check_nt: Use C99 booleans diff --git a/plugins/check_nt.c b/plugins/check_nt.c index d73d83c..19c050d 100644 --- a/plugins/check_nt.c +++ b/plugins/check_nt.c @@ -67,17 +67,17 @@ char *req_password=NULL; unsigned long lvalue_list[MAX_VALUE_LIST]; unsigned long warning_value=0L; unsigned long critical_value=0L; -int check_warning_value=FALSE; -int check_critical_value=FALSE; +bool check_warning_value=false; +bool check_critical_value=false; enum checkvars vars_to_check = CHECK_NONE; -int show_all=FALSE; +bool show_all = false; char recv_buffer[MAX_INPUT_BUFFER]; void fetch_data (const char* address, int port, const char* sendb); int process_arguments(int, char **); void preparelist(char *string); -int strtoularray(unsigned long *array, char *string, const char *delim); +bool strtoularray(unsigned long *array, char *string, const char *delim); void print_help(void); void print_usage(void); @@ -113,8 +113,8 @@ int main(int argc, char **argv){ int uphours=0; int upminutes=0; - int isPercent = FALSE; - int allRight = FALSE; + bool isPercent = false; + bool allRight = false; setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); @@ -151,7 +151,7 @@ int main(int argc, char **argv){ if (value_list==NULL) output_message = strdup (_("missing -l parameters")); - else if (strtoularray(lvalue_list,value_list,",")==FALSE) + else if (! strtoularray(lvalue_list,value_list,",")) output_message = strdup (_("wrong -l parameter.")); else { /* -l parameters is present with only integers */ @@ -224,9 +224,9 @@ int main(int argc, char **argv){ xasprintf(&output_message,_("System Uptime - %u day(s) %u hour(s) %u minute(s) |uptime=%lu"),updays, uphours, upminutes, uptime); - if (check_critical_value==TRUE && uptime <= critical_value) + if (check_critical_value && uptime <= critical_value) return_code=STATE_CRITICAL; - else if (check_warning_value==TRUE && uptime <= warning_value) + else if (check_warning_value && uptime <= warning_value) return_code=STATE_WARNING; else return_code=STATE_OK; @@ -261,9 +261,9 @@ int main(int argc, char **argv){ (total_disk_space - free_disk_space) / 1073741824, warning_used_space / 1073741824, critical_used_space / 1073741824, total_disk_space / 1073741824); - if(check_critical_value==TRUE && percent_used_space >= critical_value) + if(check_critical_value && percent_used_space >= critical_value) return_code=STATE_CRITICAL; - else if (check_warning_value==TRUE && percent_used_space >= warning_value) + else if (check_warning_value && percent_used_space >= warning_value) return_code=STATE_WARNING; else return_code=STATE_OK; @@ -285,7 +285,7 @@ int main(int argc, char **argv){ else { preparelist(value_list); /* replace , between services with & to send the request */ xasprintf(&send_buffer,"%s&%u&%s&%s", req_password,(vars_to_check==CHECK_SERVICESTATE)?5:6, - (show_all==TRUE) ? "ShowAll" : "ShowFail",value_list); + (show_all) ? "ShowAll" : "ShowFail",value_list); fetch_data (server_address, server_port, send_buffer); numstr = strtok(recv_buffer,"&"); if (numstr == NULL) @@ -321,9 +321,9 @@ int main(int argc, char **argv){ warning_used_space / 1048567, critical_used_space / 1048567, mem_commitLimit / 1048567); return_code=STATE_OK; - if(check_critical_value==TRUE && percent_used_space >= critical_value) + if(check_critical_value && percent_used_space >= critical_value) return_code=STATE_CRITICAL; - else if (check_warning_value==TRUE && percent_used_space >= warning_value) + else if (check_warning_value && percent_used_space >= warning_value) return_code=STATE_WARNING; break; @@ -371,7 +371,7 @@ int main(int argc, char **argv){ else if (isPercent) { counter_unit = strdup ("%"); - allRight = TRUE; + allRight = true; } if ((counter_unit != NULL) && (!allRight)) @@ -391,7 +391,7 @@ int main(int argc, char **argv){ if ((fmaxval == 0) && (maxval == errcvt)) output_message = strdup (_("Maximum value contains non-numbers")); else - allRight = TRUE; /* Everything is OK. */ + allRight = true; /* Everything is OK. */ } } @@ -418,9 +418,9 @@ int main(int argc, char **argv){ if (critical_value > warning_value) { /* Normal thresholds */ - if (check_critical_value == TRUE && counter_value >= critical_value) + if (check_critical_value && counter_value >= critical_value) return_code = STATE_CRITICAL; - else if (check_warning_value == TRUE && counter_value >= warning_value) + else if (check_warning_value && counter_value >= warning_value) return_code = STATE_WARNING; else return_code = STATE_OK; @@ -428,9 +428,9 @@ int main(int argc, char **argv){ else { /* inverse thresholds */ return_code = STATE_OK; - if (check_critical_value == TRUE && counter_value <= critical_value) + if (check_critical_value && counter_value <= critical_value) return_code = STATE_CRITICAL; - else if (check_warning_value == TRUE && counter_value <= warning_value) + else if (check_warning_value && counter_value <= warning_value) return_code = STATE_WARNING; } break; @@ -448,17 +448,17 @@ int main(int argc, char **argv){ output_message = strdup (description); if (critical_value > warning_value) { /* Normal thresholds */ - if(check_critical_value==TRUE && age_in_minutes >= critical_value) + if(check_critical_value && age_in_minutes >= critical_value) return_code=STATE_CRITICAL; - else if (check_warning_value==TRUE && age_in_minutes >= warning_value) + else if (check_warning_value && age_in_minutes >= warning_value) return_code=STATE_WARNING; else return_code=STATE_OK; } else { /* inverse thresholds */ - if(check_critical_value==TRUE && age_in_minutes <= critical_value) + if(check_critical_value && age_in_minutes <= critical_value) return_code=STATE_CRITICAL; - else if (check_warning_value==TRUE && age_in_minutes <= warning_value) + else if (check_warning_value && age_in_minutes <= warning_value) return_code=STATE_WARNING; else return_code=STATE_OK; @@ -600,15 +600,15 @@ int process_arguments(int argc, char **argv){ break; case 'w': /* warning threshold */ warning_value=strtoul(optarg,NULL,10); - check_warning_value=TRUE; + check_warning_value=true; break; case 'c': /* critical threshold */ critical_value=strtoul(optarg,NULL,10); - check_critical_value=TRUE; + check_critical_value=true; break; case 'd': /* Display select for services */ if (!strcmp(optarg,"SHOWALL")) - show_all = TRUE; + show_all = true; break; case 'u': socket_timeout_state=STATE_UNKNOWN; @@ -646,7 +646,7 @@ void fetch_data (const char *address, int port, const char *sendb) { die (STATE_UNKNOWN, "NSClient - %s\n",recv_buffer); } -int strtoularray(unsigned long *array, char *string, const char *delim) { +bool strtoularray(unsigned long *array, char *string, const char *delim) { /* split a delimited string into a long array */ int idx=0; char *t1; @@ -660,9 +660,9 @@ int strtoularray(unsigned long *array, char *string, const char *delim) { array[idx]=strtoul(t1,NULL,10); idx++; } else - return FALSE; + return false; } - return TRUE; + return true; } void preparelist(char *string) { -- cgit v0.10-9-g596f From ca5af12f9475775179a599875bf7cf8d3296f02a Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Wed, 18 Oct 2023 17:01:59 +0200 Subject: check_ntp: Use C99 booleans diff --git a/plugins/check_ntp.c b/plugins/check_ntp.c index 99537c8..a535943 100644 --- a/plugins/check_ntp.c +++ b/plugins/check_ntp.c @@ -39,11 +39,11 @@ const char *email = "devel@monitoring-plugins.org"; #include "utils.h" static char *server_address=NULL; -static int verbose=0; -static short do_offset=0; +static bool verbose = false; +static bool do_offset = false; static char *owarn="60"; static char *ocrit="120"; -static short do_jitter=0; +static bool do_jitter = false; static char *jwarn="5000"; static char *jcrit="10000"; @@ -696,26 +696,26 @@ int process_arguments(int argc, char **argv){ exit(STATE_UNKNOWN); break; case 'v': - verbose++; + verbose = true; break; case 'w': - do_offset=1; + do_offset = true; owarn = optarg; break; case 'c': - do_offset=1; + do_offset = true; ocrit = optarg; break; case 'j': - do_jitter=1; + do_jitter = true; jwarn = optarg; break; case 'k': - do_jitter=1; + do_jitter = true; jcrit = optarg; break; case 'H': - if(is_host(optarg) == FALSE) + if(is_host(optarg) == false) usage2(_("Invalid hostname/address"), optarg); server_address = strdup(optarg); break; @@ -749,9 +749,9 @@ int process_arguments(int argc, char **argv){ char *perfd_offset (double offset) { return fperfdata ("offset", offset, "s", - TRUE, offset_thresholds->warning->end, - TRUE, offset_thresholds->critical->end, - FALSE, 0, FALSE, 0); + true, offset_thresholds->warning->end, + true, offset_thresholds->critical->end, + false, 0, false, 0); } char *perfd_jitter (double jitter) @@ -759,7 +759,7 @@ char *perfd_jitter (double jitter) return fperfdata ("jitter", jitter, "s", do_jitter, jitter_thresholds->warning->end, do_jitter, jitter_thresholds->critical->end, - TRUE, 0, FALSE, 0); + true, 0, false, 0); } int main(int argc, char *argv[]){ -- cgit v0.10-9-g596f From a7e494192d222015bc098bfc3c7ed71e2e801590 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Wed, 18 Oct 2023 17:11:21 +0200 Subject: check_ntp_peer: Use C99 booleans diff --git a/plugins/check_ntp_peer.c b/plugins/check_ntp_peer.c index 49cb100..d4e5fd9 100644 --- a/plugins/check_ntp_peer.c +++ b/plugins/check_ntp_peer.c @@ -46,21 +46,20 @@ const char *email = "devel@monitoring-plugins.org"; static char *server_address=NULL; static int port=123; static int verbose=0; -static int quiet=0; -static short do_offset=0; +static bool quiet = false; static char *owarn="60"; static char *ocrit="120"; -static short do_stratum=0; +static bool do_stratum = false; static char *swarn="-1:16"; static char *scrit="-1:16"; -static short do_jitter=0; +static bool do_jitter = false; static char *jwarn="-1:5000"; static char *jcrit="-1:10000"; -static short do_truechimers=0; +static bool do_truechimers = false; static char *twarn="0:"; static char *tcrit="0:"; -static int syncsource_found=0; -static int li_alarm=0; +static bool syncsource_found = false; +static bool li_alarm = false; int process_arguments (int, char **); thresholds *offset_thresholds = NULL; @@ -254,7 +253,7 @@ int ntp_request(double *offset, int *offset_result, double *jitter, int *stratum die(STATE_CRITICAL, "NTP CRITICAL: Invalid packet received from NTP server\n"); } while (!(req.op&OP_READSTAT && ntohs(req.seq) == 1)); - if (LI(req.flags) == LI_ALARM) li_alarm = 1; + if (LI(req.flags) == LI_ALARM) li_alarm = true; /* Each peer identifier is 4 bytes in the data section, which * we represent as a ntp_assoc_status_pair datatype. */ @@ -276,7 +275,7 @@ int ntp_request(double *offset, int *offset_result, double *jitter, int *stratum if(PEER_SEL(peers[i].status) >= PEER_INCLUDED){ num_candidates++; if(PEER_SEL(peers[i].status) >= PEER_SYNCSOURCE){ - syncsource_found=1; + syncsource_found = true; min_peer_sel=PEER_SYNCSOURCE; } } @@ -440,7 +439,7 @@ int process_arguments(int argc, char **argv){ if (argc < 2) usage ("\n"); - while (1) { + while (true) { c = getopt_long (argc, argv, "Vhv46qw:c:W:C:j:k:m:n:t:H:p:", longopts, &option); if (c == -1 || c == EOF || c == 1) break; @@ -458,42 +457,40 @@ int process_arguments(int argc, char **argv){ verbose++; break; case 'q': - quiet = 1; + quiet = true; break; case 'w': - do_offset=1; owarn = optarg; break; case 'c': - do_offset=1; ocrit = optarg; break; case 'W': - do_stratum=1; + do_stratum = true; swarn = optarg; break; case 'C': - do_stratum=1; + do_stratum = true; scrit = optarg; break; case 'j': - do_jitter=1; + do_jitter = true; jwarn = optarg; break; case 'k': - do_jitter=1; + do_jitter = true; jcrit = optarg; break; case 'm': - do_truechimers=1; + do_truechimers = true; twarn = optarg; break; case 'n': - do_truechimers=1; + do_truechimers = true; tcrit = optarg; break; case 'H': - if(is_host(optarg) == FALSE) + if(!is_host(optarg)) usage2(_("Invalid hostname/address"), optarg); server_address = strdup(optarg); break; @@ -530,9 +527,9 @@ int process_arguments(int argc, char **argv){ char *perfd_offset (double offset) { return fperfdata ("offset", offset, "s", - TRUE, offset_thresholds->warning->end, - TRUE, offset_thresholds->critical->end, - FALSE, 0, FALSE, 0); + true, offset_thresholds->warning->end, + true, offset_thresholds->critical->end, + false, 0, false, 0); } char *perfd_jitter (double jitter) @@ -540,7 +537,7 @@ char *perfd_jitter (double jitter) return fperfdata ("jitter", jitter, "", do_jitter, jitter_thresholds->warning->end, do_jitter, jitter_thresholds->critical->end, - TRUE, 0, FALSE, 0); + true, 0, false, 0); } char *perfd_stratum (int stratum) @@ -548,7 +545,7 @@ char *perfd_stratum (int stratum) return perfdata ("stratum", stratum, "", do_stratum, (int)stratum_thresholds->warning->end, do_stratum, (int)stratum_thresholds->critical->end, - TRUE, 0, TRUE, 16); + true, 0, true, 16); } char *perfd_truechimers (int num_truechimers) @@ -556,7 +553,7 @@ char *perfd_truechimers (int num_truechimers) return perfdata ("truechimers", num_truechimers, "", do_truechimers, (int)truechimer_thresholds->warning->end, do_truechimers, (int)truechimer_thresholds->critical->end, - TRUE, 0, FALSE, 0); + true, 0, false, 0); } int main(int argc, char *argv[]){ @@ -590,10 +587,10 @@ int main(int argc, char *argv[]){ if(offset_result == STATE_UNKNOWN) { /* if there's no sync peer (this overrides ntp_request output): */ - result = (quiet == 1 ? STATE_UNKNOWN : STATE_CRITICAL); + result = (quiet ? STATE_UNKNOWN : STATE_CRITICAL); } else { /* Be quiet if there's no candidates either */ - if (quiet == 1 && result == STATE_WARNING) + if (quiet && result == STATE_WARNING) result = STATE_UNKNOWN; result = max_state_alt(result, get_status(fabs(offset), offset_thresholds)); } -- cgit v0.10-9-g596f From c849536609fbee9ab95d7db2bef23009327c1b9f Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Wed, 18 Oct 2023 17:15:19 +0200 Subject: check_ntp_time: Use C99 booleans diff --git a/plugins/check_ntp_time.c b/plugins/check_ntp_time.c index 46cc604..d19b3e4 100644 --- a/plugins/check_ntp_time.c +++ b/plugins/check_ntp_time.c @@ -44,8 +44,8 @@ const char *email = "devel@monitoring-plugins.org"; static char *server_address=NULL; static char *port="123"; -static int verbose=0; -static int quiet=0; +static bool verbose = false; +static bool quiet = false; static char *owarn="60"; static char *ocrit="120"; static int time_offset=0; @@ -485,7 +485,7 @@ int process_arguments(int argc, char **argv){ verbose++; break; case 'q': - quiet = 1; + quiet = true; break; case 'w': owarn = optarg; @@ -494,7 +494,7 @@ int process_arguments(int argc, char **argv){ ocrit = optarg; break; case 'H': - if(is_host(optarg) == FALSE) + if(!is_host(optarg)) usage2(_("Invalid hostname/address"), optarg); server_address = strdup(optarg); break; @@ -506,7 +506,7 @@ int process_arguments(int argc, char **argv){ break; case 'o': time_offset=atoi(optarg); - break; + break; case '4': address_family = AF_INET; break; @@ -534,9 +534,9 @@ int process_arguments(int argc, char **argv){ char *perfd_offset (double offset) { return fperfdata ("offset", offset, "s", - TRUE, offset_thresholds->warning->end, - TRUE, offset_thresholds->critical->end, - FALSE, 0, FALSE, 0); + true, offset_thresholds->warning->end, + true, offset_thresholds->critical->end, + false, 0, false, 0); } int main(int argc, char *argv[]){ @@ -566,7 +566,7 @@ int main(int argc, char *argv[]){ offset = offset_request(server_address, &offset_result); if (offset_result == STATE_UNKNOWN) { - result = (quiet == 1 ? STATE_UNKNOWN : STATE_CRITICAL); + result = (quiet ? STATE_UNKNOWN : STATE_CRITICAL); } else { result = get_status(fabs(offset), offset_thresholds); } @@ -651,4 +651,3 @@ print_usage(void) printf ("%s\n", _("Usage:")); printf(" %s -H [-4|-6] [-w ] [-c ] [-v verbose] [-o