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 CE72E28D8DB for ; Mon, 16 Feb 2026 20:11:20 +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=1771272682; cv=none; b=TeMnVeeOyH8FWYpYST/JDkpLkdulmM3vixyTQHNo6cqfqLeaywpF83qIXBnx3tC/fHVkD5F6zYyRJ6P/rcaEftM3P60L3QianQIzmCT3PzFi0hhEpqoEAPpsxADuC70m5UmrIRLASf3g4RKKye0JO/J7iXuMp5PwQ8yv7galvTA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771272682; c=relaxed/simple; bh=4RidujZncwFmJkYSB490pQsCTBaMjcrZekqOGcLDYu4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Saab2dyz846fVlkNI+PCSmE9KDF7kKLw1+Fux0HrXnxm0lPgrZJye+NoZc9mKqRMcE9fFE1bNWWyBdTdjhxcBltORgrX8XJebmkkoMAyCiGDW1wh3uJ+Co1Uy48/xtgBKhX4JQFv0jgpcM3pOhxacoGQFti77fVXvg5qL2FG2ps= 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=LHEfXB4c; 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="LHEfXB4c" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1771272679; bh=4RidujZncwFmJkYSB490pQsCTBaMjcrZekqOGcLDYu4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LHEfXB4cDt/ZIM+T5dVMlCJmEFoUh90+sD18wHi5izPfBf9sGlG4nmlg7vwgcxjcB K0GslEWlGKU/rqYGqWcpFkxZCVFnMQh8RXxFn9dIxTUqQk9h1vOgLHMflj+FcYLHXJ AtDWJdwqJwmOKjrb25FepyDpeen0fhx5okxN6D7o= Date: Mon, 16 Feb 2026 21:11:18 +0100 From: Thomas =?utf-8?Q?Wei=C3=9Fschuh?= To: david.laight.linux@gmail.com Cc: Willy Tarreau , linux-kernel@vger.kernel.org, Cheng Li Subject: Re: [PATCH v2 next 07/11] tools/nolibc/printf: Add support for conversion flags "#- +" and format "%X" Message-ID: References: <20260206191121.3602-1-david.laight.linux@gmail.com> <20260206191121.3602-8-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-8-david.laight.linux@gmail.com> On 2026-02-06 19:11:17+0000, david.laight.linux@gmail.com wrote: > From: David Laight > > Add support for all the normal flag chacacters except '0' (zero pad). > '-' left alignment. > '+' and ' ' Sign characters for non-negative numbers. > '#' adds 0x to hex numbers. > Partially support "%X", outputs lower case a..f the same as "%x". > > Move the "%s" code in with the numeric formats to save a va_arg() call. > > Prepend the sign (or "0x") after conversion to ascii and use the length > returned by u64toh_r() and u64toa_r(). > Both needed for precision and zero-padding in the next patch. > > Signed-off-by: David Laight > --- > > Changes for v2: > - Add support for left justifying fields (removed from patch 6). > - Merge in the changes from the old patch 8. > - Add support for "%#x" (formally part of patch 9). > > tools/include/nolibc/stdio.h | 97 ++++++++++++++++++++++++++---------- > 1 file changed, 71 insertions(+), 26 deletions(-) (...) > @@ -365,40 +384,62 @@ int __nolibc_printf(__nolibc_printf_cb cb, void *state, const char *fmt, va_list > goto do_output; > } > > + if (_NOLIBC_PF_FLAGS_CONTAIN(ch_flag, 's')) { > + /* "%s" - character string. */ > + if (!v) { > + outstr = "(null)"; > + len = 6; > + goto do_output; > + } > + outstr = (void *)v; When building for i386: In file included from ./nolibc.h:123, from ./ctype.h:8, from : ./stdio.h: In function '__nolibc_printf': ./stdio.h:445:50: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] 445 | outstr = (void *)v; | Needs a cast through (uintptr_t). Also instead of casting through (void *), please specify the actual target type that is expected. > +do_strnlen_output: > + len = strnlen(outstr, INT_MAX); > + goto do_output; > + } (...)