From 68fb21b88c6b5669f4dc40a4e1c69045191aa98a Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Mon, 12 Mar 2007 12:43:18 +0100 Subject: [PATCH] collectd-nagios, rrdtool plugin, unixsock plugin: Use `isnan' rather than `==' or `!='. --- src/collectd-nagios.c | 10 +++++----- src/rrdtool.c | 18 ++---------------- src/unixsock.c | 8 ++++---- 3 files changed, 11 insertions(+), 25 deletions(-) diff --git a/src/collectd-nagios.c b/src/collectd-nagios.c index 160412c5..b7c3ffaf 100644 --- a/src/collectd-nagios.c +++ b/src/collectd-nagios.c @@ -112,9 +112,9 @@ int match_range (range_t *range, double value) { int ret = 0; - if ((range->min != NAN) && (range->min > value)) + if (!isnan (range->min) && (range->min > value)) ret = 1; - if ((range->max != NAN) && (range->max < value)) + if (!isnan (range->max) && (range->max < value)) ret = 1; return (((ret - range->invert) == 0) ? 0 : 1); @@ -268,7 +268,7 @@ int do_check_con_none (int values_num, double *values, char **values_names) for (i = 0; i < values_num; i++) { - if (values[i] == NAN) + if (isnan (values[i])) num_warning++; else if (match_range (&range_critical_g, values[i]) != 0) num_critical++; @@ -309,7 +309,7 @@ int do_check_con_average (int values_num, double *values, char **values_names) total_num = 0; for (i = 0; i < values_num; i++) { - if (values[i] != NAN) + if (!isnan (values[i])) { total += values[i]; total_num++; @@ -354,7 +354,7 @@ int do_check_con_sum (int values_num, double *values, char **values_names) total_num = 0; for (i = 0; i < values_num; i++) { - if (values[i] != NAN) + if (!isnan (values[i])) { total += values[i]; total_num++; diff --git a/src/rrdtool.c b/src/rrdtool.c index 80fc7671..f19f2693 100644 --- a/src/rrdtool.c +++ b/src/rrdtool.c @@ -26,20 +26,6 @@ #include "utils_debug.h" /* - * This weird macro cascade forces the glibc to define `NAN'. I don't know - * another way to solve this, so more intelligent solutions are welcome. -octo - */ -#ifndef __USE_ISOC99 -# define DISABLE__USE_ISOC99 1 -# define __USE_ISOC99 1 -#endif -#include -#ifdef DISABLE__USE_ISOC99 -# undef DISABLE__USE_ISOC99 -# undef __USE_ISOC99 -#endif - -/* * Private types */ struct rrd_cache_s @@ -221,7 +207,7 @@ static int ds_get (char ***ret, const data_set_t *ds) break; } - if (d->min == NAN) + if (isnan (d->min)) { strcpy (min, "U"); } @@ -231,7 +217,7 @@ static int ds_get (char ***ret, const data_set_t *ds) min[sizeof (min) - 1] = '\0'; } - if (d->max == NAN) + if (isnan (d->max)) { strcpy (max, "U"); } diff --git a/src/unixsock.c b/src/unixsock.c index b4af8b38..0008b224 100644 --- a/src/unixsock.c +++ b/src/unixsock.c @@ -277,9 +277,9 @@ static int cache_update (const data_set_t *ds, const value_list_t *vl) vc->counter[i] = 0; } - if ((vc->gauge[i] == NAN) - || ((ds->ds[i].min != NAN) && (vc->gauge[i] < ds->ds[i].min)) - || ((ds->ds[i].max != NAN) && (vc->gauge[i] > ds->ds[i].max))) + if (isnan (vc->gauge[i]) + || (!isnan (ds->ds[i].min) && (vc->gauge[i] < ds->ds[i].min)) + || (!isnan (ds->ds[i].max) && (vc->gauge[i] > ds->ds[i].max))) vc->gauge[i] = NAN; } /* for i = 0 .. ds->ds_num */ @@ -483,7 +483,7 @@ static int us_handle_getval (FILE *fh, char **fields, int fields_num) for (i = 0; i < vc->values_num; i++) { fprintf (fh, " %s=", vc->ds->ds[i].name); - if (vc->gauge[i] == NAN) + if (isnan (vc->gauge[i])) fprintf (fh, "NaN"); else fprintf (fh, "%12e", vc->gauge[i]); -- 2.11.0