Fix some 64bit truncation problems which crept into SYSCTL_LONG() with the

last cleanup.  Since the oid_arg2 field of struct sysctl_oid is not wide
enough to hold a long, the SYSCTL_LONG() macro has been modified to only
support exporting long variables by pointer instead of by value.

Reviewed by: bde
This commit is contained in:
Doug Rabson 1998-12-27 18:03:29 +00:00
parent 4ae16510d1
commit 486bddb033
5 changed files with 21 additions and 51 deletions

View File

@ -23,7 +23,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* $Id: pcibus.c,v 1.6 1998/11/15 18:25:16 dfr Exp $ * $Id: pcibus.c,v 1.7 1998/11/18 23:53:12 dfr Exp $
* *
*/ */
@ -53,18 +53,15 @@ SYSCTL_STRING(_hw_chipset, OID_AUTO, type, CTLFLAG_RD, chipset_type, 0,
"PCI chipset type"); "PCI chipset type");
SYSCTL_INT(_hw_chipset, OID_AUTO, bwx, CTLFLAG_RD, &chipset_bwx, 0, SYSCTL_INT(_hw_chipset, OID_AUTO, bwx, CTLFLAG_RD, &chipset_bwx, 0,
"PCI chipset supports BWX access"); "PCI chipset supports BWX access");
SYSCTL_LONG(_hw_chipset, OID_AUTO, ports, CTLFLAG_RD, &chipset_ports, 0, SYSCTL_LONG(_hw_chipset, OID_AUTO, ports, CTLFLAG_RD, &chipset_ports,
"PCI chipset port address"); "PCI chipset port address");
SYSCTL_LONG(_hw_chipset, OID_AUTO, memory, CTLFLAG_RD, &chipset_memory, 0, SYSCTL_LONG(_hw_chipset, OID_AUTO, memory, CTLFLAG_RD, &chipset_memory,
"PCI chipset memory address"); "PCI chipset memory address");
SYSCTL_LONG(_hw_chipset, OID_AUTO, dense, CTLFLAG_RD, &chipset_dense, 0, SYSCTL_LONG(_hw_chipset, OID_AUTO, dense, CTLFLAG_RD, &chipset_dense,
"PCI chipset dense memory address"); "PCI chipset dense memory address");
SYSCTL_LONG(_hw_chipset, OID_AUTO, hae_mask, CTLFLAG_RD, &chipset_hae_mask, 0, SYSCTL_LONG(_hw_chipset, OID_AUTO, hae_mask, CTLFLAG_RD, &chipset_hae_mask,
"PCI chipset mask for HAE register"); "PCI chipset mask for HAE register");
static int cfgmech;
static int devmax;
#ifdef notyet #ifdef notyet
/* return max number of devices on the bus */ /* return max number of devices on the bus */

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: kern_exec.c,v 1.89 1998/12/16 16:06:27 bde Exp $ * $Id: kern_exec.c,v 1.90 1998/12/16 16:28:57 bde Exp $
*/ */
#include <sys/param.h> #include <sys/param.h>
@ -66,8 +66,11 @@
static long *exec_copyout_strings __P((struct image_params *)); static long *exec_copyout_strings __P((struct image_params *));
SYSCTL_LONG(_kern, KERN_PS_STRINGS, ps_strings, CTLFLAG_RD, 0, PS_STRINGS, ""); static long ps_strings = PS_STRINGS;
SYSCTL_LONG(_kern, KERN_USRSTACK, usrstack, CTLFLAG_RD, 0, USRSTACK, ""); SYSCTL_LONG(_kern, KERN_PS_STRINGS, ps_strings, CTLFLAG_RD, &ps_strings, "");
static long usrstack = USRSTACK;
SYSCTL_LONG(_kern, KERN_USRSTACK, usrstack, CTLFLAG_RD, &usrstack, "");
/* /*
* Each of the items is a pointer to a `const struct execsw', hence the * Each of the items is a pointer to a `const struct execsw', hence the

View File

@ -37,7 +37,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* @(#)kern_sysctl.c 8.4 (Berkeley) 4/14/94 * @(#)kern_sysctl.c 8.4 (Berkeley) 4/14/94
* $Id: kern_sysctl.c,v 1.79 1998/12/04 22:54:51 archie Exp $ * $Id: kern_sysctl.c,v 1.80 1998/12/13 07:18:54 truckman Exp $
*/ */
#include "opt_compat.h" #include "opt_compat.h"
@ -497,7 +497,7 @@ SYSCTL_NODE(_sysctl, 4, oidfmt, CTLFLAG_RD, sysctl_sysctl_oidfmt, "");
*/ */
/* /*
* Handle an integer, signed or unsigned. * Handle an int, signed or unsigned.
* Two cases: * Two cases:
* a variable: point arg1 at it. * a variable: point arg1 at it.
* a constant: pass it in arg2. * a constant: pass it in arg2.
@ -524,7 +524,7 @@ sysctl_handle_int SYSCTL_HANDLER_ARGS
} }
/* /*
* Handle an integer, signed or unsigned. * Handle a long, signed or unsigned.
* Two cases: * Two cases:
* a variable: point arg1 at it. * a variable: point arg1 at it.
* a constant: pass it in arg2. * a constant: pass it in arg2.
@ -535,10 +535,7 @@ sysctl_handle_long SYSCTL_HANDLER_ARGS
{ {
int error = 0; int error = 0;
if (arg1) error = SYSCTL_OUT(req, arg1, sizeof(long));
error = SYSCTL_OUT(req, arg1, sizeof(long));
else
error = SYSCTL_OUT(req, &arg2, sizeof(long));
if (error || !req->newptr) if (error || !req->newptr)
return (error); return (error);
@ -550,33 +547,6 @@ sysctl_handle_long SYSCTL_HANDLER_ARGS
return (error); return (error);
} }
/*
* Handle an integer, signed or unsigned.
* Two cases:
* a variable: point arg1 at it.
* a constant: pass it in arg2.
*/
int
sysctl_handle_intptr SYSCTL_HANDLER_ARGS
{
int error = 0;
if (arg1)
error = SYSCTL_OUT(req, arg1, sizeof(intptr_t));
else
error = SYSCTL_OUT(req, &arg2, sizeof(intptr_t));
if (error || !req->newptr)
return (error);
if (!arg1)
error = EPERM;
else
error = SYSCTL_IN(req, arg1, sizeof(intptr_t));
return (error);
}
/* /*
* Handle our generic '\0' terminated 'C' string. * Handle our generic '\0' terminated 'C' string.
* Two cases: * Two cases:

View File

@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: subr_devstat.c,v 1.6 1998/11/15 23:57:22 ken Exp $ * $Id: subr_devstat.c,v 1.7 1998/12/04 22:54:51 archie Exp $
*/ */
#include <sys/param.h> #include <sys/param.h>
@ -243,6 +243,6 @@ SYSCTL_PROC(_kern_devstat, OID_AUTO, all, CTLFLAG_RD|CTLTYPE_OPAQUE,
SYSCTL_INT(_kern_devstat, OID_AUTO, numdevs, CTLFLAG_RD, &devstat_num_devs, SYSCTL_INT(_kern_devstat, OID_AUTO, numdevs, CTLFLAG_RD, &devstat_num_devs,
0, "Number of devices in the devstat list"); 0, "Number of devices in the devstat list");
SYSCTL_LONG(_kern_devstat, OID_AUTO, generation, CTLFLAG_RD, SYSCTL_LONG(_kern_devstat, OID_AUTO, generation, CTLFLAG_RD,
&devstat_generation, 0, "Devstat list generation"); &devstat_generation, "Devstat list generation");
SYSCTL_INT(_kern_devstat, OID_AUTO, version, CTLFLAG_RD, &devstat_version, SYSCTL_INT(_kern_devstat, OID_AUTO, version, CTLFLAG_RD, &devstat_version,
0, "Devstat list version number"); 0, "Devstat list version number");

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* @(#)sysctl.h 8.1 (Berkeley) 6/2/93 * @(#)sysctl.h 8.1 (Berkeley) 6/2/93
* $Id: sysctl.h,v 1.66 1998/12/13 07:19:13 truckman Exp $ * $Id: sysctl.h,v 1.67 1998/12/16 16:06:29 bde Exp $
*/ */
#ifndef _SYS_SYSCTL_H_ #ifndef _SYS_SYSCTL_H_
@ -156,10 +156,10 @@ int sysctl_handle_opaque SYSCTL_HANDLER_ARGS;
SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|access, \ SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|access, \
ptr, val, sysctl_handle_int, "I", descr) ptr, val, sysctl_handle_int, "I", descr)
/* Oid for a long. If ptr is NULL, val is returned. */ /* Oid for a long. The pointer must be non NULL. */
#define SYSCTL_LONG(parent, nbr, name, access, ptr, val, descr) \ #define SYSCTL_LONG(parent, nbr, name, access, ptr, descr) \
SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|access, \ SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|access, \
ptr, val, sysctl_handle_long, "L", descr) ptr, 0, sysctl_handle_long, "L", descr)
/* Oid for an opaque object. Specified by a pointer and a length. */ /* Oid for an opaque object. Specified by a pointer and a length. */
#define SYSCTL_OPAQUE(parent, nbr, name, access, ptr, len, fmt, descr) \ #define SYSCTL_OPAQUE(parent, nbr, name, access, ptr, len, fmt, descr) \