diff options
-rw-r--r-- | build/Makefile.am | 12 | ||||
-rw-r--r-- | build/files.c | 39 | ||||
-rw-r--r-- | build/rpmbuild.h | 16 | ||||
-rwxr-xr-x | db3/configure | 2 | ||||
-rw-r--r-- | lib/psm.c | 106 | ||||
-rw-r--r-- | rpmio/rpmlog.c | 2 | ||||
-rw-r--r-- | zlib/gzio.c | 4 | ||||
-rw-r--r-- | zlib/zlib.h | 145 | ||||
-rw-r--r-- | zlib/zutil.h | 20 |
9 files changed, 213 insertions, 133 deletions
diff --git a/build/Makefile.am b/build/Makefile.am index 98cfb6053..c106ee735 100644 --- a/build/Makefile.am +++ b/build/Makefile.am @@ -12,6 +12,18 @@ INCLUDES = -I. \ LIBS = +EXTRA_PROGRAMS = tfr +tfr_SOURCES = tfr.c +tfr_LDFLAGS = -all-static +tfr_LDADD = \ + $(top_builddir)/build/librpmbuild.la \ + $(top_builddir)/lib/librpm.la \ + $(top_builddir)/rpmdb/librpmdb.la \ + $(top_builddir)/rpmio/librpmio.la \ + $(top_builddir)/popt/libpopt.la \ + @WITH_LIBELF_LIB@ \ + @INTLLIBS@ + pkgincdir = $(pkgincludedir) pkginc_HEADERS = rpmbuild.h rpmspec.h noinst_HEADERS = buildio.h diff --git a/build/files.c b/build/files.c index 06fecb1f9..ad0a64085 100644 --- a/build/files.c +++ b/build/files.c @@ -1515,7 +1515,13 @@ static /*@null@*/ FileListRec freeFileList(/*@only@*/ FileListRec fileList, /* forward ref */ static int recurseDir(FileList fl, const char * diskURL) - /*@*/; + /*@globals check_fileList, check_fileListLen, rpmGlobalMacroContext, + fileSystem, internalState @*/ + /*@modifies *fl, fl->processingFailed, + fl->fileList, fl->fileListRecsAlloced, fl->fileListRecsUsed, + fl->totalFileSize, fl->fileCount, fl->inFtw, fl->isDir, + check_fileList, check_fileListLen, rpmGlobalMacroContext, + fileSystem, internalState @*/; /** * Add a file to the package manifest. @@ -1531,9 +1537,9 @@ static int addFile(FileList fl, const char * diskURL, fileSystem, internalState @*/ /*@modifies *statp, *fl, fl->processingFailed, fl->fileList, fl->fileListRecsAlloced, fl->fileListRecsUsed, - fl->totalFileSize, fl->fileCount, fl->inFtw, fl->isDir, + fl->totalFileSize, fl->fileCount, check_fileList, check_fileListLen, rpmGlobalMacroContext, - fileSystem, internalState @*/ + fileSystem, internalState @*/ { const char *fileURL = diskURL; struct stat statbuf; @@ -1609,7 +1615,9 @@ static int addFile(FileList fl, const char * diskURL, } if ((! fl->isDir) && S_ISDIR(statp->st_mode)) { +/*@-nullstate@*/ /* FIX: fl->buildRootURL may be NULL */ return recurseDir(fl, diskURL); +/*@=nullstate@*/ } fileMode = statp->st_mode; @@ -1735,7 +1743,6 @@ static int addFile(FileList fl, const char * diskURL, * @return 0 on success */ static int recurseDir(FileList fl, const char * diskURL) - /*@*/ { char * ftsSet[2]; FTS * ftsp; @@ -1757,11 +1764,11 @@ static int recurseDir(FileList fl, const char * diskURL) case FTS_SLNONE: /* symbolic link without target */ case FTS_DEFAULT: /* none of the above */ rc = addFile(fl, fts->fts_accpath, fts->fts_statp); - break; + /*@switchbreak@*/ break; case FTS_DOT: /* dot or dot-dot */ case FTS_DP: /* postorder directory */ rc = 0; - break; + /*@switchbreak@*/ break; case FTS_NS: /* stat(2) failed */ case FTS_DNR: /* unreadable directory */ case FTS_ERR: /* error; errno is set */ @@ -1771,7 +1778,7 @@ static int recurseDir(FileList fl, const char * diskURL) case FTS_W: /* whiteout object */ default: rc = RPMERR_BADSPEC; - break; + /*@switchbreak@*/ break; } if (rc) break; @@ -1791,13 +1798,12 @@ static int recurseDir(FileList fl, const char * diskURL) * @param fileURL * @return 0 on success */ -/*@-boundswrite@*/ static int processBinaryFile(/*@unused@*/ Package pkg, FileList fl, const char * fileURL) /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/ /*@modifies *fl, fl->processingFailed, fl->fileList, fl->fileListRecsAlloced, fl->fileListRecsUsed, - fl->totalFileSize, fl->fileCount, fl->inFtw, fl->isDir, + fl->totalFileSize, fl->fileCount, rpmGlobalMacroContext, fileSystem, internalState @*/ { int doGlob; @@ -1832,6 +1838,7 @@ static int processBinaryFile(/*@unused@*/ Package pkg, FileList fl, int argc = 0; int i; + /* XXX for %dev marker in file manifest only */ if (fl->noGlob) { rpmError(RPMERR_BADSPEC, _("Glob not permitted: %s\n"), diskURL); @@ -1844,13 +1851,16 @@ static int processBinaryFile(/*@unused@*/ Package pkg, FileList fl, if (rc == 0 && argc >= 1 && !myGlobPatternP(argv[0])) { for (i = 0; i < argc; i++) { rc = addFile(fl, argv[i], NULL); +/*@-boundswrite@*/ argv[i] = _free(argv[i]); +/*@=boundswrite@*/ } argv = _free(argv); } else { rpmError(RPMERR_BADSPEC, _("File not found by glob: %s\n"), diskURL); rc = 1; + goto exit; } /*@=branchstate@*/ } else { @@ -1859,11 +1869,12 @@ static int processBinaryFile(/*@unused@*/ Package pkg, FileList fl, exit: diskURL = _free(diskURL); - if (rc) + if (rc) { fl->processingFailed = 1; + rc = RPMERR_BADSPEC; + } return rc; } -/*@=boundswrite@*/ /** */ @@ -2343,10 +2354,8 @@ int processSourceFiles(Spec spec) return fl.processingFailed; } -/** - */ /*@-boundswrite@*/ -static StringBuf getOutputFrom(char * dir, char * argv[], +StringBuf getOutputFrom(const char * dir, char * argv[], const char * writePtr, int writeBytesLeft, int failNonZero) /*@globals fileSystem, internalState@*/ @@ -2433,7 +2442,7 @@ top: /* Write any data to program */ if (toProg[1] >= 0 && FD_ISSET(toProg[1], &obits)) { - if (writeBytesLeft) { + if (writePtr && writeBytesLeft > 0) { if ((nbw = write(toProg[1], writePtr, (1024<writeBytesLeft) ? 1024 : writeBytesLeft)) < 0) { if (errno != EAGAIN) { diff --git a/build/rpmbuild.h b/build/rpmbuild.h index 798583675..9ce58f61a 100644 --- a/build/rpmbuild.h +++ b/build/rpmbuild.h @@ -449,6 +449,22 @@ int processSourceFiles(Spec spec) rpmGlobalMacroContext, fileSystem, internalState @*/; /** \ingroup rpmbuild + * Return output from helper script. + * @param dir directory to run in (or NULL) + * @param argv program and arguments to run + * @param writePtr bytes to feed to script on stdin (or NULL) + * @param writeBytesLeft no. of bytes to feed to script on stdin + * @param failNonZero is script failure an error? + * @return buffered stdout from script, NULL on error + */ +/*@null@*/ +StringBuf getOutputFrom(/*@null@*/ const char * dir, char * argv[], + const char * writePtr, int writeBytesLeft, + int failNonZero) + /*@globals fileSystem, internalState@*/ + /*@modifies fileSystem, internalState@*/; + +/** \ingroup rpmbuild * Parse spec file into spec control structure. * @retval specp spec file control structure * @param specFile diff --git a/db3/configure b/db3/configure index 3cd0d9a65..3c2f6f8ba 100755 --- a/db3/configure +++ b/db3/configure @@ -29,7 +29,7 @@ cat db.h.orig | sed \ /*@=incondefs@*/' \ -e '/^#define db_create/i\ /*@-declundef -noparams -fcnuse@*/' \ - -e '/^#define db_xa_switch/a\ + -e '/^int txn_commit __P((/a\ /*@=declundef =noparams =fcnuse =fielduse =enummemuse =typeuse @*/' > db.h # Generate manifest for rpmdb. @@ -695,15 +695,19 @@ static void handler(int signum) (void) sigaddset(&caught, signum); switch (signum) { case SIGCHLD: - { int status = 0; - pid_t reaped = waitpid(0, &status, WNOHANG); - int i; + while (1) { + int status = 0; + pid_t reaped = waitpid(0, &status, WNOHANG); + int i; + + if (reaped <= 0) + /*@innerbreak@*/ break; - if (psmtbl.psms) - for (i = 0; i < psmtbl.npsms; i++) { - rpmpsm psm = psmtbl.psms[i]; - if (psm->child != reaped) - /*@innercontinue@*/ continue; + if (psmtbl.psms) + for (i = 0; i < psmtbl.npsms; i++) { + rpmpsm psm = psmtbl.psms[i]; + if (psm->child != reaped) + /*@innercontinue@*/ continue; #if _PSM_DEBUG /*@-modfilesys@*/ @@ -712,11 +716,12 @@ fprintf(stderr, " Reap: %p[%d:%d:%d] = %p child %d\n", psmtbl.psms, i, psmt /*@=modfilesys@*/ #endif - psm->reaped = reaped; - psm->status = status; - /*@innerbreak@*/ break; + psm->reaped = reaped; + psm->status = status; + /*@innerbreak@*/ break; + } } - } /*@switchbreak@*/ break; + /*@switchbreak@*/ break; default: /*@switchbreak@*/ break; } @@ -782,26 +787,6 @@ fprintf(stderr, " Disable: %p[0:%d:%d] active %d\n", psmtbl.psms, psmtbl.npsms } /** - * Fork a new process. - * @param psm package state machine data - * @return fork(2) pid - */ -static pid_t psmFork(rpmpsm psm) - /*@globals fileSystem, internalState @*/ - /*@modifies fileSystem, internalState @*/ -{ - pid_t pid; - - if ((pid = fork()) != 0) { -/*@-modfilesys@*/ -if (_psm_debug) -fprintf(stderr, " Fork: %p[%d:%d:%d] = %p child %d\n", psmtbl.psms, 0, psmtbl.npsms, psmtbl.nalloced, psm, pid); -/*@=modfilesys@*/ - } - return pid; -} - -/** * Register a child reaper, then fork a child. * @param psm package state machine data * @return fork(2) pid @@ -835,7 +820,6 @@ static pid_t psmRegisterFork(rpmpsm psm) } empty = psmtbl.npsms++; } - psm->reaped = 0; if (psmtbl.psms) /* XXX can't happen */ psmtbl.psms[empty] = rpmpsmLink(psm, "psmRegister"); /*@-modfilesys@*/ @@ -844,15 +828,24 @@ fprintf(stderr, " Register: %p[%d:%d:%d] = %p\n", psmtbl.psms, empty, psmtbl.np /*@=modfilesys@*/ (void) enableSignal(SIGCHLD); + + psm->reaped = 0; + if ((psm->child = fork()) != 0) { +/*@-modfilesys@*/ +if (_psm_debug) +fprintf(stderr, " Fork: %p[%d:%d:%d] = %p child %d\n", psmtbl.psms, 0, psmtbl.npsms, psmtbl.nalloced, psm, pid); +/*@=modfilesys@*/ + } + (void) sigprocmask(SIG_SETMASK, &oldMask, NULL); - return psmFork(psm); + return psm->child; } /** * Unregister a child reaper. */ -static int psmUnregister(rpmpsm psm, pid_t child) +static int psmWaitUnregister(rpmpsm psm, pid_t child) /*@globals psmtbl, fileSystem, internalState @*/ /*@modifies psmtbl, fileSystem, internalState @*/ { @@ -862,6 +855,16 @@ static int psmUnregister(rpmpsm psm, pid_t child) (void) sigfillset(&newMask); /* block all signals */ (void) sigprocmask(SIG_BLOCK, &newMask, &oldMask); + /*@-infloops@*/ + while (psm->reaped != psm->child) + (void) pause(); + /*@=infloops@*/ + +/*@-modfilesys@*/ +if (_psm_debug) +fprintf(stderr, " Wait: %p[%d:%d:%d] = %p child %d\n", psmtbl.psms, 0, psmtbl.npsms, psmtbl.nalloced, psm, psm->child); +/*@=modfilesys@*/ + if (psmtbl.psms) for (i = 0; i < psmtbl.npsms; i++) { if (psmtbl.psms[i] == NULL) @@ -893,25 +896,6 @@ fprintf(stderr, "Unregister: %p[%d:%d:%d] = %p child %d\n", psmtbl.psms, i, psmt } /** - * Return reaped pid safely (i.e. with signals blocked). - * @param psm package state machine data - * @return - */ -static inline pid_t psmGetReaped(rpmpsm psm) - /*@globals fileSystem @*/ - /*@modifies fileSystem @*/ -{ - sigset_t newMask, oldMask; - pid_t reaped; - - (void) sigfillset(&newMask); /* block all signals */ - (void) sigprocmask(SIG_BLOCK, &newMask, &oldMask); - reaped = psm->reaped; - (void) sigprocmask(SIG_SETMASK, &oldMask, NULL); - return reaped; -} - -/** * Wait for child process to be reaped. * @param psm package state machine data * @return @@ -921,15 +905,7 @@ static pid_t psmWait(rpmpsm psm) /*@modifies psm, fileSystem, internalState @*/ { if (psm->reaper) { - /*@-infloops@*/ - while (psmGetReaped(psm) == 0) - (void) pause(); - /*@=infloops@*/ -/*@-modfilesys@*/ -if (_psm_debug) -fprintf(stderr, " Wait: %p[%d:%d:%d] = %p child %d\n", psmtbl.psms, 0, psmtbl.npsms, psmtbl.nalloced, psm, psm->child); -/*@=modfilesys@*/ - (void) psmUnregister(psm, psm->child); + (void) psmWaitUnregister(psm, psm->child); } else { do { psm->reaped = waitpid(psm->child, &psm->status, 0); @@ -997,7 +973,6 @@ static rpmRC runScript(rpmpsm psm, Header h, const char * sln, FD_t out; rpmRC rc = RPMRC_OK; const char *n, *v, *r; - pid_t pid; if (progArgv == NULL && script == NULL) return rc; @@ -1119,8 +1094,7 @@ static rpmRC runScript(rpmpsm psm, Header h, const char * sln, if (out == NULL) return RPMRC_FAIL; /* XXX can't happen */ /*@-branchstate@*/ - pid = psmRegisterFork(psm); - psm->child = pid; + (void) psmRegisterFork(psm); if (psm->child == 0) { const char * rootDir; int pipes[2]; diff --git a/rpmio/rpmlog.c b/rpmio/rpmlog.c index 934190be3..13abea8c6 100644 --- a/rpmio/rpmlog.c +++ b/rpmio/rpmlog.c @@ -179,7 +179,9 @@ static void vrpmlog (unsigned code, const char *fmt, va_list ap) else /* glibc 2.0 */ msgnb *= 2; msgbuf = xrealloc(msgbuf, msgnb); +/*@-mods@*/ va_end(apc); +/*@=mods@*/ } msgbuf[msgnb - 1] = '\0'; msg = msgbuf; diff --git a/zlib/gzio.c b/zlib/gzio.c index 3b42fdbf0..a52dcf17f 100644 --- a/zlib/gzio.c +++ b/zlib/gzio.c @@ -5,7 +5,7 @@ * Compile this file with -DNO_DEFLATE to avoid the compression code. */ -/* @(#) $Id$ */ +/* @(#) $Id: gzio.c,v 1.9 2002/03/17 15:46:23 jbj Exp $ */ #include <stdio.h> @@ -498,6 +498,7 @@ int ZEXPORT gzwrite (gzFile file, const voidp buf, unsigned len) s->stream.next_in = (Bytef*)buf; s->stream.avail_in = len; +/*@-infloops@*/ while (s->stream.avail_in != 0) { if (s->stream.avail_out == 0) { @@ -512,6 +513,7 @@ int ZEXPORT gzwrite (gzFile file, const voidp buf, unsigned len) s->z_err = deflate(&(s->stream), Z_NO_FLUSH); if (s->z_err != Z_OK) break; } +/*@=infloops@*/ s->crc = crc32(s->crc, (const Bytef *)buf, len); return (int)(len - s->stream.avail_in); diff --git a/zlib/zlib.h b/zlib/zlib.h index b7eb7008d..636ce3a09 100644 --- a/zlib/zlib.h +++ b/zlib/zlib.h @@ -61,8 +61,10 @@ extern "C" { crash even in case of corrupted input. */ -typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); -typedef void (*free_func) OF((voidpf opaque, voidpf address)); +typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)) + /*@*/; +typedef void (*free_func) OF((voidpf opaque, voidpf address)) + /*@*/; struct internal_state; @@ -75,6 +77,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 */ +/*@observer@*/ char *msg; /* last error message, NULL if no error */ struct internal_state FAR *state; /* not visible by applications */ @@ -87,7 +90,7 @@ typedef struct z_stream_s { uLong reserved; /* reserved for future use */ } z_stream; -typedef z_stream FAR *z_streamp; +typedef /*@abstract@*/ z_stream FAR *z_streamp; /* The application must update next_in and avail_in when avail_in has @@ -169,6 +172,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. If the first character differs, the library code actually used is @@ -199,7 +203,8 @@ ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); */ -ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); +ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)) + /*@modifies strm @*/; /* deflate compresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full. It may introduce some @@ -277,7 +282,8 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); */ -ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); +ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)) + /*@modifies strm @*/; /* All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any @@ -312,7 +318,8 @@ ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); */ -ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); +ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)) + /*@modifies strm @*/; /* inflate decompresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full. It may some @@ -381,7 +388,8 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); */ -ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); +ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)) + /*@modifies strm @*/; /* All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any @@ -444,7 +452,8 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, const Bytef *dictionary, - uInt dictLength)); + uInt dictLength)) + /*@modifies strm @*/; /* Initializes the compression dictionary from the given byte sequence without producing any compressed output. This function must be called @@ -479,7 +488,8 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, */ ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, - z_streamp source)); + z_streamp source)) + /*@modifies dest, source @*/; /* Sets the destination stream as a complete copy of the source stream. @@ -496,7 +506,8 @@ ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, destination. */ -ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); +ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)) + /*@modifies strm @*/; /* This function is equivalent to deflateEnd followed by deflateInit, but does not free and reallocate all the internal compression state. @@ -509,7 +520,8 @@ ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, int level, - int strategy)); + int strategy)) + /*@modifies strm @*/; /* Dynamically update the compression level and compression strategy. The interpretation of level and strategy is as in deflateInit2. This can be @@ -553,7 +565,8 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, const Bytef *dictionary, - uInt dictLength)); + uInt dictLength)) + /*@modifies strm @*/; /* Initializes the decompression dictionary from the given uncompressed byte sequence. This function must be called immediately after a call of inflate @@ -570,7 +583,8 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, inflate(). */ -ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); +ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)) + /*@modifies strm @*/; /* Skips invalid compressed data until a full flush point (see above the description of deflate with Z_FULL_FLUSH) can be found, or until all @@ -585,7 +599,8 @@ ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); until success or end of the input data. */ -ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); +ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)) + /*@modifies strm @*/; /* This function is equivalent to inflateEnd followed by inflateInit, but does not free and reallocate all the internal decompression state. @@ -607,7 +622,8 @@ ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); */ ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); + const Bytef *source, uLong sourceLen)) + /*@modifies *dest, *destLen @*/; /* Compresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total @@ -623,7 +639,8 @@ ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, - int level)); + int level)) + /*@modifies *dest, *destLen @*/; /* Compresses the source buffer into the destination buffer. The level parameter has the same meaning as in deflateInit. sourceLen is the byte @@ -637,7 +654,8 @@ ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, */ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); + const Bytef *source, uLong sourceLen)) + /*@modifies *dest, *destLen @*/; /* Decompresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total @@ -657,7 +675,9 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, typedef voidp gzFile; -ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); +ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)) + /*@globals fileSystem @*/ + /*@modifies fileSystem @*/; /* Opens a gzip (.gz) file for reading or writing. The mode parameter is as in fopen ("rb" or "wb") but can also include a compression level @@ -673,7 +693,9 @@ 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). */ -ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)) + /*@globals fileSystem @*/ + /*@modifies fileSystem @*/; /* gzdopen() associates a gzFile with the file descriptor fd. File descriptors are obtained from calls like open, dup, creat, pipe or @@ -686,7 +708,9 @@ ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); the (de)compression state. */ -ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); +ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)) + /*@globals fileSystem @*/ + /*@modifies file, fileSystem @*/; /* Dynamically update the compression level or strategy. See the description of deflateInit2 for the meaning of these parameters. @@ -694,7 +718,9 @@ ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); opened for writing. */ -ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)) + /*@globals errno, fileSystem @*/ + /*@modifies file, *buf, errno, fileSystem @*/; /* Reads the given number of uncompressed bytes from the compressed file. If the input file was not in gzip format, gzread copies the given number @@ -703,28 +729,36 @@ ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); end of file, -1 for error). */ ZEXTERN int ZEXPORT gzwrite OF((gzFile file, - const voidp buf, unsigned len)); + const voidp buf, unsigned len)) + /*@globals fileSystem @*/ + /*@modifies file, fileSystem @*/; /* Writes the given number of uncompressed bytes into the compressed file. gzwrite returns the number of uncompressed bytes actually written (0 in case of error). */ -ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); +ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)) + /*@globals fileSystem @*/ + /*@modifies file, fileSystem @*/; /* Converts, formats, and writes the args to the compressed file under control of the format string, as in fprintf. gzprintf returns the number of uncompressed bytes actually written (0 in case of error). */ -ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); +ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)) + /*@globals fileSystem @*/ + /*@modifies file, fileSystem @*/; /* Writes the given null-terminated string to the compressed file, excluding the terminating null character. gzputs returns the number of characters written, or -1 in case of error. */ -ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); +ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)) + /*@globals fileSystem @*/ + /*@modifies file, buf, fileSystem @*/; /* Reads bytes from the compressed file until len-1 characters are read, or a newline character is read and transferred to buf, or an end-of-file @@ -733,19 +767,25 @@ ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); gzgets returns buf, or Z_NULL in case of error. */ -ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)) + /*@globals fileSystem @*/ + /*@modifies file, fileSystem @*/; /* Writes c, converted to an unsigned char, into the compressed file. gzputc returns the value that was written, or -1 in case of error. */ -ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +ZEXTERN int ZEXPORT gzgetc OF((gzFile file)) + /*@globals fileSystem @*/ + /*@modifies file, fileSystem @*/; /* Reads one byte from the compressed file. gzgetc returns this byte or -1 in case of end of file or error. */ -ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)) + /*@globals fileSystem @*/ + /*@modifies file, fileSystem @*/; /* Flushes all pending output into the compressed file. The parameter flush is as in the deflate() function. The return value is the zlib @@ -756,7 +796,9 @@ ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); */ ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, - z_off_t offset, int whence)); + z_off_t offset, int whence)) + /*@globals fileSystem @*/ + /*@modifies file, fileSystem @*/; /* Sets the starting position for the next gzread or gzwrite on the given compressed file. The offset represents a number of bytes in the @@ -773,14 +815,18 @@ ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, would be before the current position. */ -ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); +ZEXTERN int ZEXPORT gzrewind OF((gzFile file)) + /*@globals fileSystem @*/ + /*@modifies file, fileSystem @*/; /* Rewinds the given file. This function is supported only for reading. gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) */ -ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); +ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)) + /*@globals fileSystem @*/ + /*@modifies file, fileSystem @*/; /* Returns the starting position for the next gzread or gzwrite on the given compressed file. This position represents a number of bytes in the @@ -789,20 +835,24 @@ ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) */ -ZEXTERN int ZEXPORT gzeof OF((gzFile file)); +ZEXTERN int ZEXPORT gzeof OF((gzFile file)) + /*@*/; /* Returns 1 when EOF has previously been detected reading the given input stream, otherwise zero. */ -ZEXTERN int ZEXPORT gzclose OF((gzFile file)); +ZEXTERN int ZEXPORT gzclose OF((gzFile file)) + /*@globals fileSystem @*/ + /*@modifies file, fileSystem @*/; /* Flushes all pending output if necessary, closes the compressed file and deallocates all the (de)compression state. The return value is the zlib error number (see function gzerror below). */ -ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); +ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)) + /*@modifies *errnum @*/; /* Returns the error message for the last error which occurred on the given compressed file. errnum is set to zlib error number. If an @@ -819,7 +869,8 @@ ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); compression library. */ -ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); +ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)) + /*@*/; /* Update a running Adler-32 checksum with the bytes buf[0..len-1] and @@ -836,7 +887,8 @@ 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, const Bytef *buf, uInt len)) + /*@*/; /* Update a running crc with the bytes buf[0..len-1] and return the updated crc. If buf is NULL, this function returns the required initial value @@ -859,15 +911,19 @@ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); * and the compiler's view of z_stream: */ ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, - const char *version, int stream_size)); + const char *version, int stream_size)) + /*@modifies strm @*/; ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, - const char *version, int stream_size)); + const char *version, int stream_size)) + /*@modifies strm @*/; ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy, const char *version, - int stream_size)); + int stream_size)) + /*@modifies strm @*/; ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, - const char *version, int stream_size)); + const char *version, int stream_size)) + /*@modifies strm @*/; #define deflateInit(strm, level) \ deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) #define inflateInit(strm) \ @@ -883,9 +939,12 @@ ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, struct internal_state {int dummy;}; /* hack for buggy compilers */ #endif -ZEXTERN const char * ZEXPORT zError OF((int err)); -ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); -ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); +ZEXTERN const char * ZEXPORT zError OF((int err)) + /*@*/; +ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)) + /*@modifies z @*/; +ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)) + /*@*/; #ifdef __cplusplus } diff --git a/zlib/zutil.h b/zlib/zutil.h index 718ebc15b..00740fb76 100644 --- a/zlib/zutil.h +++ b/zlib/zutil.h @@ -8,7 +8,7 @@ subject to change. Applications should only use zlib.h. */ -/* @(#) $Id$ */ +/* @(#) $Id: zutil.h,v 1.7 2002/03/17 15:46:23 jbj Exp $ */ #ifndef _Z_UTIL_H #define _Z_UTIL_H @@ -181,9 +181,12 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */ # define zmemzero(dest, len) memset(dest, 0, len) # endif #else - extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); - extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); - extern void zmemzero OF((Bytef* dest, uInt len)); + extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)) + /*@modifies dest @*/; + extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)) + /*@*/; + extern void zmemzero OF((Bytef* dest, uInt len)) + /*@modifies dest @*/; #endif /* Diagnostic functions */ @@ -208,9 +211,12 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */ typedef uLong (ZEXPORT *check_func) OF((uLong check, const Bytef *buf, - uInt len)); -voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); -void zcfree OF((voidpf opaque, voidpf ptr)); + uInt len)) + /*@*/; +voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)) + /*@*/; +void zcfree OF((voidpf opaque, /*@only@*/ voidpf ptr)) + /*@modifies ptr @*/; #define ZALLOC(strm, items, size) \ (*((strm)->zalloc))((strm)->opaque, (items), (size)) |