From patchwork Wed Mar 18 21:47:56 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Colomar X-Patchwork-Id: 131928 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 98D854B35896 for ; Wed, 18 Mar 2026 21:49:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 98D854B35896 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=LkZ7cVIT X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from tor.source.kernel.org (tor.source.kernel.org [IPv6:2600:3c04:e001:324:0:1991:8:25]) by sourceware.org (Postfix) with ESMTPS id F0E0F4BCA41F for ; Wed, 18 Mar 2026 21:48:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F0E0F4BCA41F Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kernel.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F0E0F4BCA41F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2600:3c04:e001:324:0:1991:8:25 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1773870481; cv=none; b=g/uIVDjJaR8f6v/a27A84vFXucc+kmZt84z3I7bVhTQ9lEmznmjXz0/FUtrO5i0vO6iQzUsFlWU7DtDzBsHfd9whvi1OtQr0upw5unSaHS8DGwi1HP+BPG3sN1pG0WFpAos5HC17G5yfzBtsxnbspUTD3sa1ykrRhLCXZPmkvhs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1773870481; c=relaxed/simple; bh=EZ/H9xyt77P5+NsOB/rSSC6qIH3qGLiuF1/Fy0HdrPs=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=WuyUFNpb0mLB9eJ0nCVIwvShuspkVANxabeXw6SguGkfId3YdarX/CJUE7vmOrt6jALRD9A/hflw0h6QsrBcOh0sciAW7beNaqmDqAK58EpZ+WzB80xrsvOD+KHiwShs7kBtPTb9nQUiCi+DmltXbw3ecP3bMde2O5DrznpWmTY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F0E0F4BCA41F Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 8195060133; Wed, 18 Mar 2026 21:48:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 296E2C19421; Wed, 18 Mar 2026 21:47:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773870480; bh=EZ/H9xyt77P5+NsOB/rSSC6qIH3qGLiuF1/Fy0HdrPs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LkZ7cVITV1rP7eCNgjBAYFqzUzCLC8fZJvQfUMJZflPBgBBzGY0JS1Mwpw56jJ8kz pLgeZuZc8yxKD8aqlxEdAcMvirtjAi3P/Wh1SAX7PQh+C+GY+fmChlafXO7iqWVuoW sBKoegegNr+uhHR9dOq3uWbSdKIqCefGSIGOglsW2BsJx98OvG7rxpGCGTuSXE3tWw bSU6Lr1v9xSgkniMpqfg2l40mc4mh2UdQA/V6cZGCZenXKQGjd8ENPRBveNfSZ/OCR MOahW0QhfstreWqbVkBUt5jxQT/omzUyrjbO+gnxVi4TGs6QHDzk0MlTZZkWlpMZJR s2iVr6TEJ/Aig== Date: Wed, 18 Mar 2026 22:47:56 +0100 From: Alejandro Colomar To: libc-alpha@sourceware.org Cc: Alejandro Colomar , Joseph Myers , Paul Eggert , Adhemerval Zanella Netto , Florian Weimer , "Dmitry V. Levin" , Archie Cobbs , Solar Designer , Sam James Subject: [RFC v4 2/2] manual/: Prefer aprintf(3) over asprintf(3) Message-ID: X-Mailer: git-send-email 2.53.0 References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org While it's less portable at the moment, it's a better API (simpler, safer, and less error-prone). The C Committee has expressed strong support for this API, intending to standardize it. Thus, it should be more portable in the long term. Signed-off-by: Alejandro Colomar --- manual/examples/rprintf.c | 4 ++-- manual/stdio.texi | 4 ++-- manual/string.texi | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/manual/examples/rprintf.c b/manual/examples/rprintf.c index 734a8768..736ac169 100644 --- a/manual/examples/rprintf.c +++ b/manual/examples/rprintf.c @@ -38,8 +38,8 @@ print_widget (FILE *stream, /* Format the output into a string. */ w = *((const Widget **) (args[0])); - len = asprintf (&buffer, "", w, w->name); - if (len == -1) + buffer = aprintf ("", w, w->name); + if (buffer == NULL) return -1; /* Pad to the minimum field width and print to the stream. */ diff --git a/manual/stdio.texi b/manual/stdio.texi index e7deca78..91149626 100644 --- a/manual/stdio.texi +++ b/manual/stdio.texi @@ -2458,7 +2458,7 @@ because it can potentially output more characters than can fit in the allocation size of the string @var{s}. Remember that the field width given in a conversion specification is only a @emph{minimum} value. -To avoid this problem, you can use @code{snprintf} or @code{asprintf}, +To avoid this problem, you can use @code{snprintf} or @code{aprintf}, described below. @end deftypefun @@ -2543,7 +2543,7 @@ make_message (char *name, char *value) @end group @end smallexample -In practice, it is often easier just to use @code{asprintf}, below. +In practice, it is often easier just to use @code{aprintf}, below. @strong{Attention:} In versions of @theglibc{} prior to 2.1 the return value is the number of characters stored, not including the diff --git a/manual/string.texi b/manual/string.texi index 24004f1f..7a6ee12a 100644 --- a/manual/string.texi +++ b/manual/string.texi @@ -1198,7 +1198,7 @@ strings to fit arbitrary size limits. @xref{Semantics, , Writing Robust Programs, standards, The GNU Coding Standards}. Instead of string-truncation functions, it is usually better to use dynamic memory allocation (@pxref{Unconstrained Allocation}) and functions -such as @code{strdup} or @code{asprintf} to construct strings. +such as @code{strdup} or @code{aprintf} to construct strings. @node String/Array Comparison @section String/Array Comparison