From owner-freebsd-doc@FreeBSD.ORG Mon Oct 6 11:10:13 2003 Return-Path: Delivered-To: freebsd-doc@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2BFE916A4E0 for ; Mon, 6 Oct 2003 11:10:13 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5CDDB44008 for ; Mon, 6 Oct 2003 11:10:11 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h96IABFY066983 for ; Mon, 6 Oct 2003 11:10:11 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h96IABES066982; Mon, 6 Oct 2003 11:10:11 -0700 (PDT) (envelope-from gnats) Resent-Date: Mon, 6 Oct 2003 11:10:11 -0700 (PDT) Resent-Message-Id: <200310061810.h96IABES066982@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-doc@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Ted Nolan Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D180516A4B3 for ; Mon, 6 Oct 2003 11:08:37 -0700 (PDT) Received: from colanix0.ga.erg.sri.com (colanix0.ga.erg.sri.com [192.26.245.70]) by mx1.FreeBSD.org (Postfix) with ESMTP id E457643FD7 for ; Mon, 6 Oct 2003 11:08:36 -0700 (PDT) (envelope-from ted@colanix0.ga.erg.sri.com) Received: from colanix0.ga.erg.sri.com (localhost [127.0.0.1]) h96I8YSx019327; Mon, 6 Oct 2003 14:08:34 -0400 (EDT) (envelope-from ted@colanix0.ga.erg.sri.com) Received: (from ted@localhost) by colanix0.ga.erg.sri.com (8.12.3/8.12.3/Submit) id h96I8Xds019326; Mon, 6 Oct 2003 14:08:33 -0400 (EDT) Message-Id: <200310061808.h96I8Xds019326@colanix0.ga.erg.sri.com> Date: Mon, 6 Oct 2003 14:08:33 -0400 (EDT) From: Ted Nolan To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 cc: ted@erg.sri.com Subject: docs/57669: IFMIB(4) man page uses sysctl(3) incorrectly in example code X-BeenThere: freebsd-doc@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Ted Nolan List-Id: Documentation project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Oct 2003 18:10:13 -0000 >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@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: