From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 C89F439B96B for ; Mon, 2 Mar 2026 10:18:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772446732; cv=none; b=RVBQFdOZfD1LXE1D9lyuPRUiEMoc04kHrbf0LcIsnpmjVUlrGEaykrsfXoOinGkjpy7MY0ILl0xfsXTZUVR6OZKIISftDV0xZKY44w8YYCnWXAuwHJpn2JuobhWaw0HNXBHNvcmBtFvLn48qaOUJySlns1ngdPg9DYXsBRE3gv4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772446732; c=relaxed/simple; bh=9bOVIQApIg0yzck1zM2Lts2fEzItul/O3+juqIj7tT8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oA/kFhd7Jny1/IOuhfBULrHX2l7TI1FHdPu4BXtGR0nm4h/1vcKa5xIlmEHmE3zf0YPRcbO8yQUQDGXWqzY6zE3pvMsAb99m7RpCTDyO95weWdYJkdDhCFG11x7HOX84n2SuERPzj4fEDLRqow4YAt0aHfBEWds/6M0fDxTU+oI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=oku9i7mg; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="oku9i7mg" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vx0MS-003BYX-RP; Mon, 02 Mar 2026 11:18:48 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector2; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=nMtv5CEz5u+mvhCGmTHG84fVYviigF1VOQzD6irpWg8=; b=oku9i7mg6xXg+h0q9cyDvJJeA4 apl/9THHz6V+g50+rIncbmm1sfRO0jQevi9iHtF3tXctf/izBqEaPKVzkgVp+W6J6nuCwRL2uWQhz LKOe/TBWKrDaSrmp/HEXOvqS8vkxmz8k4SU6ySlJi1o2bWTbKqmClqqWzO5x41LKNFiux2PPMuHib dUPLfPBeR7qIQLI2Lf26HYtLcDl7To7t4H07VWfeF/QEvLorCK/iWU4GKlEHGPWuWhIwbj70F0Ajl y/1q2lv7GLw2G6iJF+uFPFaOIX/QxqQ+yH/LMbRMiIEZzNRlt6dZg0/w3ked3y+ySb0g0rjwp7M6I UUIR6VQg==; Received: from [10.9.9.72] (helo=submission01.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vx0MS-0002y9-F8; Mon, 02 Mar 2026 11:18:48 +0100 Received: by submission01.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vx0ME-006y7o-H1; Mon, 02 Mar 2026 11:18:34 +0100 From: david.laight.linux@gmail.com To: Willy Tarreau , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , linux-kernel@vger.kernel.org, Cheng Li Cc: David Laight Subject: [PATCH v4 next 23/23] selftests/nolibc: Use printf variable field widths and precisions Date: Mon, 2 Mar 2026 10:18:15 +0000 Message-Id: <20260302101815.3043-24-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260302101815.3043-1-david.laight.linux@gmail.com> References: <20260302101815.3043-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: David Laight Now that printf supports '*' for field widths and precisions then can be used to simplify the test output. - aligning the "[OK]" strings. - reporting the expected sprintf() output when there is a mismatch. Acked-by: Willy Tarreau Signed-off-by: David Laight --- Unchanged for v4. tools/testing/selftests/nolibc/nolibc-test.c | 26 ++++---------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 29ad1207464f..ac4442c8c5fa 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -156,21 +156,6 @@ static const char *errorname(int err) } } -static void align_result(size_t llen) -{ - const size_t align = 64; - char buf[align]; - size_t n; - - if (llen >= align) - return; - - n = align - llen; - memset(buf, ' ', n); - buf[n] = '\0'; - fputs(buf, stdout); -} - enum RESULT { OK, FAIL, @@ -188,8 +173,10 @@ static void result(int llen, enum RESULT r) else msg = " [FAIL]"; - align_result(llen); - puts(msg); + llen = 64 - llen; + if (llen < 0) + llen = 0; + printf("%*s%s\n", llen, "", msg); } /* The tests below are intended to be used by the macroes, which evaluate @@ -1692,10 +1679,7 @@ static int expect_vfprintf(int llen, const char *expected, const char *fmt, ...) } if (memcmp(expected, buf, cmp_len) || buf[cmp_len]) { - /* Copy and truncate until "%.*s" supported */ - memcpy(buf, expected, cmp_len); - buf[cmp_len] = 0; - llen += printf(" should be \"%s\"", buf); + llen += printf(" should be \"%.*s\"", VFPRINTF_LEN, expected); result(llen, FAIL); return 1; } -- 2.39.5