Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/envstat Zero is a valid value for some sensors so u...
details: https://anonhg.NetBSD.org/src/rev/5950c24f5979
branches: trunk
changeset: 765842:5950c24f5979
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Tue Jun 07 17:24:32 2011 +0000
description:
Zero is a valid value for some sensors so update statistics code to
handle that.
diffstat:
usr.sbin/envstat/envstat.c | 22 +++++++++-------------
1 files changed, 9 insertions(+), 13 deletions(-)
diffs (70 lines):
diff -r 34cdbf557e9b -r 5950c24f5979 usr.sbin/envstat/envstat.c
--- a/usr.sbin/envstat/envstat.c Tue Jun 07 17:13:43 2011 +0000
+++ b/usr.sbin/envstat/envstat.c Tue Jun 07 17:24:32 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: envstat.c,v 1.87 2011/06/06 20:48:56 pgoyette Exp $ */
+/* $NetBSD: envstat.c,v 1.88 2011/06/07 17:24:32 pgoyette Exp $ */
/*-
* Copyright (c) 2007, 2008 Juan Romero Pardines.
@@ -27,13 +27,14 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: envstat.c,v 1.87 2011/06/06 20:48:56 pgoyette Exp $");
+__RCSID("$NetBSD: envstat.c,v 1.88 2011/06/07 17:24:32 pgoyette Exp $");
#endif /* not lint */
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdarg.h>
+#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
@@ -347,6 +348,8 @@
return NULL;
(void)strlcpy(stats->desc, desc, sizeof(stats->desc));
+ stats->min = INT32_MAX;
+ stats->max = INT32_MIN;
SIMPLEQ_INSERT_TAIL(&sensor_stats_list, stats, entries);
return stats;
@@ -625,7 +628,7 @@
continue;
/* ignore invalid data */
- if (sensor->invalid || !sensor->cur_value)
+ if (sensor->invalid)
continue;
/* find or allocate a new statistics sensor */
@@ -636,12 +639,7 @@
return ENOMEM;
}
- /* collect data */
- if (!stats->max)
- stats->max = sensor->cur_value;
- if (!stats->min)
- stats->min = sensor->cur_value;
-
+ /* update data */
if (sensor->cur_value > stats->max)
stats->max = sensor->cur_value;
@@ -649,10 +647,8 @@
stats->min = sensor->cur_value;
/* compute avg value */
- if (stats->max && stats->min)
- stats->avg =
- (sensor->cur_value + stats->max +
- stats->min) / 3;
+ stats->avg =
+ (sensor->cur_value + stats->max + stats->min) / 3;
}
}
Home |
Main Index |
Thread Index |
Old Index