Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/gen Make this lint-free (only built for real for th...



details:   https://anonhg.NetBSD.org/src/rev/8d5e8b60b4e8
branches:  trunk
changeset: 778332:8d5e8b60b4e8
user:      he <he%NetBSD.org@localhost>
date:      Thu Mar 22 13:42:36 2012 +0000

description:
Make this lint-free (only built for real for the __sh__ ports):
 * Mark some code after goto as /* NOTREACHED */
 * Add a cast for file size (off_t) to size_t to avoid warning about
   possibly losing bits.
 * Avoid a "pointer casts may be troublesome" warning from lint
   by doing a cast via "void *" instead of directly to "struct
   coff_filehdr *".

diffstat:

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

diffs (49 lines):

diff -r d18fb23c8b5c -r 8d5e8b60b4e8 lib/libc/gen/nlist_coff.c
--- a/lib/libc/gen/nlist_coff.c Thu Mar 22 13:25:45 2012 +0000
+++ b/lib/libc/gen/nlist_coff.c Thu Mar 22 13:42:36 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nlist_coff.c,v 1.9 2012/03/21 15:32:26 christos Exp $ */
+/* $NetBSD: nlist_coff.c,v 1.10 2012/03/22 13:42:36 he 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.9 2012/03/21 15:32:26 christos Exp $");
+__RCSID("$NetBSD: nlist_coff.c,v 1.10 2012/03/22 13:42:36 he Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -58,8 +58,10 @@
 #endif
 
 #ifdef NLIST_COFF
-#define        BAD             do { rv = -1; goto out; } while (/*CONSTCOND*/0)
-#define        BADUNMAP        do { rv = -1; goto unmap; } while (/*CONSTCOND*/0)
+#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 {
@@ -110,7 +112,7 @@
                errno = EFBIG;
                BAD;
        }
-       mappedsize = st.st_size;
+       mappedsize = (size_t)st.st_size;
        mappedfile = mmap(NULL, mappedsize, PROT_READ, MAP_PRIVATE|MAP_FILE,
            fd, 0);
        if (mappedfile == (char *)-1)
@@ -123,7 +125,7 @@
         */
        if (mappedsize < sizeof (struct coff_filehdr))
                BADUNMAP;
-       filehdrp = (struct coff_filehdr *)&mappedfile[0];
+       filehdrp = (void *)&mappedfile[0];
 
        if (COFF_BADMAG(filehdrp))
                BADUNMAP;



Home | Main Index | Thread Index | Old Index