Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/gen get rid of the cheesy BAD macros



details:   https://anonhg.NetBSD.org/src/rev/d020908cc4cd
branches:  trunk
changeset: 778333:d020908cc4cd
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Mar 22 14:18:34 2012 +0000

description:
get rid of the cheesy BAD macros

diffstat:

 lib/libc/gen/nlist_coff.c |  24 ++++++++++--------------
 1 files changed, 10 insertions(+), 14 deletions(-)

diffs (86 lines):

diff -r 8d5e8b60b4e8 -r d020908cc4cd lib/libc/gen/nlist_coff.c
--- a/lib/libc/gen/nlist_coff.c Thu Mar 22 13:42:36 2012 +0000
+++ b/lib/libc/gen/nlist_coff.c Thu Mar 22 14:18:34 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nlist_coff.c,v 1.10 2012/03/22 13:42:36 he Exp $ */
+/* $NetBSD: nlist_coff.c,v 1.11 2012/03/22 14:18:34 christos Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou
@@ -36,7 +36,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: nlist_coff.c,v 1.10 2012/03/22 13:42:36 he Exp $");
+__RCSID("$NetBSD: nlist_coff.c,v 1.11 2012/03/22 14:18:34 christos Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -58,10 +58,6 @@
 #endif
 
 #ifdef NLIST_COFF
-#define        BAD             do { rv = -1; goto out; } \
-                       /* NOTREACHED */ while (/*CONSTCOND*/0)
-#define        BADUNMAP        do { rv = -1; goto unmap; } \
-                       /* NOTREACHED */ while (/*CONSTCOND*/0)
 
 #define ES_LEN 18
 struct coff_extsym {
@@ -103,20 +99,20 @@
         * If we can't fstat() the file, something bad is going on.
         */
        if (fstat(fd, &st) < 0)
-               BAD;
+               goto out;
 
        /*
         * Map the file in its entirety.
         */
        if ((uintmax_t)st.st_size > (uintmax_t)SIZE_T_MAX) {
                errno = EFBIG;
-               BAD;
+               goto out;
        }
        mappedsize = (size_t)st.st_size;
        mappedfile = mmap(NULL, mappedsize, PROT_READ, MAP_PRIVATE|MAP_FILE,
            fd, 0);
-       if (mappedfile == (char *)-1)
-               BAD;
+       if (mappedfile == MAP_FAILED)
+               goto out;
 
        /*
         * Make sure we can access the executable's header
@@ -124,11 +120,11 @@
         * as an COFF binary.
         */
        if (mappedsize < sizeof (struct coff_filehdr))
-               BADUNMAP;
+               goto unmap;
        filehdrp = (void *)&mappedfile[0];
 
        if (COFF_BADMAG(filehdrp))
-               BADUNMAP;
+               goto unmap;
 
        /*
         * Find the symbol list.
@@ -137,7 +133,7 @@
        nesyms = filehdrp->f_nsyms;
 
        if (symoff + ES_LEN * nesyms > mappedsize)
-               BADUNMAP;
+               goto unmap;
        extstroff = symoff + ES_LEN * nesyms;
 
        nent = 0;
@@ -193,7 +189,7 @@
 unmap:
        munmap(mappedfile, mappedsize);
 out:
-       return (rv);
+       return rv;
 }
 
 #endif /* NLIST_COFF */



Home | Main Index | Thread Index | Old Index