docs/57669: IFMIB(4) man page uses sysctl(3) incorrectly in example code
Ted Nolan
ted at erg.sri.com
Mon Oct 6 18:10:13 UTC 2003
>Number: 57669
>Category: docs
>Synopsis: IFMIB(4) man page uses sysctl(3) incorrectly in example code
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-doc
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: doc-bug
>Submitter-Id: current-users
>Arrival-Date: Mon Oct 06 11:10:10 PDT 2003
>Closed-Date:
>Last-Modified:
>Originator: Ted Nolan
>Release: FreeBSD 4.6.2-RELEASE i386
>Organization:
SRI International
>Environment:
System: FreeBSD colanix0 4.6.2-RELEASE FreeBSD 4.6.2-RELEASE #0: Wed Aug 14 21:23:26 GMT 2002 murray at builder.freebsdmall.com:/usr/src/sys/compile/GENERIC i386
>Description:
The man page for ifmib(4) gives a code sample defining a function
get_ifmib_general(). This function uses the sysctl(3) function, but
with incorrect parameters. The 4th parameter to sysctl(3) is the
_address_ of a location to read and store the size of the data;
however the example code places the actual size here, not the _location_
of the size. The code will therefore give compilation warnings and
likely fail if run.
>How-To-Repeat:
Enter the code from the example, attempt to compile it with warnings
enabled.
>Fix:
One way to fix it would be to declare a variable
size_t len;
and replace the given sysctl() line with 2 lines:
len = sizeof(*ifmd);
return sysctl(name, 6, ifmd, &len, (void *)0, 0);
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-doc
mailing list