Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C163FC05027 for ; Sun, 19 Feb 2023 19:15:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231336AbjBSTPX (ORCPT ); Sun, 19 Feb 2023 14:15:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231328AbjBSTPV (ORCPT ); Sun, 19 Feb 2023 14:15:21 -0500 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 75BD3FF0D for ; Sun, 19 Feb 2023 11:15:20 -0800 (PST) Received: (from willy@localhost) by mail.home.local (8.17.1/8.17.1/Submit) id 31JJFGsE007217; Sun, 19 Feb 2023 20:15:16 +0100 Date: Sun, 19 Feb 2023 20:15:16 +0100 From: Willy Tarreau To: Thomas =?iso-8859-1?Q?Wei=DFschuh?= Cc: Vincent Dagonneau , linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 4/4] tools/nolibc: add tests for the integer limits in stdint.h Message-ID: References: <20230219185133.14576-1-w@1wt.eu> <20230219185133.14576-5-w@1wt.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Thomas, On Sun, Feb 19, 2023 at 07:04:04PM +0000, Thomas Wei?schuh wrote: > > +#elif __SIZEOF_LONG__ == 4 > > + CASE_TEST(limit_intptr_min); EXPECT_EQ(1, INTPTR_MIN, (intptr_t) 0x80000000); break; > > + CASE_TEST(limit_intptr_max); EXPECT_EQ(1, INTPTR_MAX, (intptr_t) 0x7fffffff); break; > > + CASE_TEST(limit_uintptr_max); EXPECT_EQ(1, UINTPTR_MAX, (uintptr_t) 0xffffffffU); break; > > + CASE_TEST(limit_ptrdiff_min); EXPECT_EQ(1, PTRDIFF_MIN, (ptrdiff_t) 0x80000000); break; > > + CASE_TEST(limit_ptrdiff_max); EXPECT_EQ(1, PTRDIFF_MAX, (ptrdiff_t) 0x7fffffff); break; > > + CASE_TEST(limit_ptrdiff_min); EXPECT_EQ(1, PTRDIFF_MIN, (ptrdiff_t) 0x80000000); break; > > + CASE_TEST(limit_ptrdiff_max); EXPECT_EQ(1, PTRDIFF_MAX, (ptrdiff_t) 0x7fffffff); break; > > ptrdiff tests are duplicate. Argh, I thought I had already removed these duplicates, I noticed them previously indeed. Vincent, please address this in your next iteration. > > + CASE_TEST(limit_size_max); EXPECT_EQ(1, SIZE_MAX, (size_t) 0xffffffffU); break; > > +#else > > +# warning "__SIZEOF_LONG__ is undefined" > > Why not #error? It's just a matter of choice. Since the tool's goal is to spot errors, and if possible several at once, I find it preferable to still not fail on other tests, as often when you get multiple failures it's easier to figure what's going on. During the last test session I precisely had a build error that was quite annoying because once I managed to fix it I figured the fix was not the right one regarding other places. Alternately we could probably just add one line that always reports a failure like the other ones (it would be even better so that we can compare all outputs and still know that something fails): +#else + CASE_TEST(__SIZEOF_LONG__defined); EXPECT_EQ(1, 1, 0); break; > > +#endif /* __WORDSIZE == 64 */ > > #endif comment is now incorrect Good catch indeed! > > > + case __LINE__: > > The "case" should be further left, no? You're right! Thank you! Willy