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 D965B34B663 for ; Sun, 8 Feb 2026 16:16:26 +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=1770567387; cv=none; b=jY0jstAVBSAynaU/+1qiRLQFAk+wJlmn0FrqzKUXT5SuIKYwyPfhDV/I6swxSaQEAfDhHdRgrSzQvYNf/CeGKveemKB/4ICdqi/wTTrgtx922YtcSwPJy9oiYq2PGmlx1Ob2YLGC8cEnbl0aLoIpAQohIxYTDzyKF8KBBw/iXqg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770567387; c=relaxed/simple; bh=9qG3hOHfS8gnKZZ2yoGqEpNgwebtPenBJgGW2cgsR4U=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Gl3N5/TVBeXUvjwasTY+w1gn636b/zg+VuBrQT4FfQVYyOo4u8j09VNJweQmhQlw8BXjpBTs5Sr9MukQEJhq9x5HB+6MmEdAMugyGU6z+K3pS7Ay1KjtFVKxRUcVSfrO+Nn7/DgXVKxTcqfPH//lPfYohO6V0QVfi0pcX4ZNva8= 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=jPbjxChf; 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="jPbjxChf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1wt.eu; s=mail; t=1770567385; bh=vREnWywrXrAB7BsRE52t9NlnEVzqCzPrSdZctligUhM=; h=From:Message-ID:From; b=jPbjxChfZLxHGbUkNhH/ZId6OsGF9+SV4BDtQnIduWyw3TY5GG1SI/VEx5ZVObhlA 5QsrCMzDNGlEd7MZYXJ0w1jrKs6bbbMgV5Tv2f2IvqLYlViglL/eqKnbMqk9W1tr8z yUtpsSN91AVC/U0MpiCvKfmZZ8xb2jaSg37J4jho= Received: from 1wt.eu (ded1.1wt.eu [163.172.96.212]) by mta1.formilux.org (Postfix) with ESMTP id CBB77C0A05; Sun, 08 Feb 2026 17:16:24 +0100 (CET) Date: Sun, 8 Feb 2026 17:16:24 +0100 From: Willy Tarreau To: david.laight.linux@gmail.com Cc: Thomas =?iso-8859-1?Q?Wei=DFschuh?= , linux-kernel@vger.kernel.org, Cheng Li Subject: Re: [PATCH v2 next 08/11] tools/nolibc/printf: Add support for zero padding and field precision Message-ID: References: <20260206191121.3602-1-david.laight.linux@gmail.com> <20260206191121.3602-9-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-9-david.laight.linux@gmail.com> On Fri, Feb 06, 2026 at 07:11:18PM +0000, david.laight.linux@gmail.com wrote: > + /* Add zero padding */ > + if (_NOLIBC_PF_FLAGS_CONTAIN(flags, '0', '.')) { > + if (!_NOLIBC_PF_FLAGS_CONTAIN(flags, '.')) { > + if (_NOLIBC_PF_FLAGS_CONTAIN(flags, '-')) > + /* Left justify overrides zero pad */ > + goto prepend_sign; > + /* eg "%05d", Zero pad to field width less sign */ > + precision = width; > + if (sign) { > + precision--; > + if (sign >= 256) This is the one that confused me with previous patch. As long as we cannot have 4 chars that's OK, otherwise the 4th char can flip the sign. We could also add and unsigned cast here to clarify this, though admittedly this should not change over time. Just for the record, this is the patch that increases the code the most (+265 bytes for me, no jump tables). But I think the feature is worth it and I'm not seeing low hanging fruits to reduce it. I honestly find the code particularly complex to follow now but that's related to the multiplicity of output formats and I doubt we can do much about this. Acked-by: Willy Tarreau Willy