From 6157cdf6e514b23ee20e2bde67eb62757bcdd2f2 Mon Sep 17 00:00:00 2001 From: Thomas Guyot-Sionnest Date: Tue, 4 Dec 2007 11:18:40 +0000 Subject: Small cleanups git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/branches/dermoth_ntp_rework@1839 f882894a-f735-0410-b71e-b25c423dba1c --- plugins/check_ntp_peer.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'plugins/check_ntp_peer.c') diff --git a/plugins/check_ntp_peer.c b/plugins/check_ntp_peer.c index e0913add..edef66a8 100644 --- a/plugins/check_ntp_peer.c +++ b/plugins/check_ntp_peer.c @@ -228,7 +228,7 @@ int ntp_request(const char *host, double *offset, int *offset_result, double *ji ntp_assoc_status_pair *peers=NULL; ntp_control_message req; const char *getvar = "stratum,offset,jitter"; - char *data=NULL, *value=NULL, *nptr=NULL; + char *data, *value, *nptr; void *tmp; status = STATE_OK; @@ -350,6 +350,7 @@ int ntp_request(const char *host, double *offset, int *offset_result, double *ji printf("parsing offset from peer %.2x: ", ntohs(peers[i].assoc)); value = extract_value(data, "offset"); + nptr=NULL; /* Convert the value if we have one */ if(value != NULL) tmp_offset = strtod(value, &nptr) / 1000; @@ -373,12 +374,13 @@ int ntp_request(const char *host, double *offset, int *offset_result, double *ji printf("parsing %s from peer %.2x: ", strstr(getvar, "dispersion") != NULL ? "dispersion" : "jitter", ntohs(peers[i].assoc)); } value = extract_value(data, strstr(getvar, "dispersion") != NULL ? "dispersion" : "jitter"); + nptr=NULL; /* Convert the value if we have one */ if(value != NULL) *jitter = strtod(value, &nptr); /* If value is null or no conversion was performed */ if(value == NULL || value==nptr){ - if(verbose) printf("error: unable to read server jitter response.\n"); + if(verbose) printf("error: unable to read server jitter/dispersion response.\n"); *jitter = -1; } else { if(verbose) printf("%g\n", *jitter); @@ -391,6 +393,8 @@ int ntp_request(const char *host, double *offset, int *offset_result, double *ji printf("parsing stratum from peer %.2x: ", ntohs(peers[i].assoc)); } value = extract_value(data, "stratum"); + nptr=NULL; + /* Convert the value if we have one */ if(value != NULL) *stratum = strtol(value, &nptr, 10); if(value == NULL || value==nptr){ -- cgit v1.2.3-74-g34f1