From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mta1.formilux.org (mta1.formilux.org [51.159.59.229]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CCC232D5957 for ; Wed, 28 Jan 2026 07:51:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=51.159.59.229 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769586698; cv=none; b=V5LXlJYhM8XAh3UdHmv3rTLAGGFz1qhdlyoZ59tG9ESQKDfpupU/oUFxIlulGr5ETnDYkjC6GNZn8B51aIAQ0LGxgyZC/+RoXgpFwgRslOgfTgD6NXI7PAcgK4DsNDzt5WaWIHkoMRydCMk6kzuD7nO/Sh/oV28Rhtv747cM1ps= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769586698; c=relaxed/simple; bh=ZIPeh2a8KQxooGVdO7yLs20gnzlYhxsmKhiXHAEPYPc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dfX//arP1hFng3IEMAImGForY7mT2Xcd24Vy0TzSq81Pa7DDpQmtw0u+Hm0aYgfpJ2pEbgVCan9p8UIvCA0lnKhsrJnNhlI8md+g8xjRCD6O0ImXle7ncK4jQaAB7nlAzHRwSrtI54xTvycJMd7PLmSTpO8rujphlQlmIECtIQ8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=1wt.eu; spf=pass smtp.mailfrom=1wt.eu; dkim=pass (1024-bit key) header.d=1wt.eu header.i=@1wt.eu header.b=hWvZkTkk; arc=none smtp.client-ip=51.159.59.229 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) header.d=1wt.eu header.i=@1wt.eu header.b="hWvZkTkk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1wt.eu; s=mail; t=1769586693; bh=KOxqSLk+mFuAV5CYWzi9tOtIOwuCul77lLTGijOWbQk=; h=From:Message-ID:From; b=hWvZkTkk/0WBlX9NsTg4PAmdLnkLoj1G1XNss3Qy0eSOxUrBqQvyeJfYQWDQiJUQM v3VXKuSW0zUUj1qqplmXhK0bxH8k7QrGuc7MwDIJKBTxSueDbVF92gU+vD9HKurtQ9 f4eo9Ct3xBsf7Ky0vmCBEZHqv0Bwo7om3cg1RB8A= Received: from 1wt.eu (ded1.1wt.eu [163.172.96.212]) by mta1.formilux.org (Postfix) with ESMTP id D4D48C0A54; Wed, 28 Jan 2026 08:51:33 +0100 (CET) Date: Wed, 28 Jan 2026 08:51:33 +0100 From: Willy Tarreau To: "licheng.li" Cc: Thomas =?iso-8859-1?Q?Wei=DFschuh?= , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] selftests/nolibc: add tests for printf left alignment Message-ID: References: <20260126031038.35387-1-im.lechain@gmail.com> <20260126031038.35387-2-im.lechain@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260126031038.35387-2-im.lechain@gmail.com> On Mon, Jan 26, 2026 at 11:10:38AM +0800, licheng.li wrote: > From: Cheng Li > > This patch adds validation for the recently added '-' flag support in > printf(). It ensures that strings and numbers are correctly padded > with spaces on the right side when the left-alignment flag is used. > > The test adds minimal overhead to the test binary size. > On x86_64: > > text data bss dec hex filename > 43677 248 112 44037 ac05 nolibc-test (before) > 43761 248 112 44121 ac59 nolibc-test (after) > > The test logic adds 84 bytes. > > Signed-off-by: Cheng Li > --- > tools/testing/selftests/nolibc/nolibc-test.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c > index 3c5a226dad3a..3d47711cad8f 100644 > --- a/tools/testing/selftests/nolibc/nolibc-test.c > +++ b/tools/testing/selftests/nolibc/nolibc-test.c > @@ -1723,6 +1723,7 @@ static int run_printf(int min, int max) > CASE_TEST(truncation); EXPECT_VFPRINTF(25, "01234567890123456789", "%s", "0123456789012345678901234"); break; > CASE_TEST(string_width); EXPECT_VFPRINTF(10, " 1", "%10s", "1"); break; > CASE_TEST(number_width); EXPECT_VFPRINTF(10, " 1", "%10d", 1); break; > + CASE_TEST(left_align); EXPECT_VFPRINTF(10, "foo |", "%-9s|", "foo"); break; > CASE_TEST(width_trunc); EXPECT_VFPRINTF(25, " ", "%25d", 1); break; > CASE_TEST(scanf); EXPECT_ZR(1, test_scanf()); break; > CASE_TEST(strerror); EXPECT_ZR(1, test_strerror()); break; Your first patch also made a special case of the '0', that will pad with zeroes on the left, and which is not obvious when reading the code (BTW I'm realizing now that it's not mentioned in the commit message), so in my opinion your patch should also test for this case, which could easily be overlooked and broken by accident. Thanks, Willy