From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailtransmit04.runbox.com (mailtransmit04.runbox.com [185.226.149.37]) (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 90B6039B4AD for ; Mon, 2 Mar 2026 10:18:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.37 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772446742; cv=none; b=J/a2qjj5iK3MCxfkz7sdqlEaXT3avP0UhQUrg1xHuIPO5wYemnUBiLjFIaotrfEuNcuX2xrpcNr32+z3BOPnshEJqJqPJD81SOLkMjjR6pQg5S4wmQ/JRlxPJ+sSIv1dzTIYtIe53a6tXkj5aXD6krh4qrmeO3u037oL/KvFMfM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772446742; c=relaxed/simple; bh=qgSwzNHzo7XYyh5Kbk4YixAxkfYFqHpzmImd7S5yLxg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Gub3yJLKZAyWuEsp7NOFn8XMKCIsn4Cjqv66MLTa1PhJLu9lAvxBBCG4NVmLTwPLSrFyJT0nCTTOUn5+HW5RlJUEGEaY2IxVF1O55hckmwWVCS2odNbzxtbiUR0WTiR/as+QUq6SXF49s+CD/hTGEXvd6gcE6LqACL6HM2773C4= 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=iRnhI4yl; arc=none smtp.client-ip=185.226.149.37 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="iRnhI4yl" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vx0MW-00384k-Oo; Mon, 02 Mar 2026 11:18:52 +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=5JXiJL2ibz7/9OE+ZqLhexoyD631zHM7ijt51sMSu1o=; b=iRnhI4ylgUWwKP5Qwr+nf0RyzH xKr0yJs6vOcuhvgbwM1inrT+cq6TEglU7hOFt0z65Uvcboy15Q0H7lG4t3GPzDtE2mAIRpCbzdWy9 ZDy6XrYMGJG09SZ7Gnc1e2HD8WfIZ9w+Ya5GeJPVmZmGA9VPOB3zmvsB9X3KJ7kikaPMWyJXBTTFb o1qCDCil5xUHRxY3f5rHwnCzAI7NZ/z5Fu0KtB0zrgUJjUQwAPFcOWjomVSHIvYyNrM5tYCKpjtjX VASTBe8n6hqFHy++Ft3EGqhXZNsC5PxZmNGVO2A/603ckDGs+YZ6vn3cyvVRbNylUzPescLzVBecO V6RTnW8g==; Received: from [10.9.9.72] (helo=submission01.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vx0MW-00055o-FU; Mon, 02 Mar 2026 11:18:52 +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 1vx0MB-006y7o-84; Mon, 02 Mar 2026 11:18:31 +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 11/23] tools/nolibc/printf: Output pad characters in 16 byte chunks Date: Mon, 2 Mar 2026 10:18:03 +0000 Message-Id: <20260302101815.3043-12-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 Simple to do and saves calls to the callback function. Change variables written, width and len to 'signed int' to get better code. Acked-by: Willy Tarreau Signed-off-by: David Laight --- For v4: no change. For v3: - Change to signed variables here rather than a later patch. tools/include/nolibc/stdio.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/include/nolibc/stdio.h b/tools/include/nolibc/stdio.h index a567b9a5c31e..5368b710c3cb 100644 --- a/tools/include/nolibc/stdio.h +++ b/tools/include/nolibc/stdio.h @@ -312,8 +312,8 @@ int __nolibc_printf(__nolibc_printf_cb cb, void *state, const char *fmt, va_list { char escape, lpref, ch; unsigned long long v; - unsigned int written, width; - size_t len, ofs; + int written, width, len; + size_t ofs; char outbuf[21]; const char *outstr; @@ -415,10 +415,14 @@ int __nolibc_printf(__nolibc_printf_cb cb, void *state, const char *fmt, va_list outstr = fmt; len = ofs - 1; flush_str: - while (width-- > len) { - if (cb(state, " ", 1) != 0) + width -= len; + while (width > 0) { + /* Output pad in 16 byte blocks with the small block first. */ + int pad_len = ((width - 1) & 15) + 1; + width -= pad_len; + written += pad_len; + if (cb(state, " ", pad_len) != 0) return -1; - written += 1; } if (cb(state, outstr, len) != 0) return -1; -- 2.39.5