From nobody Tue Feb 11 03:30:38 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4YsRmQ1sfxz5nJlC; Tue, 11 Feb 2025 03:30:46 +0000 (UTC) (envelope-from zlei@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YsRmQ0sQHz41cZ; Tue, 11 Feb 2025 03:30:46 +0000 (UTC) (envelope-from zlei@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1739244646; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5DNFRxS7CrxZi7KqkpfNHrF4lqQtsHMOy5FSCjEBcjo=; b=j7bGj1rvhB8aMTXSxoSVNk71CmgCOBXj8PssyXAGRi07xOZR4E6U9cQd/OPAq3G9Zh8HUZ cAUwGrdcso0Z4gnfDwU0Jd/bwI0mTd5Z36oEvB/dYMwkq2bcT4iosrURfM0kUxcqk7nnFE hIOL5dX8V/rCJn3GZ4Mte3DtaNIyc/F+dcXPCdvjsGZ80HNZEswB3fFJvqNk6AKtNPQeg/ hk1IjukPb53hUVuI18+Hqq5wnSWRIEySbiNKsbkgUzfk+kZigSc6RoW3LO9ZC2LFpLAFiD v3msbd8YCZXgfXaKx4o/eAlZqxWEe4M7Ihl3EtLJpK5m+Dhja8fPSv1xxkKz9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1739244646; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5DNFRxS7CrxZi7KqkpfNHrF4lqQtsHMOy5FSCjEBcjo=; b=HmCRhZfo5UMOa+K8m4C93tKh2Sj4B3MDMVekcnYVF1rrN+eE6TPpZhSrncerUnhcmCCHpc EDVQUmRD3OpmRhitDKxy4djfTPw6wf7dtE/mxKVlACAoD8LiWTCJ44OkZQK9oVYi1RM904 B/7tRJkZ2y3YBAEFN+xYoy94oblOdO2sFIZLipHb1UhtItaNNe8gpjQeMllnxbDbZwn+Xg VBhFdwV7M6mmIWGO2wisP8cUd/7cmkSwoqNd5FI9VYk2gYT/gruEu/AXyScXvQMtdlipoX pnjOClHmwxLK/mFtiejkRSqOAZNsDaMLeuqEUs9QUD2MvaFn0USLIlrUINgjyA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1739244646; a=rsa-sha256; cv=none; b=kBpp0yu1h3IP9jg3rl42yH7f4ywTJ8Y+C+vQGCgY2+PSDq8F8P+mdGhmHGxqO+Af2cTyZf 7IPf+boQzHYelB6nB/1ac89EyDAxG4+wmAtP3x3Y6jo54HT5gzXAZhGZEQNKcavp1v2VMw 2CVDgM/8R8WzKSdh+IR54i27aJnPFfl8Hz8CJ8e0EqyNPAQGSMBaNssPzZCJvN3kNBEOpi OWIILVXo5DSSD+o/b650je7maDb+VQFkDVV4SIBln2d/B2TF66ARzZwj7BlADB8ykCaWWK MqTowWvclj/r9fMj1XZOv3Fg76gbKVgavMCRjNpGKC5AsumJ0Hs4PUzfHoymfQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from smtpclient.apple (ns1.oxydns.net [45.32.91.63]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: zlei/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 4YsRmN4lTgz13ym; Tue, 11 Feb 2025 03:30:44 +0000 (UTC) (envelope-from zlei@FreeBSD.org) Content-Type: text/plain; charset=us-ascii List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.10\)) Subject: Re: git: 7bcc7a0b88cc - stable/14 - libkern: avoid local var in order_base_2() From: Zhenlei Huang In-Reply-To: <202502101115.51ABFISj016298@gitrepo.freebsd.org> Date: Tue, 11 Feb 2025 11:30:38 +0800 Cc: "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-branches@freebsd.org" Content-Transfer-Encoding: quoted-printable Message-Id: <858BD10B-A2C9-4D3A-9FF5-C5573597DF8B@FreeBSD.org> References: <202502101115.51ABFISj016298@gitrepo.freebsd.org> To: Doug Moore X-Mailer: Apple Mail (2.3696.120.41.1.10) > On Feb 10, 2025, at 7:15 PM, Doug Moore wrote: >=20 > The branch stable/14 has been updated by dougm: >=20 > URL: = https://cgit.FreeBSD.org/src/commit/?id=3D7bcc7a0b88ccb5e1fe31de88ab9a17e4= 6859318b >=20 > commit 7bcc7a0b88ccb5e1fe31de88ab9a17e46859318b > Author: Doug Moore > AuthorDate: 2024-09-27 23:43:07 +0000 > Commit: Doug Moore > CommitDate: 2025-02-10 10:30:05 +0000 >=20 > libkern: avoid local var in order_base_2() >=20 > order_base_2(n) is implemented with a variable, which keeps it from > being used at file scope. Implement it instead as ilog2(2*n-1), = which > produces a different result when 2*n overflows, which appears = unlikely > in practice. >=20 > Reviewed by: bz > Differential Revision: https://reviews.freebsd.org/D46826 >=20 > (cherry picked from commit = b7cbf741d55468ba34305a14ac3acc1c286af034) > --- > sys/sys/libkern.h | 5 +---- > 1 file changed, 1 insertion(+), 4 deletions(-) >=20 > diff --git a/sys/sys/libkern.h b/sys/sys/libkern.h > index a10289d72dc7..835e5ffaf0b7 100644 > --- a/sys/sys/libkern.h > +++ b/sys/sys/libkern.h > @@ -229,10 +229,7 @@ ilog2_long_long(long long n) >=20 > #define ilog2(n) (__builtin_constant_p(n) ? ilog2_const(n) : = ilog2_var(n)) > #define rounddown_pow_of_two(n) ((__typeof(n))1 << ilog2(n)) > -#define order_base_2(n) ({ \ > - __typeof(n) _n =3D (n); \ This local var `_n` is within the scope of the macro `order_base_2`, it = is surrounded with {} and is harmless, so it will not pollute the file scoped variables. Am I reading the commit message wrong ? Best regards, Zhenlei > - _n =3D=3D 1 ? 0 : 1 + ilog2(_n - 1); \ > -}) > +#define order_base_2(n) ilog2(2*(n)-1) > #define roundup_pow_of_two(n) ((__typeof(n))1 << = order_base_2(n)) >=20 > #define bitcount64(x) __bitcount64((uint64_t)(x))