Subject: kern/1999: sendctl(3) man page and implementation differ
To: None <gnats-bugs@NetBSD.ORG>
From: Kevin M. Lahey <email@example.com>
Date: 01/30/1996 12:53:39
>Synopsis: man page and implementation of sysctl(3) differ
>Responsible: kern-bug-people (Kernel Bug People)
>Arrival-Date: Tue Jan 30 15:35:03 1996
>Originator: Kevin M. Lahey
>Release: 1.1A, i386
System: NetBSD antie 1.1A NetBSD 1.1A (ANTIE) #411: Mon Jan 29 14:06:52 PST 1996 thorpej@antie:/work/netbsd/src/sys/arch/i386/compile/ANTIE i386
The man page for sysctl(3) claims that the function returns 0 on
success, -1 on failure. For at least some set of arguments, it
instead returns the size of the data retrieved.
As an aside, the man page lists <sys/sysctl.h> as the only include
required. This didn't quite work for me; I found that including
<sys/param.h> made it work. There may be some other include file
that would work better; beats me.
According to the man page, the following program should retrieve the
size of physical memory, with a return value of 0. Instead, the
return value is 4.
len = sizeof(int);
mib = CTL_HW;
mib = HW_PHYSMEM;
result = sysctl(mib, 2, &physmem, &len, NULL, 0);
printf("physmem = %d, return value = %d\n", physmem, result);
Change the documentation to mention additional required include
I'm not sure whether the code or the man page needs to change.
I did notice, though that when the programmer has allocated
insufficient room for the retrieved data, the function returns
an error code, but tries to fill up the space provided.
In that case, checking the return code to determine how much
data was retrieved would fail. I guess I think that the code