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 B9ED335BDB7 for ; Mon, 23 Feb 2026 10:35:51 +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=1771842953; cv=none; b=BfuiVNW6aoOCdckxHmIpM2Ke/23z9NXzU7Upfe5tlAoP+SlX/l/Kglsy9khQr9zqTxMv162N17MTlmv1X9WtNy6N5OrYRY4FNvA0ElWm8fFb2dpf9zZnLqRW/FA6QdAvAFW8+ps5EwPpmbrGi6hWlReYwOJ/hu6oBbgTzqDLilA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771842953; c=relaxed/simple; bh=lPKkgsVR52SCLMuLPByNe17cg+/mQgX0Z+Yvy+82umY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cyDXXRVeiLz5DdEOsiZGpCWQpWCePtmJTTmcjeChr4aiwBLuk2uXdajYGzmkPQ6RIP+49kFtxXgF6HVkoD9A56zHQjKNWMhxGYe0LZ+xcdv1SU7kI/sq7UnF5ri3L0+bZrtCaspAdKVYfif9TH4ouK4Z3gBpO19glHX6oZbEMOU= 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=LZXGzm8m; 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="LZXGzm8m" Received: from mailtransmit03.runbox ([10.9.9.163] 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 1vuT19-00GgoN-MN; Mon, 23 Feb 2026 11:18:19 +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=djFFzfzthcA5Yu/a7hS1HFU5pW171okYJFXqjYJQb9g=; b=LZXGzm8mOwpnIQfhGFPlPxCNto 3RZrkep07xphZ+b1iv1XTw0fShjl9XN9rGW7X+bgSHlT2YVGqu73sEUYG5IGrQ1t2xJa9LgqJBkAz nW7jdR0nzVfi0huRN5C7rFzCqGDi0hbym8jp4Xb8/FQPbVdsLZfQZ3Nruon7E8sw4mHT3ine0xYkv HtXVAL8J7R4jsuOJ8KNVo4kvHBdK6u0QfCuuNXB2Ku6JeQEpSK6T5gw/5e4eKhDRSdh82hcQ/e2tR 4iLomflGNIPz/H6p/lDxSjMXw1AC84rMuq5L5+bg5Q4Btsi4sb7ks36/kmO0N4EDxaa6go+rdQj1l d5jpJ/vQ==; Received: from [10.9.9.73] (helo=submission02.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vuT19-0001Rg-Ar; Mon, 23 Feb 2026 11:18:19 +0100 Received: by submission02.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vuT13-006AjD-FC; Mon, 23 Feb 2026 11:18:13 +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 v3 next 08/17] tools/nolibc/printf: Output pad characters in 16 byte chunks Date: Mon, 23 Feb 2026 10:17:26 +0000 Message-Id: <20260223101735.2922-9-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260223101735.2922-1-david.laight.linux@gmail.com> References: <20260223101735.2922-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 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 5c8f233336b9..ea6c514c4b7a 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; @@ -411,10 +411,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