]> granicus.if.org Git - file/commitdiff
Make these files compile with gcc warnings on and also make them pass lint.
authorAnon Ymous <ljt@astron.com>
Tue, 16 Jan 2007 14:56:45 +0000 (14:56 +0000)
committerAnon Ymous <ljt@astron.com>
Tue, 16 Jan 2007 14:56:45 +0000 (14:56 +0000)
src/ascmagic.c
src/compress.c
src/readelf.c
src/tar.h
src/test.c

index 3aa0e235c14a9fd135e02ea8af36d05b9b7e3f2e..30df77ea5c91dc83531572c18e8995492288bb51 100644 (file)
@@ -49,7 +49,7 @@
 #include "names.h"
 
 #ifndef        lint
-FILE_RCSID("@(#)$File: ascmagic.c,v 1.46 2006/10/20 21:04:15 christos Exp $")
+FILE_RCSID("@(#)$File: ascmagic.c,v 1.47 2007/01/12 17:38:27 christos 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]];
index 6391d7dcd67fe4a6510d1752848f71fa441067d2..5d845963de468db67c1c9e3b765a83fc4c3edee8 100644 (file)
@@ -51,7 +51,7 @@
 #endif
 
 #ifndef lint
-FILE_RCSID("@(#)$File: compress.c,v 1.45 2006/10/31 19:37:17 christos Exp $")
+FILE_RCSID("@(#)$File: compress.c,v 1.46 2007/01/12 17:38:27 christos 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",
index b93dd9d22e7677a48a79c5ad858a1529c4c2c91b..32d559bc06508e8dd96b7b7e3afb0b7fa5002b03 100644 (file)
@@ -37,7 +37,7 @@
 #include "readelf.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: readelf.c,v 1.61 2006/11/15 15:53:23 christos Exp $")
+FILE_RCSID("@(#)$File: readelf.c,v 1.62 2007/01/12 17:38:28 christos 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;
index 8ea64117f0cdee922eb87103488dc09fc395c046..da870ab15e4908f7b703060d1a3d2c7d01ec976a 100644 (file)
--- 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.9 2006/05/03 15:19:25 christos Exp $ # checkin only
+ * $File: tar.h,v 1.10 2007/01/12 17:38:28 christos 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
index ab4c105380b08677edb604ebdfcf680d5fcdbd4f..55b78d387c0d51495ad8d86e62e08a4896722bc6 100644 (file)
@@ -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);