Replace a use of the hw.nintr sysctl as it has just gone away, cast

size_t variables when passing them to a printf-like function, and some
minor cleanups.
This commit is contained in:
Thomas Moestl 2001-06-01 13:29:19 +00:00
parent d279178df7
commit d62de5c4bb
3 changed files with 11 additions and 6 deletions

View File

@ -74,8 +74,8 @@ void getsysctl(name, ptr, len)
strerror(errno));
}
if (nlen != len) {
error("sysctl(%s...) expected %d, got %d", name,
len, nlen);
error("sysctl(%s...) expected %lu, got %lu", name,
(unsigned long)len, (unsigned long)nlen);
}
}

View File

@ -67,4 +67,3 @@ extern int use_kvm;
#define NVAL(indx) namelist[(indx)].n_value
#define NPTR(indx) (void *)NVAL((indx))
#define NREAD(indx, buf, len) kvm_ckread(NPTR((indx)), (buf), (len))
#define LONG (sizeof (long))

View File

@ -209,6 +209,7 @@ initkre()
{
char *intrnamebuf, *cp;
int i;
size_t sz;
if ((num_devices = getnumdevs()) < 0) {
warnx("%s", devstat_errbuf);
@ -226,9 +227,14 @@ initkre()
return(0);
if (nintr == 0) {
GETSYSCTL("hw.nintr", nintr);
if (sysctlbyname("hw.intrcnt", NULL, &sz, NULL, 0) == -1) {
error("sysctl(hw.intrcnt...) failed: %s",
strerror(errno));
return (0);
}
nintr = sz / sizeof(u_long);
intrloc = calloc(nintr, sizeof (long));
intrname = calloc(nintr, sizeof (long));
intrname = calloc(nintr, sizeof (char *));
intrnamebuf = sysctl_dynread("hw.intrnames", NULL);
if (intrnamebuf == NULL || intrname == NULL ||
intrloc == NULL) {
@ -767,7 +773,7 @@ getinfo(s, st)
GETSYSCTL("debug.freevnodes", s->freevnodes);
GETSYSCTL("vfs.cache.nchstats", s->nchstats);
GETSYSCTL("vfs.numdirtybuffers", s->numdirtybuffers);
getsysctl("hw.intrcnt", s->intrcnt, nintr * LONG);
getsysctl("hw.intrcnt", s->intrcnt, nintr * sizeof(u_long));
size = sizeof(s->Total);
mib[0] = CTL_VM;