From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=51.159.59.229 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796481096; b=Qh+nuw84EB+F2hm2DSybY5OZj/cP4mvJ2vbOgr/Sy2P2HqlaY6Rth2JnENdE6CUr39vB EKZSb+kHT3LgHSucqw63lcuFJwxniIRY2OOn7kJNjo2rmasj4m/M0XDQopPrJ2PzUBaCG XYRlppzaQjq7qlwuA53m5FQ+0srmnvu1wjXA2Qa22hX4VzVLBitQ1vJKurtv0wASphxrl OcS6wDTMB3dD/Sca6Kx9DMkakzMYp51wakDjRFDWOcZVTbZk7Ufz5IdWYi7IiV6Uc7MPo JJt37CRpKzHs6R/1MF8mulKhkLBy3+/vsgEYX5CzXoPp05nN/P/v2Wn+yiEe5zx39xw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796481096; h=DMARC-Filter:DKIM-Signature:Received:Date:From:To:Cc:Subject: Message-ID:References:MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To; bh=kJqIofNMDXK8IKQjoQ95OEwN7inYLBqgnLXdGMboTTo=; b=YUsWjwjVICIMZ8GWmYjw1ko1gLp/82w1/CUNw+ZljEV5AQY9qCByee0N785xZha4gZKJ cPm9F+x22ADznbrHowid4dxiI2bpwi+VatSbPTfJu5yDtAZs6Gq3XIJasw4Ie6aMBgB/5 mOrR7GVaCNLfpPRCIYUf0m8VHvii+2tAcqAe9alAaeHPotYCCI9erDhSVgwqtdphU02cg xkuGZ0SNI57gfZ6t9VXyiW+iuJEea9JdXs5U+SWgbHilxlmvVk4ct+q50TCC5PPYd+dMk DS2HTua4c/YSz9piTWzXYXy7jZKSjEZE1N6/Dcv4qjtpmfanGJbyeQ8ZmLw+o7xHYrw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=1wt.eu; spf=pass smtp.mailfrom=1wt.eu; dkim=pass header.d=1wt.eu header.i=@1wt.eu header.a=rsa-sha256 header.s=mail header.b=fIHd25F9; arc=none smtp.remote-ip=51.159.59.229 Received: from mta1.formilux.org (mta1.formilux.org [51.159.59.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C4FE2606A32F for ; Sat, 5 Dec 2026 14:31:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C4FE2606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=1wt.eu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=1wt.eu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=1wt.eu header.i=@1wt.eu header.a=rsa-sha256 header.s=mail header.b=fIHd25F9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1wt.eu; s=mail; t=1796481093; bh=kJqIofNMDXK8IKQjoQ95OEwN7inYLBqgnLXdGMboTTo=; h=From:Message-ID:From; b=fIHd25F9fsU+GMkk63vIUYQWPwg7Qf5HtGSzeNfPl0ImBaglVnGZmw1HJBekkFHZD Q1Mbd/56nrCxBHBtGb+O7TuZCAdhFfGipka5SBT4FqFE1E/+1C/L1xC7udggPcvEnp ip92sJljVZyI+oakzzp4mIB1kxsVt5z2609/S+g4= Received: from 1wt.eu (ded1.1wt.eu [163.172.96.212]) by mta1.formilux.org (Postfix) with ESMTP id B930CC000B; Sat, 05 Dec 2026 15:31:33 +0100 (CET) Date: Sat, 5 Dec 2026 15:31:33 +0100 From: Willy Tarreau To: David Laight Cc: Thomas =?iso-8859-1?Q?Wei=DFschuh?= , linux-kernel@vger.kernel.org, Danish Khateeb Subject: Re: [PATCH v2 2/4] selftests/nolibc: split out the structure member compatibility checks Message-ID: References: <20261202-nolibc-fcntl-v2-0-651ff5781baa@weissschuh.net> <20261202-nolibc-fcntl-v2-2-651ff5781baa@weissschuh.net> <20261202112923.127f38d2@pumpkin> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20261202112923.127f38d2@pumpkin> On Wed, Dec 02, 2026 at 11:29:23AM +0000, David Laight wrote: > On Wed, 02 Dec 2026 08:29:47 +0100 > Thomas Weißschuh wrote: > > > A future test will add more similar tests. > > > > Factor out a helper to validate that two structures have compatible > > members. > > > > Signed-off-by: Thomas Weißschuh > > --- > > tools/testing/selftests/nolibc/nolibc-test.c | 30 +++++++++++++++++----------- > > 1 file changed, 18 insertions(+), 12 deletions(-) > > > > diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c > > index a924d53260fd..fce755ffed14 100644 > > --- a/tools/testing/selftests/nolibc/nolibc-test.c > > +++ b/tools/testing/selftests/nolibc/nolibc-test.c > > @@ -58,6 +58,18 @@ > > #define SINT_MAX_OF_TYPE(type) (((type)1 << (sizeof(type) * 8 - 2)) - (type)1 + ((type)1 << (sizeof(type) * 8 - 2))) > > #define SINT_MIN_OF_TYPE(type) (-SINT_MAX_OF_TYPE(type) - 1) > > > > +#define struct_members_identical(_member, _left, _right) ({ \ > > Maybe put the member parameter last? Honestly it's a matter or taste, habit or context you're working on. Most likely depending on how you start you'll use either one or the other. > I might have called them (struct_1, struct_2, member). > Those variables don't need protecting with a leading _ ... Sure but sometimes it makes it more obvious when reading the rest of the macro what is an argument and what is not, like in the series of different |= ... statements after that. > > + bool different = false; \ > > ... but, in theory, that one does. > (Clearly the calls are very limited.) Indeed it could, though unlikely to cause a problem, but might still warrant a last-minute change without emitting a 3rd version. Overall this looks good to me. Reviewed-by: Willy Tarreau Willy > David > > > + \ > > + different |= sizeof((_left)._member) != sizeof((_right)._member); \ > > + different |= offsetof(__typeof__(_left), _member) != \ > > + offsetof(__typeof__(_right), _member); \ > > + different |= !__builtin_types_compatible_p(__typeof__((_left)._member), \ > > + __typeof__((_right)._member)); \ > > + \ > > + !different; \ > > +}) > > + > > /* will be used to test initialization of environ */ > > static char **test_envp; > > > > @@ -1903,22 +1915,16 @@ int test_time_types(void) > > struct timespec ts; > > > > if (!__builtin_types_compatible_p(time_t, __kernel_time64_t)) > > - return 1; > > + return __LINE__; > > > > if (sizeof(ts) != sizeof(kts)) > > - return 1; > > - > > - if (!__builtin_types_compatible_p(__typeof__(ts.tv_sec), __typeof__(kts.tv_sec))) > > - return 1; > > - > > - if (!__builtin_types_compatible_p(__typeof__(ts.tv_nsec), __typeof__(kts.tv_nsec))) > > - return 1; > > + return __LINE__; > > > > - if (offsetof(__typeof__(ts), tv_sec) != offsetof(__typeof__(kts), tv_sec)) > > - return 1; > > + if (!struct_members_identical(tv_sec, ts, kts)) > > + return __LINE__; > > > > - if (offsetof(__typeof__(ts), tv_nsec) != offsetof(__typeof__(kts), tv_nsec)) > > - return 1; > > + if (!struct_members_identical(tv_nsec, ts, kts)) > > + return __LINE__; > > #endif /* NOLIBC */ > > > > return 0; > > >