use of kernel_sysctl

Matthew Luckie mjl at luckie.org.nz
Wed Jun 9 00:11:56 GMT 2004


in sys/netsmb/smb_subr.c the following code fragment is used:

[FreeBSD 4.10]

int smb_checksmp(void)
{
 	int name[2];
 	int olen, ncpu, plen, error;

 	name[0] = CTL_HW;
 	name[1] = HW_NCPU;
 	error = kernel_sysctl(curproc, name, 2, &ncpu, &olen, NULL, 0, &plen);
 	if (error)
 		return error;

olen is passed without having its value set.  on input, i'd expect it to 
specify sizeof(ncpu).  looking in kernel_sysctl.c, *olen is used by 
kernel_sysctl.

I had a quick grep through the source and saw a similar code fragment to 
this in nwfs.  So it could be either that I've got it wrong and I'm not 
understanding something, or the code was used as a template in more than 
one place and was bug-for-bug copied.

Feedback appreciated, cc'd

Matthew


More information about the freebsd-hackers mailing list