From 8f157ae4bf01cf0a21ecf9075910c75cfb6e8e81 Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Tue, 11 Jun 2002 17:31:46 +0000 Subject: [PATCH] Solaris compilation cleanups. --- src/apprentice.c | 20 +++++++++----------- src/ascmagic.c | 3 +-- src/compress.c | 5 +---- src/file.c | 5 +---- src/file.h | 9 +++++++-- src/fsmagic.c | 5 +---- src/is_tar.c | 5 ++--- src/print.c | 4 +--- src/readelf.c | 5 +---- src/softmagic.c | 4 +--- 10 files changed, 25 insertions(+), 40 deletions(-) diff --git a/src/apprentice.c b/src/apprentice.c index 5465c73b..1cda7d78 100644 --- a/src/apprentice.c +++ b/src/apprentice.c @@ -26,23 +26,19 @@ */ #include "file.h" -#include #include #ifdef HAVE_UNISTD_H #include #endif #include #include -#include #include -#include -#include #ifdef QUICK #include #endif #ifndef lint -FILE_RCSID("@(#)$Id: apprentice.c,v 1.46 2002/05/16 18:45:56 christos Exp $") +FILE_RCSID("@(#)$Id: apprentice.c,v 1.47 2002/06/11 17:31:46 christos Exp $") #endif /* lint */ #define EATAB {while (isascii((unsigned char) *l) && \ @@ -942,6 +938,7 @@ apprentice_map(magicp, nmagicp, fn, action) uint32 version; int needsbyteswap; char *dbname = mkdbname(fn); + void *mm; if (dbname == NULL) return -1; @@ -956,24 +953,25 @@ apprentice_map(magicp, nmagicp, fn, action) } #ifdef QUICK - if ((*magicp = mmap(0, (size_t)st.st_size, PROT_READ|PROT_WRITE, + if ((mm = mmap(0, (size_t)st.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FILE, fd, (off_t)0)) == MAP_FAILED) { (void)fprintf(stderr, "%s: Cannot map `%s' (%s)\n", progname, dbname, strerror(errno)); goto error; } #else - if ((*magicp = malloc((size_t)st.st_size)) == NULL) { + if ((mm = malloc((size_t)st.st_size)) == NULL) { (void) fprintf(stderr, "%s: Out of memory (%s).\n", progname, strerror(errno)); goto error; } - if (read(fd, *magicp, (size_t)st.st_size) != (size_t)st.st_size) { + if (read(fd, mm, (size_t)st.st_size) != (size_t)st.st_size) { (void) fprintf(stderr, "%s: Read failed (%s).\n", progname, strerror(errno)); goto error; } #endif + *magicp = mm; (void)close(fd); fd = -1; ptr = (uint32 *) *magicp; @@ -1005,11 +1003,11 @@ apprentice_map(magicp, nmagicp, fn, action) error: if (fd != -1) (void)close(fd); - if (*magicp) { + if (mm) { #ifdef QUICK - (void)munmap(*magicp, (size_t)st.st_size); + (void)munmap(mm, (size_t)st.st_size); #else - free(*magicp); + free(mm); #endif } else { *magicp = NULL; diff --git a/src/ascmagic.c b/src/ascmagic.c index c2a2f95f..a155da66 100644 --- a/src/ascmagic.c +++ b/src/ascmagic.c @@ -35,7 +35,6 @@ */ #include "file.h" -#include #include #include #include @@ -46,7 +45,7 @@ #include "names.h" #ifndef lint -FILE_RCSID("@(#)$Id: ascmagic.c,v 1.30 2001/07/26 13:15:49 christos Exp $") +FILE_RCSID("@(#)$Id: ascmagic.c,v 1.31 2002/06/11 17:31:46 christos Exp $") #endif /* lint */ typedef unsigned long unichar; diff --git a/src/compress.c b/src/compress.c index 5978fbbd..f71c2a69 100644 --- a/src/compress.c +++ b/src/compress.c @@ -6,14 +6,11 @@ * using method, return sizeof new */ #include "file.h" -#include #include #ifdef HAVE_UNISTD_H #include #endif #include -#include -#include #ifdef HAVE_SYS_WAIT_H #include #endif @@ -22,7 +19,7 @@ #endif #ifndef lint -FILE_RCSID("@(#)$Id: compress.c,v 1.23 2002/05/16 18:57:10 christos Exp $") +FILE_RCSID("@(#)$Id: compress.c,v 1.24 2002/06/11 17:31:46 christos Exp $") #endif diff --git a/src/file.c b/src/file.c index 5dc64a16..632af4ed 100644 --- a/src/file.c +++ b/src/file.c @@ -26,13 +26,10 @@ */ #include "file.h" -#include #include #include #include -#include #include /* for MAXPATHLEN */ -#include #include /* for open() */ #ifdef RESTORE_TIME # if (__COHERENT__ >= 0x420) @@ -61,7 +58,7 @@ #include "patchlevel.h" #ifndef lint -FILE_RCSID("@(#)$Id: file.c,v 1.63 2002/06/11 17:15:52 christos Exp $") +FILE_RCSID("@(#)$Id: file.c,v 1.64 2002/06/11 17:31:46 christos Exp $") #endif /* lint */ diff --git a/src/file.h b/src/file.h index 2e875895..7ba5f4ab 100644 --- a/src/file.h +++ b/src/file.h @@ -1,6 +1,6 @@ /* * file.h - definitions for file(1) program - * @(#)$Id: file.h,v 1.40 2002/06/11 17:15:52 christos Exp $ + * @(#)$Id: file.h,v 1.41 2002/06/11 17:31:46 christos Exp $ * * Copyright (c) Ian F. Darwin, 1987. * Written by Ian F. Darwin. @@ -130,6 +130,12 @@ struct mlist { #include /* Include that here, to make sure __P gets defined */ #include +/* + * Include it here, so that we don't run into problems with silly OS's that + * do #define renaming for large file support (Hi Solaris). + */ +#include +#include #ifndef __P # if defined(__STDC__) || defined(__cplusplus) @@ -144,7 +150,6 @@ extern int apprentice __P((const char *, int)); extern int ascmagic __P((unsigned char *, int)); extern void error __P((const char *, ...)); extern void ckfputs __P((const char *, FILE *)); -struct stat; extern int fsmagic __P((const char *, struct stat *)); extern char *fmttime __P((long, int)); extern int is_compress __P((const unsigned char *, int *)); diff --git a/src/fsmagic.c b/src/fsmagic.c index d6a900e1..d0148f8f 100644 --- a/src/fsmagic.c +++ b/src/fsmagic.c @@ -26,10 +26,7 @@ */ #include "file.h" -#include #include -#include -#include #ifdef HAVE_UNISTD_H #include #endif @@ -54,7 +51,7 @@ #undef HAVE_MAJOR #ifndef lint -FILE_RCSID("@(#)$Id: fsmagic.c,v 1.33 2000/08/05 17:36:48 christos Exp $") +FILE_RCSID("@(#)$Id: fsmagic.c,v 1.34 2002/06/11 17:31:46 christos Exp $") #endif /* lint */ int diff --git a/src/is_tar.c b/src/is_tar.c index 2c84ca4a..86df93d6 100644 --- a/src/is_tar.c +++ b/src/is_tar.c @@ -5,7 +5,7 @@ * Public Domain version written 26 Aug 1985 John Gilmore (ihnp4!hoptoad!gnu). * * @(#)list.c 1.18 9/23/86 Public Domain - gnu - * $Id: is_tar.c,v 1.15 2002/06/11 17:15:52 christos Exp $ + * $Id: is_tar.c,v 1.16 2002/06/11 17:31:46 christos Exp $ * * Comments changed and some code/comments reformatted * for file command by Ian Darwin. @@ -14,11 +14,10 @@ #include "file.h" #include #include -#include #include "tar.h" #ifndef lint -FILE_RCSID("@(#)$Id: is_tar.c,v 1.15 2002/06/11 17:15:52 christos Exp $") +FILE_RCSID("@(#)$Id: is_tar.c,v 1.16 2002/06/11 17:31:46 christos Exp $") #endif #define isodigit(c) ( ((c) >= '0') && ((c) <= '7') ) diff --git a/src/print.c b/src/print.c index 3c0c99a7..6f5659df 100644 --- a/src/print.c +++ b/src/print.c @@ -26,8 +26,6 @@ */ #include "file.h" -#include -#include #include #ifdef __STDC__ # include @@ -41,7 +39,7 @@ #include #ifndef lint -FILE_RCSID("@(#)$Id: print.c,v 1.35 2002/05/16 18:45:56 christos Exp $") +FILE_RCSID("@(#)$Id: print.c,v 1.36 2002/06/11 17:31:46 christos Exp $") #endif /* lint */ #define SZOF(a) (sizeof(a) / sizeof(a[0])) diff --git a/src/readelf.c b/src/readelf.c index 12c489cd..13f14f2b 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -1,20 +1,17 @@ #include "file.h" #ifdef BUILTIN_ELF -#include #include -#include #include #include #ifdef HAVE_UNISTD_H #include #endif -#include #include "readelf.h" #ifndef lint -FILE_RCSID("@(#)$Id: readelf.c,v 1.20 2002/05/16 18:57:11 christos Exp $") +FILE_RCSID("@(#)$Id: readelf.c,v 1.21 2002/06/11 17:31:46 christos Exp $") #endif #ifdef ELFCORE diff --git a/src/softmagic.c b/src/softmagic.c index be042c93..b5b680f3 100644 --- a/src/softmagic.c +++ b/src/softmagic.c @@ -26,17 +26,15 @@ */ #include "file.h" -#include #include #include #include #include -#include #include #ifndef lint -FILE_RCSID("@(#)$Id: softmagic.c,v 1.49 2002/06/11 17:15:52 christos Exp $") +FILE_RCSID("@(#)$Id: softmagic.c,v 1.50 2002/06/11 17:31:46 christos Exp $") #endif /* lint */ static int match __P((struct magic *, uint32, unsigned char *, int)); -- 2.40.0