Module Name: src Committed By: christos Date: Thu Mar 22 14:18:34 UTC 2012
Modified Files: src/lib/libc/gen: nlist_coff.c Log Message: get rid of the cheesy BAD macros To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/lib/libc/gen/nlist_coff.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/gen/nlist_coff.c diff -u src/lib/libc/gen/nlist_coff.c:1.10 src/lib/libc/gen/nlist_coff.c:1.11 --- src/lib/libc/gen/nlist_coff.c:1.10 Thu Mar 22 09:42:36 2012 +++ src/lib/libc/gen/nlist_coff.c Thu Mar 22 10:18:34 2012 @@ -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 @@ __RCSID("$NetBSD: nlist_coff.c,v 1.10 20 #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 @@ __fdnlist_coff(int fd, struct nlist *lis * 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 @@ __fdnlist_coff(int fd, struct nlist *lis * 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 @@ __fdnlist_coff(int fd, struct nlist *lis nesyms = filehdrp->f_nsyms; if (symoff + ES_LEN * nesyms > mappedsize) - BADUNMAP; + goto unmap; extstroff = symoff + ES_LEN * nesyms; nent = 0; @@ -193,7 +189,7 @@ done: unmap: munmap(mappedfile, mappedsize); out: - return (rv); + return rv; } #endif /* NLIST_COFF */