From: Anon Ymous Date: Tue, 16 Jan 2007 14:56:45 +0000 (+0000) Subject: Make these files compile with gcc warnings on and also make them pass lint. X-Git-Tag: FILE5_05~673 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=88c95fbc52458d2f5b8413f789c3afd63d5423b4;p=file Make these files compile with gcc warnings on and also make them pass lint. --- diff --git a/src/ascmagic.c b/src/ascmagic.c index 3f85e22b..301b2734 100644 --- a/src/ascmagic.c +++ b/src/ascmagic.c @@ -49,7 +49,7 @@ #include "names.h" #ifndef lint -FILE_RCSID("@(#)$File: ascmagic.c,v 1.47 2007/01/12 17:38:27 christos Exp $") +FILE_RCSID("@(#)$File: ascmagic.c,v 1.48 2007/01/16 14:56:45 ljt Exp $") #endif /* lint */ typedef unsigned long unichar; @@ -92,7 +92,7 @@ file_ascmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes) int n_cr = 0; int n_nel = 0; - int last_line_end = -1; + size_t last_line_end = (size_t)-1; int has_long_lines = 0; /* @@ -461,7 +461,7 @@ private int looks_ascii(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen) { - int i; + size_t i; *ulen = 0; @@ -480,7 +480,7 @@ looks_ascii(const unsigned char *buf, size_t nbytes, unichar *ubuf, private int looks_latin1(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen) { - int i; + size_t i; *ulen = 0; @@ -500,7 +500,7 @@ private int looks_extended(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen) { - int i; + size_t i; *ulen = 0; @@ -519,7 +519,8 @@ looks_extended(const unsigned char *buf, size_t nbytes, unichar *ubuf, private int looks_utf8(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen) { - int i, n; + size_t i; + int n; unichar c; int gotone = 0; @@ -583,7 +584,7 @@ looks_unicode(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen) { int bigend; - int i; + size_t i; if (nbytes < 2) return 0; @@ -702,7 +703,7 @@ private unsigned char ebcdic_1047_to_8859[] = { private void from_ebcdic(const unsigned char *buf, size_t nbytes, unsigned char *out) { - int i; + size_t i; for (i = 0; i < nbytes; i++) { out[i] = ebcdic_to_ascii[buf[i]]; diff --git a/src/compress.c b/src/compress.c index 4eadbd82..ca9064dc 100644 --- a/src/compress.c +++ b/src/compress.c @@ -51,7 +51,7 @@ #endif #ifndef lint -FILE_RCSID("@(#)$File: compress.c,v 1.46 2007/01/12 17:38:27 christos Exp $") +FILE_RCSID("@(#)$File: compress.c,v 1.47 2007/01/16 14:56:45 ljt Exp $") #endif private struct { @@ -74,7 +74,7 @@ private struct { { "BZh", 3, { "bzip2", "-cd", NULL }, 1 }, /* bzip2-ed */ }; -private int ncompr = sizeof(compr) / sizeof(compr[0]); +private size_t ncompr = sizeof(compr) / sizeof(compr[0]); #define NODATA ((size_t)~0) @@ -341,7 +341,7 @@ uncompressgzipped(struct magic_set *ms, const unsigned char *old, } n = (size_t)z.total_out; - inflateEnd(&z); + (void)inflateEnd(&z); /* let's keep the nul-terminate tradition */ (*newch)[n] = '\0'; @@ -389,8 +389,8 @@ uncompressbuf(struct magic_set *ms, int fd, size_t method, (void)close(2); #endif - execvp(compr[method].argv[0], - (char *const *)(intptr_t)compr[method].argv); + (void)execvp(compr[method].argv[0], + (char *const *)(intptr_t)compr[method].argv); #ifdef DEBUG (void)fprintf(stderr, "exec `%s' failed (%s)\n", compr[method].argv[0], strerror(errno)); @@ -412,7 +412,7 @@ uncompressbuf(struct magic_set *ms, int fd, size_t method, switch (fork()) { case 0: /* child */ (void)close(fdout[0]); - if (swrite(fdin[1], old, n) != n) { + if (swrite(fdin[1], old, n) != (ssize_t)n) { #ifdef DEBUG (void)fprintf(stderr, "Write failed (%s)\n", diff --git a/src/readelf.c b/src/readelf.c index e2a6a203..dd9004b5 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -37,7 +37,7 @@ #include "readelf.h" #ifndef lint -FILE_RCSID("@(#)$File: readelf.c,v 1.62 2007/01/12 17:38:28 christos Exp $") +FILE_RCSID("@(#)$File: readelf.c,v 1.63 2007/01/16 14:56:45 ljt Exp $") #endif #ifdef ELFCORE @@ -155,7 +155,7 @@ getu64(int swap, uint64_t value) #define xph_type (class == ELFCLASS32 \ ? getu32(swap, ph32.p_type) \ : getu32(swap, ph64.p_type)) -#define xph_offset (class == ELFCLASS32 \ +#define xph_offset (off_t)(class == ELFCLASS32 \ ? getu32(swap, ph32.p_offset) \ : getu64(swap, ph64.p_offset)) #define xph_align (size_t)((class == ELFCLASS32 \ @@ -293,7 +293,7 @@ dophn_core(struct magic_set *ms, int class, int swap, int fd, off_t off, * This is a PT_NOTE section; loop through all the notes * in the section. */ - if (lseek(fd, (off_t)xph_offset, SEEK_SET) == (off_t)-1) { + if (lseek(fd, xph_offset, SEEK_SET) == (off_t)-1) { file_badseek(ms); return -1; } @@ -858,7 +858,7 @@ dophn_exec(struct magic_set *ms, int class, int swap, int fd, off_t off, * This is a PT_NOTE section; loop through all the notes * in the section. */ - if (lseek(fd, (off_t)xph_offset, SEEK_SET) + if (lseek(fd, xph_offset, SEEK_SET) == (off_t)-1) { file_badseek(ms); return -1; diff --git a/src/tar.h b/src/tar.h index 7ecce32f..30d386ba 100644 --- a/src/tar.h +++ b/src/tar.h @@ -32,7 +32,7 @@ * * Created 25 August 1985 by John Gilmore, ihnp4!hoptoad!gnu. * - * $File: tar.h,v 1.10 2007/01/12 17:38:28 christos Exp $ # checkin only + * $File: tar.h,v 1.11 2007/01/16 14:56:45 ljt Exp $ # checkin only */ /* @@ -106,52 +106,6 @@ union record { #define EX_BADARCH 3 /* bad archive */ #define EX_SYSTEM 4 /* system gave unexpected error */ - -/* - * Global variables - */ -TAR_EXTERN union record *ar_block; /* Start of block of archive */ -TAR_EXTERN union record *ar_record; /* Current record of archive */ -TAR_EXTERN union record *ar_last; /* Last+1 record of archive block */ -TAR_EXTERN char ar_reading; /* 0 writing, !0 reading archive */ -TAR_EXTERN int blocking; /* Size of each block, in records */ -TAR_EXTERN int blocksize; /* Size of each block, in bytes */ -TAR_EXTERN char *ar_file; /* File containing archive */ -TAR_EXTERN char *name_file; /* File containing names to work on */ -TAR_EXTERN char *tar; /* Name of this program */ - -/* - * Flags from the command line - */ -TAR_EXTERN char f_reblock; /* -B */ -TAR_EXTERN char f_create; /* -c */ -TAR_EXTERN char f_debug; /* -d */ -TAR_EXTERN char f_sayblock; /* -D */ -TAR_EXTERN char f_follow_links; /* -h */ -TAR_EXTERN char f_ignorez; /* -i */ -TAR_EXTERN char f_keep; /* -k */ -TAR_EXTERN char f_modified; /* -m */ -TAR_EXTERN char f_oldarch; /* -o */ -TAR_EXTERN char f_use_protection; /* -p */ -TAR_EXTERN char f_sorted_names; /* -s */ -TAR_EXTERN char f_list; /* -t */ -TAR_EXTERN char f_namefile; /* -T */ -TAR_EXTERN char f_verbose; /* -v */ -TAR_EXTERN char f_extract; /* -x */ -TAR_EXTERN char f_compress; /* -z */ - -/* - * We now default to Unix Standard format rather than 4.2BSD tar format. - * The code can actually produce all three: - * f_standard ANSI standard - * f_oldarch V7 - * neither 4.2BSD - * but we don't bother, since 4.2BSD can read ANSI standard format anyway. - * The only advantage to the "neither" option is that we can cmp(1) our - * output to the output of 4.2BSD tar, for debugging. - */ -#define f_standard (!f_oldarch) - /* * Structure for keeping track of filenames and lists thereof. */ @@ -162,12 +116,6 @@ struct name { char name[NAMSIZ+1]; }; -TAR_EXTERN struct name *namelist; /* Points to first name in list */ -TAR_EXTERN struct name *namelast; /* Points to last name in list */ - -TAR_EXTERN int archive; /* File descriptor for archive file */ -TAR_EXTERN int errors; /* # of files in error */ - /* * * Due to the next struct declaration, each routine that includes @@ -185,21 +133,3 @@ struct link { short linkcount; char name[NAMSIZ+1]; }; - -TAR_EXTERN struct link *linklist; /* Points to first link in list */ - - -/* - * Error recovery stuff - */ -TAR_EXTERN char read_error_flag; - - -#if 0 -/* - * Declarations of functions available to the world. - */ -/*LINTLIBRARY*/ -#define annorec(stream, msg) anno(stream, msg, 0) /* Cur rec */ -#define annofile(stream, msg) anno(stream, msg, 1) /* Saved rec */ -#endif diff --git a/src/test.c b/src/test.c index ab4c1053..55b78d38 100644 --- a/src/test.c +++ b/src/test.c @@ -39,19 +39,19 @@ main(int argc, char **argv) ms = magic_open(MAGIC_NONE); if (ms == NULL) { - printf("ERROR: out of memory\n"); + (void) printf("ERROR: out of memory\n"); return 1; } if (magic_load(ms, NULL) == -1) { - printf("ERROR: %s\n", magic_error(ms)); + (void) printf("ERROR: %s\n", magic_error(ms)); return 1; } for (i = 1; i < argc; i++) { if ((m = magic_file(ms, argv[i])) == NULL) - printf("ERROR: %s\n", magic_error(ms)); + (void) printf("ERROR: %s\n", magic_error(ms)); else - printf("%s: %s\n", argv[i], m); + (void) printf("%s: %s\n", argv[i], m); } magic_close(ms);