From 1e74040493850eaf44433d7e70ac1c4f27617b90 Mon Sep 17 00:00:00 2001 From: guenther Date: Tue, 13 Jan 2015 07:18:21 +0000 Subject: [PATCH] Remove unnecessary calls to __atexit_register_cleanup(), calling __sinit() instead where necessary. Based on a diff from enh (at) google.com ok millert@ --- lib/libc/stdio/makebuf.c | 3 +-- lib/libc/stdio/setvbuf.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/libc/stdio/makebuf.c b/lib/libc/stdio/makebuf.c index d47e27cf30f..56e5f210cf4 100644 --- a/lib/libc/stdio/makebuf.c +++ b/lib/libc/stdio/makebuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: makebuf.c,v 1.8 2005/12/28 18:50:22 millert Exp $ */ +/* $OpenBSD: makebuf.c,v 1.9 2015/01/13 07:18:21 guenther Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -65,7 +65,6 @@ __smakebuf(FILE *fp) fp->_bf._size = 1; return; } - __atexit_register_cleanup(_cleanup); flags |= __SMBF; fp->_bf._base = fp->_p = p; fp->_bf._size = size; diff --git a/lib/libc/stdio/setvbuf.c b/lib/libc/stdio/setvbuf.c index 6c49f7a5d6d..dc79adc8244 100644 --- a/lib/libc/stdio/setvbuf.c +++ b/lib/libc/stdio/setvbuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: setvbuf.c,v 1.11 2009/11/09 00:18:27 kurt Exp $ */ +/* $OpenBSD: setvbuf.c,v 1.12 2015/01/13 07:18:21 guenther Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -114,6 +114,13 @@ nbf: flags |= __SMBF; } + /* + * We're committed to buffering from here, so make sure we've + * registered to flush buffers on exit. + */ + if (!__sdidinit) + __sinit(); + /* * Kill any seek optimization if the buffer is not the * right size. @@ -148,7 +155,6 @@ nbf: fp->_w = 0; } FUNLOCKFILE(fp); - __atexit_register_cleanup(_cleanup); return (ret); } -- 2.20.1