From nobody Tue Dec 26 03:29:50 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 4SzgJ75bjwz55Rng; Tue, 26 Dec 2023 03:29:59 +0000 (UTC) (envelope-from zlei@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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 4SzgJ752Dfz4cSL; Tue, 26 Dec 2023 03:29:59 +0000 (UTC) (envelope-from zlei@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703561399; 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: in-reply-to:in-reply-to:references:references; bh=5KafRLqrzE0vJGFti8KvzftZQSIB++e8yOjkSQv9Tl8=; b=LDSTRKoOhVFLvIntfr28sexpwzKrZw5rN22XiYZ4iVzc9UfxNodfpTN9FmJqXQraxKxBTn IDvUobl8qXK0bMs/awyoQwYPJRYl3+flv3ocgHrawIFgI/awQeetTNThveuw/xTl5rpnG4 Z2DWIgb34GOmnQ+Ca0Azbig5tLRnNduLZ1ZNcFvAUmwHx5/A/dDOaGqnKQR6gdpGQXGuvG YzzsZNgx0NK60ziPFdnBUKA+rj1VEYlN+YAyL7S+OiyxoKsNetyiK8mL6KU/vdFiiNQIQr sskcg0qOr87rdt/yRYYjdKvoNdixp8kq8xj7KQueVq1zNHDIFgm08+VFWVwg9Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1703561399; a=rsa-sha256; cv=none; b=YZikx+a4wP9AxULiEv9mQLdNcouIgRYg1ceeC2O/pkVBVlGq1u9niWIxY2GR/OSJA21gQ4 ujzjO6U5DmdqUVR7bGk6Xsr7LMEwbpQ+LW2uXD/M5jLSj+L7+zybD50AHS/uFzfFdMktZL +uuWYoQUuzHDTTgq4T5aQD2hNkN22oz7e1mqgDIZsrkWq1S8LcroctAn4f7nxkIq24AIc2 uWlHKzk4MgPdXPGiarZSqD0ja68vEZu2n52lmx+HHKxDahIQV72TXYssdHXU6Fekjbr8VP 3mKqYHHAVDr+Ex0HdT2ZEyAY1I/XSLJoiZyZWA4CRkUFup+2rZrOam+fgaUr2A== 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=1703561399; 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: in-reply-to:in-reply-to:references:references; bh=5KafRLqrzE0vJGFti8KvzftZQSIB++e8yOjkSQv9Tl8=; b=HdK9rSw03D1ahEqQWcmdviQ7DIBejtGwRVLyfa/y6e8LIL/zUe4Ac/AL4V4qEaE3/n3yhw tjejyAqlaqgFpPOMppXtlFZs/jtg1v4aCAB7oYlKGMD6KY4OFEOsnR3zxZBzABset+7QIV rTC6cPInzoaDGxW/wh9btMVKay+g/N7LX8Jl396jeCEIwnNRuNRDjXwYog3+H/06BDt+p/ RjldVQRof0EO7SS8iyOcWhM4BdW21E0YUUWflRj1P6wsp1J5X8O8sdrNrJxfwbh9hc8O1O OL41f7PDfo9pm0AskRmP/UwSKHRLk8YzioRXHxIIFbdAbS3vmEJGlxYbq2EseA== Received: from smtpclient.apple (unknown [IPv6:2001:19f0:6001:9db:98f0:9fe0:3545:10]) (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 4SzgJ55DzCz1LM7; Tue, 26 Dec 2023 03:29:57 +0000 (UTC) (envelope-from zlei@FreeBSD.org) From: Zhenlei Huang Message-Id: <72190C27-0D45-4300-BB78-719F5EB510E9@FreeBSD.org> Content-Type: multipart/alternative; boundary="Apple-Mail=_C781C9AB-69B4-4FE2-8EA1-71AB19AA400E" 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 Date: Tue, 26 Dec 2023 11:29:50 +0800 In-Reply-To: <202312260136.3BQ1aOxq051977@gitrepo.freebsd.org> Cc: "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" To: Konstantin Belousov References: <202312260136.3BQ1aOxq051977@gitrepo.freebsd.org> X-Mailer: Apple Mail (2.3696.120.41.1.4) --Apple-Mail=_C781C9AB-69B4-4FE2-8EA1-71AB19AA400E Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > 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; > } I guess we want to ensure ` typeof(a) =3D=3D typeof(b) =3D=3D fsid_t `, = to prevent such kind of error in future. I see both gcc [1] and clang [2] have __builtin_types_compatible_p , so = probably a good definition of fsidcmp should be ``` #define TYPEASSERT(v, t) \ _Static_assert(__builtin_types_compatible_p(typeof(v), t), = "Requires type '" #t "'") #define fsidcmp(a, b) ({ \ TYPEASSERT((a), fsid_t *); \ TYPEASSERT((b), fsid_t *); \ memcmp((a), (b), sizeof(fsid_t)); \ }) ``` 1. https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html 2. https://clang.llvm.org/docs/LanguageExtensions.html Best regards, Zhenlei --Apple-Mail=_C781C9AB-69B4-4FE2-8EA1-71AB19AA400E Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii

On Dec 26, 2023, at 9:36 AM, Konstantin Belousov <kib@FreeBSD.org> = wrote:

The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=3D2a1d50fc12f6e604da834= fbaea961d412aae6e85

commit = 2a1d50fc12f6e604da834fbaea961d412aae6e85
Author: =     Andrew Gierth <andrew@tao146.riddles.org.uk>
AuthorDate: = 2023-12-24 12:04:21 +0000
Commit: =     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-12-26 01:35:46 +0000

   vfs_domount_update(): correct fsidcmp() = usage

   MFC after: =      3 days
---
= sys/kern/vfs_mount.c | 2 +-
1 file changed, 1 = insertion(+), 1 deletion(-)

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;
}


I = guess we want to ensure ` typeof(a) =3D=3D typeof(b) =3D=3D fsid_t `, to prevent such kind of error in = future.

I see both gcc [1] and clang [2] = have __builtin_types_compatible_p , so probably a good definition = of fsidcmp should be

```
#define = TYPEASSERT(v, t) \
= _Static_assert(__builtin_types_compatible_p(typeof(v), t), = "Requires type '" #t "'")

#define = fsidcmp(a, b) ({ \
= TYPEASSERT((a), fsid_t *); \
= TYPEASSERT((b), fsid_t *); \
memcmp((a), (b), sizeof(fsid_t)); \
})
```

= --Apple-Mail=_C781C9AB-69B4-4FE2-8EA1-71AB19AA400E--