Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/stdlib cleanup saving and restoring errno, and make...



details:   https://anonhg.NetBSD.org/src/rev/a172f9b8c698
branches:  trunk
changeset: 765061:a172f9b8c698
user:      christos <christos%NetBSD.org@localhost>
date:      Wed May 18 01:59:39 2011 +0000

description:
cleanup saving and restoring errno, and make it similar.

diffstat:

 lib/libc/stdlib/jemalloc.c |   8 ++++----
 lib/libc/stdlib/malloc.c   |  13 +++++--------
 2 files changed, 9 insertions(+), 12 deletions(-)

diffs (100 lines):

diff -r 4062c16a6cf2 -r a172f9b8c698 lib/libc/stdlib/jemalloc.c
--- a/lib/libc/stdlib/jemalloc.c        Wed May 18 01:02:43 2011 +0000
+++ b/lib/libc/stdlib/jemalloc.c        Wed May 18 01:59:39 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: jemalloc.c,v 1.23 2011/05/13 23:11:00 christos Exp $   */
+/*     $NetBSD: jemalloc.c,v 1.24 2011/05/18 01:59:39 christos Exp $   */
 
 /*-
  * Copyright (C) 2006,2007 Jason Evans <jasone%FreeBSD.org@localhost>.
@@ -118,7 +118,7 @@
 
 #include <sys/cdefs.h>
 /* __FBSDID("$FreeBSD: src/lib/libc/stdlib/malloc.c,v 1.147 2007/06/15 22:00:16 jasone Exp $"); */ 
-__RCSID("$NetBSD: jemalloc.c,v 1.23 2011/05/13 23:11:00 christos Exp $");
+__RCSID("$NetBSD: jemalloc.c,v 1.24 2011/05/18 01:59:39 christos Exp $");
 
 #ifdef __FreeBSD__
 #include "libc_private.h"
@@ -3337,6 +3337,7 @@
                return (false);
        }
 
+       serrno = errno;
        /* Get number of CPUs. */
        {
                int mib[2];
@@ -3372,7 +3373,6 @@
                /* Get runtime configuration. */
                switch (i) {
                case 0:
-                       serrno = errno;
                        if ((linklen = readlink("/etc/malloc.conf", buf,
                                                sizeof(buf) - 1)) != -1) {
                                /*
@@ -3382,7 +3382,6 @@
                                buf[linklen] = '\0';
                                opts = buf;
                        } else {
-                               errno = serrno;
                                /* No configuration specified. */
                                buf[0] = '\0';
                                opts = buf;
@@ -3518,6 +3517,7 @@
                        }
                }
        }
+       errno = serrno;
 
        /* Take care to call atexit() only once. */
        if (opt_print_stats) {
diff -r 4062c16a6cf2 -r a172f9b8c698 lib/libc/stdlib/malloc.c
--- a/lib/libc/stdlib/malloc.c  Wed May 18 01:02:43 2011 +0000
+++ b/lib/libc/stdlib/malloc.c  Wed May 18 01:59:39 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: malloc.c,v 1.53 2011/05/13 23:11:00 christos Exp $     */
+/*     $NetBSD: malloc.c,v 1.54 2011/05/18 01:59:39 christos Exp $     */
 
 /*
  * ----------------------------------------------------------------------------
@@ -90,7 +90,7 @@
 #include <sys/cdefs.h>
 #include "extern.h"
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: malloc.c,v 1.53 2011/05/13 23:11:00 christos Exp $");
+__RCSID("$NetBSD: malloc.c,v 1.54 2011/05/18 01:59:39 christos Exp $");
 #endif /* LIBC_SCCS and not lint */
 int utrace(const char *, void *, size_t);
 
@@ -447,7 +447,7 @@
     char b[64];
     size_t i;
     ssize_t j;
-    int save_errno = errno;
+    int serrno = errno;
 
     /*
      * Compute page-size related variables.
@@ -467,12 +467,9 @@
 
     for (i = 0; i < 3; i++) {
        if (i == 0) {
-           int serrno = errno;
            j = readlink("/etc/malloc.conf", b, sizeof b - 1);
-           if (j == -1) {
-               errno = serrno; 
+           if (j == -1)
                continue;
-           }
            b[j] = '\0';
            p = b;
        } else if (i == 1 && issetugid() == 0) {
@@ -550,7 +547,7 @@
      */
     px = imalloc(sizeof *px);
 
-    errno = save_errno;
+    errno = serrno;
 }
 
 /*



Home | Main Index | Thread Index | Old Index