From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dedi548.your-server.de (dedi548.your-server.de [85.10.215.148]) by sourceware.org (Postfix) with ESMTPS id 1E86F385843E for ; Thu, 31 Mar 2022 14:35:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1E86F385843E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embedded-brains.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embedded-brains.de Received: from sslproxy01.your-server.de ([78.46.139.224]) by dedi548.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nZvtB-0006G4-06 for newlib@sourceware.org; Thu, 31 Mar 2022 16:35:05 +0200 Received: from [82.100.198.138] (helo=mail.embedded-brains.de) by sslproxy01.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nZvtA-000SmX-Tw for newlib@sourceware.org; Thu, 31 Mar 2022 16:35:04 +0200 Received: from localhost (localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id A02EE480115 for ; Thu, 31 Mar 2022 16:35:04 +0200 (CEST) Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id swSQOiGZMfuF; Thu, 31 Mar 2022 16:35:04 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 566C4480054; Thu, 31 Mar 2022 16:35:04 +0200 (CEST) X-Virus-Scanned: amavisd-new at zimbra.eb.localhost Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id A6RG9xn-AY7R; Thu, 31 Mar 2022 16:35:04 +0200 (CEST) Received: from joyce-tux.eb.localhost (unknown [10.10.171.30]) by mail.embedded-brains.de (Postfix) with ESMTPSA id E3716480114; Thu, 31 Mar 2022 16:35:03 +0200 (CEST) From: Matthew Joyce To: newlib@sourceware.org Subject: [PATCH 1/2] Fix bug introduced in previous patch (44b60f0c) Date: Thu, 31 Mar 2022 16:34:54 +0200 Message-Id: <20220331143455.4395-2-matthew.joyce@embedded-brains.de> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220331143455.4395-1-matthew.joyce@embedded-brains.de> References: <20220331143455.4395-1-matthew.joyce@embedded-brains.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authenticated-Sender: smtp-embedded@poldinet.de X-Virus-Scanned: Clear (ClamAV 0.103.5/26498/Thu Mar 31 10:19:05 2022) X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2022 14:35:07 -0000 From: Matt Joyce This fixes a bug introduced in a previous patch (Commit 44b60f0c: Make __sdidinit unused). Removed intitialization of __cleanup from __smakebuf_r(). All callers of __smakebuf_r() call __sinit() through the_CHECK_INIT macro, thus __cleanup is already initialized. This fix also allows _cleanup_r() to be made static. Changed its name to cleanup_stdio() and removed its declaration from local.h. --- newlib/libc/stdio/fflush.c | 2 +- newlib/libc/stdio/findfp.c | 8 ++++---- newlib/libc/stdio/local.h | 1 - newlib/libc/stdio/makebuf.c | 1 - 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/newlib/libc/stdio/fflush.c b/newlib/libc/stdio/fflush.c index f2d0d9bbb..2b5f13bff 100644 --- a/newlib/libc/stdio/fflush.c +++ b/newlib/libc/stdio/fflush.c @@ -234,7 +234,7 @@ __sflush_r (struct _reent *ptr, } =20 #ifdef _STDIO_BSD_SEMANTICS -/* Called from _cleanup_r. At exit time, we don't need file locking, +/* Called from cleanup_stdio(). At exit time, we don't need file lockin= g, and we don't want to move the underlying file pointer unless we're writing. */ int diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c index eca47bd92..aa5e366d8 100644 --- a/newlib/libc/stdio/findfp.c +++ b/newlib/libc/stdio/findfp.c @@ -199,8 +199,8 @@ found: * The name `_cleanup' is, alas, fairly well known outside stdio. */ =20 -void -_cleanup_r (struct _reent *ptr) +static void +cleanup_stdio (struct _reent *ptr) { int (*cleanup_func) (struct _reent *, FILE *); #ifdef _STDIO_BSD_SEMANTICS @@ -232,7 +232,7 @@ _cleanup_r (struct _reent *ptr) void _cleanup (void) { - _cleanup_r (_GLOBAL_REENT); + cleanup_stdio (_GLOBAL_REENT); } #endif =20 @@ -252,7 +252,7 @@ __sinit (struct _reent *s) } =20 /* make sure we clean up on exit */ - s->__cleanup =3D _cleanup_r; /* conservative */ + s->__cleanup =3D cleanup_stdio; /* conservative */ =20 s->__sglue._next =3D NULL; #ifndef _REENT_SMALL diff --git a/newlib/libc/stdio/local.h b/newlib/libc/stdio/local.h index 86422eb11..50818db0e 100644 --- a/newlib/libc/stdio/local.h +++ b/newlib/libc/stdio/local.h @@ -180,7 +180,6 @@ extern _fpos_t __sseek (struct _reent *, void *, _fpo= s_t, int); extern int __sclose (struct _reent *, void *); extern int __stextmode (int); extern void __sinit (struct _reent *); -extern void _cleanup_r (struct _reent *); extern void __smakebuf_r (struct _reent *, FILE *); extern int __swhatbuf_r (struct _reent *, FILE *, size_t *, int *); extern int _fwalk_reent (struct _reent *, int (*)(struct _reent *, FI= LE *)); diff --git a/newlib/libc/stdio/makebuf.c b/newlib/libc/stdio/makebuf.c index 0030812c1..b9c75bbf8 100644 --- a/newlib/libc/stdio/makebuf.c +++ b/newlib/libc/stdio/makebuf.c @@ -61,7 +61,6 @@ __smakebuf_r (struct _reent *ptr, } else { - ptr->__cleanup =3D _cleanup_r; fp->_flags |=3D __SMBF; fp->_bf._base =3D fp->_p =3D (unsigned char *) p; fp->_bf._size =3D size; --=20 2.31.1