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 154833081D7 for ; Sat, 7 Mar 2026 10:32:16 +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=1772879538; cv=none; b=iniA5XmckoqCJSlBWzSPrRyhCpnanV7V9x7Rs2UCqIRAlBwMunNx7aVxoPPhX+yhxLW3c5gbUh+crG8Eg7fVyQnddUM9cCZuGZBJR/OVUQ8UEvvOnPudDhKU+N+HeN4sUaTiPDYhlSFos3h86hvUjqLV4+F63Us8MdA0iHqxM00= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772879538; c=relaxed/simple; bh=BySl3/TUB1fkMwPuX/73fHB5ve0G4IIJE81O/BkDh6I=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OOWpfxvTmi3/1UgFYdSpfG/xTMJLKTu5T8VqkQlc4hT7IsDo0vgpZPexybodyVX+7or4Sh3c1j+c3bJRSOQUi2ltDl4js74ZTA9FTAo3kwRIKhr+9vmUVZD7iWudieww3RcSLdVfDpm2mxSduZMNf8nK3uVCxDklID7qzk3icQc= 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=bH+gvXt2; 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="bH+gvXt2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1wt.eu; s=mail; t=1772879535; bh=XKH4zEZxqJjeRI/181IgbbiILcEYyskyHE7FpEBP5dQ=; h=From:Message-ID:From; b=bH+gvXt2bU/1wIc//SptFTju0/g/keAvMAGOrugoJW6YTe5eSkUYw6gJw2AecrEOS kOQsAR9Z3nmaD8YEViTT7cR5Tf0X0YLj7dH2fjD/tJgfGF/HT/xrQpxw8gk/tIi+dp 5aiYMfzXmeJQa1m+lBm1EXT7BS0nOAfZL7R0llEU= Received: from 1wt.eu (ded1.1wt.eu [163.172.96.212]) by mta1.formilux.org (Postfix) with ESMTP id 124C5C09C5; Sat, 07 Mar 2026 11:32:15 +0100 (CET) Date: Sat, 7 Mar 2026 11:32:14 +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 v4 next 16/23] tools/nolibc/printf: Handle "%s" with the numeric formats Message-ID: References: <20260302101815.3043-1-david.laight.linux@gmail.com> <20260302101815.3043-17-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: <20260302101815.3043-17-david.laight.linux@gmail.com> On Mon, Mar 02, 2026 at 10:18:08AM +0000, david.laight.linux@gmail.com wrote: > From: David Laight > > Avoids the extra va_arg() call with is non-trivial on a lot of ^^^^ s/with/which/ I guess :-) > modern ABI. > > Signed-off-by: David Laight Acked-by: Willy Tarreau thanks! Willy > --- > > Unchanched for v4. > > Changes for v3: > - Moved to its own patch (part of patch 7 in v2).. > - Fix 32bit compile. > > tools/include/nolibc/stdio.h | 22 ++++++++++++---------- > 1 file changed, 12 insertions(+), 10 deletions(-) > > diff --git a/tools/include/nolibc/stdio.h b/tools/include/nolibc/stdio.h > index 4c7626dbd63f..484432ca87d5 100644 > --- a/tools/include/nolibc/stdio.h > +++ b/tools/include/nolibc/stdio.h > @@ -412,13 +412,13 @@ int __nolibc_printf(__nolibc_printf_cb cb, void *state, const char *fmt, va_list > */ > ch_flag = _NOLIBC_PF_FLAG(ch); > if (((ch >= 'a' && ch <= 'z') || ch == 'X') && > - _NOLIBC_PF_FLAGS_CONTAIN(ch_flag, 'c', 'd', 'i', 'u', 'x', 'p')) { > - /* 'long' is needed for pointer conversions and ltz lengths. > + _NOLIBC_PF_FLAGS_CONTAIN(ch_flag, 'c', 'd', 'i', 'u', 'x', 'p', 's')) { > + /* 'long' is needed for pointer/string conversions and ltz lengths. > * A single test can be used provided 'p' (the same bit as '0') > * is masked from flags. > */ > if (_NOLIBC_PF_FLAGS_CONTAIN(ch_flag | (flags & ~_NOLIBC_PF_FLAG('p')), > - 'p', 'l', 't', 'z')) { > + 'p', 's', 'l', 't', 'z')) { > v = va_arg(args, unsigned long); > signed_v = (long)v; > } else if (_NOLIBC_PF_FLAGS_CONTAIN(flags, 'j', 'q')) { > @@ -437,6 +437,15 @@ int __nolibc_printf(__nolibc_printf_cb cb, void *state, const char *fmt, va_list > goto do_output; > } > > + if (ch == 's') { > + /* "%s" - character string. */ > + outstr = (const char *)(uintptr_t)v; > + if (!outstr) { > + outstr = "(null)"; > + } > + goto do_strlen_output; > + } > + > out = outbuf; > > if (_NOLIBC_PF_FLAGS_CONTAIN(ch_flag, 'd', 'i')) { > @@ -465,13 +474,6 @@ int __nolibc_printf(__nolibc_printf_cb cb, void *state, const char *fmt, va_list > goto do_strlen_output; > } > > - if (ch == 's') { > - outstr = va_arg(args, char *); > - if (!outstr) > - outstr="(null)"; > - goto do_strlen_output; > - } > - > if (ch == 'm') { > #ifdef NOLIBC_IGNORE_ERRNO > outstr = "unknown error"; > -- > 2.39.5