From owner-svn-src-all@freebsd.org Sat Nov 7 19:14:55 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 53D63A29B30; Sat, 7 Nov 2015 19:14:55 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail109.syd.optusnet.com.au (mail109.syd.optusnet.com.au [211.29.132.80]) by mx1.freebsd.org (Postfix) with ESMTP id 126861F98; Sat, 7 Nov 2015 19:14:54 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from c211-30-166-197.carlnfd1.nsw.optusnet.com.au (c211-30-166-197.carlnfd1.nsw.optusnet.com.au [211.30.166.197]) by mail109.syd.optusnet.com.au (Postfix) with ESMTPS id A9D9ED63635; Sun, 8 Nov 2015 06:14:50 +1100 (AEDT) Date: Sun, 8 Nov 2015 06:14:50 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: "Conrad E. Meyer" cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r290505 - in head/sys: kern sys In-Reply-To: <201511071826.tA7IQWNR035920@repo.freebsd.org> Message-ID: <20151108054659.D5096@besplex.bde.org> References: <201511071826.tA7IQWNR035920@repo.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=R6/+YolX c=1 sm=1 tr=0 a=KA6XNC2GZCFrdESI5ZmdjQ==:117 a=PO7r1zJSAAAA:8 a=JzwRw_2MAAAA:8 a=kj9zAlcOel0A:10 a=KpWaLFP9ifmkMm4hwlsA:9 a=CjuIK1q_8ugA:10 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Nov 2015 19:14:55 -0000 On Sat, 7 Nov 2015, Conrad E. Meyer wrote: > Log: > Flesh out sysctl types further (follow-up of r290475) > > Use the right intmax_t type instead of intptr_t in a few remaining > places. > > Add support for CTLFLAG_TUN for the new fixed with types. Bruce will be > upset that the new handlers silently truncate tuned quad-sized inputs, > but so do all of the existing handlers. I think I have complained about the getenv_*() integer functions before. All of them truncate or otherwise corrupt the value. getenv_quad() does non-blind clamping using strtoq() followed by blind scaling in the suffix case. All others use getenv_quad() with blind truncation, except on 64-bit arches long == quad so getenv_long() only has the same errors as getenv_quad(). > Modified: head/sys/kern/kern_sysctl.c > ============================================================================== > --- head/sys/kern/kern_sysctl.c Sat Nov 7 18:26:02 2015 (r290504) > +++ head/sys/kern/kern_sysctl.c Sat Nov 7 18:26:32 2015 (r290505) > ... > + case CTLTYPE_S32: > + if (getenv_long(path + rem, &val_long) == 0) > + return; > + val_32 = val_long; > + req.newlen = sizeof(val_32); > + req.newptr = &val_32; > + break; This should use getenv_int(). FreeBSD never supported 16-bit ints, and POSIX now requires >= 32-bit ints. > @@ -250,6 +274,27 @@ sysctl_load_tunable_by_oid_locked(struct > req.newlen = sizeof(val_64); > req.newptr = &val_64; > break; > + case CTLTYPE_U8: > + if (getenv_uint(path + rem, (unsigned int *)&val_int) == 0) > + return; > + val_8 = val_int; > + req.newlen = sizeof(val_8); > + req.newptr = &val_8; > + break; > + case CTLTYPE_U16: > + if (getenv_uint(path + rem, (unsigned int *)&val_int) == 0) > + return; > + val_16 = val_int; > + req.newlen = sizeof(val_16); > + req.newptr = &val_16; > + break; These could use getenv_int() since int is larger than int17_t. Will null error checking, there would be little difference for the overflows caused by negative values. With non-null error checking, the checking would be slightly different. > + case CTLTYPE_U32: > + if (getenv_ulong(path + rem, (unsigned long *)&val_long) == 0) > + return; > + val_32 = val_long; > + req.newlen = sizeof(val_32); > + req.newptr = &val_32; > + break; Like for S32. Bruce