summaryrefslogtreecommitdiff
path: root/usr.bin/systat/sensors.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2010-04-20 20:49:37 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2010-04-20 20:49:37 +0000
commitcd401f6732e8849ebd763413c6d53b1126b61a05 (patch)
tree39f328c491c012082094970eb0ffc6dfe4d07d1f /usr.bin/systat/sensors.c
parent5afe4381d46759178e7417c854cb9b517bb23955 (diff)
Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug sensor that has gone away. Accessing beyond the end of the sensordev list still returns ENOENT, so that you can see there are no further devices. ok kettenis oga
Diffstat (limited to 'usr.bin/systat/sensors.c')
-rw-r--r--usr.bin/systat/sensors.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/usr.bin/systat/sensors.c b/usr.bin/systat/sensors.c
index e4c9cbe982b..f5d1cc630ca 100644
--- a/usr.bin/systat/sensors.c
+++ b/usr.bin/systat/sensors.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sensors.c,v 1.20 2010/04/20 19:44:07 oga Exp $ */
+/* $OpenBSD: sensors.c,v 1.21 2010/04/20 20:49:35 deraadt Exp $ */
/*
* Copyright (c) 2007 Deanna Phillips <deanna@openbsd.org>
@@ -43,7 +43,8 @@ struct sensinfo {
#define sn_status sn_sensor.status
#define sn_value sn_sensor.value
-char *devnames[MAXSENSORDEVICES];
+#define SYSTAT_MAXSENSORDEVICES 1024
+char *devnames[SYSTAT_MAXSENSORDEVICES];
#define ADD_ALLOC 100
static size_t sensor_cnt = 0;
@@ -134,13 +135,15 @@ read_sn(void)
sensor_cnt = 0;
- for (dev = 0; dev < MAXSENSORDEVICES; dev++) {
+ for (dev = 0; dev < SYSTAT_MAXSENSORDEVICES; dev++) {
mib[2] = dev;
sdlen = sizeof(struct sensordev);
if (sysctl(mib, 3, &sensordev, &sdlen, NULL, 0) == -1) {
- if (errno != ENOENT)
- error("sysctl: %s", strerror(errno));
- continue;
+ if (errno == ENOENT)
+ break;
+ if (errno == ENXIO)
+ continue;
+ error("sysctl: %s", strerror(errno));
}
if (devnames[dev] && strcmp(devnames[dev], sensordev.xname)) {