summaryrefslogtreecommitdiff
path: root/rpmdb
diff options
context:
space:
mode:
Diffstat (limited to 'rpmdb')
-rw-r--r--rpmdb/db1.c17
-rw-r--r--rpmdb/db3.c29
-rw-r--r--rpmdb/dbconfig.c2
-rw-r--r--rpmdb/falloc.c12
-rw-r--r--rpmdb/falloc.h5
-rw-r--r--rpmdb/fprint.c4
-rw-r--r--rpmdb/rpmdb.c112
-rw-r--r--rpmdb/rpmdb.h6
-rw-r--r--rpmdb/rpmhash.c6
9 files changed, 125 insertions, 68 deletions
diff --git a/rpmdb/db1.c b/rpmdb/db1.c
index a50ec9a66..08b181e12 100644
--- a/rpmdb/db1.c
+++ b/rpmdb/db1.c
@@ -84,7 +84,7 @@ static /*@observer@*/ char * db_strerror(int error)
}
static int cvtdberr(dbiIndex dbi, const char * msg, int error, int printit)
- /*@modifies dbi, fileSystem @*/
+ /*@*/
{
int rc = 0;
@@ -109,6 +109,7 @@ static int cvtdberr(dbiIndex dbi, const char * msg, int error, int printit)
#endif /* DYING */
static int db1sync(dbiIndex dbi, /*@unused@*/ unsigned int flags)
+ /*@globals fileSystem @*/
/*@modifies fileSystem @*/
{
int rc = 0;
@@ -133,6 +134,7 @@ static int db1sync(dbiIndex dbi, /*@unused@*/ unsigned int flags)
}
/*@null@*/ static void * doGetRecord(dbiIndex dbi, unsigned int offset)
+ /*@globals fileSystem @*/
/*@modifies dbi, fileSystem @*/
{
FD_t pkgs = dbi->dbi_db;
@@ -232,10 +234,12 @@ retry:
compressFilelist(h);
exit:
+ /*@-branchstate@*/
if (h != NULL) {
uh = headerUnload(h);
h = headerFree(h);
}
+ /*@=branchstate@*/
return uh;
}
@@ -264,6 +268,7 @@ static int db1cget(dbiIndex dbi, /*@unused@*/ DBC * dbcursor,
/*@null@*/ void ** datap,
/*@null@*/ size_t * datalen,
/*@unused@*/ unsigned int flags)
+ /*@globals fileSystem @*/
/*@modifies dbi, *keyp, *keylen, *datap, *datalen, fileSystem @*/
{
DBT key, data;
@@ -359,6 +364,7 @@ bail:
static int db1cdel(dbiIndex dbi, /*@unused@*/ DBC * dbcursor, const void * keyp,
size_t keylen, /*@unused@*/ unsigned int flags)
+ /*@globals fileSystem @*/
/*@modifies dbi, fileSystem @*/
{
DBT key;
@@ -394,6 +400,7 @@ static int db1cput(dbiIndex dbi, /*@unused@*/ DBC * dbcursor,
const void * keyp, size_t keylen,
const void * datap, size_t datalen,
/*@unused@*/ unsigned int flags)
+ /*@globals fileSystem @*/
/*@modifies dbi, datap, fileSystem @*/
{
DBT key, data;
@@ -466,7 +473,8 @@ static int db1stat(/*@unused@*/ dbiIndex dbi, /*@unused@*/ unsigned int flags)
}
static int db1close(/*@only@*/ dbiIndex dbi, /*@unused@*/ unsigned int flags)
- /*@globals rpmGlobalMacroContext @*/
+ /*@globals rpmGlobalMacroContext,
+ fileSystem @*/
/*@modifies dbi, fileSystem @*/
{
rpmdb rpmdb = dbi->dbi_rpmdb;
@@ -477,6 +485,7 @@ static int db1close(/*@only@*/ dbiIndex dbi, /*@unused@*/ unsigned int flags)
(void) urlPath(urlfn, &fn);
+ /*@-branchstate@*/
if (dbi->dbi_db) {
if (dbi->dbi_rpmtag == RPMDBI_PACKAGES) {
FD_t pkgs = dbi->dbi_db;
@@ -494,6 +503,7 @@ static int db1close(/*@only@*/ dbiIndex dbi, /*@unused@*/ unsigned int flags)
#endif
dbi->dbi_db = NULL;
}
+ /*@=branchstate@*/
rpmMessage(RPMMESS_DEBUG, _("closed db file %s\n"), urlfn);
/* Remove temporary databases */
@@ -510,7 +520,8 @@ static int db1close(/*@only@*/ dbiIndex dbi, /*@unused@*/ unsigned int flags)
static int db1open(/*@keep@*/ rpmdb rpmdb, int rpmtag,
/*@out@*/ dbiIndex * dbip)
- /*@globals rpmGlobalMacroContext @*/
+ /*@globals rpmGlobalMacroContext,
+ fileSystem @*/
/*@modifies *dbip, fileSystem @*/
{
/*@-nestedextern@*/
diff --git a/rpmdb/db3.c b/rpmdb/db3.c
index d31faa496..602836077 100644
--- a/rpmdb/db3.c
+++ b/rpmdb/db3.c
@@ -73,7 +73,9 @@ struct dbiBStats_s {
};
/*@=fielduse@*/
+/*@-globuse@*/ /* FIX: rpmError not annotated yet. */
static int cvtdberr(dbiIndex dbi, const char * msg, int error, int printit)
+ /*@globals fileSystem @*/
/*@modifies fileSystem @*/
{
int rc = 0;
@@ -93,10 +95,12 @@ static int cvtdberr(dbiIndex dbi, const char * msg, int error, int printit)
return rc;
}
+/*@=globuse@*/
static int db_fini(dbiIndex dbi, const char * dbhome,
/*@null@*/ const char * dbfile,
/*@unused@*/ /*@null@*/ const char * dbsubfile)
+ /*@globals fileSystem @*/
/*@modifies dbi, fileSystem @*/
{
rpmdb rpmdb = dbi->dbi_rpmdb;
@@ -149,7 +153,8 @@ static int db_init(dbiIndex dbi, const char * dbhome,
/*@null@*/ const char * dbfile,
/*@unused@*/ /*@null@*/ const char * dbsubfile,
/*@out@*/ DB_ENV ** dbenvp)
- /*@globals rpmGlobalMacroContext @*/
+ /*@globals rpmGlobalMacroContext,
+ fileSystem @*/
/*@modifies dbi, *dbenvp, fileSystem @*/
{
rpmdb rpmdb = dbi->dbi_rpmdb;
@@ -282,6 +287,7 @@ errxit:
/*@=moduncon@*/
static int db3sync(dbiIndex dbi, unsigned int flags)
+ /*@globals fileSystem @*/
/*@modifies fileSystem @*/
{
DB * db = dbi->dbi_db;
@@ -297,6 +303,7 @@ static int db3sync(dbiIndex dbi, unsigned int flags)
}
static int db3c_del(dbiIndex dbi, DBC * dbcursor, u_int32_t flags)
+ /*@globals fileSystem @*/
/*@modifies fileSystem @*/
{
int rc;
@@ -308,6 +315,7 @@ static int db3c_del(dbiIndex dbi, DBC * dbcursor, u_int32_t flags)
/*@unused@*/ static int db3c_dup(dbiIndex dbi, DBC * dbcursor, DBC ** dbcp,
u_int32_t flags)
+ /*@globals fileSystem @*/
/*@modifies *dbcp, fileSystem @*/
{
int rc;
@@ -320,6 +328,7 @@ static int db3c_del(dbiIndex dbi, DBC * dbcursor, u_int32_t flags)
static int db3c_get(dbiIndex dbi, DBC * dbcursor,
DBT * key, DBT * data, u_int32_t flags)
+ /*@globals fileSystem @*/
/*@modifies fileSystem @*/
{
int _printit;
@@ -343,6 +352,7 @@ static int db3c_get(dbiIndex dbi, DBC * dbcursor,
static int db3c_put(dbiIndex dbi, DBC * dbcursor,
DBT * key, DBT * data, u_int32_t flags)
+ /*@globals fileSystem @*/
/*@modifies fileSystem @*/
{
int rc;
@@ -354,6 +364,7 @@ static int db3c_put(dbiIndex dbi, DBC * dbcursor,
}
static inline int db3c_close(dbiIndex dbi, /*@only@*/ /*@null@*/ DBC * dbcursor)
+ /*@globals fileSystem @*/
/*@modifies fileSystem @*/
{
int rc;
@@ -367,6 +378,7 @@ static inline int db3c_close(dbiIndex dbi, /*@only@*/ /*@null@*/ DBC * dbcursor)
static inline int db3c_open(dbiIndex dbi, /*@null@*/ /*@out@*/ DBC ** dbcp,
int dbiflags)
+ /*@globals fileSystem @*/
/*@modifies *dbcp, fileSystem @*/
{
DB * db = dbi->dbi_db;
@@ -390,6 +402,7 @@ static inline int db3c_open(dbiIndex dbi, /*@null@*/ /*@out@*/ DBC ** dbcp,
static int db3cclose(dbiIndex dbi, /*@only@*/ /*@null@*/ DBC * dbcursor,
unsigned int flags)
+ /*@globals fileSystem @*/
/*@modifies dbi, fileSystem @*/
{
int rc = 0;
@@ -401,8 +414,10 @@ static int db3cclose(dbiIndex dbi, /*@only@*/ /*@null@*/ DBC * dbcursor,
if (!dbi->dbi_use_cursors)
return 0;
+ /*@-branchstate@*/
if (dbcursor == NULL)
dbcursor = dbi->dbi_rmw;
+ /*@=branchstate@*/
if (dbcursor) {
if (dbcursor == dbi->dbi_rmw)
dbi->dbi_rmw = NULL;
@@ -413,6 +428,7 @@ static int db3cclose(dbiIndex dbi, /*@only@*/ /*@null@*/ DBC * dbcursor,
static int db3copen(dbiIndex dbi,
/*@null@*/ /*@out@*/ DBC ** dbcp, unsigned int flags)
+ /*@globals fileSystem @*/
/*@modifies dbi, *dbcp, fileSystem @*/
{
DBC * dbcursor;
@@ -442,6 +458,7 @@ static int db3cput(dbiIndex dbi, DBC * dbcursor,
const void * keyp, size_t keylen,
const void * datap, size_t datalen,
/*@unused@*/ unsigned int flags)
+ /*@globals fileSystem @*/
/*@modifies fileSystem @*/
{
DB * db = dbi->dbi_db;
@@ -472,6 +489,7 @@ static int db3cput(dbiIndex dbi, DBC * dbcursor,
static int db3cdel(dbiIndex dbi, DBC * dbcursor,
const void * keyp, size_t keylen,
/*@unused@*/ unsigned int flags)
+ /*@globals fileSystem @*/
/*@modifies fileSystem @*/
{
DB * db = dbi->dbi_db;
@@ -507,6 +525,7 @@ static int db3cget(dbiIndex dbi, DBC * dbcursor,
/*@null@*/ void ** keyp, /*@null@*/ size_t * keylen,
/*@null@*/ void ** datap, /*@null@*/ size_t * datalen,
/*@unused@*/ unsigned int flags)
+ /*@globals fileSystem @*/
/*@modifies *keyp, *keylen, *datap, *datalen, fileSystem @*/
{
DB * db = dbi->dbi_db;
@@ -557,6 +576,7 @@ static int db3cget(dbiIndex dbi, DBC * dbcursor,
static int db3ccount(dbiIndex dbi, DBC * dbcursor,
/*@null@*/ /*@out@*/ unsigned int * countp,
/*@unused@*/ unsigned int flags)
+ /*@globals fileSystem @*/
/*@modifies *countp, fileSystem @*/
{
db_recno_t count = 0;
@@ -592,6 +612,7 @@ static int db3byteswapped(dbiIndex dbi) /*@*/
}
static int db3stat(dbiIndex dbi, unsigned int flags)
+ /*@globals fileSystem @*/
/*@modifies dbi, fileSystem @*/
{
DB * db = dbi->dbi_db;
@@ -617,7 +638,8 @@ static int db3stat(dbiIndex dbi, unsigned int flags)
/*@-moduncon@*/
static int db3close(/*@only@*/ dbiIndex dbi, /*@unused@*/ unsigned int flags)
- /*@globals rpmGlobalMacroContext @*/
+ /*@globals rpmGlobalMacroContext,
+ fileSystem @*/
/*@modifies dbi, fileSystem @*/
{
rpmdb rpmdb = dbi->dbi_rpmdb;
@@ -754,7 +776,8 @@ exit:
/*@=moduncon@*/
static int db3open(/*@keep@*/ rpmdb rpmdb, int rpmtag, dbiIndex * dbip)
- /*@globals rpmGlobalMacroContext @*/
+ /*@globals rpmGlobalMacroContext,
+ fileSystem @*/
/*@modifies *dbip, fileSystem @*/
{
/*@-nestedextern@*/
diff --git a/rpmdb/dbconfig.c b/rpmdb/dbconfig.c
index 7db701300..704bc8490 100644
--- a/rpmdb/dbconfig.c
+++ b/rpmdb/dbconfig.c
@@ -348,6 +348,7 @@ dbiIndex db3New(rpmdb rpmdb, int rpmtag)
}
/* Parse the options for the database element(s). */
+ /*@-branchstate@*/
if (dbOpts && *dbOpts && *dbOpts != '%') {
char *o, *oe;
char *p, *pe;
@@ -457,6 +458,7 @@ dbiIndex db3New(rpmdb rpmdb, int rpmtag)
}
}
}
+ /*@=branchstate@*/
dbOpts = _free(dbOpts);
diff --git a/rpmdb/falloc.c b/rpmdb/falloc.c
index 46b70f323..4785107ca 100644
--- a/rpmdb/falloc.c
+++ b/rpmdb/falloc.c
@@ -383,7 +383,7 @@ void fadFree(FD_t fd, unsigned int offset)
}
static int fadSanity(FD_t fd, int offset, const struct faHeader * fh, int printit)
- /*@modifies fileSystem @*/
+ /*@*/
{
int rc = 0;
@@ -426,13 +426,13 @@ int fadFirstOffset(FD_t fd)
return fadNextOffset(fd, 0);
}
-int fadNextOffset(FD_t fd, unsigned int lastOffset)
+int fadNextOffset(FD_t fd, unsigned int lastoff)
{
struct faHeader header;
int offset;
- offset = (lastOffset)
- ? (lastOffset - sizeof(header))
+ offset = (lastoff)
+ ? (lastoff - sizeof(header))
: sizeof(struct faFileHeader);
if (offset >= fadGetFileSize(fd))
@@ -442,7 +442,7 @@ int fadNextOffset(FD_t fd, unsigned int lastOffset)
if (Pread(fd, &header, sizeof(header), offset) != sizeof(header))
return 0;
- if (!lastOffset && header.isFree == 0)
+ if (!lastoff && header.isFree == 0)
return (offset + sizeof(header));
/*
@@ -476,7 +476,7 @@ int fadNextOffset(FD_t fd, unsigned int lastOffset)
/* Sanity check this to make sure we're not going in loops */
offset += sizeof(header);
- if (offset <= lastOffset)
+ if (offset <= lastoff)
return 0; /* XXX used to return -1 */
return offset;
diff --git a/rpmdb/falloc.h b/rpmdb/falloc.h
index b8d21fda0..23225c053 100644
--- a/rpmdb/falloc.h
+++ b/rpmdb/falloc.h
@@ -39,6 +39,7 @@ extern "C" {
/** \ingroup db1
*/
/*@null@*/ FD_t fadOpen(const char * path, int flags, mode_t perms)
+ /*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/** \ingroup db1
@@ -46,18 +47,21 @@ extern "C" {
* @return 0 on failure
*/
unsigned int fadAlloc(FD_t fd, unsigned int size)
+ /*@globals fileSystem @*/
/*@modifies fd, fileSystem @*/;
/** \ingroup db1
* @param fd file handle
*/
void fadFree(FD_t fd, unsigned int offset)
+ /*@globals fileSystem @*/
/*@modifies fd, fileSystem @*/;
/** \ingroup db1
* @param fd file handle
*/
int fadFirstOffset(FD_t fd)
+ /*@globals fileSystem @*/
/*@modifies fd, fileSystem @*/;
/** \ingroup db1
@@ -65,6 +69,7 @@ int fadFirstOffset(FD_t fd)
* @return next offset, 0 to terminate
*/
int fadNextOffset(FD_t fd, unsigned int lastoff)
+ /*@globals fileSystem @*/
/*@modifies fd, fileSystem @*/;
#ifdef __cplusplus
diff --git a/rpmdb/fprint.c b/rpmdb/fprint.c
index c9685e3b0..7563585cd 100644
--- a/rpmdb/fprint.c
+++ b/rpmdb/fprint.c
@@ -71,9 +71,11 @@ static fingerPrint doLookup(fingerPrintCache cache,
cdnl = strlen(cleanDirName);
if (*cleanDirName == '/') {
+ /*@-branchstate@*/
if (!scareMemory)
cleanDirName =
rpmCleanPath(strcpy(alloca(cdnl+1), dirName));
+ /*@=branchstate@*/
} else {
scareMemory = 0; /* XXX causes memory leak */
@@ -86,6 +88,7 @@ static fingerPrint doLookup(fingerPrintCache cache,
/* if the current directory doesn't exist, we might fail.
oh well. likewise if it's too long. */
dir[0] = '\0';
+ /*@-branchstate@*/
if (realpath(".", dir) != NULL) {
end = dir + strlen(dir);
if (end[-1] != '/') *end++ = '/';
@@ -98,6 +101,7 @@ static fingerPrint doLookup(fingerPrintCache cache,
cleanDirName = dir;
cdnl = end - dir;
}
+ /*@=branchstate@*/
}
fp.entry = NULL;
fp.subDir = NULL;
diff --git a/rpmdb/rpmdb.c b/rpmdb/rpmdb.c
index 7018f10cd..a9106c8ce 100644
--- a/rpmdb/rpmdb.c
+++ b/rpmdb/rpmdb.c
@@ -1,3 +1,4 @@
+/*@-branchstate@*/
/** \ingroup rpmdb dbi
* \file rpmdb/rpmdb.c
*/
@@ -84,7 +85,7 @@ static int dbiTagToDbix(int rpmtag)
* Initialize database (index, tag) tuple from configuration.
*/
static void dbiTagsInit(void)
- /*@globals rpmGlobalMacroContext @*/
+ /*@globals rpmGlobalMacroContext, dbiTags, dbiTagsMax @*/
/*@modifies dbiTags, dbiTagsMax @*/
{
/*@observer@*/ static const char * const _dbiTagStr_default =
@@ -854,7 +855,7 @@ static /*@only@*/ /*@null@*/
rpmdb newRpmdb(/*@kept@*/ /*@null@*/ const char * root,
/*@kept@*/ /*@null@*/ const char * home,
int mode, int perms, int flags)
- /*@globals rpmGlobalMacroContext,
+ /*@globals _db_filter_dups, rpmGlobalMacroContext,
fileSystem @*/
/*@modifies _db_filter_dups, fileSystem @*/
{
@@ -900,7 +901,8 @@ static int openDatabase(/*@null@*/ const char * prefix,
/*@null@*/ const char * dbpath,
int _dbapi, /*@null@*/ /*@out@*/ rpmdb *dbp,
int mode, int perms, int flags)
- /*@globals rpmGlobalMacroContext @*/
+ /*@globals rpmGlobalMacroContext,
+ fileSystem @*/
/*@modifies *dbp, fileSystem @*/
{
rpmdb db;
@@ -1100,6 +1102,7 @@ int rpmdbVerify(const char * prefix)
static int rpmdbFindByFile(rpmdb db, /*@null@*/ const char * filespec,
/*@out@*/ dbiIndexSet * matches)
+ /*@globals fileSystem @*/
/*@modifies db, *matches, fileSystem @*/
{
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
@@ -1277,6 +1280,7 @@ static int dbiFindMatches(dbiIndex dbi, DBC * dbcursor,
/*@null@*/ const char * version,
/*@null@*/ const char * release,
/*@out@*/ dbiIndexSet * matches)
+ /*@globals fileSystem @*/
/*@modifies dbi, *dbcursor, *matches, fileSystem @*/
{
int gotMatches;
@@ -1364,6 +1368,7 @@ exit:
*/
static int dbiFindByLabel(dbiIndex dbi, DBC * dbcursor,
/*@null@*/ const char * arg, /*@out@*/ dbiIndexSet * matches)
+ /*@globals fileSystem @*/
/*@modifies dbi, *dbcursor, *matches, fileSystem @*/
{
const char * release;
@@ -2176,7 +2181,7 @@ int rpmdbAppendIterator(rpmdbMatchIterator mi, const int * hdrNums, int nHdrNums
return 0;
}
-rpmdbMatchIterator rpmdbInitIterator(rpmdb rpmdb, int rpmtag,
+rpmdbMatchIterator rpmdbInitIterator(rpmdb db, int rpmtag,
const void * keyp, size_t keylen)
{
rpmdbMatchIterator mi = NULL;
@@ -2185,7 +2190,7 @@ rpmdbMatchIterator rpmdbInitIterator(rpmdb rpmdb, int rpmtag,
const void * mi_keyp = NULL;
int isLabel = 0;
- if (rpmdb == NULL)
+ if (db == NULL)
return NULL;
/* XXX HACK to remove rpmdbFindByLabel/findMatches from the API */
switch (rpmtag) {
@@ -2195,7 +2200,7 @@ rpmdbMatchIterator rpmdbInitIterator(rpmdb rpmdb, int rpmtag,
break;
}
- dbi = dbiOpen(rpmdb, rpmtag, 0);
+ dbi = dbiOpen(db, rpmtag, 0);
if (dbi == NULL)
return NULL;
@@ -2221,7 +2226,7 @@ fprintf(stderr, "*** RMW %s %p\n", tagName(rpmtag), dbi->dbi_rmw);
xx = dbiCclose(dbi, dbcursor, 0);
dbcursor = NULL;
} else if (rpmtag == RPMTAG_BASENAMES) {
- rc = rpmdbFindByFile(rpmdb, keyp, &set);
+ rc = rpmdbFindByFile(db, keyp, &set);
} else {
xx = dbiCopen(dbi, &dbcursor, 0);
/*@-nullpass@*/ /* LCL: keyp != NULL here. */
@@ -2252,7 +2257,7 @@ fprintf(stderr, "*** RMW %s %p\n", tagName(rpmtag), dbi->dbi_rmw);
mi->mi_keylen = keylen;
/*@-assignexpose@*/
- mi->mi_rpmdb = rpmdb;
+ mi->mi_rpmdb = db;
/*@=assignexpose@*/
mi->mi_rpmtag = rpmtag;
@@ -2313,18 +2318,18 @@ static INLINE int removeIndexEntry(dbiIndex dbi, DBC * dbcursor,
}
/* XXX install.c uninstall.c */
-int rpmdbRemove(rpmdb rpmdb, /*@unused@*/ int rid, unsigned int hdrNum)
+int rpmdbRemove(rpmdb db, /*@unused@*/ int rid, unsigned int hdrNum)
{
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
HFD_t hfd = headerFreeData;
Header h;
sigset_t signalMask;
- if (rpmdb == NULL)
+ if (db == NULL)
return 0;
{ rpmdbMatchIterator mi;
- mi = rpmdbInitIterator(rpmdb, RPMDBI_PACKAGES, &hdrNum, sizeof(hdrNum));
+ mi = rpmdbInitIterator(db, RPMDBI_PACKAGES, &hdrNum, sizeof(hdrNum));
h = rpmdbNextIterator(mi);
if (h)
h = headerLink(h);
@@ -2350,7 +2355,7 @@ int rpmdbRemove(rpmdb rpmdb, /*@unused@*/ int rid, unsigned int hdrNum)
rpmMessage(RPMMESS_DEBUG, " --- %10u %s-%s-%s\n", hdrNum, n, v, r);
}
- (void) blockSignals(rpmdb, &signalMask);
+ (void) blockSignals(db, &signalMask);
{ int dbix;
dbiIndexItem rec = dbiIndexNewItem(hdrNum, 0);
@@ -2379,7 +2384,7 @@ int rpmdbRemove(rpmdb rpmdb, /*@unused@*/ int rid, unsigned int hdrNum)
continue;
/*@notreached@*/ /*@switchbreak@*/ break;
case RPMDBI_PACKAGES:
- dbi = dbiOpen(rpmdb, rpmtag, 0);
+ dbi = dbiOpen(db, rpmtag, 0);
if (dbi != NULL) {
xx = dbiCopen(dbi, &dbcursor, DBI_WRITECURSOR);
xx = dbiDel(dbi, dbcursor, &hdrNum, sizeof(hdrNum), 0);
@@ -2395,7 +2400,7 @@ int rpmdbRemove(rpmdb rpmdb, /*@unused@*/ int rid, unsigned int hdrNum)
if (!hge(h, rpmtag, &rpmtype, (void **) &rpmvals, &rpmcnt))
continue;
- dbi = dbiOpen(rpmdb, rpmtag, 0);
+ dbi = dbiOpen(db, rpmtag, 0);
if (dbi != NULL) {
xx = dbiCopen(dbi, &dbcursor, DBI_WRITECURSOR);
@@ -2474,7 +2479,7 @@ int rpmdbRemove(rpmdb rpmdb, /*@unused@*/ int rid, unsigned int hdrNum)
rec = _free(rec);
}
- (void) unblockSignals(rpmdb, &signalMask);
+ (void) unblockSignals(db, &signalMask);
h = headerFree(h);
@@ -2522,7 +2527,7 @@ static INLINE int addIndexEntry(dbiIndex dbi, DBC * dbcursor,
}
/* XXX install.c */
-int rpmdbAdd(rpmdb rpmdb, int iid, Header h)
+int rpmdbAdd(rpmdb db, int iid, Header h)
{
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
HFD_t hfd = headerFreeData;
@@ -2538,7 +2543,7 @@ int rpmdbAdd(rpmdb rpmdb, int iid, Header h)
int rc = 0;
int xx;
- if (rpmdb == NULL)
+ if (db == NULL)
return 0;
if (iid != 0 && iid != -1) {
@@ -2559,7 +2564,7 @@ int rpmdbAdd(rpmdb rpmdb, int iid, Header h)
if (_noDirTokens)
expandFilelist(h);
- (void) blockSignals(rpmdb, &signalMask);
+ (void) blockSignals(db, &signalMask);
{
unsigned int firstkey = 0;
@@ -2569,7 +2574,7 @@ int rpmdbAdd(rpmdb rpmdb, int iid, Header h)
void * datap = NULL;
size_t datalen = 0;
- dbi = dbiOpen(rpmdb, RPMDBI_PACKAGES, 0);
+ dbi = dbiOpen(db, RPMDBI_PACKAGES, 0);
if (dbi != NULL) {
/* XXX db0: hack to pass sizeof header to fadAlloc */
@@ -2639,7 +2644,7 @@ int rpmdbAdd(rpmdb rpmdb, int iid, Header h)
continue;
/*@notreached@*/ /*@switchbreak@*/ break;
case RPMDBI_PACKAGES:
- dbi = dbiOpen(rpmdb, rpmtag, 0);
+ dbi = dbiOpen(db, rpmtag, 0);
if (dbi != NULL) {
xx = dbiCopen(dbi, &dbcursor, DBI_WRITECURSOR);
xx = dbiUpdateRecord(dbi, dbcursor, hdrNum, h);
@@ -2679,7 +2684,7 @@ int rpmdbAdd(rpmdb rpmdb, int iid, Header h)
rpmcnt = 1;
}
- dbi = dbiOpen(rpmdb, rpmtag, 0);
+ dbi = dbiOpen(db, rpmtag, 0);
if (dbi != NULL) {
xx = dbiCopen(dbi, &dbcursor, DBI_WRITECURSOR);
@@ -2782,13 +2787,13 @@ int rpmdbAdd(rpmdb rpmdb, int iid, Header h)
}
exit:
- (void) unblockSignals(rpmdb, &signalMask);
+ (void) unblockSignals(db, &signalMask);
return rc;
}
/* XXX transaction.c */
-int rpmdbFindFpList(rpmdb rpmdb, fingerPrint * fpList, dbiIndexSet * matchList,
+int rpmdbFindFpList(rpmdb db, fingerPrint * fpList, dbiIndexSet * matchList,
int numItems)
{
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
@@ -2798,9 +2803,9 @@ int rpmdbFindFpList(rpmdb rpmdb, fingerPrint * fpList, dbiIndexSet * matchList,
Header h;
int i;
- if (rpmdb == NULL) return 0;
+ if (db == NULL) return 0;
- mi = rpmdbInitIterator(rpmdb, RPMTAG_BASENAMES, NULL, 0);
+ mi = rpmdbInitIterator(db, RPMTAG_BASENAMES, NULL, 0);
/* Gather all matches from the database */
for (i = 0; i < numItems; i++) {
@@ -2906,7 +2911,7 @@ char * db1basename (int rpmtag)
return xstrdup(base);
}
-static int rpmdbRemoveDatabase(const char * rootdir,
+static int rpmdbRemoveDatabase(const char * prefix,
const char * dbpath, int _dbapi)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/
@@ -2924,21 +2929,21 @@ static int rpmdbRemoveDatabase(const char * rootdir,
dbpath = filename;
}
- filename = alloca(strlen(rootdir) + strlen(dbpath) + 40);
+ filename = alloca(strlen(prefix) + strlen(dbpath) + 40);
switch (_dbapi) {
case 3:
if (dbiTags != NULL)
for (i = 0; i < dbiTagsMax; i++) {
const char * base = tagName(dbiTags[i]);
- sprintf(filename, "%s/%s/%s", rootdir, dbpath, base);
+ sprintf(filename, "%s/%s/%s", prefix, dbpath, base);
(void)rpmCleanPath(filename);
if (!rpmfileexists(filename))
continue;
xx = unlink(filename);
}
for (i = 0; i < 16; i++) {
- sprintf(filename, "%s/%s/__db.%03d", rootdir, dbpath, i);
+ sprintf(filename, "%s/%s/__db.%03d", prefix, dbpath, i);
(void)rpmCleanPath(filename);
if (!rpmfileexists(filename))
continue;
@@ -2951,7 +2956,7 @@ static int rpmdbRemoveDatabase(const char * rootdir,
if (dbiTags != NULL)
for (i = 0; i < dbiTagsMax; i++) {
const char * base = db1basename(dbiTags[i]);
- sprintf(filename, "%s/%s/%s", rootdir, dbpath, base);
+ sprintf(filename, "%s/%s/%s", prefix, dbpath, base);
(void)rpmCleanPath(filename);
if (!rpmfileexists(filename))
continue;
@@ -2961,14 +2966,14 @@ static int rpmdbRemoveDatabase(const char * rootdir,
break;
}
- sprintf(filename, "%s/%s", rootdir, dbpath);
+ sprintf(filename, "%s/%s", prefix, dbpath);
(void)rpmCleanPath(filename);
xx = rmdir(filename);
return 0;
}
-static int rpmdbMoveDatabase(const char * rootdir,
+static int rpmdbMoveDatabase(const char * prefix,
const char * olddbpath, int _olddbapi,
const char * newdbpath, int _newdbapi)
/*@globals fileSystem @*/
@@ -2997,8 +3002,8 @@ static int rpmdbMoveDatabase(const char * rootdir,
newdbpath = nfilename;
}
- ofilename = alloca(strlen(rootdir) + strlen(olddbpath) + 40);
- nfilename = alloca(strlen(rootdir) + strlen(newdbpath) + 40);
+ ofilename = alloca(strlen(prefix) + strlen(olddbpath) + 40);
+ nfilename = alloca(strlen(prefix) + strlen(newdbpath) + 40);
switch (_olddbapi) {
case 3:
@@ -3020,22 +3025,22 @@ static int rpmdbMoveDatabase(const char * rootdir,
}
base = tagName(rpmtag);
- sprintf(ofilename, "%s/%s/%s", rootdir, olddbpath, base);
+ sprintf(ofilename, "%s/%s/%s", prefix, olddbpath, base);
(void)rpmCleanPath(ofilename);
if (!rpmfileexists(ofilename))
continue;
- sprintf(nfilename, "%s/%s/%s", rootdir, newdbpath, base);
+ sprintf(nfilename, "%s/%s/%s", prefix, newdbpath, base);
(void)rpmCleanPath(nfilename);
if ((xx = Rename(ofilename, nfilename)) != 0)
rc = 1;
}
for (i = 0; i < 16; i++) {
- sprintf(ofilename, "%s/%s/__db.%03d", rootdir, olddbpath, i);
+ sprintf(ofilename, "%s/%s/__db.%03d", prefix, olddbpath, i);
(void)rpmCleanPath(ofilename);
if (!rpmfileexists(ofilename))
continue;
xx = unlink(ofilename);
- sprintf(nfilename, "%s/%s/__db.%03d", rootdir, newdbpath, i);
+ sprintf(nfilename, "%s/%s/__db.%03d", prefix, newdbpath, i);
(void)rpmCleanPath(nfilename);
#ifdef DYING
if ((xx = Rename(ofilename, nfilename)) != 0)
@@ -3066,11 +3071,11 @@ static int rpmdbMoveDatabase(const char * rootdir,
}
base = db1basename(rpmtag);
- sprintf(ofilename, "%s/%s/%s", rootdir, olddbpath, base);
+ sprintf(ofilename, "%s/%s/%s", prefix, olddbpath, base);
(void)rpmCleanPath(ofilename);
if (!rpmfileexists(ofilename))
continue;
- sprintf(nfilename, "%s/%s/%s", rootdir, newdbpath, base);
+ sprintf(nfilename, "%s/%s/%s", prefix, newdbpath, base);
(void)rpmCleanPath(nfilename);
if ((xx = Rename(ofilename, nfilename)) != 0)
rc = 1;
@@ -3081,7 +3086,7 @@ static int rpmdbMoveDatabase(const char * rootdir,
if (rc || _olddbapi == _newdbapi)
return rc;
- rc = rpmdbRemoveDatabase(rootdir, newdbpath, _newdbapi);
+ rc = rpmdbRemoveDatabase(prefix, newdbpath, _newdbapi);
/* Remove /etc/rpm/macros.db1 configuration file if db3 rebuilt. */
@@ -3096,7 +3101,7 @@ static int rpmdbMoveDatabase(const char * rootdir,
}
/*@-globs@*/ /* FIX: rpmGlobalMacroContext not in <rpmlib.h> */
-int rpmdbRebuild(const char * rootdir)
+int rpmdbRebuild(const char * prefix)
{
rpmdb olddb;
const char * dbpath = NULL;
@@ -3112,7 +3117,7 @@ int rpmdbRebuild(const char * rootdir)
int _dbapi;
int _dbapi_rebuild;
- if (rootdir == NULL) rootdir = "/";
+ if (prefix == NULL) prefix = "/";
_dbapi = rpmExpandNumeric("%{_dbapi}");
_dbapi_rebuild = rpmExpandNumeric("%{_dbapi_rebuild}");
@@ -3125,9 +3130,9 @@ int rpmdbRebuild(const char * rootdir)
rc = 1;
goto exit;
}
- dbpath = rootdbpath = rpmGetPath(rootdir, tfn, NULL);
- if (!(rootdir[0] == '/' && rootdir[1] == '\0'))
- dbpath += strlen(rootdir);
+ dbpath = rootdbpath = rpmGetPath(prefix, tfn, NULL);
+ if (!(prefix[0] == '/' && prefix[1] == '\0'))
+ dbpath += strlen(prefix);
tfn = _free(tfn);
/*@-nullpass@*/
@@ -3143,9 +3148,9 @@ int rpmdbRebuild(const char * rootdir)
tfn = t;
nocleanup = 0;
}
- newdbpath = newrootdbpath = rpmGetPath(rootdir, tfn, NULL);
- if (!(rootdir[0] == '/' && rootdir[1] == '\0'))
- newdbpath += strlen(rootdir);
+ newdbpath = newrootdbpath = rpmGetPath(prefix, tfn, NULL);
+ if (!(prefix[0] == '/' && prefix[1] == '\0'))
+ newdbpath += strlen(prefix);
tfn = _free(tfn);
rpmMessage(RPMMESS_DEBUG, _("rebuilding database %s into %s\n"),
@@ -3170,7 +3175,7 @@ int rpmdbRebuild(const char * rootdir)
rpmMessage(RPMMESS_DEBUG, _("opening old database with dbapi %d\n"),
_dbapi);
_rebuildinprogress = 1;
- if (openDatabase(rootdir, dbpath, _dbapi, &olddb, O_RDONLY, 0644,
+ if (openDatabase(prefix, dbpath, _dbapi, &olddb, O_RDONLY, 0644,
RPMDB_FLAG_MINIMAL)) {
rc = 1;
goto exit;
@@ -3181,7 +3186,7 @@ int rpmdbRebuild(const char * rootdir)
rpmMessage(RPMMESS_DEBUG, _("opening new database with dbapi %d\n"),
_dbapi_rebuild);
(void) rpmDefineMacro(NULL, "_rpmdb_rebuild %{nil}", -1);
- if (openDatabase(rootdir, newdbpath, _dbapi_rebuild, &newdb, O_RDWR | O_CREAT, 0644, 0)) {
+ if (openDatabase(prefix, newdbpath, _dbapi_rebuild, &newdb, O_RDWR | O_CREAT, 0644, 0)) {
rc = 1;
goto exit;
}
@@ -3263,11 +3268,11 @@ int rpmdbRebuild(const char * rootdir)
rpmMessage(RPMMESS_NORMAL, _("failed to rebuild database: original database "
"remains in place\n"));
- xx = rpmdbRemoveDatabase(rootdir, newdbpath, _dbapi_rebuild);
+ xx = rpmdbRemoveDatabase(prefix, newdbpath, _dbapi_rebuild);
rc = 1;
goto exit;
} else if (!nocleanup) {
- if (rpmdbMoveDatabase(rootdir, newdbpath, _dbapi_rebuild, dbpath, _dbapi)) {
+ if (rpmdbMoveDatabase(prefix, newdbpath, _dbapi_rebuild, dbpath, _dbapi)) {
rpmMessage(RPMMESS_ERROR, _("failed to replace old database with new "
"database!\n"));
rpmMessage(RPMMESS_ERROR, _("replace files in %s with files from %s "
@@ -3291,3 +3296,4 @@ exit:
return rc;
}
/*@=globs@*/
+/*@=branchstate@*/
diff --git a/rpmdb/rpmdb.h b/rpmdb/rpmdb.h
index bf697a5fe..25875023a 100644
--- a/rpmdb/rpmdb.h
+++ b/rpmdb/rpmdb.h
@@ -365,7 +365,7 @@ extern "C" {
* @param rpmdb rpm database
*/
/*@only@*/ /*@null@*/ dbiIndex db3New(/*@keep@*/ rpmdb rpmdb, int rpmtag)
- /*@global rpmGlobalMacroContext @*/
+ /*@globals rpmGlobalMacroContext @*/
/*@modifies rpmGlobalMacroContext @*/;
/** \ingroup db3
@@ -401,9 +401,9 @@ extern "C" {
/** \ingroup dbi
* @param dbi index database handle
- * @param dbiflags DBI_WRITECURSOR or DBI_ITERATOR
+ * @param flags DBI_WRITECURSOR, DBI_ITERATOR or 0
*/
-int dbiCopen(dbiIndex dbi, /*@out@*/ DBC ** dbcp, unsigned int dbiflags)
+int dbiCopen(dbiIndex dbi, /*@out@*/ DBC ** dbcp, unsigned int flags)
/*@globals fileSystem@*/
/*@modifies dbi, *dbcp, fileSystem @*/;
diff --git a/rpmdb/rpmhash.c b/rpmdb/rpmhash.c
index 5807fa318..6abe75cdf 100644
--- a/rpmdb/rpmhash.c
+++ b/rpmdb/rpmhash.c
@@ -103,6 +103,7 @@ void htAddEntry(hashTable ht, const void * key, const void * data)
while (b && b->key && ht->eq(b->key, key))
b = b->next;
+ /*@-branchstate@*/
if (b == NULL) {
b = xmalloc(sizeof(*b));
if (ht->keySize) {
@@ -117,6 +118,7 @@ void htAddEntry(hashTable ht, const void * key, const void * data)
b->data = NULL;
ht->buckets[hash] = b;
}
+ /*@=branchstate@*/
b->data = xrealloc(b->data, sizeof(*b->data) * (b->dataCount + 1));
b->data[b->dataCount++] = data;
@@ -129,14 +131,18 @@ void htFree(hashTable ht)
for (i = 0; i < ht->numBuckets; i++) {
b = ht->buckets[i];
+ /*@-branchstate@*/
if (ht->keySize && b) free((void *)b->key);
+ /*@=branchstate@*/
while (b) {
n = b->next;
+ /*@-branchstate@*/
if (b->data) {
if (ht->freeData)
*b->data = _free(*b->data);
b->data = _free(b->data);
}
+ /*@=branchstate@*/
b = _free(b);
b = n;
}