From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 89DBF35D5F8 for ; Mon, 23 Feb 2026 11:00:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771844403; cv=none; b=hJ/mL6j7Eq4RE2UcMayl54sWTo0618/P9VIOmvLBIEQT22conQPy5Zqx7vlvx7U9dnsoqKGq7o0G91W+jm6VtseYX6hUHnhErZgP8RD07ZlIKqJjOtbDHLS0DQDJqn8H4aZ66MV3Jp1C7rNDVX1r+VZO/9GkfLN9Qg0ogm2JlxE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771844403; c=relaxed/simple; bh=aJYOgWMazHKXEzhQDu/0Z1bL2ooI7Z4gE6dbEfkjNRo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VR2fkYQebpdDKXcbbpWU2uslOxdBxlgIt2+v4uEcsiEfx+kySnwk8mKNlqAiEmDyrLu/lKq2My/xO3e7VU9t2n/DTbb9Rwlrp6nvwMjgIzN2f94ZkzdfI0ESbam2A+IaT6TbL8/piQw7HgRMnQH9eLTTn4BNMPjMXOf3HvrRkTw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=Q9iRcJGV; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="Q9iRcJGV" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vuT1F-00GoE6-P8; Mon, 23 Feb 2026 11:18:25 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector2; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=yTV4jgxjYuWLXjqEY/GNcTWw9BdfHU0teSATs59KDG4=; b=Q9iRcJGVG34A89lAcrjeYAaAf0 eCMaSCfkYK3Vpo0STxWmoXEEwNXfZL3fL8+tRQKETQt9BS2IjmAXAyzC+tNc95MQL2QHlAIZU+kqN 4veRha2FoqbZxvqGSK7EsvMpVtrnX3ypeaA8aZnq+7L4yStjZgvrorRgY2j78UuFb3IUmQTDxVT0T FGiGiM8ddCLl4Q0oITiEcK2apsccO6gZuYmS2qBxqS6tp8OHO5CmnPY3cCPo6mjax8kH0QTMFY7FE I+F4tCk2YX0xwPv5GTJEwmgU58iJ/TfTywNw74zkOf/yRPH0jErNK4IeEjY19p5cXSX1IPsy9NbK2 JuOvBMdw==; Received: from [10.9.9.73] (helo=submission02.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vuT1F-0001TB-En; Mon, 23 Feb 2026 11:18:25 +0100 Received: by submission02.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vuT15-006AjD-4o; Mon, 23 Feb 2026 11:18:15 +0100 From: david.laight.linux@gmail.com To: Willy Tarreau , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , linux-kernel@vger.kernel.org, Cheng Li Cc: David Laight Subject: [PATCH v3 next 12/17] tools/nolibc/printf: Handle "%s" with the numeric formats Date: Mon, 23 Feb 2026 10:17:30 +0000 Message-Id: <20260223101735.2922-13-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260223101735.2922-1-david.laight.linux@gmail.com> References: <20260223101735.2922-1-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-Transfer-Encoding: 8bit From: David Laight Avoids the extra va_arg() call with is non-trivial on a lot of modern ABI. Signed-off-by: David Laight --- 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 6cb106367e3b..6dd27473ab7f 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') { outstr = strerror(errno); goto do_strlen_output; -- 2.39.5