diff options
author | jbj <devnull@localhost> | 2001-06-04 13:55:58 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2001-06-04 13:55:58 +0000 |
commit | 750d54d8a33e67d8f89ed95a785c0f025c833aa8 (patch) | |
tree | b884b1b98864221da1ccc14c5551579cb885be73 | |
parent | 9e1929c9bb268faad7c8f140161504dbaf7f00f0 (diff) | |
download | librpm-tizen-750d54d8a33e67d8f89ed95a785c0f025c833aa8.tar.gz librpm-tizen-750d54d8a33e67d8f89ed95a785c0f025c833aa8.tar.bz2 librpm-tizen-750d54d8a33e67d8f89ed95a785c0f025c833aa8.zip |
lclint fiddles.
CVS patchset: 4833
CVS date: 2001/06/04 13:55:58
72 files changed, 1128 insertions, 527 deletions
@@ -7,24 +7,97 @@ +unixlib -# XXX ignore doxygen markings --unrecogcomments +-unrecogcomments # XXX ignore doxygen markings -#+mustmod # segfault in psm.c:597 #+proto-param-match -#-cpp-names -#-declundef # db3 is noisy -#-deepbreak # 485 cases -#-export-local -#-export-header -#-export-header-var +#-deepbreak # shortcut 485 cases + +# --- not-yet at strict level +#+ptrarith +#+bitwisesigned +#+strictops +#+sizeoftype + +#+mod-uncon # shortcut alloca is painful +#+mod-nomods +#+modglobsnomods +#+modstrictglobsnomods + +#+mod-uncon-nomods +#+mod-internal-strict +#+mod-file-sys +#+globnoglobs +#+internalglobs +#+internalglobnoglobs +#+modglobsunchecked +#+warnmissingglobs +#+warnmissingglobsnomods +#+impcheckedstrictglobs +#+impcheckedstrictstatics +#+strictusereleas +#+strictbranchstate +#+strictdestroy +#+modobserveruncon +#+macroempty +#+ansi-reserved-internal +#+evalorderuncon +#+elseifcomplete +#+loopswitchbreak +#+switchswitchbreak +#+looploopcontinue +#+whileblock +#+forempty +#+forblock +#+ifblock +#+noeffectuncon ++topuse +#+unusedspecial +#+export-local +#+oldstyle +#+sys-dir-errors +#controlnestdepth 15 +#stringliterallen 509 +#numstructfields 127 +#numenummembers 127 + +# --- not-yet at checks level +#+predboolptr +-ptrnegate +#-enumint +-relaxquals +#+mustmod # segfault in psm.c:597 +#+allglobs +#+impcheckmodinternals +#+uncheckedglobalias +#+deparrays +#+onlyunqglobaltrans +#+staticinittrans +#+unqualifiedinittrans +#+retalias +#+assignexpose +#+castexpose +#+retexpose +#+readonlytrans +#+sefuncon +#+ansi-reserved ++cpp-names # check for c++ names +#+infloopsuncon +#+looploopbreak +#+switchloopbreak +#+whileempty ++declundef ++export-header ++export-header-var ++redecl ++noparams +#includenest 8 # don't-bother-me-yet parameters -branchstate # painful -mustfree # alloca is painful -# not-yet normal parameters +# --- not-yet at standard level -boolops # w->n -predboolint # w->n -type # diff --git a/build/buildio.h b/build/buildio.h index 4481f46ec..4570b4ce9 100644 --- a/build/buildio.h +++ b/build/buildio.h @@ -32,15 +32,17 @@ extern "C" { * @param csa * @return 0 on success */ -int readRPM(/*@null@*/ const char * fileName, /*@out@*/ Spec * specp, - /*@out@*/ struct rpmlead * lead, /*@out@*/ Header * sigs, +/*@unused@*/ int readRPM(/*@null@*/ const char * fileName, + /*@out@*/ Spec * specp, + /*@out@*/ struct rpmlead * lead, + /*@out@*/ Header * sigs, CSA_t csa) - /*@modifies *specp, *sigs, csa, csa->cpioFdIn @*/; + /*@modifies *specp, *lead, *sigs, csa, csa->cpioFdIn @*/; /** * Write rpm package to file. * - * @warning The first header argument is now passed by reference in order to + * @warning The first argument (header) is now passed by reference in order to * return a reloaded contiguous header to the caller. * * @retval hdrp header to write (final header is returned). @@ -51,8 +53,11 @@ int readRPM(/*@null@*/ const char * fileName, /*@out@*/ Spec * specp, * @retval cookie generated cookie (i.e build host/time) * @return 0 on success */ -int writeRPM(Header * hdrp, const char * fileName, int type, - CSA_t csa, /*@null@*/ char * passPhrase, +int writeRPM(Header * hdrp, + const char * fileName, + int type, + CSA_t csa, + /*@null@*/ char * passPhrase, /*@out@*/ const char ** cookie) /*@modifies *hdrp, *cookie, csa, csa->cpioArchiveSize @*/; diff --git a/build/files.c b/build/files.c index f643a0d3a..af7f6d262 100644 --- a/build/files.c +++ b/build/files.c @@ -31,7 +31,9 @@ #define MAXDOCDIR 1024 +/*@-redecl@*/ extern int _noDirTokens; +/*@=redecl@*/ /** */ @@ -272,7 +274,7 @@ typedef struct VFA { /** */ -/*@-exportlocal@*/ +/*@-exportlocal -exportheadervar@*/ VFA_t verifyAttrs[] = { { "md5", RPMVERIFY_MD5 }, { "size", RPMVERIFY_FILESIZE }, @@ -284,7 +286,7 @@ VFA_t verifyAttrs[] = { { "rdev", RPMVERIFY_RDEV }, { NULL, 0 } }; -/*@=exportlocal@*/ +/*@=exportlocal =exportheadervar@*/ /** * @param fl package file tree walk data @@ -297,7 +299,7 @@ static int parseForVerify(char * buf, FileList fl) char *p, *pe, *q; const char *name; int *resultVerify; - int not; + int negated; int verifyFlags; specdFlags * specdFlags; @@ -339,7 +341,7 @@ static int parseForVerify(char * buf, FileList fl) while (p <= pe) *p++ = ' '; - not = 0; + negated = 0; verifyFlags = RPMVERIFY_NONE; for (p = q; *p != '\0'; p = pe) { @@ -363,7 +365,7 @@ static int parseForVerify(char * buf, FileList fl) } if (!strcmp(p, "not")) { - not ^= 1; + negated ^= 1; } else { rpmError(RPMERR_BADSPEC, _("Invalid %s token: %s\n"), name, p); fl->processingFailed = 1; @@ -371,7 +373,7 @@ static int parseForVerify(char * buf, FileList fl) } } - *resultVerify = not ? ~(verifyFlags) : verifyFlags; + *resultVerify = negated ? ~(verifyFlags) : verifyFlags; *specdFlags |= SPECD_VERIFY; return 0; @@ -740,7 +742,7 @@ static int parseForRegexMultiLib(const char *fileName) /*@*/ /** */ -/*@-exportlocal@*/ +/*@-exportlocal -exportheadervar@*/ VFA_t virtualFileAttributes[] = { { "%dir", 0 }, /* XXX why not RPMFILE_DIR? */ { "%doc", RPMFILE_DOC }, @@ -760,7 +762,7 @@ VFA_t virtualFileAttributes[] = { { NULL, 0 } }; -/*@=exportlocal@*/ +/*@=exportlocal =exportheadervar@*/ /** * @param fl package file tree walk data @@ -1547,7 +1549,7 @@ exit: static int processPackageFiles(Spec spec, Package pkg, int installSpecialDoc, int test) /*@modifies spec->macros, - pkg->cpioList, pkg->specialDoc, pkg->header */ + pkg->cpioList, pkg->fileList, pkg->specialDoc, pkg->header */ { HGE_t hge = (HGE_t)headerGetEntryMinMemory; struct FileList_s fl; @@ -2126,7 +2128,7 @@ typedef struct { /** */ -/*@-exportlocal@*/ +/*@-exportlocal -exportheadervar@*/ DepMsg_t depMsgs[] = { { "Provides", { "%{__find_provides}", NULL, NULL, NULL }, RPMTAG_PROVIDENAME, RPMTAG_PROVIDEVERSION, RPMTAG_PROVIDEFLAGS, @@ -2166,7 +2168,7 @@ DepMsg_t depMsgs[] = { 0, -1 }, { NULL, { NULL, NULL, NULL, NULL }, 0, 0, 0, 0, 0 } }; -/*@=exportlocal@*/ +/*@=exportlocal =exportheadervar@*/ /** */ diff --git a/build/pack.c b/build/pack.c index f36f1cde7..b15f9d6b6 100644 --- a/build/pack.c +++ b/build/pack.c @@ -14,7 +14,9 @@ #include "rpmlead.h" #include "debug.h" +/*@-redecl@*/ extern int _noDirTokens; +/*@=redecl@*/ /*@access StringBuf @*/ /* compared with NULL */ /*@access TFI_t @*/ /* compared with NULL */ @@ -45,7 +47,7 @@ static inline int genSourceRpmName(Spec spec) */ static int cpio_doio(FD_t fdo, /*@unused@*/ Header h, CSA_t csa, const char * fmodeMacro) - /*@modifies csa, fileSystem @*/ + /*@modifies fdo, csa, fileSystem @*/ { const char * rootDir = "/"; rpmdb rpmdb = NULL; @@ -86,7 +88,7 @@ static int cpio_doio(FD_t fdo, /*@unused@*/ Header h, CSA_t csa, /** */ static int cpio_copy(FD_t fdo, CSA_t csa) - /*@modifies csa, fileSystem @*/ + /*@modifies fdo, csa, fileSystem @*/ { char buf[BUFSIZ]; size_t nb; diff --git a/build/parseDescription.c b/build/parseDescription.c index 210d3a3b4..2eecc6fb3 100644 --- a/build/parseDescription.c +++ b/build/parseDescription.c @@ -8,7 +8,9 @@ #include "rpmbuild.h" #include "debug.h" -extern int noLang; /* XXX FIXME: pass as arg */ +/*@-exportheadervar@*/ +extern int noLang; +/*@=exportheadervar@*/ /* These have to be global scope to make up for *stupid* compilers */ /*@observer@*/ /*@null@*/ static const char *name = NULL; diff --git a/build/parsePreamble.c b/build/parsePreamble.c index 47c92afa3..fd3fe30fb 100644 --- a/build/parsePreamble.c +++ b/build/parsePreamble.c @@ -408,7 +408,9 @@ if (multiToken) { \ return RPMERR_BADSPEC; \ } -extern int noLang; /* XXX FIXME: pass as arg */ +/*@-redecl@*/ +extern int noLang; +/*@=redecl@*/ /** */ diff --git a/build/parseScript.c b/build/parseScript.c index 070e803ab..9af580c1b 100644 --- a/build/parseScript.c +++ b/build/parseScript.c @@ -13,9 +13,10 @@ /** */ -static int addTriggerIndex(Package pkg, const char *file, const char *script, const char *prog) +static int addTriggerIndex(Package pkg, const char *file, + const char *script, const char *prog) { - struct TriggerFileEntry *new; + struct TriggerFileEntry *tfe; struct TriggerFileEntry *list = pkg->triggerFiles; struct TriggerFileEntry *last = NULL; int index = 0; @@ -29,18 +30,18 @@ static int addTriggerIndex(Package pkg, const char *file, const char *script, co index = last->index + 1; } - new = xmalloc(sizeof(*new)); + tfe = xmalloc(sizeof(*tfe)); - new->fileName = (file) ? xstrdup(file) : NULL; - new->script = (script && *script != '\0') ? xstrdup(script) : NULL; - new->prog = xstrdup(prog); - new->index = index; - new->next = NULL; + tfe->fileName = (file) ? xstrdup(file) : NULL; + tfe->script = (script && *script != '\0') ? xstrdup(script) : NULL; + tfe->prog = xstrdup(prog); + tfe->index = index; + tfe->next = NULL; if (last) { - last->next = new; + last->next = tfe; } else { - pkg->triggerFiles = new; + pkg->triggerFiles = tfe; } return index; diff --git a/build/parseSpec.c b/build/parseSpec.c index 28bc3d645..b2bcf4979 100644 --- a/build/parseSpec.c +++ b/build/parseSpec.c @@ -352,7 +352,9 @@ void closeSpec(Spec spec) } } +/*@-redecl@*/ extern int noLang; /* XXX FIXME: pass as arg */ +/*@=redecl@*/ /*@todo Skip parse recursion if os is not compatible. @*/ int parseSpec(Spec *specp, const char *specFile, const char *rootURL, diff --git a/build/rpmbuild.h b/build/rpmbuild.h index 4d78c6d99..d0f09705d 100644 --- a/build/rpmbuild.h +++ b/build/rpmbuild.h @@ -18,8 +18,11 @@ /** \ingroup rpmbuild * Bit(s) to control buildSpec() operation. */ +/*@-typeuse@*/ typedef enum rpmBuildFlags_e { +/*@-enummemuse@*/ RPMBUILD_NONE = 0, +/*@=enummemuse@*/ RPMBUILD_PREP = (1 << 0), /*!< Execute %%prep. */ RPMBUILD_BUILD = (1 << 1), /*!< Execute %%build. */ RPMBUILD_INSTALL = (1 << 2), /*!< Execute %%install. */ @@ -32,6 +35,7 @@ typedef enum rpmBuildFlags_e { RPMBUILD_STRINGBUF = (1 << 9), /*!< only for doScript() */ RPMBUILD_RMSPEC = (1 << 10) /*!< Remove spec file. */ } rpmBuildFlags; +/*@=typeuse@*/ #include <ctype.h> @@ -263,17 +267,6 @@ int parseScript(Spec spec, int parsePart) spec->sl @*/; /** \ingroup rpmbuild - * Parse %%trigger et al scriptlets from a spec file. - * @param spec spec file control structure - * @param pkg package control structure - * @param field - * @param tag - * @return - */ -int parseTrigger(Spec spec, Package pkg, char * field, int tag) - /*@modifies nothing @*/; - -/** \ingroup rpmbuild * Evaluate boolean expression. * @param spec spec file control structure * @param expr expression to parse @@ -287,6 +280,7 @@ int parseExpressionBoolean(Spec spec, const char * expr) /*@*/; * @param expr expression to parse * @return */ +/*@unused@*/ char * parseExpressionString(Spec spec, const char * expr) /*@modifies nothing @*/; @@ -372,9 +366,9 @@ int rpmlibNeedsFeature(Header h, const char * feature, const char * featureEVR) * @return 0 on success */ int processBinaryFiles(Spec spec, int installSpecialDoc, int test) - /*@modifies spec->packages->cpioList, spec->packages->specialDoc, - spec->macros, - spec->packages->header @*/; + /*@modifies spec->macros, + spec->packages->cpioList, spec->packages->fileList, + spec->packages->specialDoc, spec->packages->header @*/; /** \ingroup rpmbuild * Create and initialize header for source package. @@ -431,6 +425,7 @@ int parseSpec(/*@out@*/ Spec * specp, const char * specFile, * @param force * @return */ +/*@-declundef@*/ extern int (*parseSpecVec) (Spec * specp, const char * specFile, const char * rootdir, /*@null@*/ const char * buildRoot, @@ -439,6 +434,7 @@ extern int (*parseSpecVec) (Spec * specp, const char * specFile, /*@null@*/ char * cookie, int anyarch, int force) /*@modifies *specp @*/; +/*@=declundef@*/ /** \ingroup rpmbuild * Build stages state machine driver. @@ -452,8 +448,8 @@ int buildSpec(Spec spec, int what, int test) spec->sourceRpmName, spec->macros, spec->BASpecs, spec->buildRestrictions, spec->BANames, - spec->packages->cpioList, spec->packages->specialDoc, - spec->packages->header @*/; + spec->packages->cpioList, spec->packages->fileList, + spec->packages->specialDoc, spec->packages->header @*/; /** \ingroup rpmbuild * Generate binary package(s). diff --git a/build/rpmspec.h b/build/rpmspec.h index d7f48435f..d0c44d011 100644 --- a/build/rpmspec.h +++ b/build/rpmspec.h @@ -41,10 +41,12 @@ struct Source { /** \ingroup rpmbuild */ +/*@-typeuse@*/ typedef struct ReadLevelEntry { int reading; /*@dependent@*/ struct ReadLevelEntry * next; } RLE_t; +/*@=typeuse@*/ /** \ingroup rpmbuild */ @@ -192,8 +194,10 @@ extern "C" { * @param spec spec file control structure * @return NULL always */ +/*@-declundef@*/ extern /*@null@*/ Spec (*freeSpecVec) (Spec spec) /* XXX FIXME */ /*@modifies spec @*/; +/*@=declundef@*/ /** \ingroup rpmbuild */ diff --git a/build/spec.c b/build/spec.c index e5daf2226..541d80c8d 100644 --- a/build/spec.c +++ b/build/spec.c @@ -9,8 +9,12 @@ #include "buildio.h" #include "debug.h" +/*@-redecl@*/ extern int specedit; +/*@=redecl@*/ +/*@-exportheadervar@*/ extern struct MacroContext_s rpmGlobalMacroContext; +/*@=exportheadervar@*/ #define SKIPWHITE(_x) {while(*(_x) && (xisspace(*_x) || *(_x) == ',')) (_x)++;} #define SKIPNONWHITE(_x){while(*(_x) &&!(xisspace(*_x) || *(_x) == ',')) (_x)++;} diff --git a/configure.in b/configure.in index 17e233973..24a7d5669 100644 --- a/configure.in +++ b/configure.in @@ -728,6 +728,7 @@ AC_ARG_WITH(glob, [ --with-glob use the internal GNU glob ], if test $rpm_cv_glob = no ; then AC_MSG_CHECKING(for GNU extensions to glob) + rm -f t mkdir t mkdir t/p touch t/p/foo.8 diff --git a/db3/.cvsignore b/db3/.cvsignore index 696093e50..bb2445a79 100644 --- a/db3/.cvsignore +++ b/db3/.cvsignore @@ -5,6 +5,7 @@ Makefile.in .libs *.la *.lo +db3lobjs config.cache config.log db_config.h diff --git a/db3/configure b/db3/configure index f1f1ac2df..b9390c214 100755 --- a/db3/configure +++ b/db3/configure @@ -26,10 +26,14 @@ db3_install: all install_setip \\' > Makefile mv db.h db.h.orig cat db.h.orig | sed \ - -e '/^struct __db;/i\ -/*@-incondefs@*/' \ + -e '/^typedef u_int32_t db_pgno_t;/i\ +/*@-incondefs -fielduse -enummemuse -typeuse @*/' \ -e '/^struct __key_range;/a\ -/*@=incondefs@*/' > db.h +/*@=incondefs@*/' \ + -e '/^#define db_create/i\ +/*@-declundef -noparams -fcnuse@*/' \ + -e '/^#define db_xa_switch/a\ +/*@=declundef =noparams =fcnuse =fielduse =enummemuse =typeuse @*/' > db.h # Generate manifest for rpmdb. make -s listobjs > db3lobjs diff --git a/lib/Makefile.am b/lib/Makefile.am index 6449c8f2d..77b7a2872 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -58,7 +58,7 @@ getdate.c: getdate.y @echo expect 10 shift/reduce conflicts $(YACC) $(srcdir)/getdate.y -@if test -f y.tab.c; then \ - { echo "/*@-globstate -statictrans -unqualifiedtrans @*/";\ + { echo "/*@-globstate -statictrans -unqualifiedtrans -noparams @*/";\ echo "/*@-retvalint -usedef -varuse -nullderef -nullassign @*/";\ sed -e 's,y.tab.c,getdate.c,' y.tab.c \ -e 's,^YYSTYPE ,static &,' \ @@ -67,7 +67,7 @@ getdate.c: getdate.y -e 's,^int yydebug,/*@unused@*/ static &,' \ -e 's,^int ,static &,' ;\ echo "/*@=retvalint =usedef =varuse =nullderef =nullassign @*/";\ - echo "/*@=globstate =statictrans =unqualifiedtrans @*/";\ + echo "/*@=globstate =statictrans =unqualifiedtrans =noparams @*/";\ } > getdate.c ;\ rm -f y.tab.c; \ else \ diff --git a/lib/cpio.c b/lib/cpio.c index edae3cd64..7d73ec00e 100644 --- a/lib/cpio.c +++ b/lib/cpio.c @@ -16,7 +16,9 @@ /*@access FSM_t @*/ +/*@-exportheadervar@*/ extern int _fsm_debug; +/*@=exportheadervar@*/ /** * Convert string to unsigned integer (with buffer size check). diff --git a/lib/cpio.h b/lib/cpio.h index 972fc60f7..46df6edd1 100644 --- a/lib/cpio.h +++ b/lib/cpio.h @@ -102,14 +102,16 @@ extern "C" { * @retval fsm file path and stat info * @return 0 on success */ -int cpioTrailerWrite(FSM_t fsm); +int cpioTrailerWrite(FSM_t fsm) + /*@modifies fsm, fileSystem @*/; /** * Write cpio header. * @retval fsm file path and stat info * @return 0 on success */ -int cpioHeaderWrite(FSM_t fsm, struct stat * st); +int cpioHeaderWrite(FSM_t fsm, struct stat * st) + /*@modifies fsm, fileSystem @*/; /** * Read cpio header. diff --git a/lib/depends.c b/lib/depends.c index 5539b8e09..bde10929e 100644 --- a/lib/depends.c +++ b/lib/depends.c @@ -2,7 +2,9 @@ * \file lib/depends.c */ -int _depends_debug = 0; +/*@-exportheadervar@*/ +/*@unused@*/ int _depends_debug = 0; +/*@=exportheadervar@*/ #include "system.h" @@ -592,7 +594,9 @@ exit: return result; } +/*@-typeuse@*/ typedef int (*dbrecMatch_t) (Header h, const char *reqName, const char * reqEVR, int reqFlags); +/*@=typeuse@*/ static int rangeMatchesDepFlags (Header h, const char * reqName, const char * reqEVR, int reqFlags) @@ -1165,7 +1169,7 @@ static int unsatisfiedDepend(rpmTransactionSet ts, const char * keyType, const char * keyDepend, const char * keyName, const char * keyEVR, int keyFlags, /*@null@*/ /*@out@*/ struct availablePackage *** suggestion) - /*@modifies *suggestion @*/ + /*@modifies ts, *suggestion @*/ { static int _cacheDependsRC = 1; rpmdbMatchIterator mi; @@ -1189,7 +1193,9 @@ static int unsatisfiedDepend(rpmTransactionSet ts, size_t datalen = 0; int xx; xx = dbiCopen(dbi, &dbcursor, 0); + /*@-mods@*/ /* FIX: keyDepends mod undocumented. */ xx = dbiGet(dbi, dbcursor, (void **)&keyDepend, &keylen, &datap, &datalen, 0); + /*@=mods@*/ if (xx == 0 && datap && datalen == 4) { memcpy(&rc, datap, datalen); rpmMessage(RPMMESS_DEBUG, _("%s: %-45s %-s (cached)\n"), @@ -1345,7 +1351,7 @@ exit: */ static int checkPackageDeps(rpmTransactionSet ts, problemsSet psp, Header h, const char * keyName, uint_32 multiLib) - /*@modifies h, psp */ + /*@modifies ts, h, psp */ { HGE_t hge = (HGE_t)headerGetEntryMinMemory; HFD_t hfd = headerFreeData; @@ -1533,7 +1539,7 @@ static int checkPackageDeps(rpmTransactionSet ts, problemsSet psp, */ static int checkPackageSet(rpmTransactionSet ts, problemsSet psp, const char * key, /*@only@*/ /*@null@*/ rpmdbMatchIterator mi) - /*@modifies mi, psp @*/ + /*@modifies ts, mi, psp @*/ { Header h; int rc = 0; @@ -1560,7 +1566,7 @@ static int checkPackageSet(rpmTransactionSet ts, problemsSet psp, */ static int checkDependentPackages(rpmTransactionSet ts, problemsSet psp, const char * key) - /*@modifies psp @*/ + /*@modifies ts, psp @*/ { rpmdbMatchIterator mi; mi = rpmdbInitIterator(ts->rpmdb, RPMTAG_REQUIRENAME, key, 0); @@ -1576,7 +1582,7 @@ static int checkDependentPackages(rpmTransactionSet ts, */ static int checkDependentConflicts(rpmTransactionSet ts, problemsSet psp, const char * key) - /*@modifies psp @*/ + /*@modifies ts, psp @*/ { int rc = 0; diff --git a/lib/depends.h b/lib/depends.h index 5a8e2c880..ccd917691 100644 --- a/lib/depends.h +++ b/lib/depends.h @@ -113,8 +113,8 @@ struct transactionElement { TR_REMOVED /*!< Package will be removed. */ } type; /*!< Package disposition (installed/removed). */ union { - int addedIndex; - struct { +/*@unused@*/ int addedIndex; +/*@unused@*/ struct { int dboffset; int dependsOnIndex; } removed; diff --git a/lib/formats.c b/lib/formats.c index 7a920743c..9de2fbdd4 100644 --- a/lib/formats.c +++ b/lib/formats.c @@ -399,9 +399,9 @@ static int filenamesTag(Header h, /*@out@*/ int_32 * type, /* I18N look aside diversions */ -/*@-exportlocal@*/ +/*@-exportlocal -exportheadervar@*/ int _nl_msg_cat_cntr; /* XXX GNU gettext voodoo */ -/*@=exportlocal@*/ +/*@=exportlocal =exportheadervar@*/ static const char * language = "LANGUAGE"; static char * _macro_i18ndomains = "%{?_i18ndomains:%{_i18ndomains}}"; @@ -20,9 +20,9 @@ int _fsm_debug = 0; /* XXX Failure to remove is not (yet) cause for failure. */ -/*@-exportlocal@*/ +/*@-exportlocal -exportheadervar@*/ int strict_erasures = 0; -/*@=exportlocal@*/ +/*@=exportlocal =exportheadervar@*/ rpmTransactionSet fsmGetTs(const FSM_t fsm) { const FSMI_t iter = fsm->iter; @@ -78,25 +78,25 @@ const char * fsmFsPath(/*@special@*/ /*@null@*/ const FSM_t fsm, /** \ingroup payload * Destroy file info iterator. - * @param this file info iterator + * @param p file info iterator * @retval NULL always */ -static /*@null@*/ void * mapFreeIterator(/*@only@*//*@null@*/const void * this) +static /*@null@*/ void * mapFreeIterator(/*@only@*//*@null@*/const void * p) { - return _free((void *)this); + return _free((void *)p); } /** \ingroup payload * Create file info iterator. - * @param this transaction set - * @param that transaction element file info + * @param a transaction set + * @param b transaction element file info * @return file info iterator */ static void * -mapInitIterator(/*@kept@*/ const void * this, /*@kept@*/ const void * that) +mapInitIterator(/*@kept@*/ const void * a, /*@kept@*/ const void * b) { - rpmTransactionSet ts = (void *)this; - TFI_t fi = (void *)that; + rpmTransactionSet ts = (void *)a; + TFI_t fi = (void *)b; FSMI_t iter = NULL; iter = xcalloc(1, sizeof(*iter)); @@ -110,11 +110,11 @@ mapInitIterator(/*@kept@*/ const void * this, /*@kept@*/ const void * that) /** \ingroup payload * Return next index into file info. - * @param this file info iterator + * @param a file info iterator * @return next index, -1 on termination */ -static int mapNextIterator(void * this) { - FSMI_t iter = this; +static int mapNextIterator(void * a) { + FSMI_t iter = a; const TFI_t fi = iter->fi; int i = -1; @@ -148,14 +148,14 @@ static int cpioStrCmp(const void * a, const void * b) /** \ingroup payload * Locate archive path in file info. - * @param this file info iterator + * @param a file info iterator * @param fsmPath archive path * @return index into file info, -1 if archive path was not found */ -static int mapFind(void * this, const char * fsmPath) +static int mapFind(void * a, const char * fsmPath) /*@*/ { - FSMI_t iter = this; + FSMI_t iter = a; const TFI_t fi = iter->fi; int ix = -1; @@ -188,16 +188,16 @@ typedef struct dnli_s { /** \ingroup payload * Destroy directory name iterator. - * @param this file info iterator + * @param a directory name iterator * @retval NULL always */ -static /*@null@*/ void * dnlFreeIterator(/*@only@*//*@null@*/ const void * this) +static /*@null@*/ void * dnlFreeIterator(/*@only@*//*@null@*/ const void * a) { - if (this) { - DNLI_t dnli = (void *)this; + if (a) { + DNLI_t dnli = (void *)a; if (dnli->active) free(dnli->active); } - return _free(this); + return _free(a); } /** \ingroup payload @@ -135,7 +135,7 @@ struct fsm_s { /*@kept@*/ /*@null@*/ unsigned int * archiveSize; /*!< Pointer to archive size. */ /*@kept@*/ /*@null@*/ const char ** failedFile; /*!< First file name that failed. */ /*@shared@*/ const char * subdir; /*!< Current file sub-directory. */ - char subbuf[64]; /* XXX eliminate */ +/*@unused@*/ char subbuf[64]; /* XXX eliminate */ /*@observer@*/ const char * osuffix; /*!< Old, preserved, file suffix. */ /*@observer@*/ const char * nsuffix; /*!< New, created, file suffix. */ /*@shared@*/ const char * suffix; /*!< Current file suffix. */ diff --git a/lib/header.c b/lib/header.c index 8cb2c8aed..01ab075d3 100644 --- a/lib/header.c +++ b/lib/header.c @@ -22,8 +22,9 @@ #include "debug.h" -/* XXX avoid rpmlib.h, need for debugging. */ +/*@-redecl@*/ /* FIX: avoid rpmlib.h, need for debugging. */ /*@observer@*/ const char *const tagName(int tag) /*@*/; +/*@=redecl@*/ /* * Teach header.c about legacy tags. @@ -151,10 +152,12 @@ struct sprintfToken { /** * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL. - * @param this memory to free + * @param p memory to free * @return NULL always */ -/*@unused@*/ static inline /*@null@*/ void * _free(/*@only@*/ /*@null@*/ const void * p) { +/*@unused@*/ static inline /*@null@*/ void * +_free(/*@only@*/ /*@null@*/ const void * p) /*@modifies *p @*/ +{ if (p != NULL) free((void *)p); return NULL; } @@ -250,6 +253,7 @@ static int dataLength(int_32 type, const void * p, int_32 count, int onDisk) */ static int regionSwab(/*@null@*/ struct indexEntry * entry, int il, int dl, const struct entryInfo * pe, char * dataStart, int regionid) + /*@modifies *entry, *dataStart @*/ { char * tprev = NULL; char * t = NULL; @@ -1185,6 +1189,7 @@ void headerDump(Header h, FILE *f, int flags, */ static /*@null@*/ struct indexEntry * findEntry(/*@null@*/ Header h, int_32 tag, int_32 type) + /*@modifies h @*/ { struct indexEntry * entry, * entry2, * last; struct indexEntry key; @@ -1221,7 +1226,9 @@ struct indexEntry * findEntry(/*@null@*/ Header h, int_32 tag, int_32 type) int headerIsEntry(Header h, int_32 tag) { + /*@-mods@*/ /*@ FIX: h modified by sort. */ return (findEntry(h, tag, RPM_NULL_TYPE) ? 1 : 0); + /*@=mods@*/ } int headerGetRawEntry(Header h, int_32 tag, int_32 * type, const void ** p, @@ -1233,7 +1240,9 @@ int headerGetRawEntry(Header h, int_32 tag, int_32 * type, const void ** p, if (p == NULL) return headerIsEntry(h, tag); /* First find the tag */ + /*@-mods@*/ /*@ FIX: h modified by sort. */ entry = findEntry(h, tag, RPM_NULL_TYPE); + /*@=mods@*/ if (!entry) { if (p) *p = NULL; if (c) *c = 0; @@ -1398,7 +1407,9 @@ static int intGetEntry(Header h, int_32 tag, /*@null@*/ /*@out@*/ int_32 * type, int rc; /* First find the tag */ + /*@-mods@*/ /*@ FIX: h modified by sort. */ entry = findEntry(h, tag, RPM_NULL_TYPE); + /*@mods@*/ if (entry == NULL) { if (type) type = 0; if (p) *p = NULL; @@ -1917,6 +1928,7 @@ static char escapedChar(const char ch) /*@*/ */ static /*@null@*/ struct sprintfToken * freeFormat( /*@only@*/ /*@null@*/ struct sprintfToken * format, int num) + /*@modifies *format @*/ { int i; diff --git a/lib/header.h b/lib/header.h index 15a3178b1..4df0f825d 100644 --- a/lib/header.h +++ b/lib/header.h @@ -155,7 +155,7 @@ struct headerSprintfExtension { enum headerSprintfExtenstionType type; /*!< Type of extension. */ char * name; /*!< Name of extension. */ union { - void * generic; /*!< Private extension. */ +/*@unused@*/ void * generic; /*!< Private extension. */ headerTagFormatFunction formatFunction; /*!< HEADER_EXT_TAG extension. */ headerTagTagFunction tagFunction; /*!< HEADER_EXT_FORMAT extension. */ struct headerSprintfExtension * more; /*!< Chained table extension. */ @@ -165,7 +165,9 @@ struct headerSprintfExtension { /** \ingroup header * Supported default header tag output formats. */ +/*@-redecl@*/ extern const struct headerSprintfExtension headerDefaultFormats[]; +/*@=redecl@*/ /** \ingroup header * Include calculation for 8 bytes of (magic, 0)? @@ -209,7 +211,8 @@ unsigned int headerSizeof(/*@null@*/ Header h, enum hMagic magicp) * @return header */ /*@-exportlocal@*/ -/*@null@*/ Header headerLoad(/*@kept@*/ void * uh) /*@*/; +/*@null@*/ Header headerLoad(/*@kept@*/ void * uh) + /*@modifies uh @*/; /*@=exportlocal@*/ /** \ingroup header @@ -217,7 +220,8 @@ unsigned int headerSizeof(/*@null@*/ Header h, enum hMagic magicp) * @param uh on-disk header blob (i.e. with offsets) * @return header */ -/*@null@*/ Header headerCopyLoad(void * uh) /*@*/; +/*@null@*/ Header headerCopyLoad(void * uh) + /*@modifies uh @*/; /** \ingroup header * Convert header to on-disk representation. @@ -256,13 +260,15 @@ Header headerLink(Header h) * @param h header * @return NULL always */ -/*@null@*/ Header headerFree( /*@null@*/ /*@killref@*/ Header h); +/*@null@*/ Header headerFree( /*@null@*/ /*@killref@*/ Header h) + /*@modifies h @*/; /** \ingroup header * Return header reference count. * @param h header * @return no. of references */ +/*@unused@*/ int headerUsageCount(Header h) /*@*/; /** \ingroup header @@ -271,6 +277,7 @@ int headerUsageCount(Header h) /*@*/; * @param flags 0 or HEADER_DUMP_LINLINE * @param tags array of tag name/value pairs */ +/*@unused@*/ void headerDump(Header h, FILE *f, int flags, const struct headerTagTableEntry * tags); #define HEADER_DUMP_INLINE 1 @@ -333,6 +340,7 @@ int headerModifyEntry(Header h, int_32 tag, int_32 type, void *p, int_32 c) * @param h header * @return array of locales (or NULL on error) */ +/*@unused@*/ /*@only@*/ /*@null@*/ char ** headerGetLangs(Header h) /*@*/; /** \ingroup header @@ -397,13 +405,15 @@ int headerAddOrAppendEntry(Header h, int_32 tag, int_32 type, void * p, int_32 c * * @param h header * @param tag tag - * @retval type address of tag value data type - * @retval p address of pointer to tag value(s) - * @retval c address of number of values + * @retval type address of tag value data type (or NULL) + * @retval p address of pointer to tag value(s) (or NULL) + * @retval c address of number of values (or NULL) * @return 1 on success, 0 on failure */ -int headerGetEntry(Header h, int_32 tag, /*@null@*/ /*@out@*/ int_32 *type, - /*@null@*/ /*@out@*/ void **p, /*@null@*/ /*@out@*/int_32 *c) +int headerGetEntry(Header h, int_32 tag, + /*@null@*/ /*@out@*/ int_32 * type, + /*@null@*/ /*@out@*/ void ** p, + /*@null@*/ /*@out@*/int_32 *c) /*@modifies *type, *p, *c @*/; /** \ingroup header @@ -413,13 +423,15 @@ int headerGetEntry(Header h, int_32 tag, /*@null@*/ /*@out@*/ int_32 *type, * * @param h header * @param tag tag - * @retval type address of tag value data type - * @retval p address of pointer to tag value(s) - * @retval c address of number of values + * @retval type address of tag value data type (or NULL) + * @retval p address of pointer to tag value(s) (or NULL) + * @retval c address of number of values (or NULL) * @return 1 on success, 0 on failure */ -int headerGetEntryMinMemory(Header h, int_32 tag, /*@out@*/ int_32 *type, - /*@out@*/ const void **p, /*@out@*/ int_32 *c) +int headerGetEntryMinMemory(Header h, int_32 tag, + /*@null@*/ /*@out@*/ int_32 * type, + /*@null@*/ /*@out@*/ const void ** p, + /*@null@*/ /*@out@*/ int_32 * c) /*@modifies *type, *p, *c @*/; /** \ingroup header @@ -429,14 +441,16 @@ int headerGetEntryMinMemory(Header h, int_32 tag, /*@out@*/ int_32 *type, * * @param h header * @param tag tag - * @retval type address of tag value data type - * @retval p address of pointer to tag value(s) - * @retval c address of number of values + * @retval type address of tag value data type (or NULL) + * @retval p address of pointer to tag value(s) (or NULL) + * @retval c address of number of values (or NULL) * @return 1 on success, 0 on failure */ /*@-exportlocal@*/ -int headerGetRawEntry(Header h, int_32 tag, /*@out@*/ int_32 *type, - /*@out@*/ const void **p, /*@out@*/ int_32 *c) +int headerGetRawEntry(Header h, int_32 tag, + /*@null@*/ /*@out@*/ int_32 * type, + /*@null@*/ /*@out@*/ const void ** p, + /*@null@*/ /*@out@*/ int_32 * c) /*@modifies *type, *p, *c @*/; /*@=exportlocal@*/ @@ -542,16 +556,17 @@ typedef enum rpmTagType_e { /** \ingroup header * Free data allocated when retrieved from header. - * @param data address of data - * @param type type of data + * @param data address of data (or NULL) + * @param type type of data (or -1 to force free) * @return NULL always */ /*@unused@*/ static inline /*@null@*/ void * headerFreeData( /*@only@*/ /*@null@*/ const void * data, rpmTagType type) + /*@modifies data @*/ { if (data) { /*@-branchstate@*/ - if (type < 0 || + if (type == -1 || type == RPM_STRING_ARRAY_TYPE || type == RPM_I18NSTRING_TYPE || type == RPM_BIN_TYPE) @@ -569,6 +584,7 @@ void * headerFreeData( /*@only@*/ /*@null@*/ const void * data, rpmTagType type) * value of the tag a 16 byte image of what should/will be in the header index, * followed by per-tag private data. */ +/*@-enummemuse -typeuse @*/ typedef enum rpmSubTagType_e { RPM_REGION_TYPE = -10, RPM_BIN_ARRAY_TYPE = -11, @@ -578,6 +594,7 @@ typedef enum rpmSubTagType_e { /*!<@todo Implement, intent is to to carry a (???,tagNum,valNum) cross reference to retrieve data from other tags. */ } rpmSubTagType; +/*@=enummemuse =typeuse @*/ /** * Header private tags. diff --git a/lib/manifest.h b/lib/manifest.h index 15371a874..5c5c51599 100644 --- a/lib/manifest.h +++ b/lib/manifest.h @@ -15,7 +15,8 @@ extern "C" { * @param mode file mode * @return (malloc'd) formatted mode string */ -char * rpmPermsString(int mode); +char * rpmPermsString(int mode) + /*@*/; /** * Read manifest, glob items, and append to existing args. @@ -23,7 +24,8 @@ char * rpmPermsString(int mode); * @retval argcPtr no. of args * @retval argvPtr args themselves */ -int rpmReadPackageManifest(FD_t fd, int * argcPtr, const char *** argvPtr); +int rpmReadPackageManifest(FD_t fd, int * argcPtr, const char *** argvPtr) + /*@modifies fd, *argcPtr, *argvPtr @*/; #ifdef __cplusplus } @@ -23,18 +23,18 @@ #include "debug.h" static int _ie = 0x44332211; -static union _mendian { int i; char b[4]; } *_endian = (union _mendian *)&_ie; +static union _mendian { +/*@unused@*/ int i; + char b[4]; +} *_endian = (union _mendian *)&_ie; #define IS_BIG_ENDIAN() (_endian->b[0] == '\x44') #define IS_LITTLE_ENDIAN() (_endian->b[0] == '\x11') -/*@-exportlocal@*/ -void byteReverse(unsigned char *buf, unsigned longs); -/*@=exportlocal@*/ - /* * Note: this code is harmless on little-endian machines. */ -void byteReverse(unsigned char *buf, unsigned longs) +static void byteReverse(unsigned char *buf, unsigned longs) + /*@modifies *buf @*/ { uint32 t; do { diff --git a/lib/misc.c b/lib/misc.c index 72dee9c52..a0d2fee81 100644 --- a/lib/misc.c +++ b/lib/misc.c @@ -16,7 +16,9 @@ static int _debug = 0; /*@access Header@*/ /* XXX compared with NULL */ /*@access FD_t@*/ /* XXX compared with NULL */ -char * RPMVERSION = VERSION; /* just to put a marker in librpm.a */ +/*@-exportheadervar@*/ +/*@unused@*/ char * RPMVERSION = VERSION; /* just to put a marker in librpm.a */ +/*@=exportheadervar@*/ char ** splitString(const char * str, int length, char sep) { diff --git a/lib/misc.h b/lib/misc.h index 83858c1d2..b3d7fad0f 100644 --- a/lib/misc.h +++ b/lib/misc.h @@ -18,11 +18,13 @@ extern "C" { /** */ -/*@only@*/ char ** splitString(const char * str, int length, char sep); +/*@only@*/ char ** splitString(const char * str, int length, char sep) + /*@*/; /** */ -void freeSplitString( /*@only@*/ char ** list); +void freeSplitString( /*@only@*/ char ** list) + /*@modifies list @*/; /** * Remove occurences of trailing character from string. @@ -42,11 +44,13 @@ void freeSplitString( /*@only@*/ char ** list); /** */ -int rpmfileexists(const char * urlfn) /*@*/; +int rpmfileexists(const char * urlfn) + /*@modifies fileSystem @*/; /** */ -int rpmvercmp(const char * a, const char * b); +int rpmvercmp(const char * a, const char * b) + /*@*/; /* * These are like the libc functions, but they malloc() the space which @@ -55,34 +59,42 @@ int rpmvercmp(const char * a, const char * b); /** */ -int dosetenv(const char * name, const char * value, int overwrite); +int dosetenv(const char * name, const char * value, int overwrite) + /*@modifies fileSystem @*/; /** */ -int doputenv(const char * str); +int doputenv(const char * str) + /*@modifies fileSystem @*/; /** */ -int makeTempFile(const char * prefix, /*@out@*/ const char ** fnptr, - /*@out@*/ FD_t * fdptr); +int makeTempFile(const char * prefix, + /*@null@*/ /*@out@*/ const char ** fnptr, + /*@out@*/ FD_t * fdptr) + /*@modifies *fnptr, *fdptr, fileSystem @*/; /** * @return cureent working directory (malloc'ed) */ -/*@only@*/ char * currentDirectory(void); +/*@only@*/ char * currentDirectory(void) + /*@modifies fileSystem @*/; /** */ -void compressFilelist(Header h); +void compressFilelist(Header h) + /*@modifies h @*/; /** */ -void expandFilelist(Header h); +void expandFilelist(Header h) + /*@modifies h @*/; /** */ -void buildOrigFileList(Header h, /*@out@*/ const char *** fileListPtr, - /*@out@*/ int * fileCountPtr); +void buildOrigFileList(Header h, /*@out@*/ const char *** fileListPtr, + /*@out@*/ int * fileCountPtr) + /*@modifies *fileListPtr, *fileCountPtr @*/; /** */ @@ -96,7 +108,8 @@ int rpmGlob(const char * patterns, /*@out@*/ int * argcPtr, /** */ -void providePackageNVR(Header h); +void providePackageNVR(Header h) + /*@modifies h @*/; #ifdef __cplusplus } diff --git a/lib/package.c b/lib/package.c index d71953e82..b737d9fdb 100644 --- a/lib/package.c +++ b/lib/package.c @@ -101,7 +101,6 @@ static rpmRC readPackageHeaders(FD_t fd, struct rpmlead * lead; char * defaultPrefix; struct stat sb; - int_32 true = 1; rpmRC rc; hdr = hdrPtr ? hdrPtr : &hdrBlock; @@ -175,9 +174,10 @@ static rpmRC readPackageHeaders(FD_t fd, /* XXX binary rpms always have RPMTAG_SOURCERPM, source rpms do not */ if (lead->type == RPMLEAD_SOURCE) { + int_32 one = 1; if (!headerIsEntry(*hdr, RPMTAG_SOURCEPACKAGE)) (void)headerAddEntry(*hdr, RPMTAG_SOURCEPACKAGE, RPM_INT32_TYPE, - &true, 1); + &one, 1); } else if (lead->major < 4) { /* Retrofit "Provide: name = EVR" for binary packages. */ providePackageNVR(*hdr); diff --git a/lib/poptBT.c b/lib/poptBT.c index 439c30bb6..9666a946a 100644 --- a/lib/poptBT.c +++ b/lib/poptBT.c @@ -43,8 +43,10 @@ struct rpmBuildArguments_s rpmBTArgs; #define POPT_TP 0x7470 #define POPT_TS 0x7473 +/*@-redecl@*/ extern int _noDirTokens; extern int _fsm_debug; +/*@=redecl@*/ static int force = 0; int noLang = 0; static int noBuild = 0; @@ -23,7 +23,9 @@ /*@access PSM_t @*/ /* compared with NULL */ /*@access FD_t @*/ /* compared with NULL */ +/*@-redecl@*/ extern int _fsm_debug; +/*@=redecl@*/ int rpmVersionCompare(Header first, Header second) { @@ -12,14 +12,6 @@ /** */ -struct sharedFile { - int mainFileNumber; - int secRecOffset; - int secFileNumber; -} ; - -/** - */ struct sharedFileInfo { int pkgFileNum; int otherFileNum; @@ -51,7 +43,7 @@ struct transactionFileInfo_s { int_32 * dil; /*!< Directory indice(s) (from header) */ /*@owned@*/ const char ** obnl; /*!< Original base name(s) (from header) */ /*@owned@*/ const char ** odnl; /*!< Original directory name(s) (from header) */ - int_32 * odil; /*!< Original directory indice(s) (from header) */ +/*@unused@*/ int_32 * odil; /*!< Original directory indice(s) (from header) */ /*@owned@*/ const char ** fmd5s;/*!< File MD5 sum(s) (from header) */ /*@owned@*/ const char ** flinks; /*!< File link(s) (from header) */ /* XXX setuid/setgid bits are turned off if fuser/fgroup doesn't map. */ @@ -161,7 +153,7 @@ struct psm_s { unsigned long total; /*!< Callback total. */ rpmRC rc; pkgStage goal; - pkgStage stage; +/*@unused@*/ pkgStage stage; }; #ifdef __cplusplus diff --git a/lib/query.c b/lib/query.c index 26774d385..712be0eda 100644 --- a/lib/query.c +++ b/lib/query.c @@ -154,6 +154,7 @@ int showQueryPackage(QVA_t qva, /*@unused@*/rpmdb rpmdb, Header h) const char ** fileOwnerList = NULL; const char ** fileGroupList = NULL; const char ** fileLinktoList = NULL; + int m5t, fot, fgt, ltt; const char * fileStatesList; int_32 * fileFlagsList, * fileMTimeList, * fileSizeList; int_32 * fileUIDList = NULL; @@ -203,33 +204,36 @@ int showQueryPackage(QVA_t qva, /*@unused@*/rpmdb rpmdb, Header h) te = stpcpy(te, _("(contains no files)")); goto exit; } - if (!hge(h, RPMTAG_FILESTATES, &type, (void **) &fileStatesList, &count)) { + if (!hge(h, RPMTAG_FILESTATES, &type, (void **) &fileStatesList, &count)) fileStatesList = NULL; - } - (void) hge(h, RPMTAG_DIRNAMES, &dnt, (void **) &dirNames, NULL); - (void) hge(h, RPMTAG_DIRINDEXES, NULL, (void **) &dirIndexes, NULL); - (void) hge(h, RPMTAG_FILEFLAGS, &type, (void **)&fileFlagsList, &count); - (void) hge(h, RPMTAG_FILESIZES, &type, (void **) &fileSizeList, &count); - (void) hge(h, RPMTAG_FILEMODES, &type, (void **) &fileModeList, &count); - (void) hge(h, RPMTAG_FILEMTIMES, &type, (void **)&fileMTimeList,&count); - (void) hge(h, RPMTAG_FILERDEVS, &type, (void **) &fileRdevList, &count); - (void) hge(h, RPMTAG_FILEINODES, &type, (void **)&fileInodeList,&count); - (void) hge(h, RPMTAG_FILELINKTOS,&type,(void **)&fileLinktoList,&count); - (void) hge(h, RPMTAG_FILEMD5S, &type, (void **) &fileMD5List, &count); - - if (!hge(h, RPMTAG_FILEUIDS, &type, (void **) &fileUIDList, &count)) { + if (!hge(h, RPMTAG_DIRNAMES, &dnt, (void **) &dirNames, NULL)) + dirNames = NULL; + if (!hge(h, RPMTAG_DIRINDEXES, NULL, (void **) &dirIndexes, NULL)) + dirIndexes = NULL; + if (!hge(h, RPMTAG_FILEFLAGS, &type, (void **) &fileFlagsList, &count)) + fileFlagsList = NULL; + if (!hge(h, RPMTAG_FILESIZES, &type, (void **) &fileSizeList, &count)) + fileSizeList = NULL; + if (!hge(h, RPMTAG_FILEMODES, &type, (void **) &fileModeList, &count)) + fileModeList = NULL; + if (!hge(h, RPMTAG_FILEMTIMES, &type, (void **) &fileMTimeList, &count)) + fileMTimeList = NULL; + if (!hge(h, RPMTAG_FILERDEVS, &type, (void **) &fileRdevList, &count)) + fileRdevList = NULL; + if (!hge(h, RPMTAG_FILEINODES, &type, (void **) &fileInodeList, &count)) + fileInodeList = NULL; + if (!hge(h, RPMTAG_FILELINKTOS, <t, (void **) &fileLinktoList, NULL)) + fileLinktoList = NULL; + if (!hge(h, RPMTAG_FILEMD5S, &m5t, (void **) &fileMD5List, NULL)) + fileMD5List = NULL; + if (!hge(h, RPMTAG_FILEUIDS, &type, (void **) &fileUIDList, &count)) fileUIDList = NULL; - } else if (!hge(h, RPMTAG_FILEGIDS, &type, - (void **) &fileGIDList, &count)) { + if (!hge(h, RPMTAG_FILEGIDS, &type, (void **) &fileGIDList, &count)) fileGIDList = NULL; - } - - if (!hge(h, RPMTAG_FILEUSERNAME, &type, (void **) &fileOwnerList, &count)) { + if (!hge(h, RPMTAG_FILEUSERNAME, &fot, (void **) &fileOwnerList, NULL)) fileOwnerList = NULL; - } else - if (!hge(h, RPMTAG_FILEGROUPNAME, &type, (void **) &fileGroupList, &count)) { + if (!hge(h, RPMTAG_FILEGROUPNAME, &fgt, (void **) &fileGroupList, NULL)) fileGroupList = NULL; - } for (i = 0; i < count; i++) { /* If querying only docs, skip non-doc files. */ @@ -269,7 +273,7 @@ int showQueryPackage(QVA_t qva, /*@unused@*/rpmdb rpmdb, Header h) sprintf(te, "%s%s %d %d %s 0%o ", dirNames[dirIndexes[i]], baseNames[i], fileSizeList[i], fileMTimeList[i], - fileMD5List[i], fileModeList[i]); + fileMD5List[i], (unsigned) fileModeList[i]); te += strlen(te); if (fileOwnerList && fileGroupList) { @@ -286,7 +290,7 @@ int showQueryPackage(QVA_t qva, /*@unused@*/rpmdb rpmdb, Header h) sprintf(te, " %s %s %u ", fileFlagsList[i] & RPMFILE_CONFIG ? "1" : "0", fileFlagsList[i] & RPMFILE_DOC ? "1" : "0", - (unsigned)fileRdevList[i]); + (unsigned) fileRdevList[i]); te += strlen(te); if (strlen(fileLinktoList[i])) @@ -352,10 +356,10 @@ exit: t = _free(t); dirNames = hfd(dirNames, dnt); baseNames = hfd(baseNames, bnt); - fileLinktoList = hfd(fileLinktoList, -1); - fileMD5List = hfd(fileMD5List, -1); - fileOwnerList = hfd(fileOwnerList, -1); - fileGroupList = hfd(fileGroupList, -1); + fileLinktoList = hfd(fileLinktoList, ltt); + fileMD5List = hfd(fileMD5List, m5t); + fileOwnerList = hfd(fileOwnerList, fot); + fileGroupList = hfd(fileGroupList, fgt); return rc; } @@ -469,6 +473,7 @@ int showMatches(QVA_t qva, rpmdbMatchIterator mi, QVF_t showPackage) return ec; } +/*@-redecl@*/ /** * @todo Eliminate linkage loop into librpmbuild.a */ @@ -479,6 +484,7 @@ int (*parseSpecVec) (Spec *specp, const char *specFile, const char *rootdir, * @todo Eliminate linkage loop into librpmbuild.a */ /*@null@*/ Spec (*freeSpecVec) (Spec spec) = NULL; +/*@=redecl@*/ int rpmQueryVerify(QVA_t qva, rpmQVSources source, const char * arg, rpmdb rpmdb, QVF_t showPackage) diff --git a/lib/rpminstall.c b/lib/rpminstall.c index c3b95cdd1..bc504229f 100644 --- a/lib/rpminstall.c +++ b/lib/rpminstall.c @@ -139,8 +139,8 @@ void * showProgress(/*@null@*/ const void * arg, const rpmCallbackType what, case RPMCALLBACK_TRANS_PROGRESS: case RPMCALLBACK_INST_PROGRESS: if (flags & INSTALL_PERCENT) - fprintf(stdout, "%%%% %f\n", (total - ? ((float) ((((float) amount) / total) * 100)) + fprintf(stdout, "%%%% %f\n", (double) (total + ? ((((float) amount) / total) * 100) : 100.0)); else if (flags & INSTALL_HASH) printHash(amount, total); diff --git a/lib/rpmlib.h b/lib/rpmlib.h index aeb111da1..744909b5c 100644 --- a/lib/rpmlib.h +++ b/lib/rpmlib.h @@ -33,10 +33,12 @@ extern "C" { /** * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL. - * @param this memory to free + * @param p memory to free * @return NULL always */ -/*@unused@*/ static inline /*@null@*/ void * _free(/*@only@*/ /*@null@*/ const void * p) { +/*@unused@*/ static inline /*@null@*/ void * +_free(/*@only@*/ /*@null@*/ const void * p) /*@modifies p@*/ +{ if (p != NULL) free((void *)p); return NULL; } @@ -146,10 +148,12 @@ int rpmHeaderGetEntry(Header h, int_32 tag, /*@out@*/ int_32 *type, * @retval c address of number of values * @return 0 on success, 1 on bad magic, 2 on error */ +/*@unused@*/ int rpmPackageGetEntry(void *leadp, Header sigs, Header h, int_32 tag, int_32 *type, void **p, int_32 *c) /*@modifies *type, *p, *c @*/; +/*@-redecl@*/ /** * Automatically generated table of tag name/value pairs. */ @@ -165,6 +169,7 @@ extern const int rpmTagTableSize; * @note Chains to headerDefaultFormats[]. */ extern const struct headerSprintfExtension rpmHeaderFormats[]; +/*@=redecl@*/ /** * Pseudo-tags used by the rpmdb iterator API. @@ -180,6 +185,7 @@ extern const struct headerSprintfExtension rpmHeaderFormats[]; * Tags identify data in package headers. * @note tags should not have value 0! */ +/*@-enummemuse -typeuse@*/ typedef enum rpmTag_e { RPMTAG_HEADERIMAGE = HEADER_IMAGE, /*!< Current image. */ @@ -328,26 +334,32 @@ typedef enum rpmTag_e { RPMTAG_REMOVETID = 1129, RPMTAG_FIRSTFREE_TAG /*!< internal */ } rpmTag; +/*@=enummemuse =typeuse@*/ #define RPMTAG_EXTERNAL_TAG 1000000 /** * File States (when installed). */ +/*@-typeuse@*/ typedef enum rpmfileStates_e { RPMFILE_STATE_NORMAL = 0, RPMFILE_STATE_REPLACED = 1, RPMFILE_STATE_NOTINSTALLED = 2, RPMFILE_STATE_NETSHARED = 3 } rpmfileStates; +/*@=typeuse@*/ /** * File Attributes. */ +/*@-typeuse@*/ typedef enum rpmfileAttrs_e { RPMFILE_CONFIG = (1 << 0), /*!< from %%config */ RPMFILE_DOC = (1 << 1), /*!< from %%doc */ +/*@-enummemuse@*/ RPMFILE_DONOTUSE = (1 << 2), /*!< @todo (unimplemented) from %donotuse. */ +/*@=enummemuse@*/ RPMFILE_MISSINGOK = (1 << 3), /*!< from %%config(missingok) */ RPMFILE_NOREPLACE = (1 << 4), /*!< from %%config(noreplace) */ RPMFILE_SPECFILE = (1 << 5), /*!< @todo (unnecessary) marks 1st file in srpm. */ @@ -356,6 +368,7 @@ typedef enum rpmfileAttrs_e { RPMFILE_README = (1 << 8), /*!< from %%readme */ RPMFILE_EXCLUDE = (1 << 9) /*!< from %%exclude */ } rpmfileAttrs; +/*@=typeuse@*/ #define RPMFILE_MULTILIB_SHIFT 9 #define RPMFILE_MULTILIB(N) ((N) << RPMFILE_MULTILIB_SHIFT) #define RPMFILE_MULTILIB_MASK RPMFILE_MULTILIB(7) @@ -368,7 +381,9 @@ typedef enum rpmfileAttrs_e { */ typedef enum rpmsenseFlags_e { RPMSENSE_ANY = 0, +/*@-enummemuse@*/ RPMSENSE_SERIAL = (1 << 0), /*!< @todo Legacy. */ +/*@=enummemuse@*/ RPMSENSE_LESS = (1 << 1), RPMSENSE_GREATER = (1 << 2), RPMSENSE_EQUAL = (1 << 3), @@ -394,7 +409,9 @@ typedef enum rpmsenseFlags_e { RPMSENSE_SCRIPT_INSTALL = (1 << 22),/*!< %install build dependency. */ RPMSENSE_SCRIPT_CLEAN = (1 << 23), /*!< %clean build dependency. */ RPMSENSE_RPMLIB = ((1 << 24) | RPMSENSE_PREREQ), /*!< rpmlib(feature) dependency. */ +/*@-enummemuse@*/ RPMSENSE_TRIGGERPREIN = (1 << 25) /*!< @todo Implement %triggerprein. */ +/*@=enummemuse@*/ } rpmsenseFlags; @@ -447,7 +464,9 @@ typedef enum rpmsenseFlags_e { * @deprecated Use rpmExpand() with appropriate macro expression. * @todo Eliminate from API. */ +/*@-redecl@*/ /*@observer@*/ /*@null@*/ extern const char * rpmGetVar(int var) /*@*/; +/*@=redecl@*/ /** \ingroup rpmrc * Set value of an rpmrc variable. @@ -461,7 +480,9 @@ void rpmSetVar(int var, const char *val); * This is a colon separated list of files. URI's are permitted as well, * identified by the token '://', so file paths must not begin with '//'. */ +/*@-redecl@*/ extern const char * macrofiles; +/*@=redecl@*/ /** \ingroup rpmrc * Build and install arch/os table identifiers. @@ -561,6 +582,7 @@ void rpmSetMachine(/*@null@*/ const char * arch, /*@null@*/ const char * os); * @retval arch address of arch name (or NULL) * @retval os address of os name (or NULL) */ +/*@unused@*/ void rpmGetMachine( /*@null@*/ /*@out@*/ const char **arch, /*@null@*/ /*@out@*/ const char **os) /*@modifies *arch, *os @*/; @@ -630,11 +652,11 @@ int rpmdbSync (/*@null@*/ rpmdb rpmdb) /** \ingroup rpmdb * Open all database indices. - * @param rpmdb rpm database + * @param db rpm database * @return 0 on success */ -int rpmdbOpenAll (/*@null@*/ rpmdb rpmdb) - /*@modifies fileSystem @*/; +int rpmdbOpenAll (/*@null@*/ rpmdb db) + /*@modifies db, fileSystem @*/; /** \ingroup rpmdb * Return number of instances of package in rpm database. @@ -643,7 +665,7 @@ int rpmdbOpenAll (/*@null@*/ rpmdb rpmdb) * @return number of instances */ int rpmdbCountPackages(rpmdb db, const char * name) - /*@*/; + /*@modifies db @*/; /** \ingroup rpmdb */ @@ -758,36 +780,36 @@ int rpmdbSetIteratorModified(/*@null@*/ rpmdbMatchIterator mi, int modified) /** \ingroup rpmdb * Return database iterator. - * @param rpmdb rpm database + * @param db rpm database * @param rpmtag rpm tag * @param keyp key data (NULL for sequential access) * @param keylen key data length (0 will use strlen(keyp)) * @return NULL on failure */ /*@only@*/ /*@null@*/ rpmdbMatchIterator rpmdbInitIterator( - /*@kept@*/ /*@null@*/ rpmdb rpmdb, int rpmtag, + /*@kept@*/ /*@null@*/ rpmdb db, int rpmtag, /*@null@*/ const void * key, size_t keylen) - /*@modifies fileSystem @*/; + /*@modifies db, fileSystem @*/; /** \ingroup rpmdb * Add package header to rpm database and indices. - * @param rpmdb rpm database + * @param db rpm database * @param iid install transaction id (or -1 to skip) * @param h header * @return 0 on success */ -int rpmdbAdd(rpmdb rpmdb, int iid, Header h) - /*@modifies h, fileSystem @*/; +int rpmdbAdd(rpmdb db, int iid, Header h) + /*@modifies db, h, fileSystem @*/; /** \ingroup rpmdb * Remove package header from rpm database and indices. - * @param rpmdb rpm database + * @param db rpm database * @param rid remove transaction id (or -1 to skip) * @param offset location in Packages dbi * @return 0 on success */ -int rpmdbRemove(rpmdb rpmdb, int rid, unsigned int offset) - /*@modifies fileSystem @*/; +int rpmdbRemove(rpmdb db, int rid, unsigned int offset) + /*@modifies db, fileSystem @*/; /** \ingroup rpmdb * Rebuild database indices from package headers. @@ -882,7 +904,9 @@ void printDepProblems(FILE * fp, const rpmDependencyConflict conflicts, * @param prob rpm problem * @return formatted string */ +/*@-redecl@*/ /*@only@*/ extern const char * rpmProblemString(const rpmProblem prob) /*@*/; +/*@=redecl@*/ /** * Output formatted string representation of problem to file handle. @@ -914,14 +938,16 @@ void rpmProblemSetFree( /*@only@*/ rpmProblemSet probs); * Prototype for headerFreeData() vector. */ typedef /*@null@*/ - void * (*HFD_t) (/*@only@*/ /*@null@*/ const void * data, rpmTagType type); + void * (*HFD_t) (/*@only@*/ /*@null@*/ const void * data, rpmTagType type) + /*@modifies data @*/; /** * Prototype for headerGetEntry() vector. */ -typedef int (*HGE_t) (Header h, int_32 tag, /*@null@*/ /*@out@*/ int_32 * type, +typedef int (*HGE_t) (Header h, int_32 tag, + /*@null@*/ /*@out@*/ int_32 * type, /*@null@*/ /*@out@*/ void ** p, - /*@null@*/ /*@out@*/int_32 * c) + /*@null@*/ /*@out@*/ int_32 * c) /*@modifies *type, *p, *c @*/; /** @@ -1062,6 +1088,7 @@ int rpmtransAddPackage(rpmTransactionSet ts, Header h, /*@null@*/ FD_t fd, * @param h header * @param key package private data */ +/*@unused@*/ void rpmtransAvailablePackage(rpmTransactionSet ts, Header h, /*@null@*/ /*@owned@*/ const void * key) /*@modifies h, ts @*/; @@ -1086,6 +1113,7 @@ void rpmtransFree( /*@only@*/ rpmTransactionSet ts) * @param ts transaction set * @param fd file handle */ +/*@unused@*/ void rpmtransSetScriptFd(rpmTransactionSet ts, FD_t fd) /*@modifies ts, fd @*/; @@ -1097,6 +1125,7 @@ void rpmtransSetScriptFd(rpmTransactionSet ts, FD_t fd) * @retval nep address of no. of returned elements (or NULL) * @return 0 always */ +/*@unused@*/ int rpmtransGetKeys(const rpmTransactionSet ts, /*@null@*/ /*@out@*/ const void *** ep, /*@null@*/ /*@out@*/ int * nep) /*@modifies ep, nep @*/; @@ -1157,15 +1186,21 @@ typedef enum rpmtransFlags_e { RPMTRANS_FLAG_NOTRIGGERS = (1 << 4), /*!< from --notriggers */ RPMTRANS_FLAG_NODOCS = (1 << 5), /*!< from --excludedocs */ RPMTRANS_FLAG_ALLFILES = (1 << 6), /*!< from --allfiles */ +/*@-enummemuse@*/ RPMTRANS_FLAG_KEEPOBSOLETE = (1 << 7), /*!< @todo Document. */ +/*@=enummemuse@*/ RPMTRANS_FLAG_MULTILIB = (1 << 8), /*!< @todo Document. */ RPMTRANS_FLAG_DIRSTASH = (1 << 9), /*!< from --dirstash */ RPMTRANS_FLAG_REPACKAGE = (1 << 10), /*!< from --repackage */ RPMTRANS_FLAG_PKGCOMMIT = (1 << 11), +/*@-enummemuse@*/ RPMTRANS_FLAG_PKGUNDO = (1 << 12), +/*@=enummemuse@*/ RPMTRANS_FLAG_COMMIT = (1 << 13), +/*@-enummemuse@*/ RPMTRANS_FLAG_UNDO = (1 << 14), +/*@=enummemuse@*/ RPMTRANS_FLAG_REVERSE = (1 << 15), RPMTRANS_FLAG_NOTRIGGERPREIN= (1 << 16), @@ -1176,7 +1211,9 @@ typedef enum rpmtransFlags_e { RPMTRANS_FLAG_NOPREUN = (1 << 21), RPMTRANS_FLAG_NOPOSTUN = (1 << 22), RPMTRANS_FLAG_NOTRIGGERPOSTUN = (1 << 23), +/*@-enummemuse@*/ RPMTRANS_FLAG_NOPAYLOAD = (1 << 24), +/*@=enummemuse@*/ RPMTRANS_FLAG_APPLYONLY = (1 << 25), RPMTRANS_FLAG_CHAINSAW = (1 << 26), @@ -1203,6 +1240,7 @@ typedef enum rpmtransFlags_e { * @retval address of array of rpmlib internal provide versions * @return no. of entries */ +/*@unused@*/ int rpmGetRpmlibProvides(/*@out@*/ const char *** provNames, /*@out@*/ int ** provFlags, /*@out@*/ const char *** provVersions) /*@ modifies *provNames, *provFlags, *provVersions @*/; @@ -1280,7 +1318,9 @@ int rpmRunTransactions(rpmTransactionSet ts, * @param tag tag value * @return name of tag */ +/*@-redecl@*/ /*@observer@*/ extern const char *const tagName(int tag) /*@*/; +/*@=redecl@*/ /** * Return value of tag from name. @@ -1313,7 +1353,7 @@ struct rpmlead { char name[66]; short osnum; short signature_type; /*!< Signature header type (RPMSIG_HEADERSIG) */ - char reserved[16]; /*!< Pad to 96 bytes -- 8 byte aligned! */ +/*@unused@*/ char reserved[16]; /*!< Pad to 96 bytes -- 8 byte aligned! */ } ; /** @@ -1445,6 +1485,7 @@ typedef enum rpmQVSources_e { /** \ingroup rpmcli * Bit(s) to control rpmQuery() operation, stored in qva_flags. */ +/*@-typeuse@*/ typedef enum rpmQueryFlags_e { QUERY_FOR_LIST = (1 << 1), /*!< from --list */ QUERY_FOR_STATE = (1 << 2), /*!< from --state */ @@ -1452,16 +1493,19 @@ typedef enum rpmQueryFlags_e { QUERY_FOR_CONFIG = (1 << 4), /*!< from --configfiles */ QUERY_FOR_DUMPFILES = (1 << 8) /*!< from --dump */ } rpmQueryFlags; +/*@=typeuse@*/ /** \ingroup rpmcli * Bit(s) to control rpmVerify() operation, stored in qva_flags. */ +/*@-typeuse@*/ typedef enum rpmVerifyFlags_e { VERIFY_FILES = (1 << 9), /*!< from --nofiles */ VERIFY_DEPS = (1 << 10), /*!< from --nodeps */ VERIFY_SCRIPT = (1 << 11), /*!< from --noscripts */ VERIFY_MD5 = (1 << 12) /*!< from --nomd5 */ } rpmVerifyFlags; +/*@=typeuse@*/ /** \ingroup rpmcli * Describe query/verify command line request. @@ -1470,7 +1514,7 @@ typedef struct rpmQVArguments_s { rpmQVSources qva_source; /*!< Identify CLI arg type. */ int qva_sourceCount;/*!< Exclusive check (>1 is error). */ int qva_flags; /*!< Bit(s) to control operation. */ - int qva_verbose; /*!< (unused) */ +/*@unused@*/ int qva_verbose; /*!< (unused) */ /*@only@*/ /*@null@*/ const char * qva_queryFormat; /*!< Format for headerSprintf(). */ /*@dependent@*/ /*@null@*/ const char * qva_prefix; /*!< Path to top of install tree. */ char qva_mode; /*!< 'q' is query, 'v' is verify mode. */ @@ -1490,7 +1534,8 @@ extern struct poptOption rpmQVSourcePoptTable[]; * @param db rpm database * @param h header to use for query/verify */ -typedef int (*QVF_t) (QVA_t qva, rpmdb db, Header h); +typedef int (*QVF_t) (QVA_t qva, rpmdb db, Header h) + /*@modifies db @*/; /** \ingroup rpmcli * Display query/verify information for each header in iterator. @@ -1500,7 +1545,8 @@ typedef int (*QVF_t) (QVA_t qva, rpmdb db, Header h); * @return result of last non-zero showPackage() return */ int showMatches(QVA_t qva, /*@only@*/ /*@null@*/ rpmdbMatchIterator mi, - QVF_t showPackage); + QVF_t showPackage) + /*@modifies mi @*/; /** \ingroup rpmcli */ @@ -1514,30 +1560,31 @@ extern struct poptOption rpmQueryPoptTable[]; * Display list of tags that can be used in --queryformat. * @param f file handle to use for display */ -void rpmDisplayQueryTags(FILE * f) /*@modifies f@*/; +void rpmDisplayQueryTags(FILE * f) /*@modifies f @*/; /** \ingroup rpmcli * Common query/verify source interface, called once for each CLI arg. * @param qva parsed query/verify options * @param source type of source to query/verify * @param arg name of source to query/verify - * @param rpmdb rpm database + * @param db rpm database * @param showPackage query/verify specific display routine * @return showPackage() result, 1 if rpmdbInitIterator() is NULL */ int rpmQueryVerify(QVA_t qva, rpmQVSources source, const char * arg, - rpmdb rpmdb, QVF_t showPackage) - /*@modifies fileSystem@*/; + rpmdb db, QVF_t showPackage) + /*@modifies db, fileSystem@*/; /** \ingroup rpmcli * Display results of package query. * @todo Devise a meaningful return code. * @param qva parsed query/verify options - * @param rpmdb rpm database (unused for queries) + * @param db rpm database (unused for queries) * @param h header to use for query * @return 0 always */ -int showQueryPackage(QVA_t qva, rpmdb rpmdb, Header h); +int showQueryPackage(QVA_t qva, rpmdb db, Header h) + /*@modifies db, fileSystem @*/; /** \ingroup rpmcli * Display package information. @@ -1556,12 +1603,12 @@ extern struct poptOption rpmVerifyPoptTable[]; /** \ingroup rpmcli * Display results of package verify. * @param qva parsed query/verify options - * @param rpmdb rpm database + * @param db rpm database * @param h header to use for verify * @return result of last non-zero verify return */ -int showVerifyPackage(QVA_t qva, /*@only@*/ rpmdb rpmdb, Header h) - /*@modifies fileSystem@*/; +int showVerifyPackage(QVA_t qva, /*@only@*/ rpmdb db, Header h) + /*@modifies db, fileSystem@*/; /** \ingroup rpmcli * Verify package install. @@ -1653,6 +1700,7 @@ int rpmErase(/*@null@*/ const char * rootdir, /*@null@*/ const char ** argv, /** \ingroup signature * Tags found in signature header from package. */ +/*@-enummemuse@*/ enum rpmtagSignature { RPMSIGTAG_SIZE = 1000, /*!< Size in bytes. */ /* the md5 sum was broken *twice* on big endian machines */ @@ -1684,6 +1732,7 @@ enum rpmtagSignature { RPMTAG_HASH_TIGER192= RPMTAG_HASH_BASE+6, /*!< (unused) */ RPMTAG_HASH_HAVAL_5_160= RPMTAG_HASH_BASE+7 /*!< (unused) */ }; +/*@=enummemuse@*/ /** * Return codes from verifySignature(). diff --git a/lib/rpmrc.c b/lib/rpmrc.c index 94a085868..469b4c7e6 100644 --- a/lib/rpmrc.c +++ b/lib/rpmrc.c @@ -54,8 +54,11 @@ struct rpmvarValue { struct rpmOption { const char * name; int var; - int archSpecific, required, macroize, localize; - struct rpmOptionValue * value; + int archSpecific; +/*@unused@*/ int required; + int macroize; + int localize; +/*@unused@*/ struct rpmOptionValue * value; }; typedef struct defaultEntry_s { @@ -1530,12 +1533,12 @@ void rpmFreeRpmrc(void) } for (i = 0; i < RPMVAR_NUM; i++) { - struct rpmvarValue *this; - while ((this = values[i].next) != NULL) { - values[i].next = this->next; - this->value = _free(this->value); - this->arch = _free(this->arch); - this = _free(this); + struct rpmvarValue * vp; + while ((vp = values[i].next) != NULL) { + values[i].next = vp->next; + vp->value = _free(vp->value); + vp->arch = _free(vp->arch); + vp = _free(vp); } values[i].value = _free(values[i].value); values[i].arch = _free(values[i].arch); diff --git a/lib/signature.h b/lib/signature.h index d81f82b53..2dcc91a4b 100644 --- a/lib/signature.h +++ b/lib/signature.h @@ -14,7 +14,9 @@ typedef enum sigType_e { RPMSIGTYPE_NONE = 0, /*!< unused, legacy. */ RPMSIGTYPE_PGP262_1024 = 1, /*!< unused, legacy. */ +/*@-enummemuse@*/ RPMSIGTYPE_BAD = 2, /*!< Unknown signature type. */ +/*@=enummemuse@*/ RPMSIGTYPE_MD5 = 3, /*!< unused, legacy. */ RPMSIGTYPE_MD5_PGP = 4, /*!< unused, legacy. */ RPMSIGTYPE_HEADERSIG= 5, /*!< Header style signature */ @@ -92,9 +94,11 @@ int rpmLookupSignatureType(int action) /** \ingroup signature * Return path to pgp executable of given type, or NULL when not found. */ +/*@-redecl@*/ /*@null@*/ const char * rpmDetectPGPVersion( /*@null@*/ /*@out@*/ pgpVersion * pgpVer) /*@modifies *pgpVer, fileSystem @*/; +/*@=redecl@*/ #ifdef __cplusplus } diff --git a/lib/stringbuf.c b/lib/stringbuf.c index 3e6b58b41..b5c1cfa8d 100644 --- a/lib/stringbuf.c +++ b/lib/stringbuf.c @@ -25,10 +25,12 @@ struct StringBufRec { /** * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL. - * @param this memory to free + * @param p memory to free * @return NULL always */ -/*@unused@*/ static inline /*@null@*/ void * _free(/*@only@*/ /*@null@*/ const void * p) { +/*@unused@*/ static inline /*@null@*/ void * +_free(/*@only@*/ /*@null@*/ const void * p) /*@modifies *p @*/ +{ if (p != NULL) free((void *)p); return NULL; } diff --git a/lib/stringbuf.h b/lib/stringbuf.h index c5a50eb7c..08dbf0222 100644 --- a/lib/stringbuf.h +++ b/lib/stringbuf.h @@ -15,23 +15,29 @@ extern "C" { /** */ -/*@only@*/ StringBuf newStringBuf(void); +/*@only@*/ StringBuf newStringBuf(void) + /*@*/; /** */ -/*@null@*/ StringBuf freeStringBuf( /*@only@*/ /*@null@*/ StringBuf sb); +/*@null@*/ StringBuf freeStringBuf( /*@only@*/ /*@null@*/ StringBuf sb) + /*@modifies sb @*/; /** */ -void truncStringBuf(StringBuf sb); +/*@unused@*/ +void truncStringBuf(StringBuf sb) + /*@modifies sb @*/; /** */ -/*@observer@*/ char *getStringBuf(StringBuf sb); +/*@observer@*/ char * getStringBuf(StringBuf sb) + /*@*/; /** */ -void stripTrailingBlanksStringBuf(StringBuf sb); +void stripTrailingBlanksStringBuf(StringBuf sb) + /*@modifies sb @*/; /** */ @@ -43,7 +49,8 @@ void stripTrailingBlanksStringBuf(StringBuf sb); /** */ -void appendStringBufAux(StringBuf sb, const char *s, int nl); +void appendStringBufAux(StringBuf sb, const char * s, int nl) + /*@modifies sb @*/; #ifdef __cplusplus } diff --git a/lib/transaction.c b/lib/transaction.c index 3b4965e06..6e37902de 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -1388,17 +1388,23 @@ struct tsIterator_s { }; /** + * Return transaction element order count. + * @param a transaction element iterator + * @return element order count */ -static int tsGetOc(void * this) { - struct tsIterator_s * iter = this; +static int tsGetOc(void * a) { + struct tsIterator_s * iter = a; int oc = iter->ocsave; return oc; } /** + * Return transaction element available package pointer. + * @param a transaction element iterator + * @return available package pointer */ -static /*@dependent@*/ struct availablePackage * tsGetAlp(void * this) { - struct tsIterator_s * iter = this; +static /*@dependent@*/ struct availablePackage * tsGetAlp(void * a) { + struct tsIterator_s * iter = a; struct availablePackage * alp = NULL; int oc = iter->ocsave; @@ -1413,22 +1419,22 @@ static /*@dependent@*/ struct availablePackage * tsGetAlp(void * this) { /** * Destroy transaction element iterator. - * @param this transaction element iterator + * @param a transaction element iterator * @return NULL always */ -static /*@null@*/ void * tsFreeIterator(/*@only@*//*@null@*/ const void * this) +static /*@null@*/ void * tsFreeIterator(/*@only@*//*@null@*/ const void * a) { - return _free(this); + return _free(a); } /** * Create transaction element iterator. - * @param this transaction set + * @param a transaction set * @return transaction element iterator */ -static void * tsInitIterator(/*@kept@*/ const void * this) +static void * tsInitIterator(/*@kept@*/ const void * a) { - rpmTransactionSet ts = (void *)this; + rpmTransactionSet ts = (void *)a; struct tsIterator_s * iter = NULL; iter = xcalloc(1, sizeof(*iter)); @@ -1441,11 +1447,11 @@ static void * tsInitIterator(/*@kept@*/ const void * this) /** * Return next transaction element's file info. - * @param this file info iterator + * @param a file info iterator * @return next index, -1 on termination */ -static /*@dependent@*/ TFI_t tsNextIterator(void * this) { - struct tsIterator_s * iter = this; +static /*@dependent@*/ TFI_t tsNextIterator(void * a) { + struct tsIterator_s * iter = a; rpmTransactionSet ts = iter->ts; TFI_t fi = NULL; int oc = -1; @@ -1526,7 +1532,7 @@ int rpmRunTransactions( rpmTransactionSet ts, #else struct statfs sfb; # if STAT_STATFS4 -/* this platform has the 4-argument version of the statfs call. The last two +/* This platform has the 4-argument version of the statfs call. The last two * should be the size of struct statfs and 0, respectively. The 0 is the * filesystem type, and is always 0 when statfs is called on a mounted * filesystem, as we're doing. diff --git a/lib/verify.c b/lib/verify.c index 2aa421ce2..e50762581 100644 --- a/lib/verify.c +++ b/lib/verify.c @@ -19,7 +19,10 @@ /*@access rpmdb*/ /* XXX compared with NULL */ static int _ie = 0x44332211; -static union _vendian { int i; char b[4]; } *_endian = (union _vendian *)&_ie; +static union _vendian { +/*@unused@*/ int i; + char b[4]; +} *_endian = (union _vendian *)&_ie; #define IS_BIG_ENDIAN() (_endian->b[0] == '\x44') #define IS_LITTLE_ENDIAN() (_endian->b[0] == '\x11') diff --git a/popt/popt.c b/popt/popt.c index 548cbd818..8c42f90c3 100644 --- a/popt/popt.c +++ b/popt/popt.c @@ -477,7 +477,7 @@ findOption(const struct poptOption * opt, /*@null@*/ const char * longName, } static const char * findNextArg(/*@special@*/ poptContext con, - unsigned argx, int delete) + unsigned argx, int delete_arg) /*@uses con->optionStack, con->os, con->os->next, con->os->argb, con->os->argc, con->os->argv @*/ { @@ -495,7 +495,7 @@ static const char * findNextArg(/*@special@*/ poptContext con, if (*os->argv[i] == '-') continue; if (--argx > 0) continue; arg = os->argv[i]; - if (delete) { + if (delete_arg) { if (os->argb == NULL) os->argb = PBM_ALLOC(os->argc); if (os->argb != NULL) /* XXX can't happen */ PBM_SET(i, os->argb); diff --git a/popt/popt.h b/popt/popt.h index b74f7d8c0..52819f5f0 100644 --- a/popt/popt.h +++ b/popt/popt.h @@ -142,7 +142,9 @@ typedef /*@abstract@*/ struct poptContext_s * poptContext; /** \ingroup popt */ #ifndef __cplusplus +/*@-typeuse@*/ typedef struct poptOption * poptOption; +/*@=typeuse@*/ #endif enum poptCallbackReason { POPT_CALLBACK_REASON_PRE, @@ -161,7 +163,8 @@ typedef void (*poptCallbackType) (poptContext con, enum poptCallbackReason reason, /*@null@*/ const struct poptOption * opt, /*@null@*/ const char * arg, - /*@null@*/ const void * data); + /*@null@*/ const void * data) + /*@*/; /** \ingroup popt * Initialize popt context. @@ -176,61 +179,73 @@ typedef void (*poptCallbackType) (poptContext con, /*@dependent@*/ /*@keep@*/ const char * name, int argc, /*@dependent@*/ /*@keep@*/ const char ** argv, /*@dependent@*/ /*@keep@*/ const struct poptOption * options, - int flags); + int flags) + /*@*/; /** \ingroup popt * Reinitialize popt context. * @param con context */ -void poptResetContext(/*@null@*/poptContext con); +void poptResetContext(/*@null@*/poptContext con) + /*@modifies con @*/; /** \ingroup popt * Return value of next option found. * @param con context * @return next option val, -1 on last item, POPT_ERROR_* on error */ -int poptGetNextOpt(/*@null@*/poptContext con); -/* returns NULL if no argument is available */ +int poptGetNextOpt(/*@null@*/poptContext con) + /*@modifies con @*/; +/*@-redecl@*/ /** \ingroup popt + * Return next option argument (if any). * @param con context + * @return option argument, NULL if no more options are available */ -/*@observer@*/ /*@null@*/ const char * poptGetOptArg(/*@null@*/poptContext con); +/*@observer@*/ /*@null@*/ const char * poptGetOptArg(/*@null@*/poptContext con) + /*@modifies con @*/; /** \ingroup popt * Return current option's argument. * @param con context * @return option argument, NULL if no more options are available */ -/*@observer@*/ /*@null@*/ const char * poptGetArg(/*@null@*/poptContext con); +/*@observer@*/ /*@null@*/ const char * poptGetArg(/*@null@*/poptContext con) + /*@modifies con @*/; /** \ingroup popt - * Peek at current option's argument. + * Peek at current option's argument. * @param con context * @return option argument */ -/*@observer@*/ /*@null@*/ const char * poptPeekArg(/*@null@*/poptContext con); +/*@observer@*/ /*@null@*/ const char * poptPeekArg(/*@null@*/poptContext con) + /*@*/; /** \ingroup popt * Return remaining arguments. * @param con context * @return argument array, terminated with NULL */ -/*@observer@*/ /*@null@*/ const char ** poptGetArgs(/*@null@*/poptContext con); +/*@observer@*/ /*@null@*/ const char ** poptGetArgs(/*@null@*/poptContext con) + /*@modifies con @*/; /** \ingroup popt * Return the option which caused the most recent error. * @param con context * @return offending option */ -/*@observer@*/ const char * poptBadOption(/*@null@*/poptContext con, int flags); +/*@observer@*/ const char * poptBadOption(/*@null@*/poptContext con, int flags) + /*@*/; +/*@=redecl@*/ /** \ingroup popt * Destroy context. * @param con context - * @return NULL + * @return NULL always */ -/*@null@*/ poptContext poptFreeContext( /*@only@*/ /*@null@*/ poptContext con); +/*@null@*/ poptContext poptFreeContext( /*@only@*/ /*@null@*/ poptContext con) + /*@modifies con @*/; /** \ingroup popt * Add arguments to context. @@ -238,7 +253,8 @@ int poptGetNextOpt(/*@null@*/poptContext con); * @param argv argument array, NULL terminated * @return 0 on success, POPT_ERROR_OPTSTOODEEP on failure */ -int poptStuffArgs(poptContext con, /*@keep@*/ const char ** argv); +int poptStuffArgs(poptContext con, /*@keep@*/ const char ** argv) + /*@modifies con @*/; /** \ingroup popt * Add alias to context. @@ -248,7 +264,8 @@ int poptStuffArgs(poptContext con, /*@keep@*/ const char ** argv); * @param flags (unused) * @return 0 always */ -int poptAddAlias(poptContext con, struct poptAlias alias, int flags); +int poptAddAlias(poptContext con, struct poptAlias alias, int flags) + /*@modifies con @*/; /** \ingroup popt * Read configuration file. @@ -306,8 +323,10 @@ int poptParseArgvString(const char * s, * @param error popt error * @return error string */ +/*@-redecl@*/ /*@observer@*/ const char *const poptStrerror(const int error) /*@*/; +/*@=redecl@*/ /** \ingroup popt * Limit search for executables. @@ -315,7 +334,8 @@ int poptParseArgvString(const char * s, * @param path single path to search for executables * @param allowAbsolute absolute paths only? */ -void poptSetExecPath(poptContext con, const char * path, int allowAbsolute); +void poptSetExecPath(poptContext con, const char * path, int allowAbsolute) + /*@modifies con @*/; /** \ingroup popt * Print detailed description of options. @@ -323,7 +343,8 @@ void poptSetExecPath(poptContext con, const char * path, int allowAbsolute); * @param f ouput file handle * @param flags (unused) */ -void poptPrintHelp(poptContext con, FILE * f, /*@unused@*/ int flags); +void poptPrintHelp(poptContext con, FILE * f, /*@unused@*/ int flags) + /*@modifies *f @*/; /** \ingroup popt * Print terse description of options. @@ -331,27 +352,40 @@ void poptPrintHelp(poptContext con, FILE * f, /*@unused@*/ int flags); * @param f ouput file handle * @param flags (unused) */ -void poptPrintUsage(poptContext con, FILE * f, /*@unused@*/ int flags); +void poptPrintUsage(poptContext con, FILE * f, /*@unused@*/ int flags) + /*@modifies *f @*/; /** \ingroup popt * Provide text to replace default "[OPTION...]" in help/usage output. * @param con context * @param text replacement text */ -void poptSetOtherOptionHelp(poptContext con, const char * text); +/*@-fcnuse@*/ +void poptSetOtherOptionHelp(poptContext con, const char * text) + /*@modifies con @*/; +/*@=fcnuse@*/ /** \ingroup popt * Return argv[0] from context. * @param con context + * @return argv[0] */ -/*@observer@*/ const char * poptGetInvocationName(poptContext con); +/*@-redecl -fcnuse@*/ +/*@observer@*/ const char * poptGetInvocationName(poptContext con) + /*@*/; +/*@=redecl =fcnuse@*/ /** \ingroup popt * Shuffle argv pointers to remove stripped args, returns new argc. * @param con context + * @param argc no. of args + * @param argv arg vector * @return new argc */ -int poptStrippedArgv(poptContext con, int argc, char ** argv); +/*@-fcnuse@*/ +int poptStrippedArgv(poptContext con, int argc, char ** argv) + /*@modifies *argv @*/; +/*@=fcnuse@*/ #ifdef __cplusplus } diff --git a/popt/popthelp.c b/popt/popthelp.c index 086cd4300..62822fa64 100644 --- a/popt/popthelp.c +++ b/popt/popthelp.c @@ -180,30 +180,30 @@ static int maxArgWidth(const struct poptOption * opt, /*@null@*/ const char * translation_domain) { int max = 0; - int this = 0; + int len = 0; const char * s; if (opt != NULL) while (opt->longName || opt->shortName || opt->arg) { if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) { if (opt->arg) /* XXX program error */ - this = maxArgWidth(opt->arg, translation_domain); - if (this > max) max = this; + len = maxArgWidth(opt->arg, translation_domain); + if (len > max) max = len; } else if (!(opt->argInfo & POPT_ARGFLAG_DOC_HIDDEN)) { - this = sizeof(" ")-1; - if (opt->shortName != '\0') this += sizeof("-X")-1; - if (opt->shortName != '\0' && opt->longName) this += sizeof(", ")-1; + len = sizeof(" ")-1; + if (opt->shortName != '\0') len += sizeof("-X")-1; + if (opt->shortName != '\0' && opt->longName) len += sizeof(", ")-1; if (opt->longName) { - this += ((opt->argInfo & POPT_ARGFLAG_ONEDASH) + len += ((opt->argInfo & POPT_ARGFLAG_ONEDASH) ? sizeof("-")-1 : sizeof("--")-1); - this += strlen(opt->longName); + len += strlen(opt->longName); } s = getArgDescrip(opt, translation_domain); if (s) - this += sizeof("=")-1 + strlen(s); - if (opt->argInfo & POPT_ARGFLAG_OPTIONAL) this += sizeof("[]")-1; - if (this > max) max = this; + len += sizeof("=")-1 + strlen(s); + if (opt->argInfo & POPT_ARGFLAG_OPTIONAL) len += sizeof("[]")-1; + if (len > max) max = len; } opt++; diff --git a/popt/poptint.h b/popt/poptint.h index 3a3ee9be5..59841e0db 100644 --- a/popt/poptint.h +++ b/popt/poptint.h @@ -11,11 +11,11 @@ /** * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL. - * @param this memory to free + * @param p memory to free * @retval NULL always */ -/*@unused@*/ static inline /*@null@*/ void * _free(/*@only@*/ /*@null@*/ const void * this) { - if (this != NULL) free((void *)this); +/*@unused@*/ static inline /*@null@*/ void * _free(/*@only@*/ /*@null@*/ const void * p) { + if (p != NULL) free((void *)p); return NULL; } diff --git a/popt/system.h b/popt/system.h index 8015c6445..2ff758815 100644 --- a/popt/system.h +++ b/popt/system.h @@ -42,9 +42,9 @@ char *alloca (); #define alloca __builtin_alloca #endif +#if !defined(__LCLINT__) /*@only@*/ char * xstrdup (const char *str); -#if !defined(__LCLINT__) #if HAVE_MCHECK_H && defined(__GNUC__) #define vmefail() (fprintf(stderr, "virtual memory exhausted.\n"), exit(EXIT_FAILURE), NULL) #define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail()), (_str))) diff --git a/rpmdb/.lclintrc b/rpmdb/.lclintrc index 0c404400a..51da5f7c4 100644 --- a/rpmdb/.lclintrc +++ b/rpmdb/.lclintrc @@ -7,17 +7,100 @@ +unixlib -# XXX ignore doxygen markings --unrecogcomments +-unrecogcomments # XXX ignore doxygen markings + +#+proto-param-match + +#-deepbreak # shortcut 485 cases + +# --- not-yet at strict level +#+ptrarith +#+bitwisesigned +#+strictops +#+sizeoftype + +#+mod-uncon # shortcut alloca is painful +#+mod-nomods +#+modglobsnomods +#+modstrictglobsnomods + +#+mod-uncon-nomods +#+mod-internal-strict +#+mod-file-sys +#+globnoglobs +#+internalglobs +#+internalglobnoglobs +#+modglobsunchecked +#+warnmissingglobs +#+warnmissingglobsnomods +#+impcheckedstrictglobs +#+impcheckedstrictstatics +#+strictusereleas +#+strictbranchstate +#+strictdestroy +#+modobserveruncon +#+macroempty +#+ansi-reserved-internal +#+evalorderuncon +#+elseifcomplete +#+loopswitchbreak +#+switchswitchbreak +#+looploopcontinue +#+whileblock +#+forempty +#+forblock +#+ifblock +#+noeffectuncon ++topuse +#+unusedspecial +#+export-local +#+oldstyle +#+sys-dir-errors +#controlnestdepth 15 +#stringliterallen 509 +#numstructfields 127 +#numenummembers 127 + +# --- not-yet at checks level +#+predboolptr +-ptrnegate +#-enumint +-relaxquals +#+mustmod # segfault in psm.c:597 +#+allglobs +#+impcheckmodinternals +#+uncheckedglobalias +#+deparrays +#+onlyunqglobaltrans +#+staticinittrans +#+unqualifiedinittrans +#+retalias +#+assignexpose +#+castexpose +#+retexpose +#+readonlytrans +#+sefuncon +#+ansi-reserved ++cpp-names # check for c++ names +#+infloopsuncon +#+looploopbreak +#+switchloopbreak +#+whileempty ++declundef ++export-header ++export-header-var ++redecl ++noparams +#includenest 8 # don't-bother-me-yet parameters --branchstate # ~140 painful --mustfree # ~588 alloca is painful +-branchstate # painful +-mustfree # alloca is painful -# not-yet normal parameters --boolops # ~831 w->n --predboolint # ~574 w->n --type # ~872 +# --- not-yet at standard level +-boolops # w->n +-predboolint # w->n +-type # # -weak paramaters #+boolint diff --git a/rpmdb/db1.c b/rpmdb/db1.c index e742a0a96..0fe7e8818 100644 --- a/rpmdb/db1.c +++ b/rpmdb/db1.c @@ -481,7 +481,8 @@ static int db1close(/*@only@*/ dbiIndex dbi, /*@unused@*/ unsigned int flags) return rc; } -static int db1open(/*@keep@*/ rpmdb rpmdb, int rpmtag, dbiIndex * dbip) +static int db1open(/*@keep@*/ rpmdb rpmdb, int rpmtag, + /*@out@*/ dbiIndex * dbip) { /*@-nestedextern@*/ extern struct _dbiVec db1vec; @@ -571,8 +572,10 @@ exit: /** \ingroup db1 */ +/*@-exportheadervar@*/ struct _dbiVec db1vec = { DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH, db1open, db1close, db1sync, db1copen, db1cclose, db1cdel, db1cget, db1cput, db1ccount, db1byteswapped, db1stat }; +/*@=exportheadervar@*/ diff --git a/rpmdb/db3.c b/rpmdb/db3.c index e83826bbf..61291c4d9 100644 --- a/rpmdb/db3.c +++ b/rpmdb/db3.c @@ -17,6 +17,7 @@ static int _debug = 1; /* XXX if < 0 debugging, > 0 unusual error returns */ #include <rpmurl.h> /* XXX urlPath proto */ #include "rpmdb.h" + #include "debug.h" /*@access rpmdb@*/ @@ -26,6 +27,7 @@ static int _debug = 1; /* XXX if < 0 debugging, > 0 unusual error returns */ /** \ingroup dbi * Hash database statistics. */ +/*@-fielduse@*/ struct dbiHStats_s { unsigned int hash_magic; /*!< hash database magic number. */ unsigned int hash_version; /*!< version of the hash database. */ @@ -68,6 +70,7 @@ struct dbiBStats_s { unsigned int bt_dup_pgfree; /*!< no. of bytes free in duplicate pages. */ unsigned int bt_over_pgfree;/*!< no. of bytes free in overflow pages. */ }; +/*@=fielduse@*/ #if DB_VERSION_MAJOR == 3 #define __USE_DB3 1 @@ -1172,10 +1175,12 @@ static int db3open(/*@keep@*/ rpmdb rpmdb, int rpmtag, dbiIndex * dbip) /** \ingroup db3 */ +/*@-exportheadervar@*/ struct _dbiVec db3vec = { DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH, db3open, db3close, db3sync, db3copen, db3cclose, db3cdel, db3cget, db3cput, db3ccount, db3byteswapped, db3stat }; +/*@=exportheadervar@*/ #endif /* DB_VERSION_MAJOR == 3 */ diff --git a/rpmdb/dbconfig.c b/rpmdb/dbconfig.c index 35bd2c669..c4ed81e19 100644 --- a/rpmdb/dbconfig.c +++ b/rpmdb/dbconfig.c @@ -19,9 +19,9 @@ #if DB_VERSION_MAJOR == 3 #define __USE_DB3 1 -/*@-exportlocal@*/ +/*@-exportlocal -exportheadervar@*/ struct _dbiIndex db3dbi; -/*@=exportlocal@*/ +/*@=exportlocal =exportheadervar@*/ /** \ingroup db3 * Analogue to struct poptOption @@ -39,7 +39,7 @@ struct dbOption { #define _POPT_SET_BIT (POPT_ARG_VAL|POPT_ARGFLAG_OR) #define _POPT_UNSET_BIT (POPT_ARG_VAL|POPT_ARGFLAG_NAND) -/*@-immediatetrans -exportlocal@*/ +/*@-immediatetrans -exportlocal -exportheadervar@*/ /** \ingroup db3 */ struct dbOption rdbOptions[] = { @@ -247,7 +247,7 @@ struct dbOption rdbOptions[] = { { NULL, 0,0, NULL, 0, NULL, NULL } }; -/*@=immediatetrans =exportlocal@*/ +/*@=immediatetrans =exportlocal =exportheadervar@*/ static int dbSaveLong(const struct dbOption * opt, int argInfo, long aLong) { if (argInfo & POPT_ARGFLAG_NOT) @@ -314,6 +314,7 @@ dbiIndex db3Free(dbiIndex dbi) { return dbi; } +/** @todo Set a reasonable "last gasp" default db config. */ static const char *db3_config_default = "db3:hash:mpool:cdb:usecursors:verbose:mp_mmapsize=8Mb:mp_size=512Kb:pagesize=512:perms=0644"; diff --git a/rpmdb/falloc.c b/rpmdb/falloc.c index 2eeaab761..91713c35c 100644 --- a/rpmdb/falloc.c +++ b/rpmdb/falloc.c @@ -42,10 +42,12 @@ struct faFooter { } ; /* =============================================================== */ +/*@-nullassign@*/ static struct FDIO_s fadio_s = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, fadOpen, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; +/*@=nullassign@*/ FDIO_t fadio = /*@-compmempass@*/ &fadio_s /*@=compmempass@*/ ; /* =============================================================== */ diff --git a/rpmdb/fprint.h b/rpmdb/fprint.h index d92320585..221130a9e 100644 --- a/rpmdb/fprint.h +++ b/rpmdb/fprint.h @@ -126,6 +126,7 @@ void fpLookupList(fingerPrintCache cache, const char ** dirNames, * @param h package header * @retval fpList pointer to array of finger prints */ +/*@unused@*/ void fpLookupHeader(fingerPrintCache cache, Header h, fingerPrint * fpList) /*@modifies h, cache, *fpList @*/; diff --git a/rpmdb/rpmdb.c b/rpmdb/rpmdb.c index 7fadd9c94..ac61c58ed 100644 --- a/rpmdb/rpmdb.c +++ b/rpmdb/rpmdb.c @@ -24,13 +24,15 @@ static int _debug = 0; /*@access Header@*/ /* XXX compared with NULL */ /*@access rpmdbMatchIterator@*/ +/*@-redecl@*/ extern int _noDirTokens; +/*@=redecl@*/ static int _rebuildinprogress = 0; static int _db_filter_dups = 1; -/*@-exportlocal@*/ +/*@-exportlocal -exportheadervar@*/ int _filterDbDups = 0; /* Filter duplicate entries ? (bug in pre rpm-3.0.4) */ -/*@=exportlocal@*/ +/*@=exportlocal =exportheadervar@*/ #define _DBI_FLAGS 0 #define _DBI_PERMS 0644 @@ -114,6 +116,7 @@ static void dbiTagsInit(void) dbiTagStr = _free(dbiTagStr); } +/*@-redecl@*/ #if USE_DB1 extern struct _dbiVec db1vec; #define DB1vec &db1vec @@ -134,6 +137,7 @@ extern struct _dbiVec db3vec; #else #define DB3vec NULL #endif +/*@=redecl@*/ /*@-nullassign@*/ static struct _dbiVec *mydbvecs[] = { @@ -998,7 +1002,9 @@ int rpmdbVerify(const char * prefix) /*@=unqualifiedtrans@*/ } + /*@-nullstate@*/ /* FIX: rpmdb->_dbi[] may be NULL. */ xx = rpmdbClose(rpmdb); + /*@=nullstate@*/ if (xx && rc == 0) rc = xx; rpmdb = NULL; } @@ -1742,6 +1748,7 @@ fprintf(stderr, "*** RMW %s %p\n", tagName(rpmtag), dbi->dbi_rmw); mi->mi_dbc = NULL; mi->mi_set = set; mi->mi_setx = 0; + mi->mi_ndups = 0; mi->mi_h = NULL; mi->mi_sorted = 0; mi->mi_cflags = 0; diff --git a/rpmdb/rpmdb.h b/rpmdb/rpmdb.h index 8f77db522..a090119d0 100644 --- a/rpmdb/rpmdb.h +++ b/rpmdb/rpmdb.h @@ -10,13 +10,6 @@ #include "fprint.h" -#ifdef __LCLINT__ -typedef unsigned int u_int32_t; -typedef unsigned short u_int16_t; -typedef unsigned char u_int8_t; -typedef int int32_t; -#endif - typedef /*@abstract@*/ struct _dbiIndexItem * dbiIndexItem; typedef /*@abstract@*/ struct _dbiIndex * dbiIndex; @@ -37,10 +30,12 @@ struct _dbiIndexItem { * A single item in an index database (i.e. the "data saved"). */ struct _dbiIR { - unsigned int recOffset; /*!< byte offset of header in db */ - unsigned int fileNumber; /*!< file array index */ +/*@unused@*/ unsigned int recOffset; /*!< byte offset of header in db */ +/*@unused@*/ unsigned int fileNumber; /*!< file array index */ }; +/*@-typeuse@*/ typedef struct _dbiIR * DBIR_t; +/*@=typeuse@*/ /** \ingroup dbi * Items retrieved from the index database. @@ -72,7 +67,8 @@ struct _dbiVec { * @param rpmtag rpm tag * @return 0 on success */ - int (*open) (rpmdb rpmdb, int rpmtag, /*@out@*/ dbiIndex * dbip); + int (*open) (rpmdb rpmdb, int rpmtag, /*@out@*/ dbiIndex * dbip) + /*@modifies *dbip @*/; /** \ingroup dbi * Close index database, and destroy database handle. @@ -80,7 +76,8 @@ struct _dbiVec { * @param flags (unused) * @return 0 on success */ - int (*close) (/*@only@*/ dbiIndex dbi, unsigned int flags); + int (*close) (/*@only@*/ dbiIndex dbi, unsigned int flags) + /*@modifies dbi, fileSystem @*/; /** \ingroup dbi * Flush pending operations to disk. @@ -88,7 +85,8 @@ struct _dbiVec { * @param flags (unused) * @return 0 on success */ - int (*sync) (dbiIndex dbi, unsigned int flags); + int (*sync) (dbiIndex dbi, unsigned int flags) + /*@modifies fileSystem @*/; /** \ingroup dbi * Open database cursor. @@ -96,7 +94,8 @@ struct _dbiVec { * @param dbcp address of database cursor * @param flags (unused) */ - int (*copen) (dbiIndex dbi, /*@out@*/ DBC ** dbcp, unsigned int flags); + int (*copen) (dbiIndex dbi, /*@out@*/ DBC ** dbcp, unsigned int flags) + /*@modifies dbi, *dbcp @*/; /** \ingroup dbi * Close database cursor. @@ -104,7 +103,8 @@ struct _dbiVec { * @param dbcursor database cursor * @param flags (unused) */ - int (*cclose) (dbiIndex dbi, /*@only@*/ DBC * dbcursor, unsigned int flags); + int (*cclose) (dbiIndex dbi, /*@only@*/ DBC * dbcursor, unsigned int flags) + /*@modifies dbi, *dbcursor @*/; /** \ingroup dbi * Delete (key,data) pair(s) using db->del or dbcursor->c_del. @@ -115,7 +115,9 @@ struct _dbiVec { * @param flags (unused) * @return 0 on success */ - int (*cdel) (dbiIndex dbi, DBC * dbcursor, const void * keyp, size_t keylen, unsigned int flags); + int (*cdel) (dbiIndex dbi, DBC * dbcursor, + const void * keyp, size_t keylen, unsigned int flags) + /*@modifies *dbcursor, fileSystem @*/; /** \ingroup dbi * Retrieve (key,data) pair using db->get or dbcursor->c_get. @@ -131,7 +133,9 @@ struct _dbiVec { int (*cget) (dbiIndex dbi, DBC * dbcursor, /*@out@*/ void ** keypp, /*@out@*/ size_t * keylenp, /*@out@*/ void ** datapp, /*@out@*/ size_t * datalenp, - unsigned int flags); + unsigned int flags) + /*@modifies *dbcursor, *keypp, *keylenp, *datapp, *datalenp, + fileSystem @*/; /** \ingroup dbi * Store (key,data) pair using db->put or dbcursor->c_put. @@ -147,7 +151,8 @@ struct _dbiVec { int (*cput) (dbiIndex dbi, DBC * dbcursor, const void * keyp, size_t keylen, const void * datap, size_t datalen, - unsigned int flags); + unsigned int flags) + /*@modifies *dbcursor, fileSystem @*/; /** \ingroup dbi * Retrieve count of (possible) duplicate items using dbcursor->c_count. @@ -159,14 +164,16 @@ struct _dbiVec { */ int (*ccount) (dbiIndex dbi, DBC * dbcursor, /*@out@*/ unsigned int * countp, - unsigned int flags); + unsigned int flags) + /*@modifies *dbcursor @*/; /** \ingroup dbi * Is database byte swapped? * @param dbi index database handle * @return 0 no */ - int (*byteswapped) (dbiIndex dbi); + int (*byteswapped) (dbiIndex dbi) + /*@*/; /** \ingroup dbi * Save statistics in database handle. @@ -174,7 +181,8 @@ struct _dbiVec { * @param flags retrieve statistics that don't require traversal? * @return 0 on success */ - int (*stat) (dbiIndex dbi, unsigned int flags); + int (*stat) (dbiIndex dbi, unsigned int flags) + /*@modifies dbi @*/; }; @@ -217,8 +225,9 @@ struct _dbiIndex { /* dbenv parameters */ int dbi_lorder; -/*@null@*/ void (*db_errcall) (const char *db_errpfx, char *buffer); -/*@shared@*/ FILE * dbi_errfile; +/*@unused@*/ /*@null@*/ void (*db_errcall) (const char *db_errpfx, char *buffer) + /*@modifies fileSystem @*/; +/*@unused@*/ /*@shared@*/ FILE * dbi_errfile; const char * dbi_errpfx; int dbi_verbose; int dbi_region_init; @@ -229,32 +238,40 @@ struct _dbiIndex { /* lock sub-system parameters */ unsigned int dbi_lk_max; unsigned int dbi_lk_detect; - int dbi_lk_nmodes; - unsigned char *dbi_lk_conflicts; +/*@unused@*/ int dbi_lk_nmodes; +/*@unused@*/ unsigned char * dbi_lk_conflicts; /* log sub-system parameters */ unsigned int dbi_lg_max; unsigned int dbi_lg_bsize; /* transaction sub-system parameters */ unsigned int dbi_tx_max; #if 0 - int (*dbi_tx_recover) (DB_ENV *dbenv, DBT *log_rec, DB_LSN *lsnp, int redo, void *info); + int (*dbi_tx_recover) (DB_ENV *dbenv, DBT *log_rec, + DB_LSN *lsnp, int redo, void *info) + /*@modifies fileSystem @*/; #endif /* dbinfo parameters */ int dbi_cachesize; /*!< */ int dbi_pagesize; /*!< (fs blksize) */ -/*@null@*/ void * (*dbi_malloc) (size_t nbytes); +/*@unused@*/ /*@null@*/ void * (*dbi_malloc) (size_t nbytes) + /*@*/; /* hash access parameters */ unsigned int dbi_h_ffactor; /*!< */ -/*@null@*/ unsigned int (*dbi_h_hash_fcn) (const void *bytes, unsigned int length); +/*@unused@*/ /*@null@*/ unsigned int (*dbi_h_hash_fcn) (const void *bytes, unsigned int length) + /*@modifies internalState @*/; unsigned int dbi_h_nelem; /*!< */ unsigned int dbi_h_flags; /*!< DB_DUP, DB_DUPSORT */ -/*@null@*/ int (*dbi_h_dup_compare_fcn) (const DBT *, const DBT *); +/*@unused@*/ /*@null@*/ int (*dbi_h_dup_compare_fcn) (const DBT *, const DBT *) + /*@modifies internalState @*/; /* btree access parameters */ int dbi_bt_flags; - int dbi_bt_minkey; -/*@null@*/ int (*dbi_bt_compare_fcn) (const DBT *, const DBT *); -/*@null@*/ int (*dbi_bt_dup_compare_fcn) (const DBT *, const DBT *); -/*@null@*/ size_t (*dbi_bt_prefix_fcn) (const DBT *, const DBT *); +/*@unused@*/ int dbi_bt_minkey; +/*@unused@*/ /*@null@*/ int (*dbi_bt_compare_fcn) (const DBT *, const DBT *) + /*@modifies internalState @*/; +/*@unused@*/ /*@null@*/ int (*dbi_bt_dup_compare_fcn) (const DBT *, const DBT *) + /*@modifies internalState @*/; +/*@unused@*/ /*@null@*/ size_t (*dbi_bt_prefix_fcn) (const DBT *, const DBT *) + /*@modifies internalState @*/; /* recno access parameters */ int dbi_re_flags; int dbi_re_delim; @@ -293,12 +310,16 @@ struct rpmdb_s { int db_remove_env; int db_filter_dups; /*@owned@*/ const char *db_errpfx; - void (*db_errcall) (const char *db_errpfx, char *buffer); + void (*db_errcall) (const char *db_errpfx, char *buffer) + /*@*/; /*@shared@*/ FILE * db_errfile; -/*@only@*/ void * (*db_malloc) (size_t nbytes); +/*@only@*/ void * (*db_malloc) (size_t nbytes) + /*@*/; /*@only@*/ void * (*db_realloc) (/*@only@*//*@null@*/ void * ptr, - size_t nbytes); - void (*db_free) (/*@only@*/ void * ptr); + size_t nbytes) + /*@*/; + void (*db_free) (/*@only@*/ void * ptr) + /*@modifies *ptr @*/; int db_ndbi; dbiIndex *_dbi; }; @@ -310,7 +331,9 @@ struct rpmdb_s { enum rpmdbFlags { RPMDB_FLAG_JUSTCHECK = (1 << 0), RPMDB_FLAG_MINIMAL = (1 << 1), +/*@-enummemuse@*/ RPMDB_FLAG_CHROOT = (1 << 2) +/*@=enummemuse@*/ }; #ifdef __cplusplus @@ -322,14 +345,16 @@ extern "C" { * Return new configured index database handle instance. * @param rpmdb rpm database */ -/*@only@*/ /*@null@*/ dbiIndex db3New(/*@keep@*/ rpmdb rpmdb, int rpmtag); +/*@only@*/ /*@null@*/ dbiIndex db3New(/*@keep@*/ rpmdb rpmdb, int rpmtag) + /*@*/; /** \ingroup db3 * Destroy index database handle instance. * @param dbi index database handle * @return NULL always */ -/*@null@*/ dbiIndex db3Free( /*@only@*/ /*@null@*/ dbiIndex dbi); +/*@null@*/ dbiIndex db3Free( /*@only@*/ /*@null@*/ dbiIndex dbi) + /*@*/; /** \ingroup db3 * Format db3 open flags for debugging print. @@ -337,25 +362,32 @@ extern "C" { * @param print_dbenv_flags format db env flags instead? * @return formatted flags (static buffer) */ +/*@-redecl@*/ /*@exposed@*/ extern const char *const prDbiOpenFlags(int dbflags, - int print_dbenv_flags); + int print_dbenv_flags) + /*@*/; +/*@=redecl@*/ /** \ingroup dbi * Return handle for an index database. - * @param rpmdb rpm database + * @param db rpm database * @param rpmtag rpm tag * @param flags (unused) * @return index database handle */ -/*@only@*/ /*@null@*/ dbiIndex dbiOpen(/*@null@*/ rpmdb rpmdb, int rpmtag, - unsigned int flags); +/*@only@*/ /*@null@*/ dbiIndex dbiOpen(/*@null@*/ rpmdb db, int rpmtag, + unsigned int flags) + /*@modifies db @*/; /** \ingroup dbi * @param dbi index database handle * @param dbiflags DBI_WRITECURSOR or DBI_ITERATOR */ -int dbiCopen(dbiIndex dbi, /*@out@*/ DBC ** dbcp, unsigned int dbiflags); -int XdbiCopen(dbiIndex dbi, /*@out@*/ DBC ** dbcp, unsigned int dbiflags, const char *f, unsigned int l); +int dbiCopen(dbiIndex dbi, /*@out@*/ DBC ** dbcp, unsigned int dbiflags) + /*@modifies dbi, *dbcp @*/; +int XdbiCopen(dbiIndex dbi, /*@out@*/ DBC ** dbcp, unsigned int dbiflags, + const char *f, unsigned int l) + /*@modifies dbi, *dbcp @*/; #define dbiCopen(_a,_b,_c) \ XdbiCopen(_a, _b, _c, __FILE__, __LINE__) @@ -366,8 +398,11 @@ int XdbiCopen(dbiIndex dbi, /*@out@*/ DBC ** dbcp, unsigned int dbiflags, const * @param dbi index database handle * @param flags (unused) */ -int dbiCclose(dbiIndex dbi, /*@only@*/ DBC * dbcursor, unsigned int flags); -int XdbiCclose(dbiIndex dbi, /*@only@*/ DBC * dbcursor, unsigned int flags, const char *f, unsigned int l); +int dbiCclose(dbiIndex dbi, /*@only@*/ DBC * dbcursor, unsigned int flags) + /*@modifies dbi @*/; +int XdbiCclose(dbiIndex dbi, /*@only@*/ DBC * dbcursor, unsigned int flags, + const char *f, unsigned int l) + /*@modifies dbi, *dbcursor @*/; #define dbiCclose(_a,_b,_c) \ XdbiCclose(_a, _b, _c, __FILE__, __LINE__) @@ -380,7 +415,8 @@ int XdbiCclose(dbiIndex dbi, /*@only@*/ DBC * dbcursor, unsigned int flags, cons * @return 0 on success */ int dbiDel(dbiIndex dbi, DBC * dbcursor, const void * keyp, size_t keylen, - unsigned int flags); + unsigned int flags) + /*@modifies *dbcursor, fileSystem @*/; /** \ingroup dbi * Retrieve (key,data) pair from index database. @@ -393,10 +429,12 @@ int dbiDel(dbiIndex dbi, DBC * dbcursor, const void * keyp, size_t keylen, * @return 0 on success */ int dbiGet(dbiIndex dbi, DBC * dbcursor, void ** keypp, - /*@null@*/ size_t * keylenp, - /*@null@*/ void ** datapp, - /*@null@*/ size_t * datalenp, - unsigned int flags); + /*@null@*/ size_t * keylenp, + /*@null@*/ void ** datapp, + /*@null@*/ size_t * datalenp, + unsigned int flags) + /*@modifies *dbcursor, *keypp, *keylenp, *datapp, *datalenp, + fileSystem @*/; /** \ingroup dbi * Store (key,data) pair in index database. @@ -409,7 +447,8 @@ int dbiGet(dbiIndex dbi, DBC * dbcursor, void ** keypp, * @return 0 on success */ int dbiPut(dbiIndex dbi, DBC * dbcursor, const void * keyp, size_t keylen, - const void * datap, size_t datalen, unsigned int flags); + const void * datap, size_t datalen, unsigned int flags) + /*@modifies *dbcursor, fileSystem @*/; /** \ingroup dbi * Retrieve count of (possible) duplicate items. @@ -419,8 +458,10 @@ int dbiPut(dbiIndex dbi, DBC * dbcursor, const void * keyp, size_t keylen, * @param flags (unused) * @return 0 on success */ +/*@unused@*/ int dbiCount(dbiIndex dbi, DBC * dbcursor, /*@out@*/ unsigned int * countp, - unsigned int flags); + unsigned int flags) + /*@modifies *dbcursor, fileSystem @*/; /** \ingroup dbi * Verify (and close) index database. @@ -428,7 +469,8 @@ int dbiCount(dbiIndex dbi, DBC * dbcursor, /*@out@*/ unsigned int * countp, * @param flags (unused) * @return 0 on success */ -int dbiVerify(/*@only@*/ dbiIndex dbi, unsigned int flags); +int dbiVerify(/*@only@*/ dbiIndex dbi, unsigned int flags) + /*@modifies dbi, fileSystem @*/; /** \ingroup dbi * Close index database. @@ -436,7 +478,8 @@ int dbiVerify(/*@only@*/ dbiIndex dbi, unsigned int flags); * @param flags (unused) * @return 0 on success */ -int dbiClose(/*@only@*/ dbiIndex dbi, unsigned int flags); +int dbiClose(/*@only@*/ dbiIndex dbi, unsigned int flags) + /*@modifies dbi, fileSystem @*/; /** \ingroup dbi * Flush pending operations to disk. @@ -444,45 +487,53 @@ int dbiClose(/*@only@*/ dbiIndex dbi, unsigned int flags); * @param flags (unused) * @return 0 on success */ -int dbiSync (dbiIndex dbi, unsigned int flags); +int dbiSync (dbiIndex dbi, unsigned int flags) + /*@modifies fileSystem @*/; /** \ingroup dbi * Is database byte swapped? * @param dbi index database handle * @return 0 no */ -int dbiByteSwapped(dbiIndex dbi); +int dbiByteSwapped(dbiIndex dbi) + /*@*/; /** \ingroup db1 * Return base file name for db1 database (legacy). * @param rpmtag rpm tag * @return base file name of db1 database */ -char * db1basename(int rpmtag); +char * db1basename(int rpmtag) + /*@*/; /*@=exportlocal@*/ /** \ingroup rpmdb */ -unsigned int rpmdbGetIteratorFileNum(rpmdbMatchIterator mi); +/*@unused@*/ +unsigned int rpmdbGetIteratorFileNum(rpmdbMatchIterator mi) + /*@*/; /** \ingroup rpmdb - * @param rpmdb rpm database + * @param db rpm database */ -int rpmdbFindFpList(/*@null@*/ rpmdb rpmdb, fingerPrint * fpList, - /*@out@*/dbiIndexSet * matchList, int numItems); +int rpmdbFindFpList(/*@null@*/ rpmdb db, fingerPrint * fpList, + /*@out@*/dbiIndexSet * matchList, int numItems) + /*@modifies db, *matchList @*/; /** \ingroup dbi * Destroy set of index database items. * @param set set of index database items */ -void dbiFreeIndexSet(/*@only@*/ /*@null@*/ dbiIndexSet set); +void dbiFreeIndexSet(/*@only@*/ /*@null@*/ dbiIndexSet set) + /*@modifies set @*/; /** \ingroup dbi * Count items in index database set. * @param set set of index database items * @return number of items */ -unsigned int dbiIndexSetCount(dbiIndexSet set); +unsigned int dbiIndexSetCount(dbiIndexSet set) + /*@*/; /** \ingroup dbi * Return record offset of header from element in index database set. @@ -490,7 +541,8 @@ unsigned int dbiIndexSetCount(dbiIndexSet set); * @param recno index of item in set * @return record offset of header */ -unsigned int dbiIndexRecordOffset(dbiIndexSet set, int recno); +unsigned int dbiIndexRecordOffset(dbiIndexSet set, int recno) + /*@*/; /** \ingroup dbi * Return file index from element in index database set. @@ -498,7 +550,8 @@ unsigned int dbiIndexRecordOffset(dbiIndexSet set, int recno); * @param recno index of item in set * @return file index */ -unsigned int dbiIndexRecordFileNumber(dbiIndexSet set, int recno); +unsigned int dbiIndexRecordFileNumber(dbiIndexSet set, int recno) + /*@*/; #ifdef __cplusplus } diff --git a/rpmdb/rpmhash.h b/rpmdb/rpmhash.h index 4fd243b44..b279a2ef2 100644 --- a/rpmdb/rpmhash.h +++ b/rpmdb/rpmhash.h @@ -14,6 +14,7 @@ extern "C" { /** */ typedef unsigned int (*hashFunctionType) (const void * string) /*@*/; + /** */ typedef int (*hashEqualityType) (const void * key1, const void * key2) /*@*/; @@ -59,7 +60,8 @@ void htFree( /*@only@*/ hashTable ht); * @param data pointer to data value */ void htAddEntry(hashTable ht, /*@owned@*/ const void * key, - /*@owned@*/ const void * data) /*@modifies ht */; + /*@owned@*/ const void * data) + /*@modifies ht */; /** * Retrieve item from hash table. @@ -82,6 +84,7 @@ int htGetEntry(hashTable ht, const void * key, * @param key pointer to key value * @return 1 if the key is present, 0 otherwise */ +/*@unused@*/ int htHasEntry(hashTable ht, const void * key) /*@*/; #ifdef __cplusplus diff --git a/rpmio/base64.h b/rpmio/base64.h index 47092ecb4..2fecb3e5c 100644 --- a/rpmio/base64.h +++ b/rpmio/base64.h @@ -16,6 +16,7 @@ extern "C" { * @retval lenp address of no. bytes of binary data * @return 0 on success */ +/*@unused@*/ int B64decode (const char * s, /*@out@*/ void ** datap, /*@out@*/ size_t *lenp); /** @@ -24,6 +25,7 @@ int B64decode (const char * s, /*@out@*/ void ** datap, /*@out@*/ size_t *lenp); * @param ns no. bytes of data (0 uses strlen(data)) * @return (malloc'd) base64 string */ +/*@unused@*/ char * B64encode (const void * data, size_t ns); #ifdef __cplusplus diff --git a/rpmio/digest.c b/rpmio/digest.c index c2e9628eb..c463d1509 100644 --- a/rpmio/digest.c +++ b/rpmio/digest.c @@ -361,7 +361,10 @@ MD5Transform(DIGEST_CTX ctx) static int _ie = 0x44332211; /*@-redef@*/ -static union _mendian { int i; char b[4]; } *_endian = (union _mendian *)&_ie; +static union _mendian { +/*@unused@*/ int i; + char b[4]; +} *_endian = (union _mendian *)&_ie; /*@=redef@*/ #define IS_BIG_ENDIAN() (_endian->b[0] == '\x44') #define IS_LITTLE_ENDIAN() (_endian->b[0] == '\x11') diff --git a/rpmio/macro.c b/rpmio/macro.c index 60eab1444..1edbd66c1 100644 --- a/rpmio/macro.c +++ b/rpmio/macro.c @@ -76,7 +76,7 @@ typedef struct MacroBuf { static int expandMacro(MacroBuf *mb); -/*@-exportlocal@*/ +/*@-exportlocal -exportheadervar@*/ #define MAX_MACRO_DEPTH 16 int max_macro_depth = MAX_MACRO_DEPTH; @@ -87,17 +87,19 @@ int print_expand_trace = 0; int print_macro_trace = 0; int print_expand_trace = 0; #endif -/*@=exportlocal@*/ +/*@=exportlocal =exportheadervar@*/ #define MACRO_CHUNK_SIZE 16 /** * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL. - * @param this memory to free + * @param p memory to free * @retval NULL always */ -/*@unused@*/ static inline /*@null@*/ void * _free(/*@only@*/ /*@null@*/ const void * this) { - if (this != NULL) free((void *)this); +/*@unused@*/ static inline /*@null@*/ void * +_free(/*@only@*/ /*@null@*/ const void * p) /*@modifies p@*/ +{ + if (p != NULL) free((void *)p); return NULL; } diff --git a/rpmio/rpmerr.h b/rpmio/rpmerr.h index ab8180f4a..c83ba3252 100644 --- a/rpmio/rpmerr.h +++ b/rpmio/rpmerr.h @@ -22,6 +22,7 @@ /** * Tokens used by rpmError(). */ +/*@-enummemuse -typeuse @*/ typedef enum rpmerrCode_e { RPMERR_GDBMOPEN = _em(2), /*!< gdbm open failed */ RPMERR_GDBMREAD = _em(3), /*!< gdbm read failed */ @@ -106,6 +107,7 @@ typedef enum rpmerrCode_e { RPMWARN_RMDIR = _wm(512u+17), /*!< rmdir(2) failed */ RPMWARN_FLOCK = _wm(512u+27) /*!< locking the database failed */ } rpmerrCode; +/*@=enummemuse =typeuse @*/ /** * Retrofit rpmError() onto rpmlog sub-system. @@ -114,7 +116,9 @@ typedef enum rpmerrCode_e { #define rpmErrorCode() rpmlogCode() #define rpmErrorString() rpmlogMessage() #define rpmErrorSetCallback(_cb) rpmlogSetCallback(_cb) +/*@-typeuse@*/ typedef rpmlogCallback rpmErrorCallBackType; +/*@=typeuse@*/ #endif /* H_RPMERR */ diff --git a/rpmio/rpmio.c b/rpmio/rpmio.c index 9ddc7709b..657b40de7 100644 --- a/rpmio/rpmio.c +++ b/rpmio/rpmio.c @@ -95,11 +95,13 @@ int _rpmio_debug = 0; /** * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL. - * @param this memory to free + * @param p memory to free * @retval NULL always */ -/*@unused@*/ static inline /*@null@*/ void * _free(/*@only@*/ /*@null@*/ const void * this) { - if (this != NULL) free((void *)this); +/*@unused@*/ static inline /*@null@*/ void * +_free(/*@only@*/ /*@null@*/ const void * p) /*@modifies p@*/ +{ + if (p != NULL) free((void *)p); return NULL; } diff --git a/rpmio/rpmio.h b/rpmio/rpmio.h index 0533dbeb8..53737a983 100644 --- a/rpmio/rpmio.h +++ b/rpmio/rpmio.h @@ -115,9 +115,11 @@ typedef int fdio_chdir_function_t (const char * path); typedef int fdio_rmdir_function_t (const char * path); typedef int fdio_rename_function_t (const char * oldpath, const char * newpath); typedef int fdio_unlink_function_t (const char * path); +/*@-typeuse@*/ typedef int fdio_stat_function_t (const char * path, struct stat * st); typedef int fdio_lstat_function_t (const char * path, struct stat * st); typedef int fdio_access_function_t (const char * path, int amode); +/*@=typeuse@*/ /*@}*/ @@ -155,69 +157,84 @@ struct FDIO_s { /** \ingroup rpmio * strerror(3) clone. */ -/*@observer@*/ const char * Fstrerror(/*@null@*/ FD_t fd); +/*@-redecl@*/ +/*@observer@*/ const char * Fstrerror(/*@null@*/ FD_t fd) + /*@*/; +/*@=redecl@*/ /** \ingroup rpmio * fread(3) clone. */ -size_t Fread (/*@out@*/ void * buf, size_t size, size_t nmemb, FD_t fd); +size_t Fread(/*@out@*/ void * buf, size_t size, size_t nmemb, FD_t fd) + /*@modifies fd, *buf, fileSystem @*/; /** \ingroup rpmio * fwrite(3) clone. */ -size_t Fwrite (const void * buf, size_t size, size_t nmemb, FD_t fd); - +size_t Fwrite(const void * buf, size_t size, size_t nmemb, FD_t fd) + /*@modifies fd, fileSystem @*/; /** \ingroup rpmio * fseek(3) clone. */ -int Fseek (FD_t fd, _libio_off_t offset, int whence); +int Fseek(FD_t fd, _libio_off_t offset, int whence) + /*@modifies fileSystem @*/; /** \ingroup rpmio * fclose(3) clone. */ -int Fclose ( /*@killref@*/ FD_t fd); +int Fclose( /*@killref@*/ FD_t fd) + /*@modifies fd, fileSystem @*/; /** \ingroup rpmio */ -/*@null@*/ FD_t Fdopen (FD_t fd, const char * fmode); +/*@null@*/ FD_t Fdopen(FD_t fd, const char * fmode) + /*@modifies fd, fileSystem @*/; /** \ingroup rpmio * fopen(3) clone. */ -/*@null@*/ FD_t Fopen (/*@null@*/ const char * path, /*@null@*/ const char * fmode); +/*@null@*/ FD_t Fopen(/*@null@*/ const char * path, + /*@null@*/ const char * fmode) + /*@modifies fileSystem @*/; /** \ingroup rpmio * fflush(3) clone. */ -int Fflush (/*@null@*/ FD_t fd); +int Fflush(/*@null@*/ FD_t fd) + /*@modifies fd, fileSystem @*/; /** \ingroup rpmio * ferror(3) clone. */ -int Ferror (/*@null@*/ FD_t fd); +int Ferror(/*@null@*/ FD_t fd) + /*@*/; /** \ingroup rpmio * fileno(3) clone. */ -int Fileno (FD_t fd); - +int Fileno(FD_t fd) + /*@*/; /** \ingroup rpmio * fcntl(2) clone. */ -int Fcntl (FD_t fd, int op, void *lip); +int Fcntl(FD_t fd, int op, void *lip) + /*@modifies fd, *lip, fileSystem @*/; /** \ingroup rpmio * pread(2) clone. */ -ssize_t Pread(FD_t fd, void * buf, size_t count, _libio_off_t offset); +ssize_t Pread(FD_t fd, void * buf, size_t count, _libio_off_t offset) + /*@modifies fd, *buf, fileSystem @*/; /** \ingroup rpmio * pwrite(2) clone. */ -ssize_t Pwrite(FD_t fd, const void * buf, size_t count, _libio_off_t offset); +ssize_t Pwrite(FD_t fd, const void * buf, size_t count, _libio_off_t offset) + /*@modifies fd, fileSystem @*/; + /*@}*/ /** \ingroup rpmrpc @@ -228,81 +245,97 @@ ssize_t Pwrite(FD_t fd, const void * buf, size_t count, _libio_off_t offset); /** \ingroup rpmrpc * mkdir(2) clone. */ -int Mkdir (const char * path, mode_t mode); +int Mkdir(const char * path, mode_t mode) + /*@modifies fileSystem @*/; /** \ingroup rpmrpc * chdir(2) clone. */ -int Chdir (const char * path); +int Chdir(const char * path) + /*@modifies fileSystem @*/; /** \ingroup rpmrpc * rmdir(2) clone. */ -int Rmdir (const char * path); +int Rmdir(const char * path) + /*@modifies fileSystem @*/; /** \ingroup rpmrpc * rename(2) clone. */ -int Rename (const char * oldpath, const char * newpath); +int Rename(const char * oldpath, const char * newpath) + /*@modifies fileSystem @*/; /** \ingroup rpmrpc * link(2) clone. */ -int Link (const char * oldpath, const char * newpath); +int Link(const char * oldpath, const char * newpath) + /*@modifies fileSystem @*/; /** \ingroup rpmrpc * unlink(2) clone. */ -int Unlink (const char * path); +int Unlink(const char * path) + /*@modifies fileSystem @*/; /** \ingroup rpmrpc * readlink(2) clone. */ -int Readlink(const char * path, char * buf, size_t bufsiz); - +int Readlink(const char * path, char * buf, size_t bufsiz) + /*@modifies *buf, fileSystem @*/; /** \ingroup rpmrpc * stat(2) clone. */ -int Stat (const char * path, /*@out@*/ struct stat * st); +int Stat(const char * path, /*@out@*/ struct stat * st) + /*@modifies *st, fileSystem @*/; /** \ingroup rpmrpc * lstat(2) clone. */ -int Lstat (const char * path, /*@out@*/ struct stat * st); +int Lstat(const char * path, /*@out@*/ struct stat * st) + /*@modifies *st, fileSystem @*/; /** \ingroup rpmrpc * access(2) clone. */ -int Access (const char * path, int amode); +int Access(const char * path, int amode) + /*@modifies fileSystem @*/; /** \ingroup rpmrpc * glob(3) clone. */ -int Glob (const char * pattern, int flags, - int errfunc(const char * epath, int eerrno), /*@out@*/ glob_t * pglob); +int Glob(const char * pattern, int flags, + int errfunc(const char * epath, int eerrno), + /*@out@*/ glob_t * pglob) + /*@modifies *pglob @*/; /** \ingroup rpmrpc * globfree(3) clone. */ -void Globfree( /*@only@*/ glob_t * pglob); +void Globfree( /*@only@*/ glob_t * pglob) + /*@modifies *pglob @*/; /** \ingroup rpmrpc * opendir(3) clone. */ -/*@null@*/ DIR * Opendir (const char * name); +/*@null@*/ DIR * Opendir(const char * name) + /*@modifies fileSystem @*/; /** \ingroup rpmrpc * readdir(3) clone. */ -/*@null@*/ struct dirent * Readdir (DIR * dir); +/*@null@*/ struct dirent * Readdir(DIR * dir) + /*@modifies *dir, fileSystem @*/; /** \ingroup rpmrpc * closedir(3) clone. */ -int Closedir(/*@only@*/ DIR * dir); +int Closedir(/*@only@*/ DIR * dir) + /*@modifies *dir, fileSystem @*/; + /*@}*/ @@ -313,11 +346,14 @@ int Closedir(/*@only@*/ DIR * dir); /** \ingroup rpmio */ -off_t fdSize (FD_t fd); +off_t fdSize(FD_t fd) + /*@modifies fd, fileSystem@*/; /** \ingroup rpmio */ -/*@null@*/ FD_t fdDup(int fdno); +/*@null@*/ FD_t fdDup(int fdno) + /*@modifies fileSystem@*/; + #ifdef UNUSED /*@null@*/ FILE *fdFdopen( /*@only@*/ void * cookie, const char * mode); #endif @@ -326,27 +362,32 @@ off_t fdSize (FD_t fd); /** \ingroup rpmio */ -/*@-shadow@*/ -int fdFileno(void * cookie); -/*@=shadow@*/ +/*@-shadow -declundef -fcnuse@*/ +int fdFileno(void * cookie) + /*@*/; +/*@=shadow =declundef =fcnuse@*/ /*@-exportlocal@*/ /** \ingroup rpmio */ -/*@null@*/ FD_t fdOpen(const char *path, int flags, mode_t mode); +/*@null@*/ FD_t fdOpen(const char *path, int flags, mode_t mode) + /*@modifies fileSystem @*/; /** \ingroup rpmio */ -ssize_t fdRead(void * cookie, /*@out@*/ char * buf, size_t count); +ssize_t fdRead(void * cookie, /*@out@*/ char * buf, size_t count) + /*@modifies *cookie, *buf, fileSystem @*/; /** \ingroup rpmio */ -ssize_t fdWrite(void * cookie, const char * buf, size_t count); +ssize_t fdWrite(void * cookie, const char * buf, size_t count) + /*@modifies *cookie, fileSystem @*/; /** \ingroup rpmio */ -int fdClose( /*@only@*/ void * cookie); +int fdClose( /*@only@*/ void * cookie) + /*@modifies *cookie, fileSystem @*/; /* XXX FD_t reference count debugging wrappers */ #define fdLink(_fd, _msg) fdio->_fdref(_fd, _msg, __FILE__, __LINE__) @@ -356,16 +397,19 @@ int fdClose( /*@only@*/ void * cookie); /** \ingroup rpmio */ -int fdWritable(FD_t fd, int secs); +int fdWritable(FD_t fd, int secs) + /*@modifies fd @*/; /** \ingroup rpmio */ -int fdReadable(FD_t fd, int secs); +int fdReadable(FD_t fd, int secs) + /*@modifies fd @*/; /*@=exportlocal@*/ /** \ingroup rpmio * FTP and HTTP error codes. */ +/*@-typeuse@*/ typedef enum ftperrCode_e { FTPERR_BAD_SERVER_RESPONSE = -1, /*!< Bad server response */ FTPERR_SERVER_IO_ERROR = -2, /*!< Server I/O error */ @@ -380,32 +424,42 @@ typedef enum ftperrCode_e { FTPERR_NIC_ABORT_IN_PROGRESS= -11, /*!< Abort in progress */ FTPERR_UNKNOWN = -100 /*!< Unknown or unexpected error */ } ftperrCode; +/*@=typeuse@*/ /** \ingroup rpmio */ -/*@observer@*/ const char *const ftpStrerror(int errorNumber); +/*@-redecl@*/ +/*@observer@*/ const char *const ftpStrerror(int errorNumber) /*@*/; +/*@=redecl@*/ /** \ingroup rpmio */ -/*@dependent@*/ /*@null@*/ void * ufdGetUrlinfo(FD_t fd); +/*@unused@*/ +/*@dependent@*/ /*@null@*/ void * ufdGetUrlinfo(FD_t fd) /*@*/; /** \ingroup rpmio */ -/*@observer@*/ const char * urlStrerror(const char * url); +/*@-redecl@*/ +/*@unused@*/ +/*@observer@*/ const char * urlStrerror(const char * url) /*@*/; +/*@=redecl@*/ /** \ingroup rpmio */ /*@-exportlocal@*/ -int ufdCopy(FD_t sfd, FD_t tfd); +int ufdCopy(FD_t sfd, FD_t tfd) + /*@modifies sfd, tfd, fileSystem @*/; /*@=exportlocal@*/ /** \ingroup rpmio */ -int ufdGetFile( /*@killref@*/ FD_t sfd, FD_t tfd); +int ufdGetFile( /*@killref@*/ FD_t sfd, FD_t tfd) + /*@modifies sfd, tfd, fileSystem @*/; /** \ingroup rpmio */ -int timedRead(FD_t fd, /*@out@*/ void * bufptr, int length); +int timedRead(FD_t fd, /*@out@*/ void * bufptr, int length) + /*@modifies fd, *bufptr, fileSystem @*/; #define timedRead ufdio->read @@ -436,31 +490,39 @@ int timedRead(FD_t fd, /*@out@*/ void * bufptr, int length); /*@=exportlocal@*/ /*@}*/ -/*@unused@*/ static inline int xislower(int c) {return (c >= 'a' && c <= 'z');} -/*@unused@*/ static inline int xisupper(int c) {return (c >= 'A' && c <= 'Z');} -/*@unused@*/ static inline int xisalpha(int c) { +/*@unused@*/ static inline int xislower(int c) /*@*/ { + return (c >= 'a' && c <= 'z'); +} +/*@unused@*/ static inline int xisupper(int c) /*@*/ { + return (c >= 'A' && c <= 'Z'); +} +/*@unused@*/ static inline int xisalpha(int c) /*@*/ { return (xislower(c) || xisupper(c)); } -/*@unused@*/ static inline int xisdigit(int c) {return (c >= '0' && c <= '9');} -/*@unused@*/ static inline int xisalnum(int c) { +/*@unused@*/ static inline int xisdigit(int c) /*@*/ { + return (c >= '0' && c <= '9'); +} +/*@unused@*/ static inline int xisalnum(int c) /*@*/ { return (xisalpha(c) || xisdigit(c)); } -/*@unused@*/ static inline int xisblank(int c) {return (c == ' ' || c == '\t');} -/*@unused@*/ static inline int xisspace(int c) { +/*@unused@*/ static inline int xisblank(int c) /*@*/ { + return (c == ' ' || c == '\t'); +} +/*@unused@*/ static inline int xisspace(int c) /*@*/ { return (xisblank(c) || c == '\n' || c == '\r' || c == '\f' || c == '\v'); } -/*@unused@*/ static inline int xtolower(int c) { +/*@unused@*/ static inline int xtolower(int c) /*@*/ { return ((xisupper(c)) ? (c | ('a' - 'A')) : c); } -/*@unused@*/ static inline int xtoupper(int c) { +/*@unused@*/ static inline int xtoupper(int c) /*@*/ { return ((xislower(c)) ? (c & ~('a' - 'A')) : c); } /** \ingroup rpmio * Locale insensitive strcasecmp(3). */ -int xstrcasecmp(const char *s1, const char * s2) /*@*/; +int xstrcasecmp(const char * s1, const char * s2) /*@*/; /** \ingroup rpmio * Locale insensitive strncasecmp(3). diff --git a/rpmio/rpmio_api.c b/rpmio/rpmio_api.c index a12899835..f567e3856 100644 --- a/rpmio/rpmio_api.c +++ b/rpmio/rpmio_api.c @@ -13,7 +13,7 @@ /*@access FD_t@*/ -/*@-redef@*/ +/*@-redef -redecl@*/ int fdFileno(void * cookie); /* Yet Another Prototype. */ int fdFileno(void * cookie) { FD_t fd; @@ -21,4 +21,4 @@ int fdFileno(void * cookie) { fd = c2f(cookie); return fd->fps[0].fdno; } -/*@=redef@*/ +/*@=redef =redecl@*/ diff --git a/rpmio/rpmio_internal.h b/rpmio/rpmio_internal.h index ce19ece43..98103d1ff 100644 --- a/rpmio/rpmio_internal.h +++ b/rpmio/rpmio_internal.h @@ -15,37 +15,37 @@ static inline int fdFileno(/*@null@*/ void * cookie); /** \ingroup rpmio */ typedef struct _FDSTACK_s { - FDIO_t io; + FDIO_t io; /*@dependent@*/ void * fp; - int fdno; + int fdno; } FDSTACK_t; /** \ingroup rpmio * Cumulative statistics for an I/O operation. */ typedef struct { - int count; /*!< Number of operations. */ - off_t bytes; /*!< Number of bytes transferred. */ - time_t msecs; /*!< Number of milli-seconds. */ + int count; /*!< Number of operations. */ + off_t bytes; /*!< Number of bytes transferred. */ + time_t msecs; /*!< Number of milli-seconds. */ } OPSTAT_t; /** \ingroup rpmio * Identify per-desciptor I/O operation statistics. */ enum FDSTAT_e { - FDSTAT_READ = 0, /*!< Read statistics index. */ - FDSTAT_WRITE = 1, /*!< Write statistics index. */ - FDSTAT_SEEK = 2, /*!< Seek statistics index. */ - FDSTAT_CLOSE = 3 /*!< Close statistics. index */ + FDSTAT_READ = 0, /*!< Read statistics index. */ + FDSTAT_WRITE = 1, /*!< Write statistics index. */ + FDSTAT_SEEK = 2, /*!< Seek statistics index. */ + FDSTAT_CLOSE = 3 /*!< Close statistics. index */ }; /** \ingroup rpmio * Cumulative statistics for a descriptor. */ typedef /*@abstract@*/ struct { - struct timeval create; /*!< Structure creation time. */ - struct timeval begin; /*!< Operation start time. */ - OPSTAT_t ops[4]; /*!< Cumulative statistics. */ + struct timeval create; /*!< Structure creation time. */ + struct timeval begin; /*!< Operation start time. */ + OPSTAT_t ops[4]; /*!< Cumulative statistics. */ } * FDSTAT_t; /** \ingroup rpmio @@ -65,7 +65,8 @@ typedef /*@abstract@*/ struct DIGEST_CTX_s * DIGEST_CTX; * @param flags bit(s) to control digest operation * @return digest private data */ -DIGEST_CTX rpmDigestInit(rpmDigestFlags flags); +DIGEST_CTX rpmDigestInit(rpmDigestFlags flags) + /*@*/; /** \ingroup rpmio * Update context to with next plain text buffer. @@ -73,7 +74,8 @@ DIGEST_CTX rpmDigestInit(rpmDigestFlags flags); * @param data next data buffer * @param len no. bytes of data */ -void rpmDigestUpdate(DIGEST_CTX ctx, const void * data, size_t len); +void rpmDigestUpdate(DIGEST_CTX ctx, const void * data, size_t len) + /*@modifies ctx @*/; /** \ingroup rpmio * Return digest and destroy context. @@ -87,45 +89,48 @@ void rpmDigestUpdate(DIGEST_CTX ctx, const void * data, size_t len); */ void rpmDigestFinal(/*@only@*/ DIGEST_CTX ctx, /*@null@*/ /*@out@*/ void ** datap, - /*@null@*/ /*@out@*/ size_t *lenp, int asAscii); + /*@null@*/ /*@out@*/ size_t * lenp, int asAscii) + /*@modifies *datap, *lenp @*/; /** \ingroup rpmio * The FD_t File Handle data structure. */ struct _FD_s { -/*@refs@*/ int nrefs; - int flags; +/*@refs@*/ int nrefs; + int flags; #define RPMIO_DEBUG_IO 0x40000000 #define RPMIO_DEBUG_REFS 0x20000000 - int magic; -#define FDMAGIC 0x04463138 - int nfps; - FDSTACK_t fps[8]; - int urlType; /* ufdio: */ - -/*@dependent@*/ void * url; /* ufdio: URL info */ - int rd_timeoutsecs; /* ufdRead: per FD_t timer */ - ssize_t bytesRemain; /* ufdio: */ - ssize_t contentLength; /* ufdio: */ - int persist; /* ufdio: */ - int wr_chunked; /* ufdio: */ - - int syserrno; /* last system errno encountered */ + int magic; +#define FDMAGIC 0x04463138 + int nfps; + FDSTACK_t fps[8]; + int urlType; /* ufdio: */ + +/*@dependent@*/ void * url; /* ufdio: URL info */ + int rd_timeoutsecs; /* ufdRead: per FD_t timer */ + ssize_t bytesRemain; /* ufdio: */ + ssize_t contentLength; /* ufdio: */ + int persist; /* ufdio: */ + int wr_chunked; /* ufdio: */ + + int syserrno; /* last system errno encountered */ /*@observer@*/ const void *errcookie; /* gzdio/bzdio/ufdio: */ - FDSTAT_t stats; /* I/O statistics */ -/*@owned@*/ DIGEST_CTX digest; /* Digest private data */ + FDSTAT_t stats; /* I/O statistics */ +/*@owned@*/ /*@null@*/ DIGEST_CTX digest; /* Digest private data */ - int ftpFileDoneNeeded; /* ufdio: (FTP) */ - unsigned int firstFree; /* fadio: */ - long int fileSize; /* fadio: */ - long int fd_cpioPos; /* cpio: */ + int ftpFileDoneNeeded; /* ufdio: (FTP) */ + unsigned int firstFree; /* fadio: */ + long int fileSize; /* fadio: */ + long int fd_cpioPos; /* cpio: */ }; /*@access FD_t@*/ #define FDSANE(fd) assert(fd && fd->magic == FDMAGIC) +/*@-redecl@*/ extern int _rpmio_debug; +/*@=redecl@*/ #define DBG(_f, _m, _x) \ if ((_rpmio_debug | ((_f) ? ((FD_t)(_f))->flags : 0)) & (_m)) fprintf _x @@ -149,7 +154,9 @@ int ufdClose( /*@only@*/ void * cookie); /** \ingroup rpmio */ /*@unused@*/ static inline -/*@null@*/ const FDIO_t fdGetIo(FD_t fd) { +/*@null@*/ const FDIO_t fdGetIo(FD_t fd) + /*@*/ +{ FDSANE(fd); return fd->fps[fd->nfps].io; } @@ -157,7 +164,9 @@ int ufdClose( /*@only@*/ void * cookie); /** \ingroup rpmio */ /*@unused@*/ static inline -void fdSetIo(FD_t fd, /*@kept@*/ /*@null@*/ FDIO_t io) { +void fdSetIo(FD_t fd, /*@kept@*/ /*@null@*/ FDIO_t io) + /*@modifies fd @*/ +{ FDSANE(fd); fd->fps[fd->nfps].io = io; } @@ -165,7 +174,9 @@ void fdSetIo(FD_t fd, /*@kept@*/ /*@null@*/ FDIO_t io) { /** \ingroup rpmio */ /*@unused@*/ static inline -/*@dependent@*/ /*@null@*/ FILE * fdGetFILE(FD_t fd) { +/*@dependent@*/ /*@null@*/ FILE * fdGetFILE(FD_t fd) + /*@*/ +{ FDSANE(fd); /*@+voidabstract@*/ return ((FILE *)fd->fps[fd->nfps].fp); @@ -175,7 +186,9 @@ void fdSetIo(FD_t fd, /*@kept@*/ /*@null@*/ FDIO_t io) { /** \ingroup rpmio */ /*@unused@*/ static inline -/*@dependent@*/ /*@null@*/ void * fdGetFp(FD_t fd) { +/*@dependent@*/ /*@null@*/ void * fdGetFp(FD_t fd) + /*@*/ +{ FDSANE(fd); return fd->fps[fd->nfps].fp; } @@ -183,7 +196,9 @@ void fdSetIo(FD_t fd, /*@kept@*/ /*@null@*/ FDIO_t io) { /** \ingroup rpmio */ /*@unused@*/ static inline -void fdSetFp(FD_t fd, /*@kept@*/ /*@null@*/ void * fp) { +void fdSetFp(FD_t fd, /*@kept@*/ /*@null@*/ void * fp) + /*@modifies fd @*/ +{ FDSANE(fd); fd->fps[fd->nfps].fp = fp; } @@ -191,7 +206,9 @@ void fdSetFp(FD_t fd, /*@kept@*/ /*@null@*/ void * fp) { /** \ingroup rpmio */ /*@unused@*/ static inline -int fdGetFdno(FD_t fd) { +int fdGetFdno(FD_t fd) + /*@*/ +{ FDSANE(fd); return fd->fps[fd->nfps].fdno; } @@ -199,7 +216,9 @@ int fdGetFdno(FD_t fd) { /** \ingroup rpmio */ /*@unused@*/ static inline -void fdSetFdno(FD_t fd, int fdno) { +void fdSetFdno(FD_t fd, int fdno) + /*@modifies fd @*/ +{ FDSANE(fd); fd->fps[fd->nfps].fdno = fdno; } @@ -208,6 +227,7 @@ void fdSetFdno(FD_t fd, int fdno) { */ /*@unused@*/ static inline void fdSetContentLength(FD_t fd, ssize_t contentLength) + /*@modifies fd @*/ { FDSANE(fd); fd->contentLength = fd->bytesRemain = contentLength; @@ -217,6 +237,7 @@ void fdSetContentLength(FD_t fd, ssize_t contentLength) */ /*@unused@*/ static inline void fdPush(FD_t fd, FDIO_t io, void * fp, int fdno) + /*@modifies fd @*/ { FDSANE(fd); if (fd->nfps >= (sizeof(fd->fps)/sizeof(fd->fps[0]) - 1)) @@ -229,7 +250,9 @@ void fdPush(FD_t fd, FDIO_t io, void * fp, int fdno) /** \ingroup rpmio */ -/*@unused@*/ static inline void fdPop(FD_t fd) { +/*@unused@*/ static inline void fdPop(FD_t fd) + /*@modifies fd @*/ +{ FDSANE(fd); if (fd->nfps < 0) return; fdSetIo(fd, NULL); @@ -241,6 +264,7 @@ void fdPush(FD_t fd, FDIO_t io, void * fp, int fdno) /** \ingroup rpmio */ /*@unused@*/ static inline void fdstat_enter(/*@null@*/ FD_t fd, int opx) + /*@modifies fd @*/ { if (fd == NULL || fd->stats == NULL) return; fd->stats->ops[opx].count++; @@ -250,15 +274,15 @@ void fdPush(FD_t fd, FDIO_t io, void * fp, int fdno) /** \ingroup rpmio */ /*@unused@*/ static inline -time_t tvsub(struct timeval * etv, struct timeval * btv) { +time_t tvsub(/*@null@*/ const struct timeval * etv, + /*@null@*/ const struct timeval * btv) + /*@*/ +{ time_t secs, usecs; - if (!(etv && btv)) return 0; + if (etv == NULL || btv == NULL) return 0; secs = etv->tv_sec - btv->tv_sec; - usecs = etv->tv_usec - btv->tv_usec; - while (usecs < 0) { + for (usecs = etv->tv_usec - btv->tv_usec; usecs < 0; usecs += 1000000) secs++; - usecs += 1000000; - } return ((secs * 1000) + (usecs/1000)); } @@ -266,6 +290,7 @@ time_t tvsub(struct timeval * etv, struct timeval * btv) { */ /*@unused@*/ static inline void fdstat_exit(/*@null@*/ FD_t fd, int opx, ssize_t rc) + /*@modifies fd @*/ { struct timeval end; if (fd == NULL) return; @@ -290,7 +315,9 @@ void fdstat_exit(/*@null@*/ FD_t fd, int opx, ssize_t rc) /** \ingroup rpmio */ /*@unused@*/ static inline -void fdstat_print(/*@null@*/ FD_t fd, const char * msg, FILE * fp) { +void fdstat_print(/*@null@*/ FD_t fd, const char * msg, FILE * fp) + /*@modifies *fp @*/ +{ int opx; if (fd == NULL || fd->stats == NULL) return; for (opx = 0; opx < 4; opx++) { @@ -320,7 +347,9 @@ void fdstat_print(/*@null@*/ FD_t fd, const char * msg, FILE * fp) { /** \ingroup rpmio */ /*@unused@*/ static inline -void fdSetSyserrno(FD_t fd, int syserrno, /*@kept@*/ const void * errcookie) { +void fdSetSyserrno(FD_t fd, int syserrno, /*@kept@*/ const void * errcookie) + /*@modifies fd @*/ +{ FDSANE(fd); fd->syserrno = syserrno; fd->errcookie = errcookie; @@ -329,7 +358,9 @@ void fdSetSyserrno(FD_t fd, int syserrno, /*@kept@*/ const void * errcookie) { /** \ingroup rpmio */ /*@unused@*/ static inline -int fdGetRdTimeoutSecs(FD_t fd) { +int fdGetRdTimeoutSecs(FD_t fd) + /*@*/ +{ FDSANE(fd); return fd->rd_timeoutsecs; } @@ -337,7 +368,9 @@ int fdGetRdTimeoutSecs(FD_t fd) { /** \ingroup rpmio */ /*@unused@*/ static inline -long int fdGetCpioPos(FD_t fd) { +long int fdGetCpioPos(FD_t fd) + /*@*/ +{ FDSANE(fd); return fd->fd_cpioPos; } @@ -345,7 +378,9 @@ long int fdGetCpioPos(FD_t fd) { /** \ingroup rpmio */ /*@unused@*/ static inline -void fdSetCpioPos(FD_t fd, long int cpioPos) { +void fdSetCpioPos(FD_t fd, long int cpioPos) + /*@modifies fd @*/ +{ FDSANE(fd); fd->fd_cpioPos = cpioPos; } @@ -353,7 +388,9 @@ void fdSetCpioPos(FD_t fd, long int cpioPos) { /** \ingroup rpmio */ /*@mayexit@*/ /*@unused@*/ static inline -FD_t c2f(/*@null@*/ void * cookie) { +FD_t c2f(/*@null@*/ void * cookie) + /*@*/ +{ FD_t fd = (FD_t) cookie; FDSANE(fd); /*@-refcounttrans@*/ return fd; /*@=refcounttrans@*/ @@ -362,7 +399,9 @@ FD_t c2f(/*@null@*/ void * cookie) { /** \ingroup rpmio */ /*@unused@*/ static inline -void fdInitMD5(FD_t fd, int flags) { +void fdInitMD5(FD_t fd, int flags) + /*@modifies fd @*/ +{ if (flags) flags = RPMDIGEST_NATIVE; flags |= RPMDIGEST_MD5; fd->digest = rpmDigestInit(flags); @@ -371,14 +410,21 @@ void fdInitMD5(FD_t fd, int flags) { /** \ingroup rpmio */ /*@unused@*/ static inline -void fdInitSHA1(FD_t fd) { +void fdInitSHA1(FD_t fd) + /*@modifies fd @*/ +{ fd->digest = rpmDigestInit(RPMDIGEST_SHA1); } /** \ingroup rpmio */ /*@unused@*/ static inline -void fdFiniMD5(FD_t fd, void **datap, size_t *lenp, int asAscii) { +void fdFiniMD5(FD_t fd, + /*@null@*/ /*@out@*/ void ** datap, + /*@null@*/ /*@out@*/ size_t * lenp, + int asAscii) + /*@modifies fd, *datap, *lenp @*/ +{ if (fd->digest == NULL) { if (datap) *datap = NULL; if (lenp) *lenp = 0; @@ -393,7 +439,12 @@ void fdFiniMD5(FD_t fd, void **datap, size_t *lenp, int asAscii) { /** \ingroup rpmio */ /*@unused@*/ static inline -void fdFiniSHA1(FD_t fd, void **datap, size_t *lenp, int asAscii) { +void fdFiniSHA1(FD_t fd, + /*@null@*/ /*@out@*/ void ** datap, + /*@null@*/ /*@out@*/ size_t * lenp, + int asAscii) + /*@modifies fd, *datap, *lenp @*/ +{ if (fd->digest == NULL) { if (datap) *datap = NULL; if (lenp) *lenp = 0; @@ -409,7 +460,9 @@ void fdFiniSHA1(FD_t fd, void **datap, size_t *lenp, int asAscii) { /** \ingroup rpmio */ /*@unused@*/ static inline -int fdFileno(/*@null@*/ void * cookie) { +int fdFileno(/*@null@*/ void * cookie) + /*@*/ +{ FD_t fd; if (cookie == NULL) return -2; fd = c2f(cookie); diff --git a/rpmio/rpmlog.c b/rpmio/rpmlog.c index 5b28d0119..65c48fba1 100644 --- a/rpmio/rpmlog.c +++ b/rpmio/rpmlog.c @@ -14,11 +14,13 @@ static /*@only@*/ /*@null@*/ rpmlogRec recs = NULL; /** * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL. - * @param this memory to free + * @param p memory to free * @retval NULL always */ -/*@unused@*/ static inline /*@null@*/ void * _free(/*@only@*/ /*@null@*/ const void * this) { - if (this != NULL) free((void *)this); +/*@unused@*/ static inline /*@null@*/ void * +_free(/*@only@*/ /*@null@*/ const void * p) /*@modifies p@*/ +{ + if (p != NULL) free((void *)p); return NULL; } diff --git a/rpmio/rpmlog.h b/rpmio/rpmlog.h index 12877f3b9..dce12e039 100644 --- a/rpmio/rpmlog.h +++ b/rpmio/rpmlog.h @@ -19,6 +19,7 @@ * * priorities (these are ordered) */ +/*@-typeuse@*/ typedef enum rpmlogLvl_e { RPMLOG_EMERG = 0, /*!< system is unusable */ RPMLOG_ALERT = 1, /*!< action must be taken immediately */ @@ -29,6 +30,7 @@ typedef enum rpmlogLvl_e { RPMLOG_INFO = 6, /*!< informational */ RPMLOG_DEBUG = 7 /*!< debug-level messages */ } rpmlogLvl; +/*@=typeuse@*/ #define RPMLOG_PRIMASK 0x07 /* mask to extract priority part (internal) */ /* extract priority */ @@ -65,6 +67,7 @@ RPMCODE rpmprioritynames[] = /** * facility codes */ +/*@-enummemuse -typeuse@*/ typedef enum rpmlogFac_e { RPMLOG_KERN = (0<<3), /*!< kernel messages */ RPMLOG_USER = (1<<3), /*!< random user-level messages */ @@ -92,6 +95,7 @@ typedef enum rpmlogFac_e { #define RPMLOG_NFACILITIES 24 /*!< current number of facilities */ RPMLOG_ERRMSG = (((unsigned)(RPMLOG_NFACILITIES+0))<<3) } rpmlogFac; +/*@=enummemuse =typeuse@*/ #define RPMLOG_FACMASK 0x03f8 /*!< mask to extract facility part */ #define RPMLOG_FAC(p) (((p) & RPMLOG_FACMASK) >> 3) @@ -165,42 +169,51 @@ extern "C" { * Return number of rpmError() ressages. * @return number of messages */ -int rpmlogGetNrecs(void); +int rpmlogGetNrecs(void) /*@*/; /** * Print all rpmError() messages. * @param f file handle (NULL uses stderr) */ -void rpmlogPrint(FILE *f); +void rpmlogPrint(FILE *f) + /*@modifies *f @*/; /** * Close desriptor used to write to system logger. * @todo Implement. */ -void rpmlogClose (void); +/*@unused@*/ +void rpmlogClose (void) + /*@modifies internalState @*/; /** * Open connection to system logger. * @todo Implement. */ -void rpmlogOpen (const char *ident, int option, int facility); +/*@unused@*/ +void rpmlogOpen (const char * ident, int option, int facility) + /*@modifies internalState @*/; /** * Set the log mask level. */ -int rpmlogSetMask (int mask); +int rpmlogSetMask (int mask) + /*@modifies internalState @*/; /** * Generate a log message using FMT string and option arguments. */ -/*@mayexit@*/ /*@printflike@*/ void rpmlog (int pri, const char *fmt, ...); +/*@mayexit@*/ /*@printflike@*/ void rpmlog (int pri, const char *fmt, ...) + /*@modifies internalState @*/; /*@-exportlocal@*/ /** * Return text of last rpmError() message. * @return text of last message */ -/*@observer@*/ /*@null@*/ const char * rpmlogMessage(void); +/*@-redecl@*/ +/*@observer@*/ /*@null@*/ const char * rpmlogMessage(void) /*@*/; +/*@=redecl@*/ /** * Return error code from last rpmError() message. @@ -209,33 +222,37 @@ int rpmlogSetMask (int mask); * and parsed IMHO. * @return code from last message */ -int rpmlogCode(void); +int rpmlogCode(void) /*@*/; /** * Set rpmlog callback function. */ -rpmlogCallback rpmlogSetCallback(rpmlogCallback cb); +rpmlogCallback rpmlogSetCallback(rpmlogCallback cb) + /*@modifies internalState @*/; /*@=exportlocal@*/ /** * Set rpmlog callback function. * @deprecated gnorpm needs, use rpmlogSetCallback() instead. */ -extern rpmlogCallback rpmErrorSetCallback(rpmlogCallback cb); +extern rpmlogCallback rpmErrorSetCallback(rpmlogCallback cb) + /*@modifies internalState @*/; /** * Return error code from last rpmError() message. * @deprecated Perl-RPM needs, use rpmlogCode() instead. * @return code from last message */ -extern int rpmErrorCode(void); +extern int rpmErrorCode(void) /*@*/; /** * Return text of last rpmError() message. * @deprecated gnorpm needs, use rpmlogMessage() instead. * @return text of last message */ -/*@observer@*/ /*@null@*/ extern const char * rpmErrorString(void); +/*@-redecl@*/ +/*@observer@*/ /*@null@*/ extern const char * rpmErrorString(void) /*@*/; +/*@=redecl@*/ #ifdef __cplusplus } diff --git a/rpmio/rpmmacro.h b/rpmio/rpmmacro.h index c14dfa75d..52c29de45 100644 --- a/rpmio/rpmmacro.h +++ b/rpmio/rpmmacro.h @@ -157,8 +157,10 @@ char * rpmExpand (/*@null@*/ const char * arg, ...) * @param path macro(s) to expand (NULL terminates list) * @return canonicalized path (malloc'ed) */ +/*@-redecl@*/ const char * rpmGetPath (/*@null@*/ const char * path, ...) /*@*/; +/*@=redecl@*/ /** * Merge 3 args into path, any or all of which may be a url. @@ -170,10 +172,12 @@ const char * rpmGetPath (/*@null@*/ const char * path, ...) * @param file file URL (often a file, or NULL) * @return expanded, merged, canonicalized path (malloc'ed) */ +/*@-redecl@*/ const char * rpmGenPath (/*@null@*/ const char * root, /*@null@*/ const char * mdir, /*@null@*/ const char * file) /*@*/; +/*@=redecl@*/ /** * Return macro expansion as a numeric value. diff --git a/rpmio/rpmmessages.h b/rpmio/rpmmessages.h index 2538692bb..6b789d78f 100644 --- a/rpmio/rpmmessages.h +++ b/rpmio/rpmmessages.h @@ -67,6 +67,7 @@ typedef /*@only@*/ /*@null@*/ /** */ +/*@unused@*/ void urlSetCallback(rpmCallbackFunction notify, rpmCallbackData notifyData, int notifyCount); diff --git a/rpmio/rpmrpc.c b/rpmio/rpmrpc.c index 8be9a0e54..21eed127e 100644 --- a/rpmio/rpmrpc.c +++ b/rpmio/rpmrpc.c @@ -11,7 +11,9 @@ /*@access FD_t@*/ /*@access urlinfo@*/ +/*@-redecl@*/ extern int _rpmio_debug; +/*@=redecl@*/ /* =============================================================== */ static int ftpMkdir(const char * path, /*@unused@*/ mode_t mode) { diff --git a/rpmio/ugid.h b/rpmio/ugid.h index d81530433..9c5ea46bd 100644 --- a/rpmio/ugid.h +++ b/rpmio/ugid.h @@ -16,6 +16,7 @@ int gnameToGid(const char * thisGname, /*@out@*/ gid_t * gid); /* Call w/ -1 to flush the cache, returns NULL if the user can't be found */ /*@observer@*/ /*@null@*/ char * uidToUname(uid_t uid); +/*@unused@*/ /*@observer@*/ /*@null@*/ char * gidToGname(gid_t gid); #ifdef __cplusplus diff --git a/rpmio/url.c b/rpmio/url.c index 7d101f861..72af1a048 100644 --- a/rpmio/url.c +++ b/rpmio/url.c @@ -41,11 +41,13 @@ static int uCount = 0; /** * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL. - * @param this memory to free + * @param p memory to free * @retval NULL always */ -/*@unused@*/ static inline /*@null@*/ void * _free(/*@only@*/ /*@null@*/ const void * this) { - if (this != NULL) free((void *)this); +/*@unused@*/ static inline /*@null@*/ void * +_free(/*@only@*/ /*@null@*/ const void * p) /*@modifies p@*/ +{ + if (p != NULL) free((void *)p); return NULL; } @@ -88,17 +88,23 @@ enum modes { #define MODES_FOR_TEST (MODES_BT | MODES_IE) #define MODES_FOR_ROOT (MODES_BT | MODES_IE | MODES_QV | MODES_DB) +/*@-exportheadervar@*/ extern int _ftp_debug; extern int noLibio; extern int _rpmio_debug; extern int _url_debug; extern int _noDirTokens; +/*@-varuse@*/ extern const char * rpmNAME; +/*@=varuse@*/ extern const char * rpmEVR; +/*@-varuse@*/ extern int rpmFLAGS; +/*@=varuse@*/ extern struct MacroContext_s rpmCLIMacroContext; +/*@=exportheadervar@*/ /* options for all executables */ @@ -38,6 +38,12 @@ extern time_t timezone; #endif +#ifdef __LCLINT__ +typedef unsigned int u_int32_t; +typedef unsigned short u_int16_t; +typedef unsigned char u_int8_t; +typedef int int32_t; +#endif /* Since major is a function on SVR4, we can't use `ifndef major'. */ #if MAJOR_IN_MKDEV @@ -77,16 +83,22 @@ char *memchr (); #endif #if !defined(HAVE_STPCPY) || defined(__LCLINT__) -char * stpcpy(char * dest, const char * src); +/*@-declundef@*/ +char * stpcpy(char * dest, const char * src) /*@modifies *dest @*/; +/*@=declundef@*/ #endif #if !defined(HAVE_STPNCPY) || defined(__LCLINT__) -char * stpncpy(char * dest, const char * src, size_t n); +/*@-declundef@*/ +char * stpncpy(char * dest, const char * src, size_t n) /*@modifies *dest @*/; +/*@=declundef@*/ #endif #include <errno.h> #ifndef errno +/*@-declundef @*/ extern int errno; +/*@=declundef @*/ #endif #ifdef STDC_HEADERS @@ -112,12 +124,12 @@ char *getenv (const char *name); #include <sys/file.h> #endif -#ifndef SEEK_SET +#if !defined(SEEK_SET) && !defined(__LCLINT__) #define SEEK_SET 0 #define SEEK_CUR 1 #define SEEK_END 2 #endif -#ifndef F_OK +#if !defined(F_OK) && !defined(__LCLINT__) #define F_OK 0 #define X_OK 1 #define W_OK 2 @@ -194,11 +206,14 @@ char *alloca (); #include <malloc.h> #endif -/*@only@*/ void * xmalloc (size_t size); -/*@only@*/ void * xcalloc (size_t nmemb, size_t size); -/*@only@*/ void * xrealloc (/*@only@*/ /*@null@*/ void * ptr, size_t size); -/*@only@*/ char * xstrdup (const char *str); -/*@only@*/ void *vmefail(size_t size); +/*@-declundef@*/ +/*@mayexit@*/ /*@only@*/ void * xmalloc (size_t size) /*@*/; +/*@mayexit@*/ /*@only@*/ void * xcalloc (size_t nmemb, size_t size) /*@*/; +/*@mayexit@*/ /*@only@*/ void * xrealloc (/*@only@*//*@null@*/ void * ptr, + size_t size) /*@*/; +/*@mayexit@*/ /*@only@*/ char * xstrdup (const char *str) /*@*/; +/*@=declundef@*/ +/*@unused@*/ /*@exits@*/ /*@only@*/ void * vmefail(size_t size); #if HAVE_MCHECK_H #include <mcheck.h> |