public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Fix bug from previous patch (44b60f0c)
@ 2022-03-31 14:34 Matthew Joyce
  2022-03-31 14:34 ` [PATCH 1/2] Fix bug introduced in " Matthew Joyce
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Matthew Joyce @ 2022-03-31 14:34 UTC (permalink / raw)
  To: newlib

From: Matt Joyce <matthew.joyce@embedded-brains.de>

Hello,

Patch 1 fixes a bug introduced in a previous patch (44b60f0c).

Patch 2 removes a _cleanup() from findfp.c which is now unused.

Thank you!

Sincerely,

Matt

Matt Joyce (2):
  Fix bug introduced in previous patch (44b60f0c)
  Remove unused _cleanup()

 newlib/libc/stdio/fflush.c  |  2 +-
 newlib/libc/stdio/findfp.c  | 14 +++-----------
 newlib/libc/stdio/local.h   |  1 -
 newlib/libc/stdio/makebuf.c |  1 -
 4 files changed, 4 insertions(+), 14 deletions(-)

-- 
2.31.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] Fix bug introduced in previous patch (44b60f0c)
  2022-03-31 14:34 [PATCH 0/2] Fix bug from previous patch (44b60f0c) Matthew Joyce
@ 2022-03-31 14:34 ` Matthew Joyce
  2022-03-31 14:34 ` [PATCH 2/2] Remove unused _cleanup() Matthew Joyce
  2022-04-01 14:01 ` [PATCH 0/2] Fix bug from previous patch (44b60f0c) Corinna Vinschen
  2 siblings, 0 replies; 4+ messages in thread
From: Matthew Joyce @ 2022-03-31 14:34 UTC (permalink / raw)
  To: newlib

From: Matt Joyce <matthew.joyce@embedded-brains.de>

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,
 }
 
 #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 locking,
    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.
  */
 
-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
 
@@ -252,7 +252,7 @@ __sinit (struct _reent *s)
     }
 
   /* make sure we clean up on exit */
-  s->__cleanup = _cleanup_r;	/* conservative */
+  s->__cleanup = cleanup_stdio;	/* conservative */
 
   s->__sglue._next = 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 *, _fpos_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 *, FILE *));
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 = _cleanup_r;
       fp->_flags |= __SMBF;
       fp->_bf._base = fp->_p = (unsigned char *) p;
       fp->_bf._size = size;
-- 
2.31.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] Remove unused _cleanup()
  2022-03-31 14:34 [PATCH 0/2] Fix bug from previous patch (44b60f0c) Matthew Joyce
  2022-03-31 14:34 ` [PATCH 1/2] Fix bug introduced in " Matthew Joyce
@ 2022-03-31 14:34 ` Matthew Joyce
  2022-04-01 14:01 ` [PATCH 0/2] Fix bug from previous patch (44b60f0c) Corinna Vinschen
  2 siblings, 0 replies; 4+ messages in thread
From: Matthew Joyce @ 2022-03-31 14:34 UTC (permalink / raw)
  To: newlib

From: Matt Joyce <matthew.joyce@embedded-brains.de>

Removed the unused function _cleanup() from findfp.c.
---
 newlib/libc/stdio/findfp.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c
index aa5e366d8..1370b63b8 100644
--- a/newlib/libc/stdio/findfp.c
+++ b/newlib/libc/stdio/findfp.c
@@ -228,14 +228,6 @@ cleanup_stdio (struct _reent *ptr)
   (void) _fwalk_reent (ptr, cleanup_func);
 }
 
-#ifndef _REENT_ONLY
-void
-_cleanup (void)
-{
-  cleanup_stdio (_GLOBAL_REENT);
-}
-#endif
-
 /*
  * __sinit() is called whenever stdio's internal variables must be set up.
  */
-- 
2.31.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] Fix bug from previous patch (44b60f0c)
  2022-03-31 14:34 [PATCH 0/2] Fix bug from previous patch (44b60f0c) Matthew Joyce
  2022-03-31 14:34 ` [PATCH 1/2] Fix bug introduced in " Matthew Joyce
  2022-03-31 14:34 ` [PATCH 2/2] Remove unused _cleanup() Matthew Joyce
@ 2022-04-01 14:01 ` Corinna Vinschen
  2 siblings, 0 replies; 4+ messages in thread
From: Corinna Vinschen @ 2022-04-01 14:01 UTC (permalink / raw)
  To: newlib

On Mar 31 16:34, Matthew Joyce wrote:
> From: Matt Joyce <matthew.joyce@embedded-brains.de>
> 
> Hello,
> 
> Patch 1 fixes a bug introduced in a previous patch (44b60f0c).
> 
> Patch 2 removes a _cleanup() from findfp.c which is now unused.

Pushed.


Thanks,
Corinna


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-01 14:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-31 14:34 [PATCH 0/2] Fix bug from previous patch (44b60f0c) Matthew Joyce
2022-03-31 14:34 ` [PATCH 1/2] Fix bug introduced in " Matthew Joyce
2022-03-31 14:34 ` [PATCH 2/2] Remove unused _cleanup() Matthew Joyce
2022-04-01 14:01 ` [PATCH 0/2] Fix bug from previous patch (44b60f0c) Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).