From nobody Tue Feb 11 05:23:21 2025 X-Original-To: dev-commits-src-branches@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 4YsVGb0rfWz5mxhD for ; Tue, 11 Feb 2025 05:23:35 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "WR4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YsVGZ3lCKz3FtN for ; Tue, 11 Feb 2025 05:23:34 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-38de17a5fc9so843725f8f.3 for ; Mon, 10 Feb 2025 21:23:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739251413; x=1739856213; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=r9+m78g6ry9R8pWkl5xRIMhQ4H4UUPHj9BcEuCrTRF4=; b=n5G42tIa9dlnFF0NZZyN7qyVNUOJNNGZbichfSLR2ai7eyCZlu1rmcWxovr4VJzGkK nLcdF8c/SagGKTddeLQQ4nEDBZFXNf2BYYllxVn/S3r0iLwj9GJs/qh4OodfSfTT2xw+ T6CZ9MC5kfgTIoY+OI43k4c8xi06WLj1XN9GbYXHpt6knh3UrMrfrioiGlppVYUcsKEI U90AQo4XTAfFJocoPSsjfXV6mgXGZveF9JKz2ZIpcPA8htcyZjIrJXGHja3VKomCK9Cf 0DLxCrcDMoIAC7DQQU7gC+Ut7DY3Wn7+Yup01BY4wFgRtNnTnBQ6Xw+7b/9W0ICx5rfn sCpg== X-Forwarded-Encrypted: i=1; AJvYcCXVQwlDgitZAxPiYICCUjbdvvTclhK63QjKJPAR9hHoioYz1rUb5qAy4Wzm0cAHksXHWbrDV1HZaqBFLKFSsGl4/Algk48JVmg=@freebsd.org X-Gm-Message-State: AOJu0YyX+/yYiWzFEpwc96E7MabXZ+pu2RPpZ5IiNVWepBRdV9FwDel/ q6rK4jNcqFQhGVuG0DWwFfnWh+FwGBJy4qVZHBZITIKuVeOHqqtW9h2LZpTVXA4= X-Gm-Gg: ASbGncvuf61pFn7PCYKaH+OsAgj85+VxocxDis3pKQGrkQXy4N4DHwV0uP+gIBCw/8T IM7Ortj1iUm3N8WC6rmy7AtHg0k/z5/hh6AsZnij9l0i2xNg2gmlAt1fXTAl0HZDp89aA+F9Noq pWgyo5ZDn7KoYDu07Y0/HY7UTZuEqpweZS657mZBq1OLee/7SXkEbOUUN3Lnajj6SYRWtdO8ieX ZD0P39dFs0SsmHpexRz1BuF27bGf23dvYPHAhoTFZapktWzTQcfh1SzWZVm91zJutd9XE7P/HAQ bk8xDfD0Qp1VFb39xKTBMYlKekG4mg== X-Google-Smtp-Source: AGHT+IH3Awqpnj2auuTk7eQPBWp2+zhPuhE/Vmfz+dIvFOqF4l3iiWMyxY5q/LJkZ7x9382eCTs8Fw== X-Received: by 2002:a5d:5f4a:0:b0:38d:cfff:c0d9 with SMTP id ffacd0b85a97d-38dcfffc217mr11001814f8f.39.1739251412859; Mon, 10 Feb 2025 21:23:32 -0800 (PST) Received: from smtpclient.apple ([131.111.5.201]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4393963c84esm86489895e9.27.2025.02.10.21.23.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Feb 2025 21:23:32 -0800 (PST) Content-Type: text/plain; charset=utf-8 List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.300.87.4.3\)) Subject: Re: git: 7bcc7a0b88cc - stable/14 - libkern: avoid local var in order_base_2() From: Jessica Clarke In-Reply-To: <858BD10B-A2C9-4D3A-9FF5-C5573597DF8B@FreeBSD.org> Date: Tue, 11 Feb 2025 05:23:21 +0000 Cc: Doug Moore , "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-branches@freebsd.org" Content-Transfer-Encoding: quoted-printable Message-Id: <803D3DBC-A4F5-47FB-8034-5241461D4A71@freebsd.org> References: <202502101115.51ABFISj016298@gitrepo.freebsd.org> <858BD10B-A2C9-4D3A-9FF5-C5573597DF8B@FreeBSD.org> To: Zhenlei Huang X-Mailer: Apple Mail (2.3826.300.87.4.3) X-Rspamd-Queue-Id: 4YsVGZ3lCKz3FtN X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US] On 11 Feb 2025, at 03:30, Zhenlei Huang wrote: >> 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); \ >=20 > 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. >=20 > Am I reading the commit message wrong ? It=E2=80=99s not about pollution. GNU statement expressions are just not = valid at file scope, they must be used within a function (since otherwise the implementation would have to have a full blown interpreter to constant evaluate the whole thing, just like C++ and now C to some extent have ended up with these days with constexpr). That is, you cannot write: int x =3D ({ ... }); at file scope. Jess