summaryrefslogtreecommitdiff
path: root/sbin
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 /sbin
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 'sbin')
-rw-r--r--sbin/sysctl/sysctl.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c
index 2dfed0da864..47a87365d84 100644
--- a/sbin/sysctl/sysctl.c
+++ b/sbin/sysctl/sysctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysctl.c,v 1.169 2010/04/20 19:44:07 oga Exp $ */
+/* $OpenBSD: sysctl.c,v 1.170 2010/04/20 20:49:35 deraadt Exp $ */
/* $NetBSD: sysctl.c,v 1.9 1995/09/30 07:12:50 thorpej Exp $ */
/*
@@ -2244,10 +2244,14 @@ sysctl_sensors(char *string, char **bufpp, int mib[], int flags, int *typep)
char buf[SYSCTL_BUFSIZ];
/* scan all sensor devices */
- for (dev = 0; dev < MAXSENSORDEVICES; dev++) {
+ for (dev = 0; ; dev++) {
mib[2] = dev;
- if (sysctl(mib, 3, &snsrdev, &sdlen, NULL, 0) == -1)
- continue;
+ if (sysctl(mib, 3, &snsrdev, &sdlen, NULL, 0) == -1) {
+ if (errno == ENXIO)
+ continue;
+ if (errno == ENOENT)
+ break;
+ }
snprintf(buf, sizeof(buf), "%s.%s",
string, snsrdev.xname);
print_sensordev(buf, mib, 3, &snsrdev);
@@ -2265,10 +2269,14 @@ sysctl_sensors(char *string, char **bufpp, int mib[], int flags, int *typep)
return (-1);
}
/* convert sensor device string to an integer */
- for (dev = 0; dev < MAXSENSORDEVICES; dev++) {
+ for (dev = 0; ; dev++) {
mib[2] = dev;
- if (sysctl(mib, 3, &snsrdev, &sdlen, NULL, 0) == -1)
- continue;
+ if (sysctl(mib, 3, &snsrdev, &sdlen, NULL, 0) == -1) {
+ if (errno == ENXIO)
+ continue;
+ if (errno == ENOENT)
+ break;
+ }
if (strcmp(devname, snsrdev.xname) == 0)
break;
}