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 9C6A22E6CC0 for ; Thu, 29 Jan 2026 06:41:06 +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=1769668869; cv=none; b=DZUGiPbFezmEj6QLlW1kVe5g5gi9tGd8NT2jFH6L+FEvzfVL4l9C4XyWHGZALMitm7iR+WwJdSbwWeRS0jvRjGKZkIV2lvZ9CvQWnhtKfp/0VFBmEmM8KY61wG32omEYwdAhJyukPVX0mrznTNM2tfLg9NqGC4I1TxD4QQTvZHk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769668869; c=relaxed/simple; bh=PzaDlEuY3uoTmafrTbtPmhcmk3Otu6HfMZ2NNcKk14Q=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hJK6Nr6hAFEVlFxZb1+LG8ZhwCjxMy1WcLmYP+ay85Xk1gEBLgD2MKop4q74zRDEfRzd9sC1BlWL6fUXLEfe39glKfEbxD3x56WNPpRi22gYuC1T3OfNinTLnwm+sWHBGjjzVv/cMrx1mJmjrUP4g48A5fDqmINfGV37O+9ths4= 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=UP009cDt; 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="UP009cDt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1wt.eu; s=mail; t=1769668864; bh=ws0B3BFkhOom6b3tIalNtkvdDYAyf5sGxYfEqCLP510=; h=From:Message-ID:From; b=UP009cDtI1xb1LwLj6KI0KRa6JLVUY6v1gyOIrlBnPjMUa7DFV0F11iyjO9OcsR+K N6SS6SO+KWXwdwRTHxRkcGBa48HAfaRbSws+YgzLgyFR8j8Ee1c3hemzt1WkUkhXLD 23PzXru2e9pcz1YiN+ZaZHCRHC0EKem5iEc9qh+w= Received: from 1wt.eu (ded1.1wt.eu [163.172.96.212]) by mta1.formilux.org (Postfix) with ESMTP id 6D642C0A2C; Thu, 29 Jan 2026 07:41:04 +0100 (CET) Date: Thu, 29 Jan 2026 07:41:04 +0100 From: Willy Tarreau To: "licheng.li" Cc: Thomas =?iso-8859-1?Q?Wei=DFschuh?= , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/2] tools/nolibc: support left alignment (-) and zero padding (0) in printf Message-ID: References: <20260128094224.11299-1-im.lechain@gmail.com> <20260128094224.11299-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: <20260128094224.11299-2-im.lechain@gmail.com> Hi Cheng, On Wed, Jan 28, 2026 at 05:42:23PM +0800, licheng.li wrote: > From: Cheng Li > > Currently, __nolibc_printf() in nolibc parses the width field but always > pads with spaces on the left. It ignores the '-' flag (left alignment) > and treats leading zeros in the width as part of the number parsing > (resulting in space padding instead of zero padding). > > This patch implements support for: > 1. The '-' flag: forces left alignment by padding spaces on the right. > 2. The '0' flag: forces zero padding on the left instead of spaces. > > The implementation reuses the padding character logic to handle both > cases. > > Logic behavior: > - "%5d" -> " 12" (unchanged) > - "%-5d" -> "12 " (new: left align) > - "%05d" -> "00012" (new: zero pad) > - "%-05d"-> "12 " (new: left align overrides zero pad) > > The code is optimized to keep the binary size impact minimal. > Measuring the nolibc-test binary on x86_64: > > text data bss dec hex filename > 43552 248 112 43912 ab88 nolibc-test (before) > 43677 248 112 44037 ac05 nolibc-test (after) > > The net increase is 125 bytes. Is it normal this didn't change since previous patch, or did you just forget to update that part of the commit message? In my case I'm seeing a difference: text data bss dec hex filename 35964 112 120 36196 8d64 nolibc-test-before 36070 112 120 36302 8dce nolibc-test-after1 <- first patchset: +106 36044 112 120 36276 8db4 nolibc-test-after2 <- this patchset: +80 If it's just an omission, I can edit the commit message if you paste the new before/after in response, and save you from a respin just for this! If it didn't change anything, that's possible as well, but surprising, which is why I preferred to ask. Thanks, Willy