diff options
author | jbj <devnull@localhost> | 2001-04-29 22:43:01 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2001-04-29 22:43:01 +0000 |
commit | 81ac89f4e6f176f9095e73b34d94d4ccf12da237 (patch) | |
tree | 85ef09056d85954efdee78fa6875611d460b538d /lib | |
parent | c83cfd5ed5b9637a090e57bef5aca5d5b96d00f4 (diff) | |
download | librpm-tizen-81ac89f4e6f176f9095e73b34d94d4ccf12da237.tar.gz librpm-tizen-81ac89f4e6f176f9095e73b34d94d4ccf12da237.tar.bz2 librpm-tizen-81ac89f4e6f176f9095e73b34d94d4ccf12da237.zip |
- more boring lclint annotations and fiddles.
CVS patchset: 4725
CVS date: 2001/04/29 22:43:01
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Makefile.am | 6 | ||||
-rw-r--r-- | lib/db1.c | 23 | ||||
-rw-r--r-- | lib/db2.c | 6 | ||||
-rw-r--r-- | lib/db3.c | 14 | ||||
-rw-r--r-- | lib/dbconfig.c | 2 | ||||
-rw-r--r-- | lib/depends.c | 38 | ||||
-rw-r--r-- | lib/falloc.c | 8 | ||||
-rw-r--r-- | lib/fprint.c | 2 | ||||
-rw-r--r-- | lib/fs.c | 5 | ||||
-rw-r--r-- | lib/fsm.c | 30 | ||||
-rw-r--r-- | lib/getdate.y | 76 | ||||
-rw-r--r-- | lib/hash.c | 11 | ||||
-rw-r--r-- | lib/hash.h | 10 | ||||
-rw-r--r-- | lib/header.c | 18 | ||||
-rw-r--r-- | lib/manifest.c | 4 | ||||
-rw-r--r-- | lib/md5.c | 4 | ||||
-rw-r--r-- | lib/md5.h | 4 | ||||
-rw-r--r-- | lib/misc.c | 7 | ||||
-rw-r--r-- | lib/package.c | 4 | ||||
-rw-r--r-- | lib/psm.c | 26 | ||||
-rw-r--r-- | lib/query.c | 6 | ||||
-rw-r--r-- | lib/rpmchecksig.c | 19 | ||||
-rw-r--r-- | lib/rpmdb.c | 46 | ||||
-rw-r--r-- | lib/rpminstall.c | 6 | ||||
-rw-r--r-- | lib/rpmlead.c | 1 | ||||
-rw-r--r-- | lib/rpmlib.h | 24 | ||||
-rw-r--r-- | lib/rpmrc.c | 42 | ||||
-rw-r--r-- | lib/stringbuf.c | 2 | ||||
-rw-r--r-- | lib/transaction.c | 93 |
29 files changed, 351 insertions, 186 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am index c3fa7fbf7..e3ea50581 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -57,7 +57,11 @@ getdate.c: getdate.y @echo expect 10 shift/reduce conflicts $(YACC) $(srcdir)/getdate.y -@if test -f y.tab.c; then \ - mv y.tab.c getdate.c ;\ + { echo "/*@-unqualifiedtrans -usedef -varuse -globstate@*/";\ + cat y.tab.c ;\ + echo "/*@=unqualifiedtrans =usedef =varuse =globstate@*/";\ + } > getdate.c ;\ + rm -f y.tab.c; \ else \ if test -f getdate.tab.c ; then \ mv getdate.tab.c getdate.c ; \ @@ -39,6 +39,7 @@ static int _debug = 1; /* XXX if < 0 debugging, > 0 unusual error returns */ /*@access rpmdb@*/ /*@access dbiIndex@*/ /*@access dbiIndexSet@*/ +/*@-onlytrans@*/ /* XXX remap DB3 types back into DB1 types */ static inline DBTYPE db3_to_dbtype(int dbitype) @@ -53,7 +54,9 @@ static inline DBTYPE db3_to_dbtype(int dbitype) /*@notreached@*/ return DB_HASH; } +/*@-shadow@*/ static /*@observer@*/ char * db_strerror(int error) +/*@=shadow@*/ { if (error == 0) return ("Successful return: 0"); @@ -213,6 +216,7 @@ static int db1cclose(dbiIndex dbi, /*@unused@*/ DBC * dbcursor, /*@unused@*/ uns return 0; } +/*@-compmempass@*/ static int db1cget(dbiIndex dbi, /*@unused@*/ DBC * dbcursor, void ** keyp, size_t * keylen, void ** datap, size_t * datalen, /*@unused@*/ unsigned int flags) @@ -225,10 +229,12 @@ static int db1cget(dbiIndex dbi, /*@unused@*/ DBC * dbcursor, void ** keyp, memset(&key, 0, sizeof(key)); memset(&data, 0, sizeof(data)); + /*@-unqualifiedtrans@*/ if (keyp) key.data = *keyp; if (keylen) key.size = *keylen; if (datap) data.data = *datap; if (datalen) data.size = *datalen; + /*@=unqualifiedtrans@*/ if (dbi->dbi_rpmtag == RPMDBI_PACKAGES) { FD_t pkgs = dbi->dbi_db; @@ -241,7 +247,9 @@ static int db1cget(dbiIndex dbi, /*@unused@*/ DBC * dbcursor, void ** keyp, } else { dbi->dbi_lastoffset = fadNextOffset(pkgs, dbi->dbi_lastoffset); } + /*@-immediatetrans@*/ key.data = &dbi->dbi_lastoffset; + /*@=immediatetrans@*/ key.size = sizeof(dbi->dbi_lastoffset); } @@ -291,6 +299,7 @@ static int db1cget(dbiIndex dbi, /*@unused@*/ DBC * dbcursor, void ** keyp, return rc; } +/*@=compmempass@*/ static int db1cdel(dbiIndex dbi, /*@unused@*/ DBC * dbcursor, const void * keyp, size_t keylen, /*@unused@*/ unsigned int flags) @@ -308,7 +317,9 @@ static int db1cdel(dbiIndex dbi, /*@unused@*/ DBC * dbcursor, const void * keyp, _mymemset(&key, 0, sizeof(key)); + /*@-usedef@*/ key.data = (void *)keyp; + /*@=usedef@*/ key.size = keylen; rc = db->del(db, &key, 0); @@ -341,9 +352,8 @@ static int db1cput(dbiIndex dbi, /*@unused@*/ DBC * dbcursor, if (offset == 0) { /* XXX simulated offset 0 record */ /* XXX hack: return offset as data, free in db1cput */ - if (data.size == sizeof(offset)) { - free(data.data); - } + if (data.size == sizeof(offset)) + /*@-unqualifiedtrans@*/ free(data.data); /*@=unqualifiedtrans@*/ } else { /* XXX simulated DB_KEYLAST */ Header h = headerLoad(data.data); int newSize = headerSizeof(h, HEADER_MAGIC_NO); @@ -401,13 +411,15 @@ static int db1close(/*@only@*/ dbiIndex dbi, /*@unused@*/ unsigned int flags) return rc; } -static int db1open(rpmdb rpmdb, int rpmtag, dbiIndex * dbip) +static int db1open(/*@keep@*/ rpmdb rpmdb, int rpmtag, dbiIndex * dbip) { + /*@-nestedextern@*/ + extern struct _dbiVec db1vec; + /*@=nestedextern@*/ const char * base = NULL; const char * urlfn = NULL; const char * fn = NULL; dbiIndex dbi = NULL; - extern struct _dbiVec db1vec; int rc = 0; if (dbip) @@ -479,6 +491,7 @@ exit: return rc; } +/*@=onlytrans@*/ /** \ingroup db1 */ @@ -612,13 +612,15 @@ static int db2close(/*@only@*/ dbiIndex dbi, unsigned int flags) return rc; } -static int db2open(rpmdb rpmdb, int rpmtag, dbiIndex * dbip) +static int db2open(/*@keep@*/ rpmdb rpmdb, int rpmtag, dbiIndex * dbip) { + /*@-nestedextern@*/ + extern struct _dbiVec db2vec; + /*@=nestedextern@*/ const char * urlfn = NULL; const char * dbhome; const char * dbfile; const char * dbsubfile; - extern struct _dbiVec db2vec; dbiIndex dbi = NULL; int rc = 0; int xx; @@ -386,7 +386,7 @@ static int db3cclose(dbiIndex dbi, /*@only@*/ DBC * dbcursor, dbi->dbi_rmw = NULL; rc = db3c_close(dbi, dbcursor); } - return rc; + /*@-usereleased -compdef@*/ return rc; /*@=usereleased =compdef@*/ } static int db3copen(dbiIndex dbi, /*@out@*/ DBC ** dbcp, unsigned int flags) @@ -409,7 +409,7 @@ static int db3copen(dbiIndex dbi, /*@out@*/ DBC ** dbcp, unsigned int flags) } if (dbcp) - *dbcp = dbi->dbi_rmw; + /*@-onlytrans@*/ *dbcp = dbi->dbi_rmw; /*@=onlytrans@*/ return rc; } @@ -487,10 +487,12 @@ static int db3cget(dbiIndex dbi, DBC * dbcursor, memset(&key, 0, sizeof(key)); memset(&data, 0, sizeof(data)); + /*@-unqualifiedtrans@*/ if (keyp) key.data = *keyp; if (keylen) key.size = *keylen; if (datap) data.data = *datap; if (datalen) data.size = *datalen; + /*@=unqualifiedtrans@*/ if (dbcursor == NULL) { int _printit; @@ -507,13 +509,17 @@ static int db3cget(dbiIndex dbi, DBC * dbcursor, } if (rc == 0) { + /*@-onlytrans@*/ if (keyp) *keyp = key.data; if (keylen) *keylen = key.size; if (datap) *datap = data.data; if (datalen) *datalen = data.size; + /*@=onlytrans@*/ } + /*@-compmempass@*/ return rc; + /*@=compmempass@*/ } static int db3byteswapped(dbiIndex dbi) @@ -595,11 +601,13 @@ static int db3close(/*@only@*/ dbiIndex dbi, /*@unused@*/ unsigned int flags) static int db3open(/*@keep@*/ rpmdb rpmdb, int rpmtag, dbiIndex * dbip) { + /*@-nestedextern@*/ + extern struct _dbiVec db3vec; + /*@=nestedextern@*/ const char * urlfn = NULL; const char * dbhome; const char * dbfile; const char * dbsubfile; - extern struct _dbiVec db3vec; dbiIndex dbi = NULL; int rc = 0; int xx; diff --git a/lib/dbconfig.c b/lib/dbconfig.c index ffcaa7ba4..8ece273fb 100644 --- a/lib/dbconfig.c +++ b/lib/dbconfig.c @@ -323,7 +323,9 @@ dbiIndex db3New(rpmdb rpmdb, int rpmtag) if (!(dbi->dbi_perms & 0600)) dbi->dbi_perms = 0644; dbi->dbi_mode = rpmdb->db_mode; + /*@-keeptrans@*/ dbi->dbi_rpmdb = rpmdb; + /*@=keeptrans@*/ dbi->dbi_rpmtag = rpmtag; switch (rpmtag) { diff --git a/lib/depends.c b/lib/depends.c index f2168de34..f52e9d984 100644 --- a/lib/depends.c +++ b/lib/depends.c @@ -225,8 +225,8 @@ static int dirInfoCompare(const void * one, const void * two) /*@*/ * @return available package pointer */ static /*@exposed@*/ struct availablePackage * alAddPackage(struct availableList * al, - Header h, /*@dependent@*/ const void * key, - FD_t fd, rpmRelocation * relocs) + Header h, /*@null@*/ /*@dependent@*/ const void * key, + /*@null@*/ FD_t fd, /*@null@*/ rpmRelocation * relocs) { HGE_t hge = (HGE_t)headerGetEntryMinMemory; HFD_t hfd = headerFreeData; @@ -811,7 +811,7 @@ int rpmtransAddPackage(rpmTransactionSet ts, Header h, FD_t fd, } } } - rpmdbFreeIterator(mi); + mi = rpmdbFreeIterator(mi); } if (hge(h, RPMTAG_OBSOLETENAME, &ont, (void **) &obsoletes, &count)) { @@ -848,7 +848,7 @@ int rpmtransAddPackage(rpmTransactionSet ts, Header h, FD_t fd, removePackage(ts, rpmdbGetIteratorOffset(mi), alNum); } } - rpmdbFreeIterator(mi); + mi = rpmdbFreeIterator(mi); } } @@ -1120,10 +1120,10 @@ static int unsatisfiedDepend(rpmTransactionSet ts, while ((h = rpmdbNextIterator(mi)) != NULL) { rpmMessage(RPMMESS_DEBUG, _("%s: %-45s YES (db files)\n"), keyType, keyDepend+2); - rpmdbFreeIterator(mi); + mi = rpmdbFreeIterator(mi); goto exit; } - rpmdbFreeIterator(mi); + mi = rpmdbFreeIterator(mi); } mi = rpmdbInitIterator(ts->rpmdb, RPMTAG_PROVIDENAME, keyName, 0); @@ -1133,11 +1133,11 @@ static int unsatisfiedDepend(rpmTransactionSet ts, if (rangeMatchesDepFlags(h, keyName, keyEVR, keyFlags)) { rpmMessage(RPMMESS_DEBUG, _("%s: %-45s YES (db provides)\n"), keyType, keyDepend+2); - rpmdbFreeIterator(mi); + mi = rpmdbFreeIterator(mi); goto exit; } } - rpmdbFreeIterator(mi); + mi = rpmdbFreeIterator(mi); #ifndef DYING mi = rpmdbInitIterator(ts->rpmdb, RPMTAG_NAME, keyName, 0); @@ -1147,18 +1147,20 @@ static int unsatisfiedDepend(rpmTransactionSet ts, if (rangeMatchesDepFlags(h, keyName, keyEVR, keyFlags)) { rpmMessage(RPMMESS_DEBUG, _("%s: %-45s YES (db package)\n"), keyType, keyDepend+2); - rpmdbFreeIterator(mi); + mi = rpmdbFreeIterator(mi); goto exit; } } - rpmdbFreeIterator(mi); + mi = rpmdbFreeIterator(mi); #endif } if (suggestion) + /*@-dependenttrans@*/ *suggestion = alSatisfiesDepend(&ts->availablePackages, NULL, NULL, keyName, keyEVR, keyFlags); + /*@=dependenttrans@*/ unsatisfied: rpmMessage(RPMMESS_DEBUG, _("%s: %-45s NO\n"), keyType, keyDepend+2); @@ -1356,7 +1358,7 @@ static int checkPackageDeps(rpmTransactionSet ts, struct problemsSet * psp, * Erasing: check name/provides/filename key against each requiredby match. */ static int checkPackageSet(rpmTransactionSet ts, struct problemsSet * psp, - const char * key, /*@only@*/ rpmdbMatchIterator mi) + const char * key, /*@only@*/ /*@null@*/ rpmdbMatchIterator mi) { Header h; int rc = 0; @@ -1368,7 +1370,7 @@ static int checkPackageSet(rpmTransactionSet ts, struct problemsSet * psp, break; } } - rpmdbFreeIterator(mi); + mi = rpmdbFreeIterator(mi); return rc; } @@ -1617,8 +1619,8 @@ static int orderListIndexCmp(const void * one, const void * two) * @retval rp address of last element */ static void addQ(/*@kept@*/ struct availablePackage * p, - struct availablePackage ** qp, - struct availablePackage ** rp) + /*@in@*/ /*@out@*/ struct availablePackage ** qp, + /*@in@*/ /*@out@*/ struct availablePackage ** rp) { struct availablePackage *q, *qprev; @@ -1736,7 +1738,9 @@ rescan: if (p->tsi.tsi_count != 0) continue; p->tsi.tsi_suc = NULL; + /*@-ownedtrans@*/ addQ(p, &q, &r); + /*@=ownedtrans@*/ qlen++; } @@ -2040,8 +2044,7 @@ int rpmdepCheck(rpmTransactionSet ts, } } - rpmdbFreeIterator(mi); - mi = NULL; + mi = rpmdbFreeIterator(mi); } if (ps.num) { @@ -2052,8 +2055,7 @@ int rpmdepCheck(rpmTransactionSet ts, rc = 0; exit: - if (mi != NULL) - rpmdbFreeIterator(mi); + mi = rpmdbFreeIterator(mi); ps.problems = _free(ps.problems); return rc; } diff --git a/lib/falloc.c b/lib/falloc.c index 3a5936fdd..55387c623 100644 --- a/lib/falloc.c +++ b/lib/falloc.c @@ -62,8 +62,10 @@ FD_t fadOpen(const char * path, int flags, mode_t perms) /* XXX Fstrerror */ return NULL; + /*@-modobserver -observertrans@*/ memcpy(fadio, fdio, sizeof(*fadio)); fadio->_open = fadOpen; + /*@=modobserver =observertrans@*/ fdSetIo(fd, fadio); fadSetFirstFree(fd, 0); @@ -80,6 +82,7 @@ FD_t fadOpen(const char * path, int flags, mode_t perms) fadSetFirstFree(fd, 0); fadSetFileSize(fd, sizeof(newHdr)); } else { + memset(&newHdr, 0, sizeof(newHdr)); if (Pread(fd, &newHdr, sizeof(newHdr), 0) != sizeof(newHdr)) { Fclose(fd); return NULL; @@ -310,6 +313,7 @@ void fadFree(FD_t fd, unsigned int offset) nextFreeOffset = fadGetFirstFree(fd); prevFreeOffset = 0; } else { + memset(&prevFreeHeader, 0, sizeof(prevFreeHeader)); if (Pread(fd, &prevFreeHeader, sizeof(prevFreeHeader), prevFreeOffset) != sizeof(prevFreeHeader)) return; @@ -325,16 +329,19 @@ void fadFree(FD_t fd, unsigned int offset) } if (nextFreeOffset) { + memset(&nextFreeHeader, 0, sizeof(nextFreeHeader)); if (Pread(fd, &nextFreeHeader, sizeof(nextFreeHeader), nextFreeOffset) != sizeof(nextFreeHeader)) return; } + memset(&header, 0, sizeof(header)); if (Pread(fd, &header, sizeof(header), offset) != sizeof(header)) return; footerOffset = offset + header.size - sizeof(footer); + memset(&footer, 0, sizeof(footer)); if (Pread(fd, &footer, sizeof(footer), footerOffset) != sizeof(footer)) return; @@ -389,6 +396,7 @@ int fadNextOffset(FD_t fd, unsigned int lastOffset) if (offset >= fadGetFileSize(fd)) return 0; + memset(&header, 0, sizeof(header)); if (Pread(fd, &header, sizeof(header), offset) != sizeof(header)) return 0; diff --git a/lib/fprint.c b/lib/fprint.c index 52f07fd3c..930af90b3 100644 --- a/lib/fprint.c +++ b/lib/fprint.c @@ -130,7 +130,9 @@ static fingerPrint doLookup(fingerPrintCache cache, newEntry->dirName = dn; fp.entry = newEntry; + /*@-kepttrans@*/ htAddEntry(cache->ht, dn, fp.entry); + /*@@kepttrans@*/ } if (fp.entry) { @@ -7,6 +7,8 @@ #include <rpmmacro.h> /* XXX for rpmGetPath */ #include "debug.h" +/*@-usereleased -onlytrans@*/ + struct fsinfo { /*@only@*/ const char * mntPoint; /*!< path to mount point. */ dev_t dev; /*!< devno for mount point. */ @@ -167,8 +169,10 @@ static int getFilesystemList(void) item = *itemptr; /* structure assignment */ mntdir = item.our_mntdir; #if defined(MNTOPT_RO) + /*@-compdef@*/ if (hasmntopt(itemptr, MNTOPT_RO) != NULL) rdonly = 1; + /*@=compdef@*/ #endif # elif GETMNTENT_TWO /* Solaris, maybe others */ @@ -329,3 +333,4 @@ int rpmGetFilesystemUsage(const char ** fileList, int_32 * fssizes, int numFiles return 0; } +/*@=usereleased =onlytrans@*/ @@ -305,6 +305,7 @@ static /*@observer@*/ const char * dnlNextIterator(/*@null@*/ DNLI_t dnli) * @param fsm file state machine data * @return Is chain only partially filled? */ +/*@-compmempass@*/ static int saveHardLink(FSM_t fsm) { struct stat * st = &fsm->sb; @@ -337,15 +338,17 @@ static int saveHardLink(FSM_t fsm) if (fsm->goal == FSM_PKGINSTALL) fsm->li->linksLeft = 0; + /*@-kepttrans@*/ fsm->li->next = fsm->links; + /*@=kepttrans@*/ fsm->links = fsm->li; } if (fsm->goal == FSM_PKGBUILD) --fsm->li->linksLeft; fsm->li->filex[fsm->li->linksLeft] = fsm->ix; - /*@-observertrans@*/ + /*@-observertrans -dependenttrans@*/ fsm->li->nsuffix[fsm->li->linksLeft] = fsm->nsuffix; - /*@=observertrans@*/ + /*@=observertrans =dependenttrans@*/ if (fsm->goal == FSM_PKGINSTALL) fsm->li->linksLeft++; #if 0 @@ -383,6 +386,7 @@ fprintf(stderr, "*** %p link[%d:%d] %d filex %d %s\n", fsm->li, fsm->li->linksLe rc = fsmStage(fsm, FSM_MAP); return rc; } +/*@=compmempass@*/ /** \ingroup payload * Destroy set of hard links. @@ -667,6 +671,7 @@ exit: * @param writeData should data be written? * @return 0 on success */ +/*@-compmempass@*/ static int writeFile(FSM_t fsm, int writeData) /*@modifies fsm @*/ { @@ -786,10 +791,13 @@ static int writeFile(FSM_t fsm, int writeData) exit: if (fsm->rfd) (void) fsmStage(fsm, FSM_RCLOSE); + /*@-dependenttrans@*/ fsm->opath = opath; fsm->path = path; + /*@=dependenttrans@*/ return rc; } +/*@=compmempass@*/ /** \ingroup payload * Write set of linked files to payload stream. @@ -890,6 +898,7 @@ static int fsmMakeLinks(FSM_t fsm) * @param fsm file state machine data * @return 0 on success */ +/*@-compmempass@*/ static int fsmCommitLinks(FSM_t fsm) { const char * path = fsm->path; @@ -922,6 +931,7 @@ static int fsmCommitLinks(FSM_t fsm) fsm->path = path; return rc; } +/*@=compmempass@*/ /** * Remove (if created) directories not explicitly included in package. @@ -938,6 +948,7 @@ static int fsmRmdirs(FSM_t fsm) fsm->path = NULL; dn[0] = '\0'; + /*@-observertrans -dependenttrans@*/ while ((fsm->path = dnlNextIterator(dnli)) != NULL) { int dnlen = strlen(fsm->path); char * te; @@ -962,6 +973,8 @@ static int fsmRmdirs(FSM_t fsm) } while ((te - dn) > fsm->dnlx[dc]); } dnli = dnlFreeIterator(dnli); + /*@=observertrans =dependenttrans@*/ + fsm->path = path; return rc; } @@ -987,6 +1000,7 @@ static int fsmMkdirs(FSM_t fsm) dn[0] = '\0'; fsm->dnlx = (dc ? xcalloc(dc, sizeof(*fsm->dnlx)) : NULL); + /*@-observertrans -dependenttrans@*/ while ((fsm->path = dnlNextIterator(dnli)) != NULL) { int dnlen = strlen(fsm->path); char * te; @@ -1052,12 +1066,15 @@ static int fsmMkdirs(FSM_t fsm) fsm->ldnlen = dnlen; } dnli = dnlFreeIterator(dnli); + /*@=observertrans =dependenttrans@*/ + fsm->path = path; st->st_mode = st_mode; /* XXX restore st->st_mode */ return rc; } +/*@-compmempass@*/ int fsmStage(FSM_t fsm, fileStage stage) { #ifdef UNUSED @@ -1344,7 +1361,9 @@ int fsmStage(FSM_t fsm, fileStage stage) fsm->opath = opath; } + /*@-dependenttrans@*/ fsm->path = path; + /*@=dependenttrans@*/ if (rc != CPIOERR_LSTAT_FAILED) return rc; rc = expandRegular(fsm); } else if (S_ISDIR(st->st_mode)) { @@ -1372,7 +1391,9 @@ int fsmStage(FSM_t fsm, fileStage stage) fsm->wrbuf[st->st_size] = '\0'; /* XXX symlink(fsm->opath, fsm->path) */ - fsm->opath = fsm->wrbuf; /* XXX abuse fsm->path */ + /*@-dependenttrans@*/ + fsm->opath = fsm->wrbuf; + /*@=dependenttrans@*/ rc = fsmStage(fsm, FSM_VERIFY); if (rc == CPIOERR_LSTAT_FAILED) rc = fsmStage(fsm, FSM_SYMLINK); @@ -1496,7 +1517,7 @@ int fsmStage(FSM_t fsm, fileStage stage) rc = fsmStage(fsm, FSM_UNLINK); if (!rc) break; if (!(errno == ENOENT && (fsm->fflags & RPMFILE_MISSINGOK))) - rpmError(RPMERR_UNLINK, + rpmError( (strict_erasures ? RPMERR_UNLINK : RPMWARN_UNLINK), _("%s unlink of %s failed: %s\n"), fiTypeString(fi), fsm->path, strerror(errno)); @@ -1908,6 +1929,7 @@ if (fsm->rdnb != fsm->wrnb) fprintf(stderr, "*** short write: had %d, got %d\n", } return rc; } +/*@=compmempass@*/ /*@obserever@*/ const char *const fileActionString(fileAction a) { diff --git a/lib/getdate.y b/lib/getdate.y index e5a4630f7..2da7e077b 100644 --- a/lib/getdate.y +++ b/lib/getdate.y @@ -108,15 +108,20 @@ struct timeb { unportable getdate.c's), but that seems to cause as many problems as it solves. */ +#if 0 extern struct tm *gmtime(); extern struct tm *localtime(); +#endif + +extern time_t get_date(char * p, struct timeb * now); #define yyparse getdate_yyparse #define yylex getdate_yylex #define yyerror getdate_yyerror -static int yylex (); -static int yyerror (); +static int yyparse (void); +static int yylex (void); +static int yyerror(const char * s); #define EPOCH 1970 #define HOUR(x) ((time_t)(x) * 60) @@ -422,7 +427,7 @@ static TABLE const MonthDayTable[] = { { "thurs", tDAY, 4 }, { "friday", tDAY, 5 }, { "saturday", tDAY, 6 }, - { NULL } + { NULL, 0, 0 } }; /* Time units table. */ @@ -437,7 +442,7 @@ static TABLE const UnitsTable[] = { { "min", tMINUTE_UNIT, 1 }, { "second", tSEC_UNIT, 1 }, { "sec", tSEC_UNIT, 1 }, - { NULL } + { NULL, 0, 0 } }; /* Assorted relative-time words. */ @@ -462,7 +467,7 @@ static TABLE const OtherTable[] = { { "eleventh", tUNUMBER, 11 }, { "twelfth", tUNUMBER, 12 }, { "ago", tAGO, 1 }, - { NULL } + { NULL, 0, 0 } }; /* The timezone table. */ @@ -547,7 +552,7 @@ static TABLE const TimezoneTable[] = { { "nzst", tZONE, -HOUR(12) }, /* New Zealand Standard */ { "nzdt", tDAYZONE, -HOUR(12) }, /* New Zealand Daylight */ { "idle", tZONE, -HOUR(12) }, /* International Date Line East */ - { NULL } + { NULL, 0, 0 } }; /* Military timezone table. */ @@ -577,7 +582,7 @@ static TABLE const MilitaryTable[] = { { "x", tZONE, HOUR(-11) }, { "y", tZONE, HOUR(-12) }, { "z", tZONE, HOUR( 0) }, - { NULL } + { NULL, 0, 0 } }; @@ -585,19 +590,14 @@ static TABLE const MilitaryTable[] = { /* ARGSUSED */ static int -yyerror(s) - char *s; +yyerror(const char * s) { return 0; } static time_t -ToSeconds(Hours, Minutes, Seconds, Meridian) - time_t Hours; - time_t Minutes; - time_t Seconds; - MERIDIAN Meridian; +ToSeconds(time_t Hours, time_t Minutes, time_t Seconds, MERIDIAN Meridian) { if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 59) return -1; @@ -630,15 +630,9 @@ ToSeconds(Hours, Minutes, Seconds, Meridian) * A number from 0 to 99, which means a year from 1900 to 1999, or * The actual year (>=100). */ static time_t -Convert(Month, Day, Year, Hours, Minutes, Seconds, Meridian, DSTmode) - time_t Month; - time_t Day; - time_t Year; - time_t Hours; - time_t Minutes; - time_t Seconds; - MERIDIAN Meridian; - DSTMODE DSTmode; +Convert(time_t Month, time_t Day, time_t Year, + time_t Hours, time_t Minutes, time_t Seconds, + MERIDIAN Meridian, DSTMODE DSTmode) { static int DaysInMonth[12] = { 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 @@ -680,9 +674,7 @@ Convert(Month, Day, Year, Hours, Minutes, Seconds, Meridian, DSTmode) static time_t -DSTcorrect(Start, Future) - time_t Start; - time_t Future; +DSTcorrect(time_t Start, time_t Future) { time_t StartDay; time_t FutureDay; @@ -694,10 +686,7 @@ DSTcorrect(Start, Future) static time_t -RelativeDate(Start, DayOrdinal, DayNumber) - time_t Start; - time_t DayOrdinal; - time_t DayNumber; +RelativeDate(time_t Start, time_t DayOrdinal, time_t DayNumber) { struct tm *tm; time_t now; @@ -711,9 +700,7 @@ RelativeDate(Start, DayOrdinal, DayNumber) static time_t -RelativeMonth(Start, RelMonth) - time_t Start; - time_t RelMonth; +RelativeMonth(time_t Start, time_t RelMonth) { struct tm *tm; time_t Month; @@ -733,8 +720,7 @@ RelativeMonth(Start, RelMonth) static int -LookupWord(buff) - char *buff; +LookupWord(char * buff) { register char *p; register char *q; @@ -840,7 +826,7 @@ LookupWord(buff) static int -yylex() +yylex(void) { register char c; register char *p; @@ -889,17 +875,18 @@ yylex() Count--; } while (Count > 0); } + /*@notreached@*/ + return 0; } #define TM_YEAR_ORIGIN 1900 /* Yield A - B, measured in seconds. */ static long -difftm (a, b) - struct tm *a, *b; +difftm (const struct tm * a, const struct tm * b) { - int ay = a->tm_year + (TM_YEAR_ORIGIN - 1); - int by = b->tm_year + (TM_YEAR_ORIGIN - 1); + unsigned ay = a->tm_year + (TM_YEAR_ORIGIN - 1); + unsigned by = b->tm_year + (TM_YEAR_ORIGIN - 1); int days = ( /* difference in day of year */ a->tm_yday - b->tm_yday @@ -916,9 +903,7 @@ difftm (a, b) } time_t -get_date(p, now) - char *p; - struct timeb *now; +get_date(char * p, struct timeb * now) { struct tm *tm, gmt; struct timeb ftz; @@ -927,6 +912,7 @@ get_date(p, now) time_t nowtime; yyInput = p; + memset(&gmt, 0, sizeof(gmt)); if (now == NULL) { struct tm *gmt_ptr; @@ -947,7 +933,9 @@ get_date(p, now) return -1; if (gmt_ptr != NULL) + /*@-observertrans -dependenttrans@*/ ftz.timezone = difftm (&gmt, tm) / 60; + /*@=observertrans =dependenttrans@*/ else /* We are on a system like VMS, where the system clock is in local time and the system has no concept of timezones. @@ -982,9 +970,11 @@ get_date(p, now) yyHaveTime = 0; yyHaveZone = 0; + /*@-unrecog@*/ if (yyparse() || yyHaveTime > 1 || yyHaveZone > 1 || yyHaveDate > 1 || yyHaveDay > 1) return -1; + /*@=unrecog@*/ if (yyHaveDate || yyHaveTime || yyHaveDay) { Start = Convert(yyMonth, yyDay, yyYear, yyHour, yyMinutes, yySeconds, diff --git a/lib/hash.c b/lib/hash.c index d9f162b86..8bb17f8ae 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -129,16 +129,17 @@ void htFree(hashTable ht) while (b) { n = b->next; if (b->data) { - if (ht->freeData && *b->data) free((void *)*b->data); - free((void *)b->data); + if (ht->freeData) + *b->data = _free(*b->data); + b->data = _free(b->data); } - free(b); + b = _free(b); b = n; } } - free(ht->buckets); - free(ht); + ht->buckets = _free(ht->buckets); + ht = _free(ht); } int htHasEntry(hashTable ht, const void * key) diff --git a/lib/hash.h b/lib/hash.h index 48ff9cab7..402cd29c9 100644 --- a/lib/hash.h +++ b/lib/hash.h @@ -59,7 +59,7 @@ 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. @@ -70,9 +70,11 @@ void htAddEntry(hashTable ht, /*@owned@*/ const void * key, * @retval tableKey address to store key value from bucket (may be NULL) * @return 0 on success, 1 if the item is not found. */ -int htGetEntry(hashTable ht, const void * key, /*@out@*/ const void *** data, - /*@out@*/ int * dataCount, /*@out@*/ const void ** tableKey) - /*@modifies *data, *dataCount, *tableKey @*/; +int htGetEntry(hashTable ht, const void * key, + /*@null@*/ /*@out@*/ const void *** data, + /*@null@*/ /*@out@*/ int * dataCount, + /*@null@*/ /*@out@*/ const void ** tableKey) + /*@modifies *data, *dataCount, *tableKey @*/; /** * Check for key in hash table. diff --git a/lib/header.c b/lib/header.c index e53b45ed9..6f2450540 100644 --- a/lib/header.c +++ b/lib/header.c @@ -363,6 +363,7 @@ static void copyEntry(const struct indexEntry * entry, /*@out@*/ int_32 * type, char * t; int i; + /*@-mods@*/ if (minMem) { *p = xmalloc(tableSize); ptrEntry = (const char **) *p; @@ -374,6 +375,7 @@ static void copyEntry(const struct indexEntry * entry, /*@out@*/ int_32 * type, t += tableSize; memcpy(t, entry->data, entry->length); } + /*@=mods@*/ for (i = 0; i < count; i++) { *ptrEntry++ = t; t = strchr(t, 0); @@ -897,9 +899,11 @@ Header headerReload(Header h, int tag) { Header nh; int length; + /*@-onlytrans@*/ void * uh = doHeaderUnload(h, &length); headerFree(h); + /*@=onlytrans@*/ nh = headerLoad(uh); if (nh == NULL) { free(uh); @@ -1499,7 +1503,9 @@ static void copyData(int_32 type, /*@out@*/ void * dstPtr, const void * srcPtr, break; default: + /*@-mayaliasunique@*/ memcpy(dstPtr, srcPtr, dataLength); + /*@=mayaliasunique@*/ break; } } @@ -1629,7 +1635,9 @@ int headerAddI18NString(Header h, int_32 tag, const char * string, const char * table->info.offset = 0; } else table->data = xrealloc(table->data, table->length + length); + /*@-mayaliasunique@*/ memcpy(((char *)table->data) + table->length, lang, length); + /*@=mayaliasunique@*/ table->length += length; table->info.count++; } @@ -1654,7 +1662,9 @@ int headerAddI18NString(Header h, int_32 tag, const char * string, const char * entry->data = xrealloc(entry->data, entry->length + length); memset(((char *)entry->data) + entry->length, '\0', ghosts); + /*@-mayaliasunique@*/ strcpy(((char *)entry->data) + entry->length + ghosts, string); + /*@=mayaliasunique@*/ entry->length += length; entry->info.count = langNum + 1; @@ -1695,7 +1705,9 @@ int headerAddI18NString(Header h, int_32 tag, const char * string, const char * entry->info.offset = 0; } else free(entry->data); + /*@-dependenttrans@*/ entry->data = buf; + /*@=dependenttrans@*/ } return 0; @@ -1940,7 +1952,9 @@ static int parseFormat(char * str, const struct headerTagTableEntry * tags, if (currToken < 0 || format[currToken].type != PTOK_STRING) { currToken++; format[currToken].type = PTOK_STRING; + /*@-temptrans@*/ dst = format[currToken].u.string.string = start; + /*@=temptrans@*/ } start++; @@ -2112,7 +2126,9 @@ static int parseFormat(char * str, const struct headerTagTableEntry * tags, if (currToken < 0 || format[currToken].type != PTOK_STRING) { currToken++; format[currToken].type = PTOK_STRING; + /*@-temptrans@*/ dst = format[currToken].u.string.string = start; + /*@=temptrans@*/ } if (*start == '\\') { @@ -2594,7 +2610,9 @@ char * headerSprintf(Header h, const char * origFmt, const char * piece; int pieceLength; + /*@-mods@*/ piece = singleSprintf(h, format + i, extensions, extCache, 0); + /*@=mods@*/ if (piece) { pieceLength = strlen(piece); if ((answerLength + pieceLength) >= answerAlloced) { diff --git a/lib/manifest.c b/lib/manifest.c index 9526a2e03..06d639fb1 100644 --- a/lib/manifest.c +++ b/lib/manifest.c @@ -146,8 +146,8 @@ int rpmReadPackageManifest(FD_t fd, int * argcPtr, const char *** argvPtr) exit: if (argvPtr == NULL || (rc != 0 && av)) { for (i = 0; i < ac; i++) - av[i] = _free(av[i]); - av = _free(av); + /*@-unqualifiedtrans@*/av[i] = _free(av[i]); /*@=unqualifiedtrans@*/ + /*@-dependenttrans@*/ av = _free(av); /*@=dependenttrans@*/ } freeStringBuf(sb); return rc; @@ -122,7 +122,9 @@ void rpmMD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len * Final wrapup - pad to 64-byte boundary with the bit pattern * 1 0* (64-bit count of bits processed, MSB-first) */ +/*@-fixedformalarray@*/ void rpmMD5Final(unsigned char digest[16], struct MD5Context *ctx) +/*@=fixedformalarray@*/ { unsigned count; unsigned char *p; @@ -183,7 +185,9 @@ void rpmMD5Final(unsigned char digest[16], struct MD5Context *ctx) * reflect the addition of 16 longwords of new data. rpmMD5Update blocks * the data and converts bytes into longwords for this routine. */ +/*@-fixedformalarray@*/ void rpmMD5Transform(uint32 buf[4], uint32 const in[16]) +/*@=fixedformalarray@*/ { register uint32 a, b, c, d; @@ -51,7 +51,9 @@ void rpmMD5Update(struct MD5Context *context, unsigned char const *buf, * @retval MD5 digest * @param context MD5 private data */ +/*@-fixedformalarray@*/ void rpmMD5Final(unsigned char digest[16], struct MD5Context *context); +/*@=fixedformalarray@*/ /** * The core of the MD5 algorithm. @@ -60,7 +62,9 @@ void rpmMD5Final(unsigned char digest[16], struct MD5Context *context); * @param buf current MD5 variables * @param in next block of data to add */ +/*@-fixedformalarray@*/ void rpmMD5Transform(uint32 buf[4], uint32 const in[16]); +/*@=fixedformalarray@*/ /** * Return MD5 sum of file as ASCII string. diff --git a/lib/misc.c b/lib/misc.c index a95774129..0b0c4acf1 100644 --- a/lib/misc.c +++ b/lib/misc.c @@ -56,7 +56,9 @@ char ** splitString(const char * str, int length, char sep) void freeSplitString(char ** list) { + /*@-unqualifiedtrans@*/ list[0] = _free(list[0]); + /*@=unqualifiedtrans@*/ list = _free(list); } @@ -355,7 +357,9 @@ int makeTempFile(const char * prefix, const char ** fnptr, FD_t * fdptr) errxit: tempfn = _free(tempfn); + /*@-usereleased@*/ if (fd) Fclose(fd); + /*@=usereleased@*/ return 1; } @@ -430,6 +434,7 @@ void compressFilelist(Header h) char savechar; int len = baseName - fileNames[i]; + needle = dirNames; savechar = *baseName; *baseName = '\0'; if (dirIndex < 0 || @@ -656,7 +661,9 @@ if (_debug) fprintf(stderr, "*** rpmGlob argv[%d] \"%s\"\n", argc, globURL); argv[argc++] = xstrdup(globURL); } + /*@-immediatetrans@*/ Globfree(&gl); + /*@=immediatetrans@*/ globURL = _free(globURL); } if (argv != NULL && argc > 0) { diff --git a/lib/package.c b/lib/package.c index e71c5efa6..b3d256462 100644 --- a/lib/package.c +++ b/lib/package.c @@ -19,6 +19,7 @@ /*@access Header@*/ /* XXX compared with NULL */ +/*@-mods@*/ void headerMergeLegacySigs(Header h, const Header sig) { HeaderIterator hi; @@ -76,6 +77,7 @@ Header headerRegenSigHeader(const Header h) headerFreeIterator(hi); return sig; } +/*@=mods@*/ /** * Retrieve package components from file handle. @@ -216,8 +218,10 @@ rpmRC rpmReadPackageHeader(FD_t fd, Header * hdrp, int * isSource, int * major, } if (isSource) *isSource = lead.type == RPMLEAD_SOURCE; + /*@-mods@*/ if (major) *major = lead.major; if (minor) *minor = lead.minor; + /*@=mods@*/ exit: return rc; @@ -523,7 +523,7 @@ static int markReplacedFiles(PSM_t psm) sfi++; } } - rpmdbFreeIterator(mi); + mi = rpmdbFreeIterator(mi); return 0; } @@ -564,6 +564,7 @@ static rpmRC chkdir (const char * dpath, const char * dname) return RPMRC_OK; } +/*@-compmempass@*/ rpmRC rpmInstallSourcePackage(const char * rootDir, FD_t fd, const char ** specFilePtr, rpmCallbackFunction notify, rpmCallbackData notifyData, @@ -585,7 +586,9 @@ rpmRC rpmInstallSourcePackage(const char * rootDir, FD_t fd, int i; ts->notify = notify; + /*@-temptrans@*/ ts->notifyData = notifyData; + /*@=temptrans@*/ rc = rpmReadPackageHeader(fd, &h, &isSource, NULL, NULL); if (rc) @@ -686,8 +689,10 @@ rpmRC rpmInstallSourcePackage(const char * rootDir, FD_t fd, fi->dil = (int *)(fi->dnl + fi->dc); memset(fi->dil, 0, fi->fc * sizeof(*fi->dil)); fi->dil[i] = 1; + /*@-dependenttrans@*/ fi->dnl[0] = t = (char *)(fi->dil + fi->fc); fi->dnl[1] = t = stpcpy( stpcpy(t, _sourcedir), "/") + 1; + /*@=dependenttrans@*/ (void) stpcpy( stpcpy(t, _specdir), "/"); t = xmalloc(speclen + strlen(fi->bnl[i]) + 1); @@ -721,13 +726,14 @@ exit: if (fi) { freeFi(fi); - free(fi); + fi = _free(fi); } if (ts) rpmtransFree(ts); return rc; } +/*@=compmempass@*/ static char * SCRIPT_PATH = "PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin"; @@ -1142,7 +1148,7 @@ static int runTriggers(PSM_t psm) rc |= handleOneTrigger(psm, fi->h, triggeredH, numPackage, NULL); } - rpmdbFreeIterator(mi); + mi = rpmdbFreeIterator(mi); psm->countCorrection = countCorrection; } @@ -1193,7 +1199,7 @@ static int runImmedTriggers(PSM_t psm) triggersRun); } - rpmdbFreeIterator(mi); + mi = rpmdbFreeIterator(mi); } } triggerIndices = hfd(triggerIndices, tit); @@ -1280,12 +1286,13 @@ assert(psm->mi == NULL); rpmdbSetIteratorRelease(psm->mi, fi->release); while ((psm->oh = rpmdbNextIterator(psm->mi))) { fi->record = rpmdbGetIteratorOffset(psm->mi); - psm->oh = (ts->transFlags & RPMTRANS_FLAG_MULTILIB) - ? headerCopy(psm->oh) : NULL; + if (ts->transFlags & RPMTRANS_FLAG_MULTILIB) + psm->oh = headerCopy(psm->oh); + else + psm->oh = NULL; break; } - rpmdbFreeIterator(psm->mi); - psm->mi = NULL; + psm->mi = rpmdbFreeIterator(psm->mi); rc = RPMRC_OK; if (fi->fc > 0 && fi->fstates == NULL) { @@ -1803,8 +1810,7 @@ assert(psm->mi == NULL); fi->h = rpmdbNextIterator(psm->mi); if (fi->h) fi->h = headerLink(fi->h); - rpmdbFreeIterator(psm->mi); - psm->mi = NULL; + psm->mi = rpmdbFreeIterator(psm->mi); rc = (fi->h ? RPMRC_OK : RPMRC_FAIL); break; case PSM_RPMDB_ADD: diff --git a/lib/query.c b/lib/query.c index 73d8b3b5a..6edae3a8e 100644 --- a/lib/query.c +++ b/lib/query.c @@ -390,7 +390,9 @@ printNewSpecfile(Spec spec) switch(t->t_tag) { case RPMTAG_SUMMARY: case RPMTAG_GROUP: + /*@-unqualifiedtrans@*/ sl->sl_lines[t->t_startx] = _free(sl->sl_lines[t->t_startx]); + /*@=unqualifiedtrans@*/ if (t->t_lang && strcmp(t->t_lang, RPMBUILD_DEFAULT_LANG)) continue; { char *buf = xmalloc(strlen(tn) + sizeof(": ") + strlen(msgstr)); @@ -400,8 +402,10 @@ printNewSpecfile(Spec spec) break; case RPMTAG_DESCRIPTION: for (j = 1; j < t->t_nlines; j++) { + /*@-unqualifiedtrans@*/ sl->sl_lines[t->t_startx + j] = _free(sl->sl_lines[t->t_startx + j]); + /*@=unqualifiedtrans@*/ } if (t->t_lang && strcmp(t->t_lang, RPMBUILD_DEFAULT_LANG)) { sl->sl_lines[t->t_startx] = _free(sl->sl_lines[t->t_startx]); @@ -458,7 +462,7 @@ int showMatches(QVA_t *qva, rpmdbMatchIterator mi, QVF_t showPackage) if ((rc = showPackage(qva, rpmdbGetIteratorRpmDB(mi), h)) != 0) ec = rc; } - rpmdbFreeIterator(mi); + mi = rpmdbFreeIterator(mi); return ec; } diff --git a/lib/rpmchecksig.c b/lib/rpmchecksig.c index 2a311b5e6..d4f8025b6 100644 --- a/lib/rpmchecksig.c +++ b/lib/rpmchecksig.c @@ -15,7 +15,8 @@ /*@access Header@*/ /* XXX compared with NULL */ /*@access FD_t@*/ /* XXX compared with NULL */ -static int manageFile(FD_t *fdp, const char **fnp, int flags, int rc) +static int manageFile(FD_t *fdp, const char **fnp, int flags, + /*@unused@*/ int rc) { const char *fn; FD_t fd; @@ -45,13 +46,15 @@ static int manageFile(FD_t *fdp, const char **fnp, int flags, int rc) /* open a temp file */ if (*fdp == NULL && (fnp == NULL || *fnp == NULL)) { + fn = NULL; if (makeTempFile(NULL, (fnp ? &fn : NULL), &fd)) { rpmError(RPMERR_MAKETEMP, _("makeTempFile failed\n")); return 1; } if (fnp) - *fnp = fn; - *fdp = fd; + *fnp = fn; + *fdp = fdLink(fd, "manageFile return"); + fdFree(fd, "manageFile return"); return 0; } @@ -117,6 +120,7 @@ int rpmReSign(rpmResignFlags add, char *passPhrase, const char **argv) if (manageFile(&fd, &rpm, O_RDONLY, 0)) goto exit; + memset(l, 0, sizeof(*l)); if (readLead(fd, l)) { rpmError(RPMERR_READLEAD, _("%s: readLead failed\n"), rpm); goto exit; @@ -248,7 +252,8 @@ int rpmCheckSig(rpmCheckSigFlags flags, const char **argv) goto bottom; } - if (readLead(fd, &lead)) { + memset(l, 0, sizeof(*l)); + if (readLead(fd, l)) { rpmError(RPMERR_READLEAD, _("%s: readLead failed\n"), rpm); res++; goto bottom; @@ -347,10 +352,14 @@ int rpmCheckSig(rpmCheckSigFlags flags, const char **argv) if (tempKey) { if (res3 == RPMSIG_NOKEY) { strcat(missingKeys, " PGP#"); + /*@-compdef@*/ strncat(missingKeys, tempKey + offset, 8); + /*@=compdef@*/ } else { strcat(untrustedKeys, " PGP#"); + /*@-compdef@*/ strncat(untrustedKeys, tempKey + offset, 8); + /*@=compdef@*/ } } } break; @@ -368,7 +377,9 @@ int rpmCheckSig(rpmCheckSigFlags flags, const char **argv) strcat(missingKeys, " GPG#"); tempKey = strstr(result, "key ID"); if (tempKey) + /*@-compdef@*/ strncat(missingKeys, tempKey+7, 8); + /*@=compdef@*/ break; default: strcat(buffer, "GPG "); diff --git a/lib/rpmdb.c b/lib/rpmdb.c index 1a63de95a..7acc3a6c0 100644 --- a/lib/rpmdb.c +++ b/lib/rpmdb.c @@ -551,7 +551,9 @@ static INLINE int dbiAppendSet(dbiIndexSet set, const void * recs, memset(set->recs + set->count, 0, nrecs * sizeof(*(set->recs))); while (nrecs-- > 0) { + /*@-mayaliasunique@*/ memcpy(set->recs + set->count, rptr, rlen); + /*@=mayaliasunique@*/ rptr += recsize; set->count++; } @@ -682,8 +684,10 @@ int rpmdbClose (rpmdb rpmdb) for (dbix = rpmdb->db_ndbi; --dbix >= 0; ) { if (rpmdb->_dbi[dbix] == NULL) continue; + /*@-unqualifiedtrans@*/ dbiClose(rpmdb->_dbi[dbix], 0); rpmdb->_dbi[dbix] = NULL; + /*@=unqualifiedtrans@*/ } rpmdb->db_errpfx = _free(rpmdb->db_errpfx); rpmdb->db_root = _free(rpmdb->db_root); @@ -732,14 +736,14 @@ static /*@only@*/ rpmdb newRpmdb(/*@kept@*/ const char * root, if (!(rpmdb->db_home && rpmdb->db_home[0] != '%')) { rpmError(RPMERR_DBOPEN, _("no dbpath has been set\n")); rpmdbClose(rpmdb); - return NULL; + /*@-globstate@*/ return NULL; /*@=globstate@*/ } rpmdb->db_errpfx = rpmExpand( (epfx && *epfx ? epfx : _DB_ERRPFX), NULL); rpmdb->db_remove_env = 0; rpmdb->db_filter_dups = _filterDbDups; rpmdb->db_ndbi = dbiTagsMax; rpmdb->_dbi = xcalloc(rpmdb->db_ndbi, sizeof(*rpmdb->_dbi)); - return rpmdb; + /*@-globstate@*/ return rpmdb; /*@=globstate@*/ } static int openDatabase(const char * prefix, const char * dbpath, int _dbapi, @@ -934,7 +938,7 @@ static int rpmdbFindByFile(rpmdb rpmdb, const char * filespec, h = rpmdbNextIterator(mi); if (h) h = headerLink(h); - rpmdbFreeIterator(mi); + mi = rpmdbFreeIterator(mi); } if (h == NULL) { @@ -944,7 +948,7 @@ static int rpmdbFindByFile(rpmdb rpmdb, const char * filespec, hge(h, RPMTAG_BASENAMES, &bnt, (void **) &baseNames, NULL); hge(h, RPMTAG_DIRNAMES, &dnt, (void **) &dirNames, NULL); - hge(h, RPMTAG_DIRINDEXES, NULL, (const void **) &dirIndexes, NULL); + hge(h, RPMTAG_DIRINDEXES, NULL, (void **) &dirIndexes, NULL); do { fingerPrint fp2; @@ -1057,7 +1061,7 @@ static int dbiFindMatches(dbiIndex dbi, DBC * dbcursor, h = rpmdbNextIterator(mi); if (h) h = headerLink(h); - rpmdbFreeIterator(mi); + mi = rpmdbFreeIterator(mi); } if (h == NULL) { @@ -1092,7 +1096,7 @@ static int dbiFindMatches(dbiIndex dbi, DBC * dbcursor, exit: if (rc && matches && *matches) { - dbiFreeIndexSet(*matches); + /*@-unqualifiedtrans@*/dbiFreeIndexSet(*matches);/*@=unqualifiedtrans@*/ *matches = NULL; } return rc; @@ -1118,7 +1122,7 @@ static int dbiFindByLabel(dbiIndex dbi, DBC * dbcursor, const char * arg, dbiInd rc = dbiFindMatches(dbi, dbcursor, arg, NULL, NULL, matches); if (rc != 1) return rc; if (*matches) { - dbiFreeIndexSet(*matches); + /*@-unqualifiedtrans@*/dbiFreeIndexSet(*matches);/*@=unqualifiedtrans@*/ *matches = NULL; } @@ -1133,7 +1137,10 @@ static int dbiFindByLabel(dbiIndex dbi, DBC * dbcursor, const char * arg, dbiInd *chptr = '\0'; rc = dbiFindMatches(dbi, dbcursor, localarg, chptr + 1, NULL, matches); if (rc != 1) return rc; - if (*matches) dbiFreeIndexSet(*matches); + if (*matches) { + /*@-unqualifiedtrans@*/dbiFreeIndexSet(*matches);/*@=unqualifiedtrans@*/ + *matches = NULL; + } /* how about name-version-release? */ @@ -1197,13 +1204,13 @@ struct _rpmdbMatchIterator { /*@only@*/ const char *mi_release; }; -void rpmdbFreeIterator(rpmdbMatchIterator mi) +rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi) { dbiIndex dbi = NULL; int xx; if (mi == NULL) - return; + return mi; dbi = dbiOpen(mi->mi_rpmdb, RPMDBI_PACKAGES, 0); if (mi->mi_h) { @@ -1234,6 +1241,7 @@ void rpmdbFreeIterator(rpmdbMatchIterator mi) } mi->mi_keyp = _free(mi->mi_keyp); mi = _free(mi); + return mi; } rpmdb rpmdbGetIteratorRpmDB(rpmdbMatchIterator mi) { @@ -1384,7 +1392,7 @@ exit: mi->mi_offset, mi->mi_h); } #endif - return mi->mi_h; + /*@-compdef -usereleased@*/ return mi->mi_h; /*@=compdef =usereleased@*/ } static void rpmdbSortIterator(rpmdbMatchIterator mi) { @@ -1602,7 +1610,7 @@ int rpmdbRemove(rpmdb rpmdb, int rid, unsigned int hdrNum) h = rpmdbNextIterator(mi); if (h) h = headerLink(h); - rpmdbFreeIterator(mi); + mi = rpmdbFreeIterator(mi); } if (h == NULL) { @@ -1847,7 +1855,9 @@ int rpmdbAdd(rpmdb rpmdb, int iid, Header h) memcpy(&hdrNum, datap, sizeof(hdrNum)); ++hdrNum; if (rc == 0 && datap) { + /*@-refcounttrans@*/ memcpy(datap, &hdrNum, sizeof(hdrNum)); + /*@=refcounttrans@*/ } else { datap = &hdrNum; datalen = sizeof(hdrNum); @@ -1940,7 +1950,9 @@ int rpmdbAdd(rpmdb rpmdb, int iid, Header h) (const char *)rpmvals, tagName(dbi->dbi_rpmtag)); /* XXX force uniform headerGetEntry return */ + /*@-observertrans@*/ av[0] = (const char *) rpmvals; + /*@=observertrans@*/ rpmvals = av; rpmcnt = 1; } else { @@ -2059,7 +2071,7 @@ int rpmdbFindFpList(rpmdb rpmdb, fingerPrint * fpList, dbiIndexSet * matchList, } if ((i = rpmdbGetIteratorCount(mi)) == 0) { - rpmdbFreeIterator(mi); + mi = rpmdbFreeIterator(mi); return 0; } fpc = fpCacheCreate(i); @@ -2109,7 +2121,9 @@ int rpmdbFindFpList(rpmdb rpmdb, fingerPrint * fpList, dbiIndexSet * matchList, /* Add db (recnum,filenum) to list for fingerprint matches. */ for (i = 0; i < num; i++, im++) { if (FP_EQUAL(fps[i], fpList[im->fpNum])) + /*@-usedef@*/ dbiAppendSet(matchList[im->fpNum], im, 1, sizeof(*im), 0); + /*@=usedef@*/ } fps = _free(fps); @@ -2121,7 +2135,7 @@ int rpmdbFindFpList(rpmdb rpmdb, fingerPrint * fpList, dbiIndexSet * matchList, mi->mi_setx = end; } - rpmdbFreeIterator(mi); + mi = rpmdbFreeIterator(mi); fpCacheFree(fpc); @@ -2439,7 +2453,7 @@ int rpmdbRebuild(const char * rootdir) skip = 1; break; } - rpmdbFreeIterator(mi); + mi = rpmdbFreeIterator(mi); } /*@=shadow@*/ @@ -2463,7 +2477,7 @@ int rpmdbRebuild(const char * rootdir) } } - rpmdbFreeIterator(mi); + mi = rpmdbFreeIterator(mi); } diff --git a/lib/rpminstall.c b/lib/rpminstall.c index be239fd90..f2834f27b 100644 --- a/lib/rpminstall.c +++ b/lib/rpminstall.c @@ -393,7 +393,7 @@ restart: count = 0; break; } - rpmdbFreeIterator(mi); + mi = rpmdbFreeIterator(mi); if (count == 0) { headerFree(h); continue; @@ -602,7 +602,7 @@ int rpmErase(const char * rootdir, const char ** argv, } } } - rpmdbFreeIterator(mi); + mi = rpmdbFreeIterator(mi); } if (!(interfaceFlags & UNINSTALL_NODEPS)) { @@ -655,10 +655,12 @@ int rpmInstallSource(const char * rootdir, const char * arg, } if (rc != 0) { rpmMessage(RPMMESS_ERROR, _("%s cannot be installed\n"), arg); + /*@-unqualifiedtrans@*/ if (specFile && *specFile) *specFile = _free(*specFile); if (cookie && *cookie) *cookie = _free(*cookie); + /*@=unqualifiedtrans@*/ } Fclose(fd); diff --git a/lib/rpmlead.c b/lib/rpmlead.c index 9b262e10f..366b05be1 100644 --- a/lib/rpmlead.c +++ b/lib/rpmlead.c @@ -44,6 +44,7 @@ int writeLead(FD_t fd, struct rpmlead *lead) int readLead(FD_t fd, struct rpmlead *lead) { + memset(lead, 0, sizeof(*lead)); if (timedRead(fd, (char *)lead, sizeof(*lead)) != sizeof(*lead)) { rpmError(RPMERR_READ, _("read failed: %s (%d)\n"), Fstrerror(fd), errno); diff --git a/lib/rpmlib.h b/lib/rpmlib.h index 4fa11bec0..f3d0c3103 100644 --- a/lib/rpmlib.h +++ b/lib/rpmlib.h @@ -625,8 +625,10 @@ typedef /*@abstract@*/ struct _rpmdbMatchIterator * rpmdbMatchIterator; /** \ingroup rpmdb * Destroy rpm database iterator. * @param mi rpm database iterator + * @return NULL always */ -void rpmdbFreeIterator( /*@only@*/ rpmdbMatchIterator mi); +rpmdbMatchIterator rpmdbFreeIterator(/*@only@*//*@null@*/rpmdbMatchIterator mi) + /*@modifies mi @*/; /** \ingroup rpmdb * Return rpm database used by iterator. @@ -704,11 +706,12 @@ int rpmdbSetIteratorModified(rpmdbMatchIterator mi, int modified) * @param mi rpm database iterator * @return NULL on end of iteration. */ -Header rpmdbNextIterator(rpmdbMatchIterator mi) +/*@null@*/ Header rpmdbNextIterator(/*@null@*/ rpmdbMatchIterator mi) /*@modifies mi @*/; #define rpmdbNextIterator(_a) \ XrpmdbNextIterator(_a, __FILE__, __LINE__) -Header XrpmdbNextIterator(rpmdbMatchIterator mi, const char * f, unsigned int l) +/*@null@*/ Header XrpmdbNextIterator(/*@null@*/ rpmdbMatchIterator mi, + const char * f, unsigned int l) /*@modifies mi @*/; /** \ingroup rpmdb @@ -973,8 +976,9 @@ typedef /*@abstract@*/ struct rpmTransactionSet_s * rpmTransactionSet; * @param rootdir path to top of install tree * @return transaction set */ -/*@only@*/ rpmTransactionSet rpmtransCreateSet(rpmdb rpmdb, - const char * rootdir); +/*@only@*/ rpmTransactionSet rpmtransCreateSet( + /*@null@*/ /*@kept@*/ rpmdb rpmdb, + /*@null@*/ const char * rootdir); /** \ingroup rpmtrans * Add package to be installed to unordered transaction set. @@ -992,9 +996,9 @@ typedef /*@abstract@*/ struct rpmTransactionSet_s * rpmTransactionSet; * @param relocs package file relocations * @return 0 on success, 1 on I/O error, 2 needs capabilities */ -int rpmtransAddPackage(rpmTransactionSet ts, Header h, FD_t fd, - /*@owned@*/ const void * key, int update, - rpmRelocation * relocs); +int rpmtransAddPackage(rpmTransactionSet ts, Header h, /*@null@*/ FD_t fd, + /*@null@*/ /*@owned@*/ const void * key, int update, + /*@null@*/ rpmRelocation * relocs); /** \ingroup rpmtrans * Add package to universe of possible packages to install in transaction set. @@ -1003,7 +1007,7 @@ int rpmtransAddPackage(rpmTransactionSet ts, Header h, FD_t fd, * @param key package private data */ void rpmtransAvailablePackage(rpmTransactionSet ts, Header h, - /*@owned@*/ const void * key); + /*@null@*/ /*@owned@*/ const void * key); /** \ingroup rpmtrans * Add package to be removed to unordered transaction set. @@ -1035,7 +1039,7 @@ void rpmtransSetScriptFd(rpmTransactionSet ts, FD_t fd) * @return 0 always */ int rpmtransGetKeys(const rpmTransactionSet ts, - /*@out@*/ const void *** ep, /*@out@*/ int * nep) + /*@null@*/ /*@out@*/ const void *** ep, /*@null@*/ /*@out@*/ int * nep) /*@modifies ep, nep @*/; /** \ingroup rpmtrans diff --git a/lib/rpmrc.c b/lib/rpmrc.c index 2ac66987b..98eda9838 100644 --- a/lib/rpmrc.c +++ b/lib/rpmrc.c @@ -8,14 +8,14 @@ #define __power_pc() 0 #endif -/*@ access FD_t @*/ /* compared with NULL */ - #include <rpmlib.h> #include <rpmmacro.h> #include "misc.h" #include "debug.h" +/*@access FD_t@*/ /* compared with NULL */ + static const char *defrcfiles = LIBRPMRC_FILENAME ":/etc/rpmrc:~/.rpmrc"; const char * macrofiles = MACROFILES; @@ -294,7 +294,9 @@ static int addCanon(struct canonEntry ** table, int * tableLen, char * line, *table = xmalloc(2 * sizeof(struct canonEntry)); } else { (*tableLen) += 2; + /*@-unqualifiedtrans@*/ *table = xrealloc(*table, sizeof(struct canonEntry) * (*tableLen)); + /*@=unqualifiedtrans@*/ } t = & ((*table)[*tableLen - 2]); @@ -342,10 +344,13 @@ static int addDefault(struct defaultEntry **table, int *tableLen, char *line, *table = xmalloc(sizeof(struct defaultEntry)); } else { (*tableLen)++; + /*@-unqualifiedtrans@*/ *table = xrealloc(*table, sizeof(struct defaultEntry) * (*tableLen)); + /*@=unqualifiedtrans@*/ } t = & ((*table)[*tableLen - 1]); + /*@-temptrans@*/ t->name = strtok(line, ": \t"); t->defName = strtok(NULL, " \t"); if (! (t->name && t->defName)) { @@ -361,6 +366,7 @@ static int addDefault(struct defaultEntry **table, int *tableLen, char *line, t->name = xstrdup(t->name); t->defName = xstrdup(t->defName); + /*@=temptrans@*/ return 0; } @@ -370,9 +376,11 @@ static /*@null@*/ const struct canonEntry *lookupInCanonTable(const char *name, { while (tableLen) { tableLen--; - if (!strcmp(name, table[tableLen].name)) { - return &(table[tableLen]); - } + if (strcmp(name, table[tableLen].name)) + continue; + /*@-immediatetrans@*/ + return &(table[tableLen]); + /*@=immediatetrans@*/ } return NULL; @@ -1003,25 +1011,25 @@ static void defaultMachine(/*@out@*/ const char ** arch, /*@out@*/ const char ** !strncmp(un.release, "4.0", 3)) { /* we are on ncr-sysv4 */ - char *prelid = NULL; - FD_t fd; - fd = Fopen("/etc/.relid", "r.fdio"); + char * prelid = NULL; + FD_t fd = Fopen("/etc/.relid", "r.fdio"); + int gotit = 0; if (!Ferror(fd)) { - chptr = (char *) xcalloc(1, 256); - if (chptr != NULL) { - int irelid = Fread(chptr, sizeof(*chptr), 256, fd); + chptr = xcalloc(1, 256); + { int irelid = Fread(chptr, sizeof(*chptr), 256, fd); Fclose(fd); /* example: "112393 RELEASE 020200 Version 01 OS" */ if (irelid > 0) { - if ((prelid=strstr(chptr, "RELEASE "))){ + if ((prelid = strstr(chptr, "RELEASE "))){ prelid += strlen("RELEASE ")+1; sprintf(un.sysname,"ncr-sysv4.%.*s",1,prelid); + gotit = 1; } } - free (chptr); } + chptr = _free (chptr); } - if (prelid == NULL) /* parsing /etc/.relid file failed? */ + if (!gotit) /* parsing /etc/.relid file failed? */ strcpy(un.sysname,"ncr-sysv4"); /* wrong, just for now, find out how to look for i586 later*/ strcpy(un.machine,"i486"); @@ -1186,7 +1194,7 @@ const char *rpmGetVar(int var) } /* this doesn't free the passed pointer! */ -static void freeRpmVar(struct rpmvarValue * orig) { +static void freeRpmVar(/*@only@*/ struct rpmvarValue * orig) { struct rpmvarValue * next, * var = orig; while (var) { @@ -1200,7 +1208,9 @@ static void freeRpmVar(struct rpmvarValue * orig) { } void rpmSetVar(int var, const char *val) { + /*@-immediatetrans@*/ freeRpmVar(&values[var]); + /*@=immediatetrans@*/ values[var].value = (val ? xstrdup(val) : NULL); } @@ -1442,7 +1452,9 @@ void rpmRebuildTargetVars(const char **buildtarget, const char ** canontarget) else ct = _free(ct); ca = _free(ca); + /*@-usereleased@*/ co = _free(co); + /*@=usereleased@*/ } void rpmFreeRpmrc(void) diff --git a/lib/stringbuf.c b/lib/stringbuf.c index 0be19a708..203f869c5 100644 --- a/lib/stringbuf.c +++ b/lib/stringbuf.c @@ -82,7 +82,9 @@ void appendStringBufAux(StringBuf sb, const char *s, int nl) sb->tail = sb->buf + (sb->allocated - sb->free); } + /*@-mayaliasunique@*/ strcpy(sb->tail, s); + /*@=mayaliasunique@*/ sb->tail += l; sb->free -= l; if (nl) { diff --git a/lib/transaction.c b/lib/transaction.c index b217158d5..cdc115182 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -62,14 +62,19 @@ struct diskspaceInfo { #define XSTRCMP(a, b) ((!(a) && !(b)) || ((a) && (b) && !strcmp((a), (b)))) -static void freeFl(rpmTransactionSet ts, TFI_t flList) +static /*@null@*/ void * freeFl(rpmTransactionSet ts, /*@only@*/ /*@null@*/ TFI_t flList) { - TFI_t fi; - int oc; + if (flList) { + TFI_t fi; + int oc; - for (oc = 0, fi = flList; oc < ts->orderCount; oc++, fi++) { - freeFi(fi); + /*@-usereleased@*/ + for (oc = 0, fi = flList; oc < ts->orderCount; oc++, fi++) + freeFi(fi); + flList = _free(flList); + /*@=usereleased@*/ } + return NULL; } void rpmtransSetScriptFd(rpmTransactionSet ts, FD_t fd) @@ -422,7 +427,7 @@ static Header relocateFileList(const rpmTransactionSet ts, TFI_t fi, const char ** actualRelocations; int numActual; - actualRelocations = xmalloc(sizeof(*actualRelocations) * numValid); + actualRelocations = xmalloc(numValid * sizeof(*actualRelocations)); numActual = 0; for (i = 0; i < numValid; i++) { for (j = 0; j < numRelocations; j++) { @@ -588,7 +593,7 @@ static Header relocateFileList(const rpmTransactionSet ts, TFI_t fi, const char ** newDirList; haveRelocatedFile = 1; - newDirList = xmalloc(sizeof(*newDirList) * (dirCount + 1)); + newDirList = xmalloc((dirCount + 1) * sizeof(*newDirList)); for (j = 0; j < dirCount; j++) newDirList[j] = alloca_strdup(dirNames[j]); dirNames = hfd(dirNames, RPM_STRING_ARRAY_TYPE); @@ -870,7 +875,7 @@ static int handleInstInstalledFiles(TFI_t fi, rpmdb db, mi = rpmdbInitIterator(db, RPMDBI_PACKAGES, &shared->otherPkg, sizeof(shared->otherPkg)); h = rpmdbNextIterator(mi); if (h == NULL) { - rpmdbFreeIterator(mi); + mi = rpmdbFreeIterator(mi); return 1; } @@ -881,7 +886,7 @@ static int handleInstInstalledFiles(TFI_t fi, rpmdb db, hge(h, RPMTAG_FILEFLAGS, NULL, (void **) &otherFlags, NULL); hge(h, RPMTAG_FILESIZES, NULL, (void **) &otherSizes, NULL); - fi->replaced = xmalloc(sizeof(*fi->replaced) * sharedCount); + fi->replaced = xmalloc(sharedCount * sizeof(*fi->replaced)); for (i = 0; i < sharedCount; i++, shared++) { int otherFileNum, fileNum; @@ -931,7 +936,7 @@ static int handleInstInstalledFiles(TFI_t fi, rpmdb db, otherMd5s = hfd(otherMd5s, omtype); otherLinks = hfd(otherLinks, oltype); - rpmdbFreeIterator(mi); + mi = rpmdbFreeIterator(mi); fi->replaced = xrealloc(fi->replaced, /* XXX memory leak */ sizeof(*fi->replaced) * (numReplaced + 1)); @@ -955,7 +960,7 @@ static int handleRmvdInstalledFiles(TFI_t fi, rpmdb db, &shared->otherPkg, sizeof(shared->otherPkg)); h = rpmdbNextIterator(mi); if (h == NULL) { - rpmdbFreeIterator(mi); + mi = rpmdbFreeIterator(mi); return 1; } @@ -972,7 +977,7 @@ static int handleRmvdInstalledFiles(TFI_t fi, rpmdb db, fi->actions[fileNum] = FA_SKIP; } - rpmdbFreeIterator(mi); + mi = rpmdbFreeIterator(mi); return 0; } @@ -1375,7 +1380,7 @@ static int tsGetOc(void * this) { /** */ -static struct availablePackage * tsGetAlp(void * this) { +static /*@dependent@*/ struct availablePackage * tsGetAlp(void * this) { struct tsIterator_s * iter = this; struct availablePackage * alp = NULL; int oc = iter->ocsave; @@ -1422,7 +1427,7 @@ static void * tsInitIterator(/*@kept@*/ const void * this) * @param this file info iterator * @return next index, -1 on termination */ -static TFI_t tsNextIterator(void * this) { +static /*@dependent@*/ TFI_t tsNextIterator(void * this) { struct tsIterator_s * iter = this; rpmTransactionSet ts = iter->ts; TFI_t fi = NULL; @@ -1570,7 +1575,7 @@ int rpmRunTransactions( rpmTransactionSet ts, mi = rpmdbInitIterator(ts->rpmdb, RPMTAG_NAME, alp->name, 0); while ((oldH = rpmdbNextIterator(mi)) != NULL) ensureOlder(alp, oldH, ts->probs); - rpmdbFreeIterator(mi); + mi = rpmdbFreeIterator(mi); } /* XXX multilib should not display "already installed" problems */ @@ -1584,7 +1589,7 @@ int rpmRunTransactions( rpmTransactionSet ts, NULL, NULL, NULL, 0); break; } - rpmdbFreeIterator(mi); + mi = rpmdbFreeIterator(mi); } totalFileCount += alp->filesCount; @@ -1604,37 +1609,34 @@ int rpmRunTransactions( rpmTransactionSet ts, if (headerGetEntry(h, RPMTAG_BASENAMES, NULL, NULL, &fileCount)) totalFileCount += fileCount; } - rpmdbFreeIterator(mi); + mi = rpmdbFreeIterator(mi); } /* =============================================== * Initialize file list: */ ts->flEntries = ts->addedPackages.size + ts->numRemovedPackages; - ts->flList = alloca(sizeof(*ts->flList) * (ts->flEntries)); + ts->flList = xcalloc(ts->flEntries, sizeof(*ts->flList)); /* * FIXME?: we'd be better off assembling one very large file list and * calling fpLookupList only once. I'm not sure that the speedup is * worth the trouble though. */ - for (oc = 0, fi = ts->flList; oc < ts->orderCount; oc++, fi++) { - const char **preTrans; - int preTransCount; - - memset(fi, 0, sizeof(*fi)); + tsi = tsInitIterator(ts); + while ((fi = tsNextIterator(tsi)) != NULL) { + oc = tsGetOc(tsi); fi->magic = TFIMAGIC; - preTrans = NULL; - preTransCount = 0; + /* XXX watchout: fi->type must be set for tsGetAlp() to "work" */ fi->type = ts->order[oc].type; switch (fi->type) { case TR_ADDED: i = ts->order[oc].u.addedIndex; - alp = ts->addedPackages.list + i; - fi->ap = alp; + /* XXX watchout: fi->type must be set for tsGetAlp() to "work" */ + fi->ap = tsGetAlp(tsi); fi->record = 0; - loadFi(alp->h, fi); + loadFi(fi->ap->h, fi); if (fi->fc == 0) { hdrs[i] = headerLink(fi->h); continue; @@ -1642,13 +1644,13 @@ int rpmRunTransactions( rpmTransactionSet ts, /* Allocate file actions (and initialize to FA_UNKNOWN) */ fi->actions = xcalloc(fi->fc, sizeof(*fi->actions)); - hdrs[i] = relocateFileList(ts, fi, alp, fi->h, fi->actions); + hdrs[i] = relocateFileList(ts, fi, fi->ap, fi->h, fi->actions); /* Skip netshared paths, not our i18n files, and excluded docs */ skipFiles(ts, fi); break; case TR_REMOVED: - fi->ap = alp = NULL; + fi->ap = NULL; fi->record = ts->order[oc].u.removed.dboffset; { rpmdbMatchIterator mi; @@ -1656,7 +1658,7 @@ int rpmRunTransactions( rpmTransactionSet ts, &fi->record, sizeof(fi->record)); if ((fi->h = rpmdbNextIterator(mi)) != NULL) fi->h = headerLink(fi->h); - rpmdbFreeIterator(mi); + mi = rpmdbFreeIterator(mi); } if (fi->h == NULL) { /* ACK! */ @@ -1668,8 +1670,9 @@ int rpmRunTransactions( rpmTransactionSet ts, } if (fi->fc) - fi->fps = xmalloc(sizeof(*fi->fps) * fi->fc); + fi->fps = xmalloc(fi->fc * sizeof(*fi->fps)); } + tsi = tsFreeIterator(tsi); /* Open all database indices before installing. */ rpmdbOpenAll(ts->rpmdb); @@ -1686,14 +1689,18 @@ int rpmRunTransactions( rpmTransactionSet ts, /* =============================================== * Add fingerprint for each file not skipped. */ - for (fi = ts->flList; (fi - ts->flList) < ts->flEntries; fi++) { + tsi = tsInitIterator(ts); + while ((fi = tsNextIterator(tsi)) != NULL) { fpLookupList(fpc, fi->dnl, fi->bnl, fi->dil, fi->fc, fi->fps); for (i = 0; i < fi->fc; i++) { if (XFA_SKIPPING(fi->actions[i])) continue; + /*@-dependenttrans@*/ htAddEntry(ht, fi->fps + i, fi); + /*@=dependenttrans@*/ } } + tsi = tsFreeIterator(tsi); NOTIFY(ts, (NULL, RPMCALLBACK_TRANS_START, 6, ts->flEntries, NULL, ts->notifyData)); @@ -1701,7 +1708,8 @@ int rpmRunTransactions( rpmTransactionSet ts, /* =============================================== * Compute file disposition for each package in transaction set. */ - for (fi = ts->flList; (fi - ts->flList) < ts->flEntries; fi++) { + tsi = tsInitIterator(ts); + while ((fi = tsNextIterator(tsi)) != NULL) { dbiIndexSet * matches; int knownBad; @@ -1713,14 +1721,14 @@ int rpmRunTransactions( rpmTransactionSet ts, /* Extract file info for all files in this package from the database. */ matches = xcalloc(sizeof(*matches), fi->fc); if (rpmdbFindFpList(ts->rpmdb, fi->fps, matches, fi->fc)) - return 1; + return 1; /* XXX WTFO? */ numShared = 0; for (i = 0; i < fi->fc; i++) numShared += dbiIndexSetCount(matches[i]); /* Build sorted file info list for this package. */ - shared = sharedList = xmalloc(sizeof(*sharedList) * (numShared + 1)); + shared = sharedList = xmalloc((numShared + 1) * sizeof(*sharedList)); for (i = 0; i < fi->fc; i++) { /* * Take care not to mark files as replaced in packages that will @@ -1829,9 +1837,7 @@ int rpmRunTransactions( rpmTransactionSet ts, break; } } - - NOTIFY(ts, (NULL, RPMCALLBACK_TRANS_STOP, 6, ts->flEntries, - NULL, ts->notifyData)); + tsi = tsFreeIterator(tsi); if (ts->chrootDone) { /*@-unrecog@*/ chroot("."); /*@-unrecog@*/ @@ -1839,6 +1845,9 @@ int rpmRunTransactions( rpmTransactionSet ts, chdir(ts->currDir); } + NOTIFY(ts, (NULL, RPMCALLBACK_TRANS_STOP, 6, ts->flEntries, + NULL, ts->notifyData)); + /* =============================================== * Free unused memory as soon as possible. */ @@ -1868,7 +1877,8 @@ int rpmRunTransactions( rpmTransactionSet ts, headerFree(hdrs[alp - ts->addedPackages.list]); } - freeFl(ts, ts->flList); + ts->flList = freeFl(ts, ts->flList); + ts->flEntries = 0; return ts->orderCount; } @@ -1982,7 +1992,8 @@ if (fi->ap == NULL) fi->ap = alp; /* XXX WTFO? */ } tsi = tsFreeIterator(tsi); - freeFl(ts, ts->flList); + ts->flList = freeFl(ts, ts->flList); + ts->flEntries = 0; if (ourrc) return -1; |