diff options
author | jbj <devnull@localhost> | 2002-10-01 15:18:16 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2002-10-01 15:18:16 +0000 |
commit | 69f31f57625896cad0bd54e5e35b53808d2c641c (patch) | |
tree | 7f1c2e99ec3738f7c3f5276ac21ebd9472558c1b | |
parent | 9e39ec258af280198beb131dc969b0386db536d5 (diff) | |
download | librpm-tizen-69f31f57625896cad0bd54e5e35b53808d2c641c.tar.gz librpm-tizen-69f31f57625896cad0bd54e5e35b53808d2c641c.tar.bz2 librpm-tizen-69f31f57625896cad0bd54e5e35b53808d2c641c.zip |
lclint fiddles.
CVS patchset: 5741
CVS date: 2002/10/01 15:18:16
-rw-r--r-- | file/.lclintrc | 75 | ||||
-rw-r--r-- | file/apprentice.c | 65 | ||||
-rw-r--r-- | file/ascmagic.c | 8 | ||||
-rw-r--r-- | file/compress.c | 32 | ||||
-rw-r--r-- | file/file.c | 25 | ||||
-rw-r--r-- | file/file.h | 55 | ||||
-rw-r--r-- | file/names.h | 4 | ||||
-rw-r--r-- | file/print.c | 6 | ||||
-rw-r--r-- | file/softmagic.c | 54 | ||||
-rw-r--r-- | file/tar.h | 10 |
10 files changed, 178 insertions, 156 deletions
diff --git a/file/.lclintrc b/file/.lclintrc index 8a2e54d83..172c48c2e 100644 --- a/file/.lclintrc +++ b/file/.lclintrc @@ -1,4 +1,4 @@ --I. +-I. -DHAVE_CONFIG_H -DSTDC #+partial +forcehints @@ -14,80 +14,47 @@ +strict # lclint level # --- in progress --branchstate # 4 --exitarg # 6 -exportheader # 19 -formatconst # 9 --globstate # 3 --globuse # 4 --macroredef # 1 --modobserver # 2 --mods # 7 --moduncon # 4 +-macroredef # 1 tar.h +-moduncon # 1 getopt_long -modunconnomods # 12 ctype.h --mustmod # 6 --noeffectuncon # 1 --noparams # 44 zlib --nullderef # 2 --nullpass # 6 +-mustmod # 1 mman.h +-noparams # 3 getopt_long +#-nullderef # 4 +-nullpass # 27 -nullptrarith # 1 --paramuse # 2 --redecl # 1 -redef # 4 --retvalint --shadow -sizeoftype # 29 --type # 2 zlib -uniondef # 6 --usereleased # 1 -usevarargs # 1 --warnmissingglobs # 2 - --dependenttrans # 2 --immediatetrans # 2 --kepttrans # 1 --observertrans # 4 --temptrans # 1 --unqualifiedtrans # 2 - --whileempty # --- +partial artifacts --declundef # 32 tar.h --exportheadervar --exportlocal - --varuse # 5 +-exportlocal # 18 # --- not-yet at strict level --bitwisesigned # pita --elseifcomplete # 95 occurences +-bitwisesigned # 47 +-elseifcomplete # 3 -fielduse # 21 tar.h --forblock # tedious --ifblock # tedious --incondefs # <bits/{ipc,pthreadtypes}.h> heartburn +-forblock # 6 +-ifblock # 231 +-incondefs # 36 -namechecks # tedious ANSI compliance checks -ptrarith # tedious --compdestroy -mustdefine -shiftimplementation # 148 ctype.h --strictops --strictusereleased --whileblock # tedious +-strictops # 4 +-whileblock # 17 # --- not-yet at checks level --ansi-reserved -+enumint --mustfree --predboolptr --usedef +-mustfree # 17 +-usedef # 41 # --- not-yet at standard level --boolops -predboolint -+boolint -+charint -+ignorequals -+matchanyintegral ++boolint # 36 ++charint # 147 ++ignorequals # 49 ++matchanyintegral # 83 diff --git a/file/apprentice.c b/file/apprentice.c index 60c3f3ea2..d830f98d0 100644 --- a/file/apprentice.c +++ b/file/apprentice.c @@ -93,14 +93,14 @@ static int parse(/*@out@*/ struct magic **magicp, static void eatsize(/*@out@*/ char **p) /*@modifies *p @*/; static int apprentice_1(const char *fn, int action) - /*@globals lineno, mlist, fileSystem @*/ - /*@modifies lineno, mlist, fileSystem @*/; + /*@globals lineno, mlist, fileSystem, internalState @*/ + /*@modifies lineno, mlist, fileSystem, internalState @*/; static int apprentice_file(/*@out@*/ struct magic **magicp, /*@out@*/ uint32_t *nmagicp, const char *fn, int action) /*@globals lineno, maxmagic, fileSystem @*/ /*@modifies *magicp, *nmagicp, lineno, maxmagic, fileSystem @*/; -static void byteswap(struct magic *magic, uint32_t nmagic) - /*@modifies magic @*/; +static void byteswap(struct magic *m, uint32_t nmagic) + /*@modifies m @*/; static void bs1(struct magic *m) /*@modifies m @*/; static uint16_t swap2(uint16_t sv) @@ -113,12 +113,12 @@ static char *mkdbname(const char *fn) /*@modifies fileSystem @*/; static int apprentice_map(/*@out@*/ struct magic **magicp, /*@out@*/ uint32_t *nmagicp, const char *fn, int action) - /*@globals fileSystem @*/ - /*@modifies *magicp, *nmagicp, fileSystem @*/; + /*@globals fileSystem, internalState @*/ + /*@modifies *magicp, *nmagicp, fileSystem, internalState @*/; static int apprentice_compile(/*@out@*/ struct magic **magicp, /*@out@*/ uint32_t *nmagicp, const char *fn, int action) - /*@globals fileSystem @*/ - /*@modifies *magicp, *nmagicp, fileSystem @*/; + /*@globals fileSystem, internalState @*/ + /*@modifies fileSystem, internalState @*/; #ifdef COMPILE_ONLY const char *magicfile; @@ -155,8 +155,10 @@ main(int argc, char *argv[]) static int apprentice_1(const char *fn, int action) { +/*@-shadow@*/ struct magic *magic = NULL; uint32_t nmagic = 0; +/*@=shadow@*/ struct mlist *ml; int rv = -1; @@ -193,10 +195,16 @@ apprentice_1(const char *fn, int action) mlist.prev->next = ml; ml->prev = mlist.prev; +/*@-immediatetrans@*/ ml->next = &mlist; +/*@=immediatetrans@*/ +/*@-kepttrans@*/ mlist.prev = ml; +/*@=kepttrans@*/ +/*@-compdef@*/ return rv; +/*@=compdef@*/ #endif /* COMPILE_ONLY */ } @@ -208,35 +216,44 @@ apprentice(const char *fn, int action) char *p, *mfn; int file_err, errs = -1; - mlist.next = mlist.prev = &mlist; +/*@-immediatetrans@*/ + mlist.next = &mlist; + mlist.prev = &mlist; +/*@=immediatetrans@*/ mfn = malloc(strlen(fn)+1); if (mfn == NULL) { (void) fprintf(stderr, "%s: Out of memory (%s).\n", progname, strerror(errno)); +/*@-compmempass@*/ if (action == CHECK) return -1; else - exit(1); + exit(EXIT_FAILURE); +/*@=compmempass@*/ } fn = strcpy(mfn, fn); - while (fn) { +/*@-branchstate@*/ + while (fn != NULL) { p = strchr(fn, PATHSEP); - if (p) + if (p != NULL) *p++ = '\0'; file_err = apprentice_1(fn, action); if (file_err > errs) errs = file_err; fn = p; } +/*@=branchstate@*/ if (errs == -1) (void) fprintf(stderr, "%s: couldn't find any magic files!\n", progname); if (action == CHECK && errs) - exit(1); + exit(EXIT_FAILURE); free(mfn); +/*@-compdef -compmempass@*/ return errs; +/*@=compdef =compmempass@*/ } /* @@ -352,17 +369,21 @@ parse(struct magic **magicp, uint32_t *nmagicp, char *l, int action) #define ALLOC_INCR 200 if (*nmagicp + 1 >= maxmagic){ maxmagic += ALLOC_INCR; +/*@-unqualifiedtrans @*/ if ((m = (struct magic *) realloc(*magicp, sizeof(struct magic) * maxmagic)) == NULL) { (void) fprintf(stderr, "%s: Out of memory (%s).\n", progname, strerror(errno)); - if (*magicp) +/*@-usereleased@*/ + if (*magicp != NULL) free(*magicp); +/*@=usereleased@*/ if (action == CHECK) return -1; else - exit(1); + exit(EXIT_FAILURE); } +/*@=unqualifiedtrans @*/ *magicp = m; memset(&(*magicp)[*nmagicp], 0, sizeof(struct magic) * ALLOC_INCR); @@ -695,7 +716,7 @@ GetDesc: } else m->nospflag = 0; while ((m->desc[i++] = *l++) != '\0' && i<MAXDESC) - /* NULLBODY */; + {}; #ifndef COMPILE_ONLY if (action == CHECK) { @@ -935,7 +956,7 @@ eatsize(char **p) */ static int apprentice_map(struct magic **magicp, uint32_t *nmagicp, const char *fn, - int action) + /*@unused@*/ int action) { int fd; struct stat st; @@ -1008,7 +1029,8 @@ apprentice_map(struct magic **magicp, uint32_t *nmagicp, const char *fn, error: if (fd != -1) (void)close(fd); - if (mm) { +/*@-branchstate@*/ + if (mm != NULL) { #ifdef QUICK (void)munmap(mm, (size_t)st.st_size); #else @@ -1018,6 +1040,7 @@ error: *magicp = NULL; *nmagicp = 0; } +/*@=branchstate@*/ return -1; } @@ -1026,7 +1049,7 @@ error: */ static int apprentice_compile(struct magic **magicp, uint32_t *nmagicp, const char *fn, - int action) + /*@unused@*/ int action) { int fd; char *dbname = mkdbname(fn); @@ -1094,11 +1117,11 @@ mkdbname(const char *fn) * Byteswap an mmap'ed file if needed */ static void -byteswap(struct magic *magic, uint32_t nmagic) +byteswap(struct magic *m, uint32_t nmagic) { uint32_t i; for (i = 0; i < nmagic; i++) - bs1(&magic[i]); + bs1(&m[i]); } /* diff --git a/file/ascmagic.c b/file/ascmagic.c index ab08de06a..db314efc1 100644 --- a/file/ascmagic.c +++ b/file/ascmagic.c @@ -267,19 +267,19 @@ subtype_identified: } if (iflag) { - if (subtype_mime) + if (subtype_mime != NULL) ckfputs(subtype_mime, stdout); else ckfputs("text/plain", stdout); - if (code_mime) { + if (code_mime != NULL) { ckfputs("; charset=", stdout); ckfputs(code_mime, stdout); } } else { ckfputs(code, stdout); - if (subtype) { + if (subtype != NULL) { ckfputs(" ", stdout); ckfputs(subtype, stdout); } @@ -643,7 +643,7 @@ unsigned char ebcdic_to_ascii[] = { * cases for the NEL character can be taken out of the code. */ -/*@unchecked@*/ /*@observer@*/ +/*@unchecked@*/ /*@unused@*/ /*@observer@*/ unsigned char ebcdic_1047_to_8859[] = { 0x00,0x01,0x02,0x03,0x9C,0x09,0x86,0x7F,0x97,0x8D,0x8E,0x0B,0x0C,0x0D,0x0E,0x0F, 0x10,0x11,0x12,0x13,0x9D,0x0A,0x08,0x87,0x18,0x19,0x92,0x8F,0x1C,0x1D,0x1E,0x1F, diff --git a/file/compress.c b/file/compress.c index c8970a367..2991e119d 100644 --- a/file/compress.c +++ b/file/compress.c @@ -51,15 +51,13 @@ static int ncompr = sizeof(compr) / sizeof(compr[0]); static int swrite(int fd, const void *buf, size_t n) - /*@globals fileSystem @*/ - /*@modifies fileSystem @*/; + /*@*/; static int sread(int fd, /*@out@*/ void *buf, size_t n) - /*@globals fileSystem @*/ - /*@modifies *buf, fileSystem @*/; + /*@modifies *buf @*/; static int uncompressbuf(int method, const unsigned char *old, /*@out@*/ unsigned char **newch, int n) - /*@globals fileSystem @*/ - /*@modifies *newch, fileSystem @*/; + /*@globals fileSystem, internalState @*/ + /*@modifies *newch, fileSystem, internalState @*/; #ifdef HAVE_LIBZ static int uncompressgzipped(const unsigned char *old, /*@out@*/ unsigned char **newch, int n) @@ -79,10 +77,10 @@ zmagic(const char *fname, unsigned char *buf, int nbytes) continue; if (memcmp(buf, compr[i].magic, compr[i].maglen) == 0 && (newsize = uncompressbuf(i, buf, &newbuf, nbytes)) != 0) { - tryit(fname, newbuf, newsize, 1); + (void) tryit(fname, newbuf, newsize, 1); free(newbuf); printf(" ("); - tryit(fname, buf, nbytes, 0); + (void) tryit(fname, buf, nbytes, 0); printf(")"); return 1; } @@ -249,24 +247,30 @@ uncompressgzipped(const unsigned char *old, unsigned char **newch, int n) z.avail_in = n - data_start; z.next_out = *newch; z.avail_out = HOWMANY; - z.zalloc = Z_NULL; - z.zfree = Z_NULL; - z.opaque = Z_NULL; + z.zalloc = NULL; + z.zfree = NULL; + z.opaque = NULL; +/*@-type@*/ rc = inflateInit2(&z, -15); +/*@=type@*/ if (rc != Z_OK) { (void) fprintf(stderr,"%s: zlib: %s\n", progname, z.msg); return 0; } +/*@-type@*/ rc = inflate(&z, Z_SYNC_FLUSH); +/*@=type@*/ if (rc != Z_OK && rc != Z_STREAM_END) { fprintf(stderr,"%s: zlib: %s\n", progname, z.msg); return 0; } n = z.total_out; - inflateEnd(&z); +/*@-type@*/ + (void) inflateEnd(&z); +/*@=type@*/ /* let's keep the nul-terminate tradition */ (*newch)[n++] = '\0'; @@ -307,9 +311,9 @@ uncompressbuf(int method, const unsigned char *old, unsigned char **newch, if (compr[method].silent) (void) close(2); - execvp(compr[method].argv[0], + (void) execvp(compr[method].argv[0], (char *const *)compr[method].argv); - exit(1); + exit(EXIT_FAILURE); /*@notreached@*/break; case -1: error("could not fork (%s).\n", strerror(errno)); diff --git a/file/file.c b/file/file.c index 0db2a29ff..61307c0ec 100644 --- a/file/file.c +++ b/file/file.c @@ -92,11 +92,11 @@ int /* Global command-line options */ nobuffer = 0, /* Do not buffer stdout */ kflag = 0; /* Keep going after the first match */ -/*@unchecked@*/ +/*@unchecked@*/ /*@unused@*/ int /* Misc globals */ nmagic = 0; /* number of valid magic[]s */ -/*@unchecked@*/ +/*@unchecked@*/ /*@unused@*/ struct magic *magic; /* array of magic entries */ /*@unchecked@*/ /*@null@*/ @@ -111,25 +111,26 @@ int lineno; /* line number in the magic file */ static void unwrap(char *fn) - /*@globals fileSystem @*/ - /*@modifies fileSystem @*/; + /*@globals fileSystem, internalState @*/ + /*@modifies fileSystem, internalState @*/; /*@exits@*/ static void usage(void) /*@globals fileSystem @*/ /*@modifies fileSystem @*/; #ifdef HAVE_GETOPT_H +/*@exits@*/ static void help(void) /*@globals fileSystem @*/ /*@modifies fileSystem @*/; #endif int main(int argc, char *argv[]) - /*@globals debug, lflag, bflag, zflag, sflag, iflag, nobuffer, kflag, + /*@globals debug, bflag, zflag, sflag, iflag, nobuffer, kflag, default_magicfile, lineno, magicfile, mlist, optind, progname, - fileSystem @*/ - /*@modifies debug, lflag, bflag, zflag, sflag, iflag, nobuffer, kflag, + fileSystem, internalState @*/ + /*@modifies argv, debug, bflag, zflag, sflag, iflag, nobuffer, kflag, default_magicfile, lineno, magicfile, mlist, optind, progname, - fileSystem @*/; + fileSystem, internalState @*/; /* * main - parse arguments and handle options @@ -177,10 +178,12 @@ main(int argc, char **argv) _wildcard(&argc, &argv); #endif +/*@-modobserver@*/ if ((progname = strrchr(argv[0], '/')) != NULL) progname++; else progname = argv[0]; +/*@=modobserver@*/ magicfile = default_magicfile; if ((usermagic = getenv("MAGIC")) != NULL) @@ -432,7 +435,7 @@ process(const char *inname, int wid) * first try judging the file based on its filesystem status */ if (fsmagic(inname, &sb) != 0) { - putchar('\n'); + (void) putchar('\n'); return; } @@ -546,14 +549,14 @@ usage(void) #ifdef HAVE_GETOPT_H (void)fputs("Try `file --help' for more information.\n", stderr); #endif - exit(1); + exit(EXIT_FAILURE); } #ifdef HAVE_GETOPT_H static void help(void) { - puts( + (void) puts( "Usage: file [OPTION]... [FILE]...\n" "Determine file type of FILEs.\n" "\n" diff --git a/file/file.h b/file/file.h index ee5e4bda2..4625dfbaf 100644 --- a/file/file.h +++ b/file/file.h @@ -126,12 +126,15 @@ struct magic { struct mlist { struct magic *magic; /* array of magic entries */ uint32_t nmagic; /* number of entries in array */ - struct mlist *next, *prev; +/*@null@*/ + struct mlist *next; +/*@null@*/ + struct mlist *prev; }; -/*@unchecked@*/ +/*@unchecked@*/ /*@observer@*/ /*@null@*/ extern char *progname; /* the program name */ -/*@unchecked@*/ +/*@unchecked@*/ /*@dependent@*/ /*@observer@*/ extern const char *magicfile; /* name of the magic file */ /*@unchecked@*/ extern int lineno; /* current line number in magic file */ @@ -174,18 +177,10 @@ extern char *sys_errlist[]; #define QUICK #endif -#if defined(__LCLINT__) -#define FILE_RCSID(id) -#else -#define FILE_RCSID(id) \ -static const char *rcsid(const char *p) { \ - return rcsid(p = id); \ -} -#endif - +/*@mayexit@*/ extern int apprentice(const char *fn, int action) - /*@globals lineno, mlist, fileSystem @*/ - /*@modifies lineno, mlist, fileSystem @*/; + /*@globals lineno, mlist, fileSystem, internalState @*/ + /*@modifies lineno, mlist, fileSystem, internalState @*/; extern int ascmagic(unsigned char *buf, int nbytes) /*@globals fileSystem @*/ /*@modifies fileSystem @*/; @@ -200,10 +195,13 @@ struct stat; extern int fsmagic(const char *fn, /*@out@*/ struct stat *sb) /*@globals fileSystem @*/ /*@modifies *sb, fileSystem @*/; +/*@observer@*/ extern char *fmttime(long v, int local) /*@*/; +#if 0 extern int is_compress(const unsigned char *, int *) /*@*/; +#endif extern int is_tar(unsigned char *buf, int nbytes) /*@*/; extern void magwarn(const char *f, ...) @@ -213,8 +211,8 @@ extern void mdump(struct magic *m) /*@globals fileSystem @*/ /*@modifies fileSystem @*/; extern void process(const char *inname, int wid) - /*@globals fileSystem @*/ - /*@modifies fileSystem @*/; + /*@globals fileSystem, internalState @*/ + /*@modifies fileSystem, internalState @*/; extern void showstr(FILE *fp, const char *s, int len) /*@globals fileSystem @*/ /*@modifies fp, fileSystem @*/; @@ -222,11 +220,11 @@ extern int softmagic(unsigned char *buf, int nbytes) /*@globals fileSystem @*/ /*@modifies buf, fileSystem @*/; extern int tryit(const char *fn, unsigned char *buf, int nb, int zfl) - /*@globals fileSystem @*/ - /*@modifies buf, fileSystem @*/; + /*@globals fileSystem, internalState @*/ + /*@modifies buf, fileSystem, internalState @*/; extern int zmagic(const char *fname, unsigned char *buf, int nbytes) - /*@globals fileSystem @*/ - /*@modifies buf, fileSystem @*/; + /*@globals fileSystem, internalState @*/ + /*@modifies buf, fileSystem, internalState @*/; extern void ckfprintf(FILE *f, const char *fmt, ...) /*@globals fileSystem @*/ /*@modifies f, fileSystem @*/; @@ -234,10 +232,19 @@ extern uint32_t signextend(struct magic *m, uint32_t v) /*@globals fileSystem @*/ /*@modifies fileSystem @*/; extern void tryelf(int fd, unsigned char *buf, int nbytes) - /*@globals fileSystem @*/ - /*@modifies fileSystem @*/; + /*@globals fileSystem, internalState @*/ + /*@modifies fileSystem, internalState @*/; extern int pipe2file(int fd, void *startbuf, size_t nbytes) - /*@globals errno, fileSystem @*/ - /*@modifies errno, fileSystem @*/; + /*@globals errno, fileSystem, internalState @*/ + /*@modifies errno, fileSystem, internalState @*/; + +#if defined(__LCLINT__) +#define FILE_RCSID(id) +#else +#define FILE_RCSID(id) \ +static inline const char *rcsid(const char *p) { \ + return rcsid(p = id); \ +} +#endif #endif /* __file_h__ */ diff --git a/file/names.h b/file/names.h index 2acf5db59..1da9f49b7 100644 --- a/file/names.h +++ b/file/names.h @@ -34,7 +34,7 @@ #define L_BCPL 12 /* BCPL */ #define L_M4 13 /* M4 */ -/*@unchecked@*/ /*@observer@*/ +/*@unchecked@*/ /*@unused@*/ /*@observer@*/ static const struct { /*@observer@*/ /*@null@*/ char *human; @@ -95,7 +95,7 @@ static const struct { * as Java, as it comes after "the" and "The". Perhaps we need a fancier * heuristic to identify Java? */ -/*@unchecked@*/ /*@observer@*/ +/*@unchecked@*/ /*@unused@*/ /*@observer@*/ static struct names { /*@observer@*/ /*@null@*/ const char *name; diff --git a/file/print.c b/file/print.c index 891a8504a..df133fe7f 100644 --- a/file/print.c +++ b/file/print.c @@ -172,7 +172,7 @@ error(const char *f, ...) (void) fprintf(stderr, "%s: ", progname); (void) vfprintf(stderr, f, va); va_end(va); - exit(1); + exit(EXIT_FAILURE); } /*VARARGS*/ @@ -190,7 +190,7 @@ magwarn(const char *f, ...) progname, magicfile, lineno); (void) vfprintf(stderr, f, va); va_end(va); - fputc('\n', stderr); + (void) fputc('\n', stderr); } @@ -224,8 +224,10 @@ fmttime(long v, int local) pp = asctime(tm); } +/*@-modobserver@*/ if ((rt = strchr(pp, '\n')) != NULL) *rt = '\0'; +/*@=modobserver@*/ return pp; } #endif diff --git a/file/softmagic.c b/file/softmagic.c index 2f8923b08..fd66ae9c1 100644 --- a/file/softmagic.c +++ b/file/softmagic.c @@ -37,13 +37,15 @@ FILE_RCSID("@(#)Id: softmagic.c,v 1.51 2002/07/03 18:26:38 christos Exp ") #endif /* lint */ +/*@-redecl@*/ /*@unchecked@*/ extern int kflag; +/*@=redecl@*/ -static int match(struct magic *magic, uint32_t nmagic, +static int match(struct magic *m, uint32_t nmagic, unsigned char *s, int nbytes) /*@globals fileSystem @*/ - /*@modifies *magic, s, fileSystem @*/; + /*@modifies m, s, fileSystem @*/; static int mget(union VALUETYPE *p, unsigned char *s, struct magic *m, int nbytes) /*@globals fileSystem @*/ @@ -107,7 +109,7 @@ softmagic(unsigned char *buf, int nbytes) * so that higher-level continuations are processed. */ static int -match(struct magic *magic, uint32_t nmagic, unsigned char *s, int nbytes) +match(struct magic *m, uint32_t nmagic, unsigned char *s, int nbytes) { int magindex = 0; int cont_level = 0; @@ -126,14 +128,14 @@ match(struct magic *magic, uint32_t nmagic, unsigned char *s, int nbytes) for (magindex = 0; magindex < nmagic; magindex++) { /* if main entry matches, print it... */ - if (!mget(&p, s, &magic[magindex], nbytes) || - !mcheck(&p, &magic[magindex])) { + if (!mget(&p, s, &m[magindex], nbytes) || + !mcheck(&p, &m[magindex])) { /* * main entry didn't match, * flush its continuations */ while (magindex < nmagic && - magic[magindex + 1].cont_level != 0) + m[magindex + 1].cont_level != 0) magindex++; continue; } @@ -143,35 +145,35 @@ match(struct magic *magic, uint32_t nmagic, unsigned char *s, int nbytes) printf("\n- "); } - tmpoff[cont_level] = mprint(&p, &magic[magindex]); + tmpoff[cont_level] = mprint(&p, &m[magindex]); /* * If we printed something, we'll need to print * a blank before we print something else. */ - if (magic[magindex].desc[0]) + if (m[magindex].desc[0]) need_separator = 1; /* and any continuations that match */ if (++cont_level >= tmplen) if ((tmpoff = (int32_t *) realloc(tmpoff, tmplen += 20)) == NULL) error("out of memory\n"); - while (magic[magindex+1].cont_level != 0 && + while (m[magindex+1].cont_level != 0 && ++magindex < nmagic) { - if (cont_level >= magic[magindex].cont_level) { - if (cont_level > magic[magindex].cont_level) { + if (cont_level >= m[magindex].cont_level) { + if (cont_level > m[magindex].cont_level) { /* * We're at the end of the level * "cont_level" continuations. */ - cont_level = magic[magindex].cont_level; + cont_level = m[magindex].cont_level; } - if (magic[magindex].flag & OFFADD) { - oldoff=magic[magindex].offset; - magic[magindex].offset += + if (m[magindex].flag & OFFADD) { + oldoff=m[magindex].offset; + m[magindex].offset += tmpoff[cont_level-1]; } - if (mget(&p, s, &magic[magindex], nbytes) && - mcheck(&p, &magic[magindex])) { + if (mget(&p, s, &m[magindex], nbytes) && + mcheck(&p, &m[magindex])) { /* * This continuation matched. * Print its message, with @@ -181,15 +183,15 @@ match(struct magic *magic, uint32_t nmagic, unsigned char *s, int nbytes) */ /* space if previous printed */ if (need_separator - && (magic[magindex].nospflag == 0) - && (magic[magindex].desc[0] != '\0') + && (m[magindex].nospflag == 0) + && (m[magindex].desc[0] != '\0') ) { (void) putchar(' '); need_separator = 0; } tmpoff[cont_level] = - mprint(&p, &magic[magindex]); - if (magic[magindex].desc[0]) + mprint(&p, &m[magindex]); + if (m[magindex].desc[0]) need_separator = 1; /* @@ -203,8 +205,8 @@ match(struct magic *magic, uint32_t nmagic, unsigned char *s, int nbytes) tmplen += 20)) == NULL) error("out of memory\n"); } - if (magic[magindex].flag & OFFADD) { - magic[magindex].offset = oldoff; + if (m[magindex].flag & OFFADD) { + m[magindex].offset = oldoff; } } } @@ -256,7 +258,7 @@ mprint(union VALUETYPE *p, struct magic *m) else { if (*m->value.s == '\0') { char *cp = strchr(p->s,'\n'); - if (cp) + if (cp != NULL) *cp = '\0'; } (void) printf(m->desc, p->s); @@ -576,13 +578,16 @@ mget(union VALUETYPE *p, unsigned char *s, struct magic *m, int nbytes) { int32_t offset = m->offset; +/*@-branchstate@*/ if (m->type == REGEX) { /* * offset is interpreted as last line to search, * (starting at 1), not as bytes-from start-of-file */ char *last = NULL; +/*@-temptrans@*/ p->buf = s; +/*@=temptrans@*/ for (; offset && (s = strchr(s, '\n')) != NULL; offset--, s++) last = s; if (last != NULL) @@ -599,6 +604,7 @@ mget(union VALUETYPE *p, unsigned char *s, struct magic *m, int nbytes) if (have > 0) memcpy(p, s + offset, have); } +/*@=branchstate@*/ if (debug) { mdebug(offset, (char *) p, sizeof(union VALUETYPE)); diff --git a/file/tar.h b/file/tar.h index 6def803b4..b8d7c9345 100644 --- a/file/tar.h +++ b/file/tar.h @@ -8,6 +8,9 @@ * Id: tar.h,v 1.5 1999/01/13 15:44:10 christos Exp # checkin only */ +#ifndef __tar_h__ +#define __tar_h__ + /* * Kludge for handling systems that can't cope with multiple * external definitions of a variable. In ONE routine (tar.c), @@ -79,6 +82,7 @@ union record { #define EX_SYSTEM 4 /* system gave unexpected error */ +#if 0 /* * Global variables */ @@ -111,6 +115,7 @@ TAR_EXTERN char f_namefile; /* -T */ TAR_EXTERN char f_verbose; /* -v */ TAR_EXTERN char f_extract; /* -x */ TAR_EXTERN char f_compress; /* -z */ +#endif /* * We now default to Unix Standard format rather than 4.2BSD tar format. @@ -134,11 +139,13 @@ struct name { char name[NAMSIZ+1]; }; +#if 0 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 */ +#endif /* * @@ -158,6 +165,7 @@ struct link { char name[NAMSIZ+1]; }; +#if 0 TAR_EXTERN struct link *linklist; /* Points to first link in list */ @@ -165,4 +173,6 @@ TAR_EXTERN struct link *linklist; /* Points to first link in list */ * Error recovery stuff */ TAR_EXTERN char read_error_flag; +#endif +#endif /* __tar_h__ */ |