From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 CBA1D236A73 for ; Mon, 16 Feb 2026 19:30:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771270231; cv=none; b=neVXrplajK940YwgE4bu0f3U4sWIQYzvdDoEQu1qvO8t+Ef7uVn7x+ofTFGT2g4vTX8J6m3SfGZrmj9eysCDwV+u6YqWWGtx+ZaTn0gQaQ/l+YfLlGYDDCAhEpY70mE2Opaiu2xPrUEplL2ISlfoV7jp/TcJW4EbCq3iwEzE39A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771270231; c=relaxed/simple; bh=9bqCUF4xNB4xbJRRwRCDWnKL0p8wKg61KZYbzcOOhG4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=R8tDeWpMgABs1leQQ8zXRZnRidf4VEqmyOcVk+JaS/1TB73RaASHJTMhN9jCTg5fVoBCKZMxTT97I2NqUMIDnkPKthgoFc9grbKdEmNJEDxwWT8tWlk5vjFgpHXujgGVcR9QlSr0PMlcoaHreQxk2norZSvM9TckACP/xRgw2OU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=dg90A+FA; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="dg90A+FA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1771270228; bh=9bqCUF4xNB4xbJRRwRCDWnKL0p8wKg61KZYbzcOOhG4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dg90A+FA2wohYgv0/O3H3zkPOsQ4nQQsANpXhJ30tJMPvHn/VPwWU0XGG3dD//6nV CBO3FvKBTSo1BIdoVP1Aj8kzaXb+R8cjkKtUUCjQfp5pP6VZh3PJt0JOKJEAmzM3JR pu3P5z9gI6MllCrew4nukJ9MI17bBB90OrRjNQG0= Date: Mon, 16 Feb 2026 20:30:27 +0100 From: Thomas =?utf-8?Q?Wei=C3=9Fschuh?= To: david.laight.linux@gmail.com, g@t-8ch.de Cc: Willy Tarreau , linux-kernel@vger.kernel.org, Cheng Li Subject: Re: [PATCH v2 next 04/11] tools/nolibc/printf: Output pad characters in 16 byte chunks Message-ID: References: <20260206191121.3602-1-david.laight.linux@gmail.com> <20260206191121.3602-5-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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260206191121.3602-5-david.laight.linux@gmail.com> On 2026-02-06 19:11:14+0000, david.laight.linux@gmail.com wrote: > From: David Laight > > Simple to do and saves calls to the callback function. > > Signed-off-by: David Laight > --- > > Changes for v2: > Formally patch 3, unchanged. > > tools/include/nolibc/stdio.h | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/tools/include/nolibc/stdio.h b/tools/include/nolibc/stdio.h > index 552f09d51d82..c044a6b3babe 100644 > --- a/tools/include/nolibc/stdio.h > +++ b/tools/include/nolibc/stdio.h > @@ -355,10 +355,12 @@ 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) > + while (width > len) { > + unsigned int pad_len = ((width - len - 1) & 15) + 1; So this is a modulo, which does not return 0. While I am sure you and Willy recognize this instantly, I had to squint a bit. While I understand that a regular modulo operator might be problematic on some architectures, does it also apply to constant module values? The compiler could do this on its own. If not, we should have a macro. I am wondering why it is a modulo and not some sort of max()... Could you move the tests for the new functionality into the patches that introduce that functionality? That would make it easier to review and play with the code. Also it would allow to selectively apply the patches. For example I get compiler warnings/errors in the later patches, so I the full array of new tests will fail if I skip these later patches. > + 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 >