From nobody Tue Dec 26 04:09:47 2023 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 4SzhBH0d4Kz55V8K; Tue, 26 Dec 2023 04:09:59 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SzhBG73X5z4hsY; Tue, 26 Dec 2023 04:09:58 +0000 (UTC) (envelope-from zlei@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703563799; 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=eQ2aWZLRGyS11PzYo/fb5hHKF4Bs+W5YIMsw7gUVUU8=; b=g18DZEWa8MEUK5ubTvD5HyepEuTMLtDgUYM9fU+xotVD0szRvzfRzmljs5LMpXIdBZLhh/ SqyWTmXVX2pp50Cx0T2EouVNfmEfqFNYrT56tyG38Vg4GC2cNOBs8o4A7CnKxfUMcY0Hop CQ5hQkbJWE3NqwqG3jmnG4EX1ASdfNk8Zg0Lq/tpOkH0/iRrmm0J1WbgqY9uet0mt5wAwB zZVmI1PdC7gNpbnMpkD/vC2R/uM7tnTORHPlmYwyqjz/1928lw/Ty1u8BSTU6+O/jq/SEP sPiJTD1voxLQ+1r4l4qb9CEQgH9bl0C6HqUQyqUQgp48uT8msFn4mv/TBSx7Aw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1703563799; a=rsa-sha256; cv=none; b=xp0/3zPEdttAUNg4G1q2IPjugEV9WynDWPI4uKEsGW4RPdpeCfxV4z0t6JCUHYLnIKXZyW dgQqhUmLP9cUQPwPq0qAaJni7DtkodTkDDJal9hn53GrDDHQD+37SuxT6bDyIEBCyP7rLG +Y1kEgDTg46cW6BK3kteXOusUr4dsYOxinhrUyOZ0oylPXjLGhjqdmtM745iEzcedZBXny w8LRO5N+tlDH4N+QtLtO7F9xc+ZtUIeBIYNa9z4FOIXBILSzHsp08L9jQXNiMq6jH9RMxT bM2eJaYgoz6JhoVdietwYzsCllUTfG+22wxhAIuQp1o9FTwOUcXrgDmNKSpTdg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703563799; 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=eQ2aWZLRGyS11PzYo/fb5hHKF4Bs+W5YIMsw7gUVUU8=; b=xTNyMHkpdElQuo/0RF9Dpk6XhRlgP/37W6wKrfaJ9lTffcTW5WVFYAMYN4He9UY2+FUh+6 kasCq3/XLvO9cANEur3UmAezAsRx/yCC2htog7CkpB3ilfulvAPB2ZByE09iElSq+Mah1G CzyJUkwGph29zlcRqjYp2Yc7aTrTY9cST56s8OUiTTRQy8FR//wcX6XdDSY5xQWBidZfHL mOc1F8GB29r7rtEZTXliPg25dnrubXzGZ9iPraBMaZEjUuqYnDclEMfqeRPI0bfaW86cqI zy+062LReuQjPlPIbpMo773IFto8NSWvanSwvoDqi+2d63NlouIsvYfNRMlvNw== 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 4SzhBD5zPhz1M1b; Tue, 26 Dec 2023 04:09:56 +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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.4\)) Subject: Re: git: 2a1d50fc12f6 - main - vfs_domount_update(): correct fsidcmp() usage From: Zhenlei Huang In-Reply-To: Date: Tue, 26 Dec 2023 12:09:47 +0800 Cc: "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" Content-Transfer-Encoding: quoted-printable Message-Id: <640284C5-ACE1-4D31-9BBB-AF181C0C7632@FreeBSD.org> References: <202312260136.3BQ1aOxq051977@gitrepo.freebsd.org> <72190C27-0D45-4300-BB78-719F5EB510E9@FreeBSD.org> <78061056-76D8-457C-A522-8CE62B481317@FreeBSD.org> To: Konstantin Belousov X-Mailer: Apple Mail (2.3696.120.41.1.4) > On Dec 26, 2023, at 11:57 AM, Konstantin Belousov = wrote: >=20 > On Tue, Dec 26, 2023 at 11:31:38AM +0800, Zhenlei Huang wrote: >>=20 >>=20 >>> On Dec 26, 2023, at 11:29 AM, Zhenlei Huang = wrote: >>>=20 >>>=20 >>>=20 >>>> On Dec 26, 2023, at 9:36 AM, Konstantin Belousov > wrote: >>>>=20 >>>> The branch main has been updated by kib: >>>>=20 >>>> URL: = https://cgit.FreeBSD.org/src/commit/?id=3D2a1d50fc12f6e604da834fbaea961d41= 2aae6e85 = >>>>=20 >>>> commit 2a1d50fc12f6e604da834fbaea961d412aae6e85 >>>> Author: Andrew Gierth > >>>> AuthorDate: 2023-12-24 12:04:21 +0000 >>>> Commit: Konstantin Belousov > >>>> CommitDate: 2023-12-26 01:35:46 +0000 >>>>=20 >>>> vfs_domount_update(): correct fsidcmp() usage >>>>=20 >>>> MFC after: 3 days >>>> --- >>>> sys/kern/vfs_mount.c | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>>=20 >>>> diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c >>>> index 8e54c832e9f1..331e4887c200 100644 >>>> --- a/sys/kern/vfs_mount.c >>>> +++ b/sys/kern/vfs_mount.c >>>> @@ -1388,7 +1388,7 @@ vfs_domount_update( >>>> error =3D EINVAL; >>>> goto end; >>>> } >>>> - if (fsidcmp(&fsid_up, &mp->mnt_stat.f_fsid) !=3D 0) { >>>> + if (fsidcmp(fsid_up, &mp->mnt_stat.f_fsid) !=3D 0) { >>>> error =3D ENOENT; >>>> goto end; >>>> } >>>=20 >>>=20 >>=20 >> The fsidcmp is currently defined as >> ``` >> #define fsidcmp(a, b) memcmp((a), (b), sizeof(fsid_t)) >> ``` > Yes, and the issue should be fixed by making it (inline) function, = which > automatically would type-check it args. An inline function sound much better (than macro). It is also simple ;) >=20 >>=20 >>>=20 >>> I guess we want to ensure ` typeof(a) =3D=3D typeof(b) =3D=3D fsid_t = `, to prevent such kind of error in future. >>>=20 >>> I see both gcc [1] and clang [2] have __builtin_types_compatible_p , = so probably a good definition of fsidcmp should be >>>=20 >>> ``` >>> #define TYPEASSERT(v, t) \ >>> _Static_assert(__builtin_types_compatible_p(typeof(v), t), = "Requires type '" #t "'") >>>=20 >>> #define fsidcmp(a, b) ({ \ >>> TYPEASSERT((a), fsid_t *); \ >>> TYPEASSERT((b), fsid_t *); \ >>> memcmp((a), (b), sizeof(fsid_t)); \ >>> }) >>> ``` >>>=20 >>> 1. https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html = >>> 2. https://clang.llvm.org/docs/LanguageExtensions.html = >>> Best regards, >>> Zhenlei >>>=20 >>=20 >>=20