From e5a9674ee310e6c36d253c4509221331af77acf4 Mon Sep 17 00:00:00 2001 From: jbj Date: Tue, 3 Aug 2004 06:01:33 +0000 Subject: [PATCH] Splint fiddles. CVS patchset: 7386 CVS date: 2004/08/03 06:01:33 --- zlib/.splintrc | 31 ++++++++----------------------- zlib/crc32.h | 1 + zlib/deflate.c | 2 ++ zlib/deflate.h | 9 ++++++++- zlib/gzio.c | 8 ++++++-- zlib/inflate.h | 3 +++ zlib/trees.c | 16 ++++++++++++++++ zlib/zlib.h | 15 +++++++++++---- zlib/zutil.h | 6 ++++-- 9 files changed, 59 insertions(+), 32 deletions(-) diff --git a/zlib/.splintrc b/zlib/.splintrc index 89f90ae..8a3d3f4 100644 --- a/zlib/.splintrc +++ b/zlib/.splintrc @@ -12,43 +12,28 @@ +strict # lclint level # --- in progress --globs -infloops # 1 --nullassign # 1 --staticinittrans # 5 --abstract # 4 -aliasunique # 2 --assignexpose -branchstate -bufferoverflowhigh -castfcnptr # 6 --compdef # 16 --compmempass # 37 +-compdef # 20 +-compmempass # 39 -evalorder # 2 --globstate # 1 --mods # 5 -noeffectuncon # 10 -nullderef # 9 --nullpass # 24 +-nullpass # 2 -nullptrarith # 4 --nullret # 11 --protoparammatch # 22 +-protoparammatch # 4 -redef # 4 --retalias # 4 -retvalint # painful -sizeoftype # 106 -type # 3 --usereleased # 38 - --dependenttrans # 2 --immediatetrans --kepttrans # 8 --observertrans --readonlytrans --statictrans --temptrans # 7 --unqualifiedtrans # 10 +-usereleased # 35 + +-statictrans # 4 +-temptrans # 6 -casebreak -looploopbreak diff --git a/zlib/crc32.h b/zlib/crc32.h index 8053b61..f64ecf2 100644 --- a/zlib/crc32.h +++ b/zlib/crc32.h @@ -2,6 +2,7 @@ * Generated automatically by crc32.c */ +/*@unchecked@*/ /*@observer@*/ local const unsigned long FAR crc_table[TBLS][256] = { { diff --git a/zlib/deflate.c b/zlib/deflate.c index 3158197..c1dda62 100644 --- a/zlib/deflate.c +++ b/zlib/deflate.c @@ -51,6 +51,7 @@ #include "deflate.h" +/*@unchecked@*/ /*@observer@*/ const char deflate_copyright[] = " deflate 1.2.1.1 Copyright 1995-2003 Jean-loup Gailly "; /* @@ -142,6 +143,7 @@ typedef struct config_s { compress_func func; } config; +/*@unchecked@*/ /*@observer@*/ #ifdef FASTEST local const config configuration_table[2] = { /* good lazy nice chain */ diff --git a/zlib/deflate.h b/zlib/deflate.h index 2aafca6..8c8b7cb 100644 --- a/zlib/deflate.h +++ b/zlib/deflate.h @@ -74,8 +74,10 @@ typedef struct ct_data_s { typedef struct static_tree_desc_s static_tree_desc; typedef struct tree_desc_s { +/*@shared@*/ ct_data *dyn_tree; /* the dynamic tree */ int max_code; /* largest code with non zero frequency */ +/*@shared@*/ static_tree_desc *stat_desc; /* the corresponding static tree */ } FAR tree_desc; @@ -90,8 +92,10 @@ typedef unsigned IPos; typedef struct internal_state { z_streamp strm; /* pointer back to this zlib stream */ int status; /* as the name implies */ +/*@owned@*/ Bytef *pending_buf; /* output still pending */ ulg pending_buf_size; /* size of pending_buf */ +/*@dependent@*/ Bytef *pending_out; /* next pending byte to output to the stream */ int pending; /* nb of bytes in the pending buffer */ int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ @@ -206,6 +210,7 @@ typedef struct internal_state { /* Depth of each subtree used as tie breaker for trees of equal frequency */ +/*@kept@*/ uchf *l_buf; /* buffer for literals or lengths */ uInt lit_bufsize; @@ -284,7 +289,7 @@ void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len, /*@modifies *s @*/; void _tr_align OF((deflate_state *s)) /*@modifies *s @*/; -void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len, +void _tr_stored_block OF((deflate_state *s, /*@null@*/ charf *buf, ulg stored_len, int eof)) /*@modifies *s @*/; @@ -302,7 +307,9 @@ void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len, extern uch _length_code[]; extern uch _dist_code[]; #else +/*@unchecked@*/ /*@observer@*/ extern const uch _length_code[]; +/*@unchecked@*/ /*@observer@*/ extern const uch _dist_code[]; #endif diff --git a/zlib/gzio.c b/zlib/gzio.c index 0b85cb5..28d0e3a 100644 --- a/zlib/gzio.c +++ b/zlib/gzio.c @@ -7,6 +7,8 @@ /* @(#) $Id$ */ +/*@access FILE @*/ + #include #include "zutil.h" @@ -45,6 +47,7 @@ extern void free OF((voidpf ptr)) #define ALLOC(size) malloc(size) #define TRYFREE(p) {if (p) free(p);} +/*@unchecked@*/ /*@observer@*/ static int const gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */ /* gzip flag byte */ @@ -59,7 +62,7 @@ typedef struct gz_stream { z_stream stream; int z_err; /* error code for last stream operation */ int z_eof; /* set if end of input file */ -/*@relnull@*/ +/*@relnull@*/ /*@dependent@*/ FILE *file; /* .gz file */ /*@relnull@*/ Byte *inbuf; /* input buffer */ @@ -80,6 +83,7 @@ typedef struct gz_stream { } gz_stream; +/*@null@*/ local gzFile gz_open OF((const char *path, const char *mode, int fd)) /*@globals errno, fileSystem, internalState @*/ /*@modifies errno, fileSystem, internalState @*/; @@ -92,7 +96,7 @@ local int get_byte OF((gz_stream *s)) local void check_header OF((gz_stream *s)) /*@globals errno, fileSystem @*/ /*@modifies s, errno, fileSystem @*/; -local int destroy OF((gz_stream *s)) +local int destroy OF((/*@only@*/ gz_stream *s)) /*@globals fileSystem @*/ /*@modifies s, fileSystem @*/; local void putLong OF((FILE *file, uLong x)) diff --git a/zlib/inflate.h b/zlib/inflate.h index 9a12c8f..621bddb 100644 --- a/zlib/inflate.h +++ b/zlib/inflate.h @@ -101,7 +101,9 @@ struct inflate_state { /* for table and code decoding */ unsigned extra; /* extra bits needed */ /* fixed and dynamic code tables */ +/*@shared@*/ code const FAR *lencode; /* starting table for length/literal codes */ +/*@shared@*/ code const FAR *distcode; /* starting table for distance codes */ unsigned lenbits; /* index bits for lencode */ unsigned distbits; /* index bits for distcode */ @@ -110,6 +112,7 @@ struct inflate_state { unsigned nlen; /* number of length code lengths */ unsigned ndist; /* number of distance code lengths */ unsigned have; /* number of code lengths in lens[] */ +/*@shared@*/ code FAR *next; /* next available space in codes[] */ unsigned short lens[320]; /* temporary storage for code lengths */ unsigned short work[288]; /* work area for code table building */ diff --git a/zlib/trees.c b/zlib/trees.c index 4fa7db6..7405863 100644 --- a/zlib/trees.c +++ b/zlib/trees.c @@ -58,15 +58,19 @@ #define REPZ_11_138 18 /* repeat a zero length 11-138 times (7 bits of repeat count) */ +/*@unchecked@*/ /*@observer@*/ local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */ = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0}; +/*@unchecked@*/ /*@observer@*/ local const int extra_dbits[D_CODES] /* extra bits for each distance code */ = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; +/*@unchecked@*/ /*@observer@*/ local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */ = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7}; +/*@unchecked@*/ /*@observer@*/ local const uch bl_order[BL_CODES] = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; /* The lengths of the bit length codes are sent in order of decreasing @@ -87,6 +91,7 @@ local const uch bl_order[BL_CODES] #if defined(GEN_TREES_H) || !defined(STDC) /* non ANSI compilers may not accept trees.h */ +/*@unchecked@*/ local ct_data static_ltree[L_CODES+2]; /* The static literal tree. Since the bit lengths are imposed, there is no * need for the L_CODES extra codes used during heap construction. However @@ -94,6 +99,7 @@ local ct_data static_ltree[L_CODES+2]; * below). */ +/*@unchecked@*/ local ct_data static_dtree[D_CODES]; /* The static distance tree. (Actually a trivial tree since all codes use * 5 bits.) @@ -108,9 +114,11 @@ uch _dist_code[DIST_CODE_LEN]; uch _length_code[MAX_MATCH-MIN_MATCH+1]; /* length code for each normalized match length (0 == MIN_MATCH) */ +/*@unchecked@*/ local int base_length[LENGTH_CODES]; /* First normalized length for each code (0 = MIN_MATCH) */ +/*@unchecked@*/ local int base_dist[D_CODES]; /* First normalized distance for each code (0 = distance of 1) */ @@ -119,19 +127,24 @@ local int base_dist[D_CODES]; #endif /* GEN_TREES_H */ struct static_tree_desc_s { +/*@observer@*/ /*@relnull@*/ const ct_data *static_tree; /* static tree or NULL */ +/*@observer@*/ const intf *extra_bits; /* extra bits for each code or NULL */ int extra_base; /* base index for extra_bits */ int elems; /* max number of elements in the tree */ int max_length; /* max bit length for the codes */ }; +/*@unchecked@*/ local static_tree_desc static_l_desc = {static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS}; +/*@unchecked@*/ local static_tree_desc static_d_desc = {static_dtree, extra_dbits, 0, D_CODES, MAX_BITS}; +/*@unchecked@*/ local static_tree_desc static_bl_desc = {(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; @@ -881,6 +894,7 @@ void _tr_stored_block(deflate_state *s, charf *buf, ulg stored_len, int eof) * on one bit only. */ void _tr_align(deflate_state *s) + /*@globals static_ltree @*/ { send_bits(s, STATIC_TREES<<1, 3); send_code(s, END_BLOCK, static_ltree); @@ -909,6 +923,7 @@ void _tr_align(deflate_state *s) * trees or store, and output the encoded block to the zip file. */ void _tr_flush_block(deflate_state *s, charf *buf, ulg stored_len, int eof) + /*@globals static_dtree, static_ltree @*/ { ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ int max_blindex = 0; /* index of last bit length code of non zero freq */ @@ -1052,6 +1067,7 @@ int _tr_tally (deflate_state *s, unsigned dist, unsigned lc) * Send the block data compressed using the given Huffman trees */ local void compress_block(deflate_state *s, ct_data *ltree, ct_data *dtree) + /*@globals base_dist, base_length @*/ { unsigned dist; /* distance of matched string */ int lc; /* match length or unmatched char (if dist == 0) */ diff --git a/zlib/zlib.h b/zlib/zlib.h index 3dc8130..a09ed7e 100644 --- a/zlib/zlib.h +++ b/zlib/zlib.h @@ -94,7 +94,7 @@ typedef struct z_stream_s { uInt avail_out; /* remaining free space at next_out */ uLong total_out; /* total nb of bytes output so far */ -/*@relnull@*/ +/*@relnull@*/ /*@observer@*/ char *msg; /* last error message, NULL if no error */ /*@relnull@*/ struct internal_state FAR *state; /* not visible by applications */ @@ -195,6 +195,7 @@ typedef z_stream FAR *z_streamp; /* basic functions */ +/*@observer@*/ ZEXTERN const char * ZEXPORT zlibVersion OF((void)) /*@*/; /* The application can compare zlibVersion and ZLIB_VERSION for consistency. @@ -968,6 +969,7 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, typedef voidp gzFile; +/*@null@*/ ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)) /*@globals fileSystem, internalState @*/ /*@modifies fileSystem, internalState @*/; @@ -987,6 +989,7 @@ ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)) can be checked to distinguish the two cases (if errno is zero, the zlib error is Z_MEM_ERROR). */ +/*@null@*/ ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)) /*@globals fileSystem, internalState @*/ /*@modifies fileSystem, internalState @*/; @@ -1056,6 +1059,7 @@ ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)) gzputs returns the number of characters written, or -1 in case of error. */ +/*@null@*/ ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)) /*@globals fileSystem @*/ /*@modifies file, buf, fileSystem @*/; @@ -1153,7 +1157,7 @@ ZEXTERN int ZEXPORT gzeof OF((gzFile file)) input stream, otherwise zero. */ -ZEXTERN int ZEXPORT gzclose OF((gzFile file)) +ZEXTERN int ZEXPORT gzclose OF((/*@only@*/ gzFile file)) /*@globals fileSystem @*/ /*@modifies file, fileSystem @*/; /* @@ -1162,6 +1166,7 @@ ZEXTERN int ZEXPORT gzclose OF((gzFile file)) error number (see function gzerror below). */ +/*@observer@*/ ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)) /*@modifies *errnum @*/; /* @@ -1188,7 +1193,7 @@ ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)) compression library. */ -ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)) +ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, /*@null@*/ const Bytef *buf, uInt len)) /*@*/; /* @@ -1206,7 +1211,7 @@ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)) if (adler != original_adler) error(); */ -ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)) +ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, /*@null@*/ const Bytef *buf, uInt len)) /*@*/; /* Update a running crc with the bytes buf[0..len-1] and return the updated @@ -1268,10 +1273,12 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_stream FAR *strm, int windowBits, struct internal_state {int dummy;}; /* hack for buggy compilers */ #endif +/*@observer@*/ ZEXTERN const char * ZEXPORT zError OF((int err)) /*@*/; ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)) /*@modifies z @*/; +/*@observer@*/ ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)) /*@*/; diff --git a/zlib/zutil.h b/zlib/zutil.h index 904e032..96f5389 100644 --- a/zlib/zutil.h +++ b/zlib/zutil.h @@ -38,13 +38,14 @@ typedef unsigned short ush; typedef ush FAR ushf; typedef unsigned long ulg; +/*@unchecked@*/ /*@observer@*/ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ /* (size given to avoid silly warnings with Visual C++) */ #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] #define ERR_RETURN(strm,err) \ - return (strm->msg = (char*)ERR_MSG(err), (err)) + return /*@-mods@*/ (strm->msg = (char*)ERR_MSG(err), (err)) /*@=mods@*/ /* To be used only when the state is known to be valid */ /* common constants */ @@ -249,9 +250,10 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ #endif +/*@null@*/ voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)) /*@*/; -void zcfree OF((voidpf opaque, voidpf ptr)) +void zcfree OF((voidpf opaque, /*@only@*/ voidpf ptr)) /*@modifies ptr @*/; #define ZALLOC(strm, items, size) \ -- 2.7.4