[monitoring-plugins] check_ntp_peer: Fixes for Wmaybe-unitialized and ...

RincewindsHat git at monitoring-plugins.org
Thu Nov 23 10:10:12 CET 2023


 Module: monitoring-plugins
 Branch: master
 Commit: 479ff15249f0eb395c97a95fe53b3238f7bb59b9
 Author: RincewindsHat <12514511+RincewindsHat at users.noreply.github.com>
   Date: Thu Nov 23 00:11:39 2023 +0100
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=479ff15

check_ntp_peer: Fixes for Wmaybe-unitialized and some restructuring

---

 plugins/check_ntp_peer.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/plugins/check_ntp_peer.c b/plugins/check_ntp_peer.c
index 4fb9018..464a9e1 100644
--- a/plugins/check_ntp_peer.c
+++ b/plugins/check_ntp_peer.c
@@ -558,7 +558,6 @@ char *perfd_truechimers (int num_truechimers)
 
 int main(int argc, char *argv[]){
 	int result, offset_result, stratum, num_truechimers;
-	int oresult, jresult, sresult, tresult = STATE_UNKNOWN;
 	double offset=0, jitter=0;
 	char *result_line, *perfdata_line;
 
@@ -595,18 +594,28 @@ int main(int argc, char *argv[]){
 			result = STATE_UNKNOWN;
 		result = max_state_alt(result, get_status(fabs(offset), offset_thresholds));
 	}
-	oresult = result;
+
+	int oresult = result;
+
+
+	int tresult = STATE_UNKNOWN;
 	
 	if(do_truechimers) {
 		tresult = get_status(num_truechimers, truechimer_thresholds);
 		result = max_state_alt(result, tresult);
 	}
 
+
+	int sresult = STATE_UNKNOWN;
+
 	if(do_stratum) {
 		sresult = get_status(stratum, stratum_thresholds);
 		result = max_state_alt(result, sresult);
 	}
 
+
+	int jresult = STATE_UNKNOWN;
+
 	if(do_jitter) {
 		jresult = get_status(jitter, jitter_thresholds);
 		result = max_state_alt(result, jresult);



More information about the Commits mailing list