From owner-svn-src-all@freebsd.org Mon Sep 28 06:07:55 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 41B883F784D; Mon, 28 Sep 2020 06:07:55 +0000 (UTC) (envelope-from scottl@samsco.org) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4C0Brp65Jkz3fmn; Mon, 28 Sep 2020 06:07:54 +0000 (UTC) (envelope-from scottl@samsco.org) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 6CAD6873; Mon, 28 Sep 2020 02:07:52 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 28 Sep 2020 02:07:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsco.org; h= content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; s=fm1; bh=O WqOaa4p8jIZQxdCS5VVPXqMFSzKHePBJ+BU8Mcce9k=; b=cW3trF3W59BLPaoRb 357ZMt4QsRUHL+zO06c/2kSimNJjTn1JfewaKgc8D2zLy68572YJoupiOyoSIWWa xmmnnFDOAKI+PM3+TZv/NyEYXLJHPAGxgNizrE5l94MpFfnfUyc08ilj2JJBsxdV xuvbKV3t/E1nO5jzKyYp91wWbqTp+b5EIOdPKkY6YzTo781QKNl0QSbS3p8HashT 9o6KbLskvzigzmZz5/meplTV2jVdvbWhcMz7RUoV9++iK7FWYLBjKk4TL4c7EBNR UamEbgrAiWwB7ceHyU8koyrL7ock1JD5gN8Uznu4078JYWGopIstgOlaC5sNqqQX K5rMw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=OWqOaa4p8jIZQxdCS5VVPXqMFSzKHePBJ+BU8Mcce 9k=; b=fEwOeJqve0x7S7DWPfFYuV4IlarDmsjSFXIic6v+Ef446UiUb9eAfNZKr x1bsKqdIHJsVy/rFyJD4kjQ772pfp36ZxDldL7Bx/zzjc64Bwop2vyV/FC50pO1H cAxgwiD2i4S5dbqPGPqDwyPdachgYtCllOmhNZ5HIIWLizoZCU3Azi4IMsIywKMK 4nOcS7w9bE+T6ZXXV+Nc43PJHPMFEY/eqF3NuuQET5wVy/WOqMeWEGF6mXN5FEHV BK3+bP7KdhKiBQnLHshTeP6PbSZZAoObz73m3Sg+aNwfqzGyczgnaGdFhouELo/M zJQ3oxoaPMJrbuDa3l82KPhSN7olw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvdehgddutdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurheptggguffhjgffgffkfhfvofesthhqmhdthhdtjeenucfhrhhomhepufgtohht thcunfhonhhguceoshgtohhtthhlsehsrghmshgtohdrohhrgheqnecuggftrfgrthhtvg hrnhepudduveekheehiedukeekleelvedufeevfeetudfgtdffteffleehheffueffgfeh necuffhomhgrihhnpehfrhgvvggsshgurdhorhhgnecukfhppeekrdegiedrkeelrddvud efnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshgt ohhtthhlsehsrghmshgtohdrohhrgh X-ME-Proxy: Received: from [192.168.0.114] (unknown [8.46.89.213]) by mail.messagingengine.com (Postfix) with ESMTPA id 651D73280059; Mon, 28 Sep 2020 02:07:51 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: svn commit: r366207 - head/lib/libc/gen From: Scott Long In-Reply-To: Date: Mon, 28 Sep 2020 00:07:50 -0600 Cc: Konstantin Belousov , src-committers , svn-src-all , svn-src-head Content-Transfer-Encoding: quoted-printable Message-Id: References: <202009272226.08RMQf1h054050@repo.freebsd.org> <20200927231519.GI2643@kib.kiev.ua> To: Alan Somers X-Mailer: Apple Mail (2.3608.120.23.2.1) X-Rspamd-Queue-Id: 4C0Brp65Jkz3fmn X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:11403, ipnet:64.147.123.0/24, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 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: Mon, 28 Sep 2020 06:07:55 -0000 > On Sep 27, 2020, at 10:08 PM, Alan Somers wrote: >=20 > On Sun, Sep 27, 2020 at 5:15 PM Konstantin Belousov = wrote: > On Sun, Sep 27, 2020 at 10:26:41PM +0000, Alan Somers wrote: > > Author: asomers > > Date: Sun Sep 27 22:26:41 2020 > > New Revision: 366207 > > URL: https://svnweb.freebsd.org/changeset/base/366207 > >=20 > > Log: > > Misc compiler warning fixes in lib/libc > > =20 > > Reviewed by: kevans, imp > > MFC after: 2 weeks > > Differential Revision: https://reviews.freebsd.org/D26534 > >=20 > > Modified: > > head/lib/libc/gen/auxv.c > > head/lib/libc/gen/basename_compat.c > > head/lib/libc/gen/crypt.c > > head/lib/libc/gen/dirname_compat.c > > head/lib/libc/gen/fts-compat.c > > head/lib/libc/gen/ftw-compat11.c > > head/lib/libc/gen/getentropy.c > >=20 > > Modified: head/lib/libc/gen/auxv.c > > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > > --- head/lib/libc/gen/auxv.c Sun Sep 27 21:43:19 2020 = (r366206) > > +++ head/lib/libc/gen/auxv.c Sun Sep 27 22:26:41 2020 = (r366207) > > @@ -67,7 +67,8 @@ __init_elf_aux_vector(void) > > } > > =20 > > static pthread_once_t aux_once =3D PTHREAD_ONCE_INIT; > > -static int pagesize, osreldate, canary_len, ncpus, pagesizes_len, = bsdflags; > > +static int pagesize, osreldate, ncpus, bsdflags; > > +static size_t canary_len, pagesizes_len; > > static int hwcap_present, hwcap2_present; > > static char *canary, *pagesizes, *execpath; > > static void *ps_strings, *timekeep; > > @@ -245,16 +246,21 @@ int > > _elf_aux_info(int aux, void *buf, int buflen) > > { > > int res; > > + size_t buflen_; > > =20 > > __init_elf_aux_vector(); > > if (__elf_aux_vector =3D=3D NULL) > > return (ENOSYS); > > _once(&aux_once, init_aux); > > =20 > > + if (buflen < 0) > > + return (EINVAL); > > + buflen_ =3D (size_t)buflen; > > + > > switch (aux) { > > case AT_CANARY: > > - if (canary !=3D NULL && canary_len >=3D buflen) { > > - memcpy(buf, canary, buflen); > > + if (canary !=3D NULL && canary_len >=3D buflen_) { > > + memcpy(buf, canary, buflen_); > > memset(canary, 0, canary_len); > > canary =3D NULL; > > res =3D 0; > > @@ -267,35 +273,35 @@ _elf_aux_info(int aux, void *buf, int buflen) > > else if (buf =3D=3D NULL) > > res =3D EINVAL; > > else { > > - if (strlcpy(buf, execpath, buflen) >=3D = buflen) > > + if (strlcpy(buf, execpath, buflen_) >=3D = buflen_) > > res =3D EINVAL; > > else > > res =3D 0; > > } > > break; > > case AT_HWCAP: > > - if (hwcap_present && buflen =3D=3D sizeof(u_long)) { > > + if (hwcap_present && buflen_ =3D=3D sizeof(u_long)) { > > *(u_long *)buf =3D hwcap; > > res =3D 0; > > } else > > res =3D ENOENT; > > break; > > case AT_HWCAP2: > > - if (hwcap2_present && buflen =3D=3D sizeof(u_long)) { > > + if (hwcap2_present && buflen_ =3D=3D sizeof(u_long)) { > > *(u_long *)buf =3D hwcap2; > > res =3D 0; > > } else > > res =3D ENOENT; > > break; > > case AT_PAGESIZES: > > - if (pagesizes !=3D NULL && pagesizes_len >=3D buflen) = { > > - memcpy(buf, pagesizes, buflen); > > + if (pagesizes !=3D NULL && pagesizes_len >=3D buflen_) = { > > + memcpy(buf, pagesizes, buflen_); > > res =3D 0; > > } else > > res =3D ENOENT; > > break; > > case AT_PAGESZ: > > - if (buflen =3D=3D sizeof(int)) { > > + if (buflen_ =3D=3D sizeof(int)) { > > if (pagesize !=3D 0) { > > *(int *)buf =3D pagesize; > > res =3D 0; > > @@ -305,7 +311,7 @@ _elf_aux_info(int aux, void *buf, int buflen) > > res =3D EINVAL; > > break; > > case AT_OSRELDATE: > > - if (buflen =3D=3D sizeof(int)) { > > + if (buflen_ =3D=3D sizeof(int)) { > > if (osreldate !=3D 0) { > > *(int *)buf =3D osreldate; > > res =3D 0; > > @@ -315,7 +321,7 @@ _elf_aux_info(int aux, void *buf, int buflen) > > res =3D EINVAL; > > break; > > case AT_NCPUS: > > - if (buflen =3D=3D sizeof(int)) { > > + if (buflen_ =3D=3D sizeof(int)) { > > if (ncpus !=3D 0) { > > *(int *)buf =3D ncpus; > > res =3D 0; > > @@ -325,7 +331,7 @@ _elf_aux_info(int aux, void *buf, int buflen) > > res =3D EINVAL; > > break; > > case AT_TIMEKEEP: > > - if (buflen =3D=3D sizeof(void *)) { > > + if (buflen_ =3D=3D sizeof(void *)) { > > if (timekeep !=3D NULL) { > > *(void **)buf =3D timekeep; > > res =3D 0; > > @@ -335,14 +341,14 @@ _elf_aux_info(int aux, void *buf, int buflen) > > res =3D EINVAL; > > break; > > case AT_BSDFLAGS: > > - if (buflen =3D=3D sizeof(int)) { > > + if (buflen_ =3D=3D sizeof(int)) { > > *(int *)buf =3D bsdflags; > > res =3D 0; > > } else > > res =3D EINVAL; > > break; > > case AT_PS_STRINGS: > > - if (buflen =3D=3D sizeof(void *)) { > > + if (buflen_ =3D=3D sizeof(void *)) { > > if (ps_strings !=3D NULL) { > > *(void **)buf =3D ps_strings; > > res =3D 0; >=20 > This is significant uglification of the code in the name of fixing = pointless > warnings. >=20 > Warnings are NOT pointless. 99% of them are. But the only way to = find the 1% that aren't is to quell the 99% that are. Last week I wrote = a bug that fortunately got caught in code review. But it shouldn't have = made it that far. It should've been caught by the compiler, but libc is = only built with WARNS=3D2. This commit is one step towards raising = libc's WARNs level to 3. Only 334 files left to go. > =20 A suggestion that might make the diff of the first file a little smaller = and attractive is to rename the passed in variable from =E2=80=9Cbuflen=E2= =80=9D to =E2=80=9C_buflen=E2=80=9D and call the new local variable = =E2=80=9Cbuflen=E2=80=9D. You=E2=80=99d still need the test and = assignment at the top of the function, but a lot of the rest of the diff = would have evaporated away. Scott