From patchwork Thu Oct 3 04:50:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Collin Funk X-Patchwork-Id: 98314 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9035F3858C48 for ; Thu, 3 Oct 2024 04:51:54 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by sourceware.org (Postfix) with ESMTPS id 7EF903858C48 for ; Thu, 3 Oct 2024 04:51:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7EF903858C48 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7EF903858C48 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::630 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727931087; cv=none; b=eQF7yfgWAZzN0mmaarPz2W7outTWEF36cU/JiURLETLFibWvy4EEjUoNMBpEjPX1TivWw5pXs4OjtMhmLFJwd9LSe3Mam86FqpKO4lGHMij6mmIsoqUlkJ3TOOUMCYadiJJEtSKRxwo4IOXNU7BivTOpDOJ3OTQW+N4GyyDp8bU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727931087; c=relaxed/simple; bh=4KPlwmfcjxJ57kII5ZTO6n+l7FkhwJfuL3pfLza9olI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=nz7P2uCaYRbr8Wkvz2ml6iLNcgSs84YscUtZSiYMoP9VgviERqYdcBrFwQjhMcTwiPrGfIljmf7MPsEUZTeJTyf9rnLGfgHDu0emLkODr+ej4wD/T+QD13tSH9w6PRnmDOPCEvY9WD5GNbNmfW277nb5Px4iZNqXMCFqDLsVA5M= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-20ba9f3824fso3653585ad.0 for ; Wed, 02 Oct 2024 21:51:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727931083; x=1728535883; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=bFwrUCOWnnF25zVQWO0bfIkuRO9lTMCq1jfBXkz6bwk=; b=NyTywNkQV8dssHu7Epk5/ZkD8XVXyiM0AwjZmzq+RLPjtEUgaUk21v5NN2gzVCFILp VToRstYUoslBkQLcn8NT3AlAqyibDRWJzkrg3QZII/Vvkzpe1pvGlQ6E0cp9y+oVf6rw pOcA0OTL+C7lvga9Dy8yv8seEOylDiqLPc/Rtuzquy4GuvUdwr9Cpol6L5Al3Q8mKNBN WKbpF6yfkFEAgsxyehin+LphyyckYPNinv/S9UB1Hk/zr0n5lGO4s9QuwBB+MVvufOmG xuMBytjvFGnsnR/6oncR+6Q8TjSOKIBMVexmkggJqMKtyKT7lXOykb1wIcOvMc9+S2zL BbRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727931083; x=1728535883; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bFwrUCOWnnF25zVQWO0bfIkuRO9lTMCq1jfBXkz6bwk=; b=fpi9w2mw+gnvXcjCbgx5/UHrRsQ2UKY8hBJcLG0VGIPme2IeNHjR5dZqvfrKGPQymV 2kyOGeePy5X/SrHfgCtPj85biA+BPuMQa+SBVJFKo8uWFUimtxue3wH0JTS1vh1xRhB3 xnUzRlE3LPkqKFTeHxBLYM465k7lN1KwVcCh3M1bWZiQI0OC9KBZcM0qPDwDpcLvgk9X ItK3CX9GIGN93RCUHKz6Apv8lnQlg1xPmBrE3E4j57GBbTRvLFnw/4zPRLXys8E+EtYm CxR5R09s2dV+hh6EKvczwobPCgVVFWmWw/ZNh56eVhH+vAcsXRs2usCWlozqBhMzUG06 k6Mw== X-Gm-Message-State: AOJu0Yxt16E/oEeAC2+yfHcD2BB3Jc16hfj7VQKbaFTc0A/su/YFZsJo 454Kuai7HHQog1KO5+UqZR/4L75kD7Xn9tFXY5eEWE7y4Xp37ulykxeEqA== X-Google-Smtp-Source: AGHT+IE1w3+/gJV6VdwNL3r5VThYSTMG/3+eKB8YrJYFiKR9csC5+0GywfEROK9AadJ88aUC3yKhgA== X-Received: by 2002:a17:902:f691:b0:20b:b238:9d28 with SMTP id d9443c01a7336-20bc59bd141mr81803515ad.15.1727931082702; Wed, 02 Oct 2024 21:51:22 -0700 (PDT) Received: from fedora.. ([138.199.43.96]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7e9dbcf0d1dsm15552a12.3.2024.10.02.21.51.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 21:51:22 -0700 (PDT) From: Collin Funk To: libc-alpha@sourceware.org Cc: Collin Funk Subject: [PATCH] error: Don't call va_end twice [BZ #32233]. Date: Wed, 2 Oct 2024 21:50:13 -0700 Message-ID: <20241003045108.303424-1-collin.funk1@gmail.com> X-Mailer: git-send-email 2.46.2 MIME-Version: 1.0 X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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 server2.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 Sync file from Gnulib. Patch removes an extra va_end call in error_tail that is already handled by the caller. All other differences are namespacing used by Gnulib which do not get compiled in glibc. Signed-off-by: Collin Funk --- misc/error.c | 89 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 52 insertions(+), 37 deletions(-) diff --git a/misc/error.c b/misc/error.c index e5d5588434..6816805326 100644 --- a/misc/error.c +++ b/misc/error.c @@ -20,9 +20,16 @@ #if !_LIBC # include +# define _GL_NO_INLINE_ERROR +# define __error_internal(status, err, fmt, args, flags) \ + verror (status, err, fmt, args) +# define __error_at_line_internal(status, err, file, line, fmt, args, flags) \ + verror_at_line (status, err, file, line, fmt, args) +# define error_tail(status, err, fmt, args, flags) \ + error_tail (status, err, fmt, args) #endif -#include "error.h" +#include #include #include @@ -41,7 +48,7 @@ # include # define mbsrtowcs __mbsrtowcs # define USE_UNLOCKED_IO 0 -# define _GL_ATTRIBUTE_FORMAT_PRINTF(a, b) +# define _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD(a, b) # define _GL_ARG_NONNULL(a) #endif @@ -74,9 +81,9 @@ unsigned int error_message_count; extern void __error (int status, int errnum, const char *message, ...) __attribute__ ((__format__ (__printf__, 3, 4))); extern void __error_at_line (int status, int errnum, const char *file_name, - unsigned int line_number, const char *message, - ...) - __attribute__ ((__format__ (__printf__, 5, 6)));; + unsigned int line_number, const char *message, + ...) + __attribute__ ((__format__ (__printf__, 5, 6))); # define error __error # define error_at_line __error_at_line @@ -92,43 +99,52 @@ extern void __error_at_line (int status, int errnum, const char *file_name, # include # include -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +# if defined _WIN32 && ! defined __CYGWIN__ /* Get declarations of the native Windows API functions. */ # define WIN32_LEAN_AND_MEAN # include /* Get _get_osfhandle. */ -# include "msvc-nothrow.h" +# if GNULIB_MSVC_NOTHROW +# include "msvc-nothrow.h" +# else +# include +# endif # endif /* The gnulib override of fcntl is not needed in this file. */ # undef fcntl -# if !HAVE_DECL_STRERROR_R +# if !(GNULIB_STRERROR_R_POSIX || HAVE_DECL_STRERROR_R) # ifndef HAVE_DECL_STRERROR_R "this configure-time declaration test was not run" # endif # if STRERROR_R_CHAR_P -char *strerror_r (); +char *strerror_r (int errnum, char *buf, size_t buflen); # else -int strerror_r (); +int strerror_r (int errnum, char *buf, size_t buflen); # endif # endif -/* The calling program should define program_name and set it to the - name of the executing program. */ -extern char *program_name; +# define program_name getprogname () -# if HAVE_STRERROR_R || defined strerror_r +# if GNULIB_STRERROR_R_POSIX || HAVE_STRERROR_R || defined strerror_r # define __strerror_r strerror_r -# endif /* HAVE_STRERROR_R || defined strerror_r */ -#endif /* not _LIBC */ +# endif /* GNULIB_STRERROR_R_POSIX || HAVE_STRERROR_R || defined strerror_r */ + +# if GNULIB_defined_verror +# undef verror +# endif +# if GNULIB_defined_verror_at_line +# undef verror_at_line +# endif +#endif /* not _LIBC */ #if !_LIBC /* Return non-zero if FD is open. */ static int is_open (int fd) { -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +# if defined _WIN32 && ! defined __CYGWIN__ /* On native Windows: The initial state of unassigned standard file descriptors is that they are open but point to an INVALID_HANDLE_VALUE. There is no fcntl, and the gnulib replacement fcntl does not support @@ -173,9 +189,9 @@ print_errno_message (int errnum) { char const *s; -#if defined HAVE_STRERROR_R || _LIBC +#if _LIBC || GNULIB_STRERROR_R_POSIX || defined HAVE_STRERROR_R char errbuf[1024]; -# if _LIBC || STRERROR_R_CHAR_P +# if _LIBC || (!GNULIB_STRERROR_R_POSIX && STRERROR_R_CHAR_P) s = __strerror_r (errnum, errbuf, sizeof errbuf); # else if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0) @@ -199,9 +215,9 @@ print_errno_message (int errnum) #endif } -static void _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0) _GL_ARG_NONNULL ((3)) +static void _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0) _GL_ARG_NONNULL ((3)) error_tail (int status, int errnum, const char *message, va_list args, - unsigned int mode_flags) + unsigned int mode_flags) { #if _LIBC int ret = __vfxprintf (stderr, message, args, mode_flags); @@ -212,7 +228,6 @@ error_tail (int status, int errnum, const char *message, va_list args, #else vfprintf (stderr, message, args); #endif - va_end (args); ++error_message_count; if (errnum) @@ -234,7 +249,7 @@ error_tail (int status, int errnum, const char *message, va_list args, Exit with status STATUS if it is nonzero. */ void __error_internal (int status, int errnum, const char *message, - va_list args, unsigned int mode_flags) + va_list args, unsigned int mode_flags) { #if defined _LIBC /* We do not want this call to be cut short by a thread @@ -281,8 +296,8 @@ int error_one_per_line; void __error_at_line_internal (int status, int errnum, const char *file_name, - unsigned int line_number, const char *message, - va_list args, unsigned int mode_flags) + unsigned int line_number, const char *message, + va_list args, unsigned int mode_flags) { if (error_one_per_line) { @@ -290,13 +305,13 @@ __error_at_line_internal (int status, int errnum, const char *file_name, static unsigned int old_line_number; if (old_line_number == line_number - && (file_name == old_file_name - || (old_file_name != NULL - && file_name != NULL - && strcmp (old_file_name, file_name) == 0))) + && (file_name == old_file_name + || (old_file_name != NULL + && file_name != NULL + && strcmp (old_file_name, file_name) == 0))) - /* Simply return and print nothing. */ - return; + /* Simply return and print nothing. */ + return; old_file_name = file_name; old_line_number = line_number; @@ -325,11 +340,11 @@ __error_at_line_internal (int status, int errnum, const char *file_name, } #if _LIBC - __fxprintf (NULL, file_name != NULL ? "%s:%d: " : " ", - file_name, line_number); + __fxprintf (NULL, file_name != NULL ? "%s:%u: " : " ", + file_name, line_number); #else - fprintf (stderr, file_name != NULL ? "%s:%d: " : " ", - file_name, line_number); + fprintf (stderr, file_name != NULL ? "%s:%u: " : " ", + file_name, line_number); #endif error_tail (status, errnum, message, args, mode_flags); @@ -342,12 +357,12 @@ __error_at_line_internal (int status, int errnum, const char *file_name, void error_at_line (int status, int errnum, const char *file_name, - unsigned int line_number, const char *message, ...) + unsigned int line_number, const char *message, ...) { va_list ap; va_start (ap, message); __error_at_line_internal (status, errnum, file_name, line_number, - message, ap, 0); + message, ap, 0); va_end (ap); }