summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2001-05-03 21:00:18 +0000
committerjbj <devnull@localhost>2001-05-03 21:00:18 +0000
commitd78e027808deb6aef4e65338d160986d7e576a90 (patch)
tree53cddb260f6b5a0fab362b6c0f6f3375d0cacb8b /lib
parent0ecdbba93587408c670124e88d39451c681a77eb (diff)
downloadlibrpm-tizen-d78e027808deb6aef4e65338d160986d7e576a90.tar.gz
librpm-tizen-d78e027808deb6aef4e65338d160986d7e576a90.tar.bz2
librpm-tizen-d78e027808deb6aef4e65338d160986d7e576a90.zip
- still more boring lclint annotations and fiddles.
CVS patchset: 4738 CVS date: 2001/05/03 21:00:18
Diffstat (limited to 'lib')
-rw-r--r--lib/.lclintrc1
-rw-r--r--lib/Makefile.am9
-rw-r--r--lib/db1.c10
-rw-r--r--lib/db3.c58
-rw-r--r--lib/depends.c107
-rw-r--r--lib/depends.h24
-rw-r--r--lib/fprint.c11
-rw-r--r--lib/fs.c2
-rw-r--r--lib/fsm.c19
-rw-r--r--lib/fsm.h4
-rw-r--r--lib/hash.c3
-rw-r--r--lib/header.c127
-rw-r--r--lib/header.h28
-rw-r--r--lib/manifest.c10
-rw-r--r--lib/md5.h2
-rw-r--r--lib/misc.c3
-rw-r--r--lib/package.c2
-rw-r--r--lib/poptBT.c4
-rw-r--r--lib/poptQV.c6
-rw-r--r--lib/problems.c32
-rw-r--r--lib/psm.c45
-rw-r--r--lib/psm.h4
-rw-r--r--lib/query.c19
-rw-r--r--lib/rpmchecksig.c7
-rw-r--r--lib/rpmdb.c143
-rw-r--r--lib/rpmdb.h38
-rw-r--r--lib/rpminstall.c35
-rw-r--r--lib/rpmlib.h138
-rw-r--r--lib/rpmrc.c180
-rw-r--r--lib/signature.c109
-rw-r--r--lib/signature.h25
-rw-r--r--lib/transaction.c42
-rw-r--r--lib/verify.c13
33 files changed, 792 insertions, 468 deletions
diff --git a/lib/.lclintrc b/lib/.lclintrc
index 7aa8dd046..ebc4dddc4 100644
--- a/lib/.lclintrc
+++ b/lib/.lclintrc
@@ -16,7 +16,6 @@
# not-yet normal parameters
-boolops # ~831 w->n
-#-null # ~267
-predboolint # ~576 w->n
-type # ~872
diff --git a/lib/Makefile.am b/lib/Makefile.am
index f68c13693..dc7aec1b7 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -57,9 +57,9 @@ getdate.c: getdate.y
@echo expect 10 shift/reduce conflicts
$(YACC) $(srcdir)/getdate.y
-@if test -f y.tab.c; then \
- { echo "/*@-globstate -retvalint -unqualifiedtrans -usedef -varuse@*/";\
+ { echo "/*@-globstate -retvalint -unqualifiedtrans -usedef -varuse -nullderef@*/";\
cat y.tab.c ;\
- echo "/*@=globstate =retvalint =unqualifiedtrans =usedef =varuse@*/";\
+ echo "/*@=globstate =retvalint =unqualifiedtrans =usedef =varuse =nullderef@*/";\
} > getdate.c ;\
rm -f y.tab.c; \
else \
@@ -72,7 +72,10 @@ getdate.c: getdate.y
BUILT_SOURCES = tagtable.c getdate.c
-.PHONY: lclint
+.PHONY: sources
+sources:
+ @echo $(librpm_la_SOURCES:%=lib/%)
+
.PHONY: lclint
lclint:
lclint $(DEFS) $(INCLUDES) $(librpm_la_SOURCES)
diff --git a/lib/db1.c b/lib/db1.c
index 4bc7d4ec2..4162afb48 100644
--- a/lib/db1.c
+++ b/lib/db1.c
@@ -310,7 +310,9 @@ if (keylen) *keylen = key.size;
if (datalen) *datalen = data.size;
}
+ /*@-nullstate@*/
return rc;
+ /*@=nullstate@*/
}
/*@=compmempass@*/
@@ -335,7 +337,8 @@ static int db1cdel(dbiIndex dbi, /*@unused@*/ DBC * dbcursor, const void * keyp,
/*@=usedef@*/
key.size = keylen;
- rc = db->del(db, &key, 0);
+ if (db)
+ rc = db->del(db, &key, 0);
rc = cvtdberr(dbi, "db->del", rc, _debug);
}
@@ -382,7 +385,8 @@ static int db1cput(dbiIndex dbi, /*@unused@*/ DBC * dbcursor,
} else {
DB * db = dbi->dbi_db;
- rc = db->put(db, &key, &data, 0);
+ if (db)
+ rc = db->put(db, &key, &data, 0);
rc = cvtdberr(dbi, "db->put", rc, _debug);
}
@@ -495,7 +499,7 @@ static int db1open(/*@keep@*/ rpmdb rpmdb, int rpmtag, dbiIndex * dbip)
exit:
if (rc == 0 && dbi->dbi_db != NULL && dbip) {
dbi->dbi_vec = &db1vec;
- *dbip = dbi;
+ if (dbip) *dbip = dbi;
} else
(void) db1close(dbi, 0);
diff --git a/lib/db3.c b/lib/db3.c
index 14dd3094f..c6759ecd8 100644
--- a/lib/db3.c
+++ b/lib/db3.c
@@ -109,8 +109,9 @@ static int cvtdberr(dbiIndex dbi, const char * msg, int error, int printit) {
return rc;
}
-static int db_fini(dbiIndex dbi, const char * dbhome, const char * dbfile,
- /*@unused@*/ const char * dbsubfile)
+static int db_fini(dbiIndex dbi, const char * dbhome,
+ /*@null@*/ const char * dbfile,
+ /*@unused@*/ /*@null@*/ const char * dbsubfile)
{
rpmdb rpmdb = dbi->dbi_rpmdb;
DB_ENV * dbenv = dbi->dbi_dbenv;
@@ -161,8 +162,10 @@ static int db3_fsync_disable(/*@unused@*/ int fd) {
return 0;
}
-static int db_init(dbiIndex dbi, const char *dbhome, const char *dbfile,
- /*@unused@*/ const char * dbsubfile, /*@out@*/ DB_ENV **dbenvp)
+static int db_init(dbiIndex dbi, const char *dbhome,
+ /*@null@*/ const char *dbfile,
+ /*@unused@*/ /*@null@*/ const char * dbsubfile,
+ /*@out@*/ DB_ENV **dbenvp)
{
rpmdb rpmdb = dbi->dbi_rpmdb;
DB_ENV *dbenv = NULL;
@@ -189,18 +192,21 @@ static int db_init(dbiIndex dbi, const char *dbhome, const char *dbfile,
goto errxit;
#if defined(__USE_DB3)
+ if (dbenv == NULL)
+ return 1;
+
{ int xx;
dbenv->set_errcall(dbenv, rpmdb->db_errcall);
dbenv->set_errfile(dbenv, rpmdb->db_errfile);
dbenv->set_errpfx(dbenv, rpmdb->db_errpfx);
/* dbenv->set_paniccall(???) */
- dbenv->set_verbose(dbenv, DB_VERB_CHKPOINT,
+ (void) dbenv->set_verbose(dbenv, DB_VERB_CHKPOINT,
(dbi->dbi_verbose & DB_VERB_CHKPOINT));
- dbenv->set_verbose(dbenv, DB_VERB_DEADLOCK,
+ (void) dbenv->set_verbose(dbenv, DB_VERB_DEADLOCK,
(dbi->dbi_verbose & DB_VERB_DEADLOCK));
- dbenv->set_verbose(dbenv, DB_VERB_RECOVERY,
+ (void) dbenv->set_verbose(dbenv, DB_VERB_RECOVERY,
(dbi->dbi_verbose & DB_VERB_RECOVERY));
- dbenv->set_verbose(dbenv, DB_VERB_WAITSFOR,
+ (void) dbenv->set_verbose(dbenv, DB_VERB_WAITSFOR,
(dbi->dbi_verbose & DB_VERB_WAITSFOR));
/* dbenv->set_lg_max(???) */
/* dbenv->set_lk_conflicts(???) */
@@ -269,12 +275,13 @@ errxit:
static int db3sync(dbiIndex dbi, unsigned int flags)
{
DB * db = dbi->dbi_db;
- int rc;
+ int rc = 0;
#if defined(__USE_DB2) || defined(__USE_DB3)
int _printit;
- rc = db->sync(db, flags);
+ if (db != NULL)
+ rc = db->sync(db, flags);
/* XXX DB_INCOMPLETE is returned occaisionally with multiple access. */
_printit = (rc == DB_INCOMPLETE ? 0 : _debug);
rc = cvtdberr(dbi, "db->sync", rc, _printit);
@@ -337,10 +344,12 @@ static int db3c_put(dbiIndex dbi, DBC * dbcursor,
return rc;
}
-static inline int db3c_close(dbiIndex dbi, /*@only@*/ DBC * dbcursor)
+static inline int db3c_close(dbiIndex dbi, /*@only@*/ /*@null@*/ DBC * dbcursor)
{
int rc;
+ if (dbcursor == NULL) return -2;
+
rc = dbcursor->c_close(dbcursor);
rc = cvtdberr(dbi, "dbcursor->c_close", rc, _debug);
return rc;
@@ -353,6 +362,7 @@ static inline int db3c_open(dbiIndex dbi, /*@out@*/ DBC ** dbcp)
int flags;
int rc;
+ if (db == NULL) return -2;
#if defined(__USE_DB3)
if ((dbi->dbi_eflags & DB_INIT_CDB) && !(dbi->dbi_oflags & DB_RDONLY))
flags = DB_WRITECURSOR;
@@ -367,7 +377,7 @@ static inline int db3c_open(dbiIndex dbi, /*@out@*/ DBC ** dbcp)
return rc;
}
-static int db3cclose(dbiIndex dbi, /*@only@*/ DBC * dbcursor,
+static int db3cclose(dbiIndex dbi, /*@only@*/ /*@null@*/ DBC * dbcursor,
unsigned int flags)
{
int rc = 0;
@@ -432,6 +442,7 @@ static int db3cput(dbiIndex dbi, DBC * dbcursor,
data.size = datalen;
if (dbcursor == NULL) {
+ if (db == NULL) return -2;
rc = db->put(db, txnid, &key, &data, 0);
rc = cvtdberr(dbi, "db->put", rc, _debug);
} else {
@@ -459,6 +470,7 @@ static int db3cdel(dbiIndex dbi, DBC * dbcursor,
key.size = keylen;
if (dbcursor == NULL) {
+ if (db == NULL) return -2;
rc = db->del(db, txnid, &key, 0);
rc = cvtdberr(dbi, "db->del", rc, _debug);
} else {
@@ -496,6 +508,9 @@ static int db3cget(dbiIndex dbi, DBC * dbcursor,
if (dbcursor == NULL) {
int _printit;
+ /*@-compmempass@*/
+ if (db == NULL) return -2;
+ /*@=compmempass@*/
rc = db->get(db, txnid, &key, &data, 0);
/* XXX DB_NOTFOUND can be returned */
_printit = (rc == DB_NOTFOUND ? 0 : _debug);
@@ -517,9 +532,9 @@ static int db3cget(dbiIndex dbi, DBC * dbcursor,
/*@=onlytrans@*/
}
- /*@-compmempass@*/
+ /*@-compmempass -nullstate@*/
return rc;
- /*@=compmempass@*/
+ /*@=compmempass =nullstate@*/
}
static int db3byteswapped(dbiIndex dbi)
@@ -528,7 +543,8 @@ static int db3byteswapped(dbiIndex dbi)
int rc = 0;
#if defined(__USE_DB3)
- rc = db->get_byteswapped(db);
+ if (db != NULL)
+ rc = db->get_byteswapped(db);
#endif /* __USE_DB3 */
return rc;
@@ -583,7 +599,9 @@ static int db3close(/*@only@*/ dbiIndex dbi, /*@unused@*/ unsigned int flags)
}
if (dbi->dbi_use_dbenv)
- xx = db_fini(dbi, dbhome, dbfile, dbsubfile);
+ /*@-nullstate@*/
+ xx = db_fini(dbi, (dbhome ? dbhome : ""), dbfile, dbsubfile);
+ /*@=nullstate@*/
#else /* __USE_DB2 || __USE_DB3 */
@@ -622,7 +640,9 @@ static int db3open(/*@keep@*/ rpmdb rpmdb, int rpmtag, dbiIndex * dbip)
if (dbip)
*dbip = NULL;
if ((dbi = db3New(rpmdb, rpmtag)) == NULL)
+ /*@-nullstate@*/
return 1;
+ /*@=nullstate@*/
dbi->dbi_api = DB_VERSION_MAJOR;
urlfn = rpmGenPath(
@@ -671,7 +691,7 @@ static int db3open(/*@keep@*/ rpmdb rpmdb, int rpmtag, dbiIndex * dbip)
#if defined(__USE_DB3)
rc = db_create(&db, dbenv, dbi->dbi_cflags);
rc = cvtdberr(dbi, "db_create", rc, _debug);
- if (rc == 0) {
+ if (rc == 0 && db != NULL) {
if (dbi->dbi_lorder) {
rc = db->set_lorder(db, dbi->dbi_lorder);
rc = cvtdberr(dbi, "db->set_lorder", rc, _debug);
@@ -776,7 +796,7 @@ static int db3open(/*@keep@*/ rpmdb rpmdb, int rpmtag, dbiIndex * dbip)
_("cannot get %s lock on %s/%s\n"),
((dbi->dbi_mode & O_RDWR)
? _("exclusive") : _("shared")),
- dbhome, dbfile);
+ dbhome, (dbfile ? dbfile : ""));
rc = 1;
} else if (dbfile) {
rpmMessage(RPMMESS_DEBUG,
@@ -838,7 +858,9 @@ static int db3open(/*@keep@*/ rpmdb rpmdb, int rpmtag, dbiIndex * dbip)
urlfn = _free(urlfn);
+ /*@-nullstate@*/
return rc;
+ /*@=nullstate@*/
}
/** \ingroup db3
diff --git a/lib/depends.c b/lib/depends.c
index e9a26f1e8..437e78432 100644
--- a/lib/depends.c
+++ b/lib/depends.c
@@ -156,7 +156,8 @@ static void alFree(struct availableList * al)
rpmRelocation * r;
int i;
- for (i = 0, p = al->list; i < al->size; i++, p++) {
+ if ((p = al->list) != NULL)
+ for (i = 0; i < al->size; i++, p++) {
{ struct tsortInfo * tsi;
while ((tsi = p->tsi.tsi_next) != NULL) {
@@ -184,15 +185,16 @@ static void alFree(struct availableList * al)
p->fd = fdFree(p->fd, "alAddPackage (alFree)");
}
+ if (al->dirs != NULL)
for (i = 0; i < al->numDirs; i++) {
al->dirs[i].dirName = _free(al->dirs[i].dirName);
al->dirs[i].files = _free(al->dirs[i].files);
}
- if (al->numDirs && al->dirs)
- al->dirs = _free(al->dirs);
- if (al->alloced && al->list)
- al->list = _free(al->list);
+ al->dirs = _free(al->dirs);
+ al->numDirs = 0;
+ al->list = _free(al->list);
+ al->alloced = 0;
alFreeIndex(al);
}
@@ -429,7 +431,7 @@ static void alMakeIndex(struct availableList * al)
struct availableIndex * ai = &al->index;
int i, j, k;
- if (ai->size) return;
+ if (ai->size || al->list == NULL) return;
for (i = 0; i < al->size; i++)
ai->size += al->list[i].providesCount;
@@ -777,6 +779,9 @@ int rpmtransAddPackage(rpmTransactionSet ts, Header h, FD_t fd,
ts->order = xrealloc(ts->order, sizeof(*ts->order) * ts->orderAlloced);
}
ts->order[ts->orderCount].type = TR_ADDED;
+ if (ts->addedPackages.list == NULL)
+ return 0;
+
alNum = alAddPackage(&ts->addedPackages, h, key, fd, relocs) -
ts->addedPackages.list;
ts->order[ts->orderCount++].u.addedIndex = alNum;
@@ -920,14 +925,16 @@ alFileSatisfiesDepend(struct availableList * al,
struct dirInfo_s dirNeedle;
dirInfo dirMatch;
- if (al->numDirs == 0) /* Solaris 2.6 bsearch sucks down on this. */
+ /* Solaris 2.6 bsearch sucks down on this. */
+ if (al->numDirs == 0 || al->dirs == NULL || al->list == NULL)
return NULL;
{ char * chptr = xstrdup(fileName);
dirName = chptr;
- chptr = strrchr(chptr, '/');
- chptr++;
- *chptr = '\0';
+ if ((chptr = strrchr(chptr, '/')) != NULL) {
+ chptr++; /* leave the trailing '/' */
+ *chptr = '\0';
+ }
}
dirNeedle.dirName = (char *) dirName;
@@ -935,25 +942,28 @@ alFileSatisfiesDepend(struct availableList * al,
dirMatch = bsearch(&dirNeedle, al->dirs, al->numDirs,
sizeof(dirNeedle), dirInfoCompare);
dirName = _free(dirName);
- if (!dirMatch) return NULL;
+ if (dirMatch == NULL) return NULL;
baseName = strrchr(fileName, '/') + 1;
/* XXX FIXME: these file lists should be sorted and bsearched */
for (i = 0; i < dirMatch->numFiles; i++) {
- if (!strcmp(dirMatch->files[i].baseName, baseName)) {
+ if (dirMatch->files[i].baseName == NULL ||
+ strcmp(dirMatch->files[i].baseName, baseName))
+ continue;
- /* If a file dependency would be satisfied by a file
- we are not going to install, skip it. */
- if (al->list[dirMatch->files[i].pkgNum].multiLib &&
+ /*
+ * If a file dependency would be satisfied by a file
+ * we are not going to install, skip it.
+ */
+ if (al->list[dirMatch->files[i].pkgNum].multiLib &&
!isFileMULTILIB(dirMatch->files[i].fileFlags))
- continue;
+ continue;
- if (keyType)
- rpmMessage(RPMMESS_DEBUG, _("%s: %-45s YES (added files)\n"),
+ if (keyType)
+ rpmMessage(RPMMESS_DEBUG, _("%s: %-45s YES (added files)\n"),
keyType, fileName);
- return al->list + dirMatch->files[i].pkgNum;
- }
+ return al->list + dirMatch->files[i].pkgNum;
}
return NULL;
@@ -981,7 +991,7 @@ alFileSatisfiesDepend(struct availableList * al,
if (*keyName == '/')
return alFileSatisfiesDepend(al, keyType, keyName);
- if (!al->index.size) return NULL;
+ if (!al->index.size || al->index.index == NULL) return NULL;
needle.entry = keyName;
needle.entryLen = strlen(keyName);
@@ -1078,7 +1088,9 @@ static int unsatisfiedDepend(rpmTransactionSet ts,
if (!(keyFlags & RPMSENSE_SENSEMASK) &&
(rcProvidesString = rpmGetVar(RPMVAR_PROVIDES))) {
i = strlen(keyName);
+ /*@-nullpass -observertrans -mayaliasunique@*/
while ((start = strstr(rcProvidesString, keyName))) {
+ /*@=nullpass =observertrans =mayaliasunique@*/
if (xisspace(start[i]) || start[i] == '\0' || start[i] == ',') {
rpmMessage(RPMMESS_DEBUG, _("%s: %-45s YES (rpmrc provides)\n"),
keyType, keyDepend+2);
@@ -1457,13 +1469,13 @@ static void markLoop(struct tsortInfo * tsi, struct availablePackage * q)
{
struct availablePackage * p;
- while (tsi != NULL) {
- p = tsi->tsi_suc;
+ while (tsi != NULL && (p = tsi->tsi_suc) != NULL) {
tsi = tsi->tsi_next;
if (p->tsi.tsi_pkg != NULL)
continue;
p->tsi.tsi_pkg = q;
- markLoop(p->tsi.tsi_next, p);
+ if (p->tsi.tsi_next != NULL)
+ markLoop(p->tsi.tsi_next, p);
}
}
@@ -1505,16 +1517,21 @@ zapRelation(struct availablePackage * q, struct availablePackage * p,
struct tsortInfo * tsi;
const char *dp = NULL;
- if (q == NULL)
- return dp;
for (tsi_prev = &q->tsi, tsi = q->tsi.tsi_next;
tsi != NULL;
+ /* XXX Note: the loop traverses "not found", break on "found". */
+ /*@-nullderef@*/
tsi_prev = tsi, tsi = tsi->tsi_next)
+ /*@=nullderef@*/
{
int j;
if (tsi->tsi_suc != p)
continue;
+ if (p->requires == NULL) continue; /* XXX can't happen */
+ if (p->requireFlags == NULL) continue; /* XXX can't happen */
+ if (p->requiresEVR == NULL) continue; /* XXX can't happen */
+
j = tsi->tsi_reqx;
dp = printDepend( identifyDepend(p->requireFlags[j]),
p->requires[j], p->requiresEVR[j], p->requireFlags[j]);
@@ -1532,7 +1549,9 @@ zapRelation(struct availablePackage * q, struct availablePackage * p,
_("removing %s-%s-%s \"%s\" from tsort relations.\n"),
p->name, p->version, p->release, dp);
p->tsi.tsi_count--;
+ /*@-nullderef@*/
tsi_prev->tsi_next = tsi->tsi_next;
+ /*@=nullderef@*/
tsi->tsi_next = NULL;
tsi->tsi_suc = NULL;
tsi = _free(tsi);
@@ -1541,6 +1560,7 @@ zapRelation(struct availablePackage * q, struct availablePackage * p,
if (zap)
zap--;
}
+ /* XXX Note: the loop traverses "not found", get out now! */
break;
}
return dp;
@@ -1561,6 +1581,7 @@ static inline int addRelation( const rpmTransactionSet ts,
struct tsortInfo * tsi;
int matchNum;
+ /*@-nullderef@*/
q = alSatisfiesDepend(&ts->addedPackages, NULL, NULL,
p->requires[j], p->requiresEVR[j], p->requireFlags[j]);
@@ -1571,6 +1592,7 @@ static inline int addRelation( const rpmTransactionSet ts,
/* Avoid rpmlib feature dependencies. */
if (!strncmp(p->requires[j], "rpmlib(", sizeof("rpmlib(")-1))
return 0;
+ /*@=nullderef@*/
#if defined(DEPENDENCY_WHITEOUT)
/* Avoid certain dependency relations. */
@@ -1673,7 +1695,8 @@ int rpmdepOrder(rpmTransactionSet ts)
/* Record all relations. */
rpmMessage(RPMMESS_DEBUG, _("========== recording tsort relations\n"));
- for (i = 0, p = ts->addedPackages.list; i < npkgs; i++, p++) {
+ if ((p = ts->addedPackages.list) != NULL)
+ for (i = 0; i < npkgs; i++, p++) {
int matchNum;
if (p->requiresCount <= 0)
@@ -1690,6 +1713,8 @@ int rpmdepOrder(rpmTransactionSet ts)
/* First, do pre-requisites. */
for (j = 0; j < p->requiresCount; j++) {
+ if (p->requireFlags == NULL) continue; /* XXX can't happen */
+
/* Skip if not %pre/%post requires or legacy prereq. */
if (isErasePreReq(p->requireFlags[j]) ||
@@ -1705,6 +1730,8 @@ int rpmdepOrder(rpmTransactionSet ts)
/* Then do co-requisites. */
for (j = 0; j < p->requiresCount; j++) {
+ if (p->requireFlags == NULL) continue; /* XXX can't happen */
+
/* Skip if %pre/%post requires or legacy prereq. */
if (isErasePreReq(p->requireFlags[j]) ||
@@ -1719,7 +1746,8 @@ int rpmdepOrder(rpmTransactionSet ts)
}
/* Save predecessor count. */
- for (i = 0, p = ts->addedPackages.list; i < npkgs; i++, p++) {
+ if ((p = ts->addedPackages.list) != NULL)
+ for (i = 0; i < npkgs; i++, p++) {
p->npreds = p->tsi.tsi_count;
}
@@ -1729,7 +1757,8 @@ int rpmdepOrder(rpmTransactionSet ts)
rescan:
q = r = NULL;
qlen = 0;
- for (i = 0, p = ts->addedPackages.list; i < npkgs; i++, p++) {
+ if ((p = ts->addedPackages.list) != NULL)
+ for (i = 0; i < npkgs; i++, p++) {
/* Prefer packages in presentation order. */
if (!chainsaw)
@@ -1762,10 +1791,12 @@ rescan:
tsi_next = tsi->tsi_next;
tsi->tsi_next = NULL;
p = tsi->tsi_suc;
- if ((--p->tsi.tsi_count) <= 0) {
+ if (p && (--p->tsi.tsi_count) <= 0) {
/* XXX FIXME: add control bit. */
p->tsi.tsi_suc = NULL;
+ /*@-nullstate@*/
addQ(p, &q->tsi.tsi_suc, &r);
+ /*@=nullstate@*/
qlen++;
}
tsi = _free(tsi);
@@ -1783,7 +1814,8 @@ rescan:
/* T9. Initialize predecessor chain. */
nzaps = 0;
- for (i = 0, q = ts->addedPackages.list; i < npkgs; i++, q++) {
+ if ((q = ts->addedPackages.list) != NULL)
+ for (i = 0; i < npkgs; i++, q++) {
q->tsi.tsi_pkg = NULL;
q->tsi.tsi_reqx = 0;
/* Mark packages already sorted. */
@@ -1792,7 +1824,8 @@ rescan:
}
/* T10. Mark all packages with their predecessors. */
- for (i = 0, q = ts->addedPackages.list; i < npkgs; i++, q++) {
+ if ((q = ts->addedPackages.list) != NULL)
+ for (i = 0; i < npkgs; i++, q++) {
if ((tsi = q->tsi.tsi_next) == NULL)
continue;
q->tsi.tsi_next = NULL;
@@ -1801,7 +1834,8 @@ rescan:
}
/* T11. Print all dependency loops. */
- for (i = 0, r = ts->addedPackages.list; i < npkgs; i++, r++) {
+ if ((r = ts->addedPackages.list) != NULL)
+ for (i = 0; i < npkgs; i++, r++) {
int printed;
printed = 0;
@@ -1831,7 +1865,8 @@ rescan:
/* Print next member of loop. */
sprintf(buf, "%s-%s-%s", p->name, p->version, p->release);
- rpmMessage(RPMMESS_WARNING, " %-40s %s\n", buf, dp);
+ rpmMessage(RPMMESS_WARNING, " %-40s %s\n", buf,
+ (dp ? dp : "not found!?!"));
dp = _free(dp);
}
@@ -1881,6 +1916,7 @@ rescan:
key.alIndex = ordering[i];
needle = bsearch(&key, orderList, npkgs, sizeof(key),orderListIndexCmp);
/* bsearch should never, ever fail */
+ if (needle == NULL) continue;
newOrder[newOrderCount++] = ts->order[needle->orIndex];
for (j = needle->orIndex + 1; j < ts->orderCount; j++) {
@@ -1938,7 +1974,8 @@ int rpmdepCheck(rpmTransactionSet ts,
* Look at all of the added packages and make sure their dependencies
* are satisfied.
*/
- for (i = 0, p = ts->addedPackages.list; i < npkgs; i++, p++)
+ if ((p = ts->addedPackages.list) != NULL)
+ for (i = 0; i < npkgs; i++, p++)
{
rpmMessage(RPMMESS_DEBUG, ("========== +++ %s-%s-%s\n"),
diff --git a/lib/depends.h b/lib/depends.h
index c32b71d8e..fd59c78dc 100644
--- a/lib/depends.h
+++ b/lib/depends.h
@@ -14,12 +14,12 @@
struct tsortInfo {
union {
int count;
- /*@kept@*/ struct availablePackage * suc;
+ /*@kept@*//*@null@*/ struct availablePackage * suc;
} tsi_u;
#define tsi_count tsi_u.count
#define tsi_suc tsi_u.suc
-/*@owned@*/ struct tsortInfo * tsi_next;
-/*@kept@*/ struct availablePackage * tsi_pkg;
+/*@owned@*//*@null@*/ struct tsortInfo * tsi_next;
+/*@kept@*//*@null@*/ struct availablePackage * tsi_pkg;
int tsi_reqx;
int tsi_qcnt;
} ;
@@ -35,11 +35,11 @@ struct availablePackage {
/*@owned@*/ const char ** provides; /*!< Provides: name strings. */
/*@owned@*/ const char ** providesEVR; /*!< Provides: [epoch:]version[-release] strings. */
/*@dependent@*/ int * provideFlags; /*!< Provides: logical range qualifiers. */
-/*@owned@*/ const char ** requires; /*!< Requires: name strings. */
-/*@owned@*/ const char ** requiresEVR; /*!< Requires: [epoch:]version[-release] strings. */
-/*@dependent@*/ int * requireFlags; /*!< Requires: logical range qualifiers. */
-/*@owned@*/ const char ** baseNames; /*!< Header file basenames. */
-/*@dependent@*/ int_32 * epoch; /*!< Header epoch (if any). */
+/*@owned@*//*@null@*/ const char ** requires; /*!< Requires: name strings. */
+/*@owned@*//*@null@*/ const char ** requiresEVR;/*!< Requires: [epoch:]version[-release] strings. */
+/*@dependent@*//*@null@*/ int * requireFlags; /*!< Requires: logical range qualifiers. */
+/*@owned@*//*@null@*/ const char ** baseNames; /*!< Header file basenames. */
+/*@dependent@*//*@null@*/ int_32 * epoch; /*!< Header epoch (if any). */
int providesCount; /*!< No. of Provide:'s in header. */
int requiresCount; /*!< No. of Require:'s in header. */
int filesCount; /*!< No. of files in header. */
@@ -47,8 +47,8 @@ struct availablePackage {
int depth; /*!< Max. depth in dependency tree. */
struct tsortInfo tsi; /*!< Dependency tsort data. */
uint_32 multiLib; /* MULTILIB */
-/*@kept@*/ const void * key; /*!< Private data associated with a package (e.g. file name of package). */
- rpmRelocation * relocs;
+/*@kept@*//*@null@*/ const void * key; /*!< Private data associated with a package (e.g. file name of package). */
+/*@null@*/ rpmRelocation * relocs;
/*@null@*/ FD_t fd;
} ;
@@ -78,7 +78,7 @@ struct availableIndex {
struct fileIndexEntry {
int pkgNum; /*!< Containing package number. */
int fileFlags; /* MULTILIB */
-/*@dependent@*/ const char * baseName; /*!< File basename. */
+/*@dependent@*/ /*@null@*/ const char * baseName; /*!< File basename. */
} ;
/** \ingroup rpmdep
@@ -101,7 +101,7 @@ struct availableList {
int size; /*!< No. of pkgs in list. */
int alloced; /*!< No. of pkgs allocated for list. */
int numDirs; /*!< No. of directories. */
-/*@owned@*/ dirInfo dirs; /*!< Set of directories. */
+/*@owned@*/ /*@null@*/ dirInfo dirs; /*!< Set of directories. */
} ;
/** \ingroup rpmdep
diff --git a/lib/fprint.c b/lib/fprint.c
index a5f5a1cb9..1a9e4c8ba 100644
--- a/lib/fprint.c
+++ b/lib/fprint.c
@@ -97,6 +97,10 @@ static fingerPrint doLookup(fingerPrintCache cache,
cdnl = end - dir;
}
}
+ fp.entry = NULL;
+ fp.subDir = NULL;
+ fp.baseName = NULL;
+ if (cleanDirName == NULL) return fp; /* XXX can't happen */
buf = strcpy(alloca(cdnl + 1), cleanDirName);
end = buf + cdnl;
@@ -107,9 +111,6 @@ static fingerPrint doLookup(fingerPrintCache cache,
*end = '\0';
}
- fp.entry = NULL;
- fp.subDir = NULL;
- fp.baseName = NULL;
while (1) {
/* as we're stating paths here, we want to follow symlinks */
@@ -163,7 +164,7 @@ static fingerPrint doLookup(fingerPrintCache cache,
/*@notreached@*/
- return fp;
+ /*@-nullret@*/ return fp; /*@=nullret@*/ /* LCL: can't happen. */
}
fingerPrint fpLookup(fingerPrintCache cache, const char * dirName,
@@ -200,8 +201,10 @@ int fpEqual(const void * key1, const void * key2)
return 0;
/* Otherwise, compare fingerprints by value. */
+ /*@-nullpass@*/ /* LCL: whines about (*k2).subdir */
if (FP_EQUAL(*k1, *k2))
return 0;
+ /*@=nullpass@*/
return 1;
}
diff --git a/lib/fs.c b/lib/fs.c
index d7e2ec6f0..2734e220c 100644
--- a/lib/fs.c
+++ b/lib/fs.c
@@ -305,7 +305,7 @@ int rpmGetFilesystemUsage(const char ** fileList, int_32 * fssizes, int numFiles
if (lastDev != sb.st_dev) {
for (j = 0; j < numFilesystems; j++)
- if (filesystems[j].dev == sb.st_dev) break;
+ if (filesystems && filesystems[j].dev == sb.st_dev) break;
if (j == numFilesystems) {
rpmError(RPMERR_BADDEV,
diff --git a/lib/fsm.c b/lib/fsm.c
index dbe404c4d..fc1405e6d 100644
--- a/lib/fsm.c
+++ b/lib/fsm.c
@@ -54,6 +54,7 @@ static /*@only@*//*@null@*/ const char * fsmFsPath(/*@null@*/ const FSM_t fsm,
if (fsm) {
int nb;
char * t;
+ /*@-nullpass@*/ /* LCL: subdir/suffix != NULL */
nb = strlen(fsm->dirName) +
(st && subdir && !S_ISDIR(st->st_mode) ? strlen(subdir) : 0) +
(st && suffix && !S_ISDIR(st->st_mode) ? strlen(suffix) : 0) +
@@ -65,6 +66,7 @@ static /*@only@*//*@null@*/ const char * fsmFsPath(/*@null@*/ const FSM_t fsm,
t = stpcpy(t, fsm->baseName);
if (st && suffix && !S_ISDIR(st->st_mode))
t = stpcpy(t, suffix);
+ /*@=nullpass@*/
}
return s;
}
@@ -283,10 +285,11 @@ static /*@observer@*/ const char * dnlNextIterator(/*@null@*/ DNLI_t dnli)
{
const char * dn = NULL;
- if (dnli && dnli->active) {
+ if (dnli) {
TFI_t fi = dnli->fi;
int i = -1;
+ if (dnli->active)
do {
i = (!dnli->reverse ? dnli->i++ : --dnli->i);
} while (i >= 0 && i < fi->dc && !dnli->active[i]);
@@ -384,7 +387,9 @@ fprintf(stderr, "*** %p link[%d:%d] %d filex %d %s\n", fsm->li, fsm->li->linksLe
fsm->path = _free(fsm->path);
fsm->ix = ix;
rc = fsmStage(fsm, FSM_MAP);
+ /*@-nullstate@*/ /* FIX: fsm->path null annotation? */
return rc;
+ /*@=nullstate@*/
}
/*@=compmempass@*/
@@ -453,7 +458,7 @@ int fsmSetup(FSM_t fsm, fileStage goal,
memset(fsm->sufbuf, 0, sizeof(fsm->sufbuf));
if (fsm->goal == FSM_PKGINSTALL) {
- if (ts->id > 0)
+ if (ts && ts->id > 0)
sprintf(fsm->sufbuf, ";%08x", (unsigned)ts->id);
}
@@ -480,7 +485,9 @@ int fsmTeardown(FSM_t fsm) {
fsm->cfd = NULL;
}
fsm->failedFile = NULL;
+ /*@-nullstate@*/ /* FIX: fsm->iter null annotation? */
return rc;
+ /*@=nullstate@*/
}
int fsmMapPath(FSM_t fsm)
@@ -566,8 +573,10 @@ fprintf(stderr, "*** %s:%s %s\n", fiTypeString(fi), fileActionString(fsm->action
if ((fsm->mapFlags & CPIO_MAP_PATH) || fsm->nsuffix) {
const struct stat * st = &fsm->sb;
fsm->path = _free(fsm->path);
+ /*@-nullstate@*/ /* FIX: fsm->path null annotation? */
fsm->path = fsmFsPath(fsm, st, fsm->subdir,
(fsm->suffix ? fsm->suffix : fsm->nsuffix));
+ /*@=nullstate@*/
}
}
return rc;
@@ -1473,8 +1482,12 @@ int fsmStage(FSM_t fsm, fileStage stage)
if (fsm->diskchecked && fsm->exists && fsm->osuffix) {
const char * opath = fsm->opath;
const char * path = fsm->path;
+ /*@-nullstate@*/ /* FIX: fsm->opath null annotation? */
fsm->opath = fsmFsPath(fsm, st, NULL, NULL);
+ /*@=nullstate@*/
+ /*@-nullstate@*/ /* FIX: fsm->path null annotation? */
fsm->path = fsmFsPath(fsm, st, NULL, fsm->osuffix);
+ /*@=nullstate@*/
rc = fsmStage(fsm, FSM_RENAME);
if (!rc) {
rpmMessage(RPMMESS_WARNING, _("%s saved as %s\n"),
@@ -1539,7 +1552,7 @@ int fsmStage(FSM_t fsm, fileStage stage)
if (!rc && fsm->nsuffix) {
const char * opath = fsmFsPath(fsm, st, NULL, NULL);
rpmMessage(RPMMESS_WARNING, _("%s created as %s\n"),
- opath, fsm->path);
+ (opath ? opath : ""), fsm->path);
opath = _free(opath);
}
fsm->opath = _free(fsm->opath);
diff --git a/lib/fsm.h b/lib/fsm.h
index 34b82cb90..e187151ae 100644
--- a/lib/fsm.h
+++ b/lib/fsm.h
@@ -185,7 +185,7 @@ extern "C" {
* Create file state machine instance.
* @return file state machine data
*/
-/*@only@*/ /*@null@*/ FSM_t newFSM(void);
+/*@only@*/ FSM_t newFSM(void);
/**
* Destroy file state machine instance.
@@ -254,7 +254,7 @@ int fsmMapAttrs(FSM_t fsm)
* @param stage next stage
* @return 0 on success
*/
-int fsmStage(FSM_t fsm, fileStage stage)
+int fsmStage(/*@partial@*/ FSM_t fsm, fileStage stage)
/*@modifies fsm @*/;
#ifdef __cplusplus
diff --git a/lib/hash.c b/lib/hash.c
index 8bb17f8ae..e33395429 100644
--- a/lib/hash.c
+++ b/lib/hash.c
@@ -34,7 +34,8 @@ struct hashTable_s {
* @param key pointer to key value
* @return pointer to hash bucket of key (or NULL)
*/
-static /*@shared@*/ struct hashBucket * findEntry(hashTable ht, const void * key)
+static /*@shared@*/ /*@null@*/
+struct hashBucket *findEntry(hashTable ht, const void * key)
{
unsigned int hash;
struct hashBucket * b;
diff --git a/lib/header.c b/lib/header.c
index 3019e7c61..545b54d20 100644
--- a/lib/header.c
+++ b/lib/header.c
@@ -87,7 +87,7 @@ struct indexEntry {
* The Header data structure.
*/
struct headerToken {
-/*@owned@*/ struct indexEntry *index; /*!< Array of tags. */
+/*@owned@*/ struct indexEntry * index; /*!< Array of tags. */
int indexUsed; /*!< Current size of tag array. */
int indexAlloced; /*!< Allocated size of tag array. */
int region_allocated; /*!< Is 1st header region allocated? */
@@ -99,13 +99,13 @@ struct headerToken {
/**
*/
struct sprintfTag {
- headerTagTagFunction ext; /*!< if NULL tag element is invalid */
+/*@null@*/ headerTagTagFunction ext; /*!< if NULL tag element is invalid */
int extNum;
int_32 tag;
int justOne;
int arrayCount;
/*@kept@*/ char * format;
-/*@kept@*/ char * type;
+/*@kept@*/ /*@null@*/ char * type;
int pad;
};
@@ -140,9 +140,9 @@ struct sprintfToken {
int len;
} string;
struct {
- /*@only@*/ struct sprintfToken * ifFormat;
+ /*@only@*/ /*@null@*/ struct sprintfToken * ifFormat;
int numIfTokens;
- /*@only@*/ struct sprintfToken * elseFormat;
+ /*@only@*/ /*@null@*/ struct sprintfToken * elseFormat;
int numElseTokens;
struct sprintfTag tag;
} cond;
@@ -238,7 +238,7 @@ static int dataLength(int_32 type, const void * p, int_32 count, int onDisk)
* @param regionid region offset
* @return no. bytes of data in region
*/
-static int regionSwab(struct indexEntry * entry, int il, int dl,
+static int regionSwab(/*@null@*/ struct indexEntry * entry, int il, int dl,
const struct entryInfo * pe, char * dataStart, int regionid)
{
char * tprev = NULL;
@@ -315,8 +315,11 @@ assert(ie.info.type >= RPM_MIN_TYPE && ie.info.type <= RPM_MAX_TYPE);
* @retval c address of count (or NULL)
* @param minMem string pointers refer to header memory?
*/
-static void copyEntry(const struct indexEntry * entry, /*@out@*/ int_32 * type,
- /*@out@*/ const void ** p, /*@out@*/ int_32 * c, int minMem)
+static void copyEntry(const struct indexEntry * entry,
+ /*@null@*/ /*@out@*/ int_32 * type,
+ /*@null@*/ /*@out@*/ const void ** p,
+ /*@null@*/ /*@out@*/ int_32 * c,
+ int minMem)
/*@modifies *type, *p, *c @*/
{
int_32 count = entry->info.count;
@@ -481,7 +484,7 @@ Header headerCopy(Header h)
headerNextIterator(hi, &tag, &type, &ptr, &count);
ptr = headerFreeData((void *)ptr, type))
{
- (void) headerAddEntry(nh, tag, type, ptr, count);
+ if (ptr) (void) headerAddEntry(nh, tag, type, ptr, count);
}
headerFreeIterator(hi);
@@ -925,6 +928,8 @@ int headerWrite(FD_t fd, Header h, enum hMagic magicp)
int length;
const void * uh;
+ if (h == NULL)
+ return 1;
uh = doHeaderUnload(h, &length);
switch (magicp) {
case HEADER_MAGIC_YES:
@@ -1129,11 +1134,13 @@ void headerDump(Header h, FILE *f, int flags,
* @param type entry type
* @return header entry
*/
-static struct indexEntry *findEntry(Header h, int_32 tag, int_32 type)
+static /*@null@*/
+struct indexEntry * findEntry(/*@null@*/ Header h, int_32 tag, int_32 type)
{
struct indexEntry * entry, * entry2, * last;
struct indexEntry key;
+ if (h == NULL) return NULL;
if (!h->sorted) headerSort(h);
key.info.tag = tag;
@@ -1330,8 +1337,10 @@ headerFindI18NString(Header h, struct indexEntry *entry)
* @param minMem string pointers reference header memory?
* @return 1 on success, 0 on not found
*/
-static int intGetEntry(Header h, int_32 tag, /*@out@*/ int_32 *type,
- /*@out@*/ const void **p, /*@out@*/ int_32 *c, int minMem)
+static int intGetEntry(Header h, int_32 tag, /*@null@*/ /*@out@*/ int_32 * type,
+ /*@null@*/ /*@out@*/ const void ** p,
+ /*@null@*/ /*@out@*/ int_32 *c,
+ int minMem)
/*@modifies *type, *p, *c @*/
{
struct indexEntry * entry;
@@ -1431,9 +1440,13 @@ int headerUsageCount(Header h)
unsigned int headerSizeof(Header h, enum hMagic magicp)
{
struct indexEntry * entry;
- unsigned int size = 0, pad = 0;
+ unsigned int size = 0;
+ unsigned int pad = 0;
int i;
+ if (h == NULL)
+ return size;
+
headerSort(h);
switch (magicp) {
@@ -1485,7 +1498,7 @@ static void copyData(int_32 type, /*@out@*/ void * dstPtr, const void * srcPtr,
{
const char ** src;
char * dst;
- int i, len;
+ int i;
switch (type) {
case RPM_STRING_ARRAY_TYPE:
@@ -1495,9 +1508,11 @@ static void copyData(int_32 type, /*@out@*/ void * dstPtr, const void * srcPtr,
src = (const char **) srcPtr;
dst = dstPtr;
while (i--) {
- len = *src ? strlen(*src) + 1 : 0;
- memcpy(dst, *src, len);
- dst += len;
+ if (*src) {
+ int len = strlen(*src) + 1;
+ memcpy(dst, *src, len);
+ dst += len;
+ }
src++;
}
break;
@@ -1573,6 +1588,7 @@ headerGetLangs(Header h)
if (!headerGetRawEntry(h, HEADER_I18NTABLE, &type, (const void **)&s, &count))
return NULL;
+ /* XXX xcalloc never returns NULL. */
if ((table = (char **)xcalloc((count+1), sizeof(char *))) == NULL)
return NULL;
@@ -1580,13 +1596,12 @@ headerGetLangs(Header h)
table[i] = e;
table[count] = NULL;
- return table;
+ /*@-nullret@*/ return table; /*@=nullret@*/ /* LCL: double indirection? */
}
int headerAddI18NString(Header h, int_32 tag, const char * string, const char * lang)
{
struct indexEntry * table, * entry;
- char * chptr;
const char ** strArray;
int length;
int ghosts;
@@ -1618,12 +1633,15 @@ int headerAddI18NString(Header h, int_32 tag, const char * string, const char *
table = findEntry(h, HEADER_I18NTABLE, RPM_STRING_ARRAY_TYPE);
}
+ if (!table)
+ return 0;
if (!lang) lang = "C";
- chptr = table->data;
- for (langNum = 0; langNum < table->info.count; langNum++) {
- if (!strcmp(chptr, lang)) break;
- chptr += strlen(chptr) + 1;
+ { const char * l = table->data;
+ for (langNum = 0; langNum < table->info.count; langNum++) {
+ if (!strcmp(l, lang)) break;
+ l += strlen(l) + 1;
+ }
}
if (langNum >= table->info.count) {
@@ -1837,10 +1855,12 @@ static char escapedChar(const char ch) /*@*/
}
}
-static void freeFormat( /*@only@*/ struct sprintfToken * format, int num)
+static
+void freeFormat( /*@only@*/ /*@null@*/ struct sprintfToken * format, int num)
{
int i;
+ if (format == NULL) return;
for (i = 0; i < num; i++) {
switch (format[i].type) {
case PTOK_ARRAY:
@@ -1914,13 +1934,14 @@ static void findTag(char * name, const struct headerTagTableEntry * tags,
static int parseExpression(struct sprintfToken * token, char * str,
const struct headerTagTableEntry * tags,
const struct headerSprintfExtension * extensions,
- /*@out@*/char ** endPtr, /*@out@*/const char ** errmsg)
+ /*@out@*/char ** endPtr, /*@null@*/ /*@out@*/ errmsg_t * errmsg)
/*@modifies str, *str, *token, *endPtr, *errmsg @*/;
static int parseFormat(char * str, const struct headerTagTableEntry * tags,
const struct headerSprintfExtension * extensions,
/*@out@*/struct sprintfToken ** formatPtr, /*@out@*/int * numTokensPtr,
- /*@out@*/char ** endPtr, int state, /*@out@*/const char ** errmsg)
+ /*@null@*/ /*@out@*/char ** endPtr, int state,
+ /*@null@*/ /*@out@*/errmsg_t * errmsg)
/*@modifies str, *str, *formatPtr, *numTokensPtr, *endPtr, *errmsg @*/
{
char * chptr, * start, * next, * dst;
@@ -1990,7 +2011,7 @@ static int parseFormat(char * str, const struct headerTagTableEntry * tags,
while (*chptr && *chptr != '{' && *chptr != '%') chptr++;
if (!*chptr || *chptr == '%') {
/*@-observertrans@*/
- *errmsg = _("missing { after %");
+ if (errmsg) *errmsg = _("missing { after %");
/*@=observertrans@*/
freeFormat(format, numTokens);
return 1;
@@ -2020,7 +2041,7 @@ static int parseFormat(char * str, const struct headerTagTableEntry * tags,
while (*next && *next != '}') next++;
if (!*next) {
/*@-observertrans@*/
- *errmsg = _("missing } after %{");
+ if (errmsg) *errmsg = _("missing } after %{");
/*@=observertrans@*/
freeFormat(format, numTokens);
return 1;
@@ -2034,7 +2055,7 @@ static int parseFormat(char * str, const struct headerTagTableEntry * tags,
*chptr++ = '\0';
if (!*chptr) {
/*@-observertrans@*/
- *errmsg = _("empty tag format");
+ if (errmsg) *errmsg = _("empty tag format");
/*@=observertrans@*/
freeFormat(format, numTokens);
return 1;
@@ -2046,7 +2067,7 @@ static int parseFormat(char * str, const struct headerTagTableEntry * tags,
if (!*start) {
/*@-observertrans@*/
- *errmsg = _("empty tag name");
+ if (errmsg) *errmsg = _("empty tag name");
/*@=observertrans@*/
freeFormat(format, numTokens);
return 1;
@@ -2063,7 +2084,7 @@ static int parseFormat(char * str, const struct headerTagTableEntry * tags,
format[currToken].u.tag.extNum = ext - extensions;
} else {
/*@-observertrans@*/
- *errmsg = _("unknown tag");
+ if (errmsg) *errmsg = _("unknown tag");
/*@=observertrans@*/
freeFormat(format, numTokens);
return 1;
@@ -2090,7 +2111,7 @@ static int parseFormat(char * str, const struct headerTagTableEntry * tags,
if (!start) {
/*@-observertrans@*/
- *errmsg = _("] expected at end of array");
+ if (errmsg) *errmsg = _("] expected at end of array");
/*@=observertrans@*/
freeFormat(format, numTokens);
return 1;
@@ -2106,19 +2127,20 @@ static int parseFormat(char * str, const struct headerTagTableEntry * tags,
case '}':
if ((*start == ']' && state != PARSER_IN_ARRAY) ||
(*start == '}' && state != PARSER_IN_EXPR)) {
- if (*start == ']')
+ if (*start == ']') {
/*@-observertrans@*/
- *errmsg = _("unexpected ]");
+ if (errmsg) *errmsg = _("unexpected ]");
/*@=observertrans@*/
- else
+ } else {
/*@-observertrans@*/
- *errmsg = _("unexpected }");
+ if (errmsg) *errmsg = _("unexpected }");
/*@=observertrans@*/
+ }
freeFormat(format, numTokens);
return 1;
}
*start++ = '\0';
- *endPtr = start;
+ if (endPtr) *endPtr = start;
done = 1;
break;
@@ -2161,20 +2183,20 @@ static int parseFormat(char * str, const struct headerTagTableEntry * tags,
static int parseExpression(struct sprintfToken * token, char * str,
const struct headerTagTableEntry * tags,
const struct headerSprintfExtension * extensions,
- /*@out@*/ char ** endPtr, /*@out@*/ const char ** errmsg)
+ /*@out@*/ char ** endPtr, /*@null@*/ /*@out@*/ errmsg_t * errmsg)
{
const struct headerTagTableEntry * tag;
const struct headerSprintfExtension * ext;
char * chptr;
char * end;
- *errmsg = NULL;
+ if (errmsg) *errmsg = NULL;
chptr = str;
while (*chptr && *chptr != '?') chptr++;
if (*chptr != '?') {
/*@-observertrans@*/
- *errmsg = _("? expected in expression");
+ if (errmsg) *errmsg = _("? expected in expression");
/*@=observertrans@*/
return 1;
}
@@ -2183,7 +2205,7 @@ static int parseExpression(struct sprintfToken * token, char * str,
if (*chptr != '{') {
/*@-observertrans@*/
- *errmsg = _("{ expected after ? in expression");
+ if (errmsg) *errmsg = _("{ expected after ? in expression");
/*@=observertrans@*/
return 1;
}
@@ -2196,7 +2218,7 @@ static int parseExpression(struct sprintfToken * token, char * str,
if (!*end) {
/*@-observertrans@*/
- *errmsg = _("} expected in expression");
+ if (errmsg) *errmsg = _("} expected in expression");
/*@=observertrans@*/
freeFormat(token->u.cond.ifFormat, token->u.cond.numIfTokens);
token->u.cond.ifFormat = NULL;
@@ -2206,7 +2228,7 @@ static int parseExpression(struct sprintfToken * token, char * str,
chptr = end;
if (*chptr != ':' && *chptr != '|') {
/*@-observertrans@*/
- *errmsg = _(": expected following ? subexpression");
+ if (errmsg) *errmsg = _(": expected following ? subexpression");
/*@=observertrans@*/
freeFormat(token->u.cond.ifFormat, token->u.cond.numIfTokens);
token->u.cond.ifFormat = NULL;
@@ -2223,7 +2245,7 @@ static int parseExpression(struct sprintfToken * token, char * str,
if (*chptr != '{') {
/*@-observertrans@*/
- *errmsg = _("{ expected after : in expression");
+ if (errmsg) *errmsg = _("{ expected after : in expression");
/*@=observertrans@*/
freeFormat(token->u.cond.ifFormat, token->u.cond.numIfTokens);
token->u.cond.ifFormat = NULL;
@@ -2238,7 +2260,7 @@ static int parseExpression(struct sprintfToken * token, char * str,
return 1;
if (!*end) {
/*@-observertrans@*/
- *errmsg = _("} expected in expression");
+ if (errmsg) *errmsg = _("} expected in expression");
/*@=observertrans@*/
freeFormat(token->u.cond.ifFormat, token->u.cond.numIfTokens);
token->u.cond.ifFormat = NULL;
@@ -2248,7 +2270,7 @@ static int parseExpression(struct sprintfToken * token, char * str,
chptr = end;
if (*chptr != '|') {
/*@-observertrans@*/
- *errmsg = _("| expected at end of expression");
+ if (errmsg) *errmsg = _("| expected at end of expression");
/*@=observertrans@*/
freeFormat(token->u.cond.ifFormat, token->u.cond.numIfTokens);
token->u.cond.ifFormat = NULL;
@@ -2580,7 +2602,7 @@ static void freeExtensionCache(const struct headerSprintfExtension * extensions,
char * headerSprintf(Header h, const char * origFmt,
const struct headerTagTableEntry * tags,
const struct headerSprintfExtension * extensions,
- const char ** errmsg)
+ errmsg_t * errmsg)
{
char * fmtString;
struct sprintfToken * format;
@@ -2671,16 +2693,17 @@ static char * hexFormat(int_32 type, const void * data,
static char * realDateFormat(int_32 type, const void * data,
char * formatPrefix, int padding, /*@unused@*/int element,
- char * strftimeFormat)
+ const char * strftimeFormat)
/*@modifies formatPrefix @*/
{
char * val;
- struct tm * tstruct;
- char buf[50];
if (type != RPM_INT32_TYPE) {
val = xstrdup(_("(not a number)"));
} else {
+ struct tm * tstruct;
+ char buf[50];
+
val = xmalloc(50 + padding);
strcat(formatPrefix, "s");
@@ -2688,7 +2711,9 @@ static char * realDateFormat(int_32 type, const void * data,
{ time_t dateint = *((int_32 *) data);
tstruct = localtime(&dateint);
}
- (void)strftime(buf, sizeof(buf) - 1, strftimeFormat, tstruct);
+ buf[0] = '\0';
+ if (tstruct)
+ (void) strftime(buf, sizeof(buf) - 1, strftimeFormat, tstruct);
sprintf(val, formatPrefix, buf);
}
diff --git a/lib/header.h b/lib/header.h
index 4bccd08f4..d0032c0ff 100644
--- a/lib/header.h
+++ b/lib/header.h
@@ -181,7 +181,7 @@ enum hMagic {
* @param magicp read (and verify) 8 bytes of (magic, 0)?
* @return header (or NULL on error)
*/
-Header headerRead(FD_t fd, enum hMagic magicp)
+/*@null@*/ Header headerRead(FD_t fd, enum hMagic magicp)
/*@modifies fd @*/;
/** \ingroup header
@@ -191,7 +191,7 @@ Header headerRead(FD_t fd, enum hMagic magicp)
* @param magicp prefix write with 8 bytes of (magic, 0)?
* @return 0 on success, 1 on error
*/
-int headerWrite(FD_t fd, Header h, enum hMagic magicp)
+int headerWrite(FD_t fd, /*@null@*/ Header h, enum hMagic magicp)
/*@modifies fd, h @*/;
/** \ingroup header
@@ -200,7 +200,7 @@ int headerWrite(FD_t fd, Header h, enum hMagic magicp)
* @param magicp include size of 8 bytes for (magic, 0)?
* @return size of on-disk header
*/
-unsigned int headerSizeof(Header h, enum hMagic magicp)
+unsigned int headerSizeof(/*@null@*/ Header h, enum hMagic magicp)
/*@modifies h @*/;
/** \ingroup header
@@ -208,14 +208,14 @@ unsigned int headerSizeof(Header h, enum hMagic magicp)
* @param p on-disk header (with offsets)
* @return header
*/
-Header headerLoad(/*@kept@*/ void *p) /*@*/;
+/*@null@*/ Header headerLoad(/*@kept@*/ void * p) /*@*/;
/** \ingroup header
* Make a copy and convert header to in-memory representation.
* @param p on-disk header (with offsets)
* @return header
*/
-Header headerCopyLoad(void *p) /*@*/;
+/*@null@*/ Header headerCopyLoad(void * p) /*@*/;
/** \ingroup header
* Convert header to on-disk representation.
@@ -232,7 +232,7 @@ Header headerCopyLoad(void *p) /*@*/;
* @param tag region tag
* @return on-disk header (with offsets)
*/
-Header headerReload(/*@only@*/ Header h, int tag)
+/*@null@*/ Header headerReload(/*@only@*/ Header h, int tag)
/*@modifies h @*/;
/** \ingroup header
@@ -272,7 +272,9 @@ void headerDump(Header h, FILE *f, int flags,
const struct headerTagTableEntry * tags);
#define HEADER_DUMP_INLINE 1
+/*@-redef@*/ /* LCL: no clue */
typedef const char * errmsg_t;
+/*@=redef@*/
/** \ingroup header
* Return formatted output string from header tags.
@@ -288,7 +290,7 @@ typedef const char * errmsg_t;
/*@only@*/ char * headerSprintf(Header h, const char * fmt,
const struct headerTagTableEntry * tags,
const struct headerSprintfExtension * extentions,
- /*@out@*/ errmsg_t * errmsg)
+ /*@null@*/ /*@out@*/ errmsg_t * errmsg)
/*@modifies *errmsg @*/;
/** \ingroup header
@@ -397,8 +399,8 @@ int headerAddOrAppendEntry(Header h, int_32 tag, int_32 type, void * p, int_32 c
* @retval c address of number of values
* @return 1 on success, 0 on failure
*/
-int headerGetEntry(Header h, int_32 tag, /*@out@*/ int_32 *type,
- /*@out@*/ void **p, /*@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
@@ -439,7 +441,7 @@ int headerGetRawEntry(Header h, int_32 tag, /*@out@*/ int_32 *type,
* @param tag tag
* @return 1 on success, 0 on failure
*/
-int headerIsEntry(Header h, int_32 tag) /*@*/;
+int headerIsEntry(/*@null@*/Header h, int_32 tag) /*@*/;
/** \ingroup header
* Delete tag in header.
@@ -486,7 +488,7 @@ void headerFreeIterator( /*@only@*/ HeaderIterator iter);
* @param h header
* @return new header instance
*/
-Header headerCopy(Header h)
+/*@null@*/ Header headerCopy(Header h)
/*@modifies h @*/;
/** \ingroup header
@@ -536,8 +538,8 @@ typedef enum rpmTagType_e {
* @param type type of data
* @return NULL always
*/
-/*@unused@*/ static inline /*@null@*/ void * headerFreeData(
- /*@only@*/ const void * data, rpmTagType type)
+/*@unused@*/ static inline /*@null@*/
+void * headerFreeData( /*@only@*/ /*@null@*/ const void * data, rpmTagType type)
{
if (data) {
if (type < 0 ||
diff --git a/lib/manifest.c b/lib/manifest.c
index 06d639fb1..7660cb449 100644
--- a/lib/manifest.c
+++ b/lib/manifest.c
@@ -66,14 +66,16 @@ int rpmReadPackageManifest(FD_t fd, int * argcPtr, const char *** argvPtr)
const char ** av = NULL;
int argc = (argcPtr ? *argcPtr : 0);
const char ** argv = (argvPtr ? *argvPtr : NULL);
+ FILE * f = fdGetFp(fd);
int rc = 0;
int i;
+ if (f != NULL)
while (1) {
char line[BUFSIZ];
/* Read next line. */
- s = fgets(line, sizeof(line) - 1, fdGetFp(fd));
+ s = fgets(line, sizeof(line) - 1, f);
if (s == NULL) {
/* XXX Ferror check needed */
break;
@@ -129,7 +131,8 @@ int rpmReadPackageManifest(FD_t fd, int * argcPtr, const char *** argvPtr)
memcpy(nav + ac, argv + i, (argc - i) * sizeof(*nav));
nav[nac] = NULL;
- *argvPtr = argv = _free(argv);
+ if (argvPtr)
+ *argvPtr = argv = _free(argv);
av = _free(av);
av = nav;
ac = nac;
@@ -145,10 +148,13 @@ int rpmReadPackageManifest(FD_t fd, int * argcPtr, const char *** argvPtr)
exit:
if (argvPtr == NULL || (rc != 0 && av)) {
+ if (av)
for (i = 0; i < ac; i++)
/*@-unqualifiedtrans@*/av[i] = _free(av[i]); /*@=unqualifiedtrans@*/
/*@-dependenttrans@*/ av = _free(av); /*@=dependenttrans@*/
}
freeStringBuf(sb);
+ /*@-nullstate@*/
return rc;
+ /*@=nullstate@*/
}
diff --git a/lib/md5.h b/lib/md5.h
index a2a7e9d63..1709d5781 100644
--- a/lib/md5.h
+++ b/lib/md5.h
@@ -23,7 +23,9 @@ struct MD5Context {
/*
* This is needed to make RSAREF happy on some MS-DOS compilers.
*/
+/*@-mutrep@*/ /* FIX: redefine as pointer */
typedef /*@abstract@*/ struct MD5Context MD5_CTX;
+/*@=mutrep@*/
#ifdef __cplusplus
extern "C" {
diff --git a/lib/misc.c b/lib/misc.c
index 3ab73fb06..ced0aa804 100644
--- a/lib/misc.c
+++ b/lib/misc.c
@@ -681,7 +681,8 @@ fprintf(stderr, "*** rpmGlob argv[%d] \"%s\"\n", argc, globURL);
exit:
av = _free(av);
- if ((rc || argvPtr == NULL) && argv) {
+ if (rc || argvPtr == NULL) {
+ if (argv != NULL)
for (i = 0; i < argc; i++)
argv[i] = _free(argv[i]);
argv = _free(argv);
diff --git a/lib/package.c b/lib/package.c
index 06d739bd6..2638ead73 100644
--- a/lib/package.c
+++ b/lib/package.c
@@ -42,6 +42,7 @@ void headerMergeLegacySigs(Header h, const Header sig)
continue;
/*@notreached@*/ break;
}
+ if (ptr == NULL) continue; /* XXX can't happen */
if (!headerIsEntry(h, tag))
(void) headerAddEntry(h, tag, type, ptr, count);
}
@@ -71,6 +72,7 @@ Header headerRegenSigHeader(const Header h)
continue;
/*@notreached@*/ break;
}
+ if (ptr == NULL) continue; /* XXX can't happen */
if (!headerIsEntry(sig, stag))
(void) headerAddEntry(sig, stag, type, ptr, count);
}
diff --git a/lib/poptBT.c b/lib/poptBT.c
index c262f1887..439c30bb6 100644
--- a/lib/poptBT.c
+++ b/lib/poptBT.c
@@ -11,7 +11,7 @@
#include "build.h"
#include "debug.h"
-struct rpmBuildArguments rpmBTArgs;
+struct rpmBuildArguments_s rpmBTArgs;
#define POPT_USECATALOG 1000
#define POPT_NOLANG 1001
@@ -59,7 +59,7 @@ static void buildArgCallback( /*@unused@*/ poptContext con,
const struct poptOption * opt, const char * arg,
/*@unused@*/ const void * data)
{
- struct rpmBuildArguments * rba = &rpmBTArgs;
+ BTA_t rba = &rpmBTArgs;
switch (opt->val) {
case POPT_REBUILD:
diff --git a/lib/poptQV.c b/lib/poptQV.c
index a9c1dc316..1920cfa8e 100644
--- a/lib/poptQV.c
+++ b/lib/poptQV.c
@@ -9,7 +9,7 @@
#include <rpmurl.h>
#include "debug.h"
-struct rpmQVArguments rpmQVArgs;
+struct rpmQVArguments_s rpmQVArgs;
int specedit = 0;
/* ======================================================================== */
@@ -27,7 +27,7 @@ static void rpmQVSourceArgCallback( /*@unused@*/ poptContext con,
const struct poptOption * opt, /*@unused@*/ const char * arg,
/*@unused@*/ const void * data)
{
- QVA_t *qva = &rpmQVArgs;
+ QVA_t qva = &rpmQVArgs;
switch (opt->val) {
case 'q':
@@ -99,7 +99,7 @@ static void queryArgCallback(/*@unused@*/poptContext con, /*@unused@*/enum poptC
const struct poptOption * opt, const char * arg,
/*@unused@*/ const void * data)
{
- QVA_t *qva = &rpmQVArgs;
+ QVA_t qva = &rpmQVArgs;
switch (opt->val) {
case 'c': qva->qva_flags |= QUERY_FOR_CONFIG | QUERY_FOR_LIST; break;
diff --git a/lib/problems.c b/lib/problems.c
index 1ff730906..82dffb119 100644
--- a/lib/problems.c
+++ b/lib/problems.c
@@ -107,74 +107,74 @@ static inline int snprintf(char * buf, int nb, const char * fmt, ...)
const char * rpmProblemString(rpmProblem prob) /*@*/
{
- int nb = (prob->pkgNEVR ? strlen(prob->pkgNEVR) : 0) +
- (prob->str1 ? strlen(prob->str1) : 0) +
- (prob->altNEVR ? strlen(prob->altNEVR) : 0) +
- 100;
+/*@observer@*/ const char * pkgNEVR = (prob->pkgNEVR ? prob->pkgNEVR : "");
+/*@observer@*/ const char * altNEVR = (prob->altNEVR ? prob->altNEVR : "");
+/*@observer@*/ const char * str1 = (prob->str1 ? prob->str1 : "");
+ int nb = strlen(pkgNEVR) + strlen(str1) + strlen(altNEVR) + 100;
char * buf = xmalloc(nb+1);
switch (prob->type) {
case RPMPROB_BADARCH:
(void) snprintf(buf, nb,
_("package %s is for a different architecture"),
- prob->pkgNEVR);
+ pkgNEVR);
break;
case RPMPROB_BADOS:
(void) snprintf(buf, nb,
_("package %s is for a different operating system"),
- prob->pkgNEVR);
+ pkgNEVR);
break;
case RPMPROB_PKG_INSTALLED:
(void) snprintf(buf, nb,
_("package %s is already installed"),
- prob->pkgNEVR);
+ pkgNEVR);
break;
case RPMPROB_BADRELOCATE:
(void) snprintf(buf, nb,
_("path %s in package %s is not relocateable"),
- prob->str1, prob->pkgNEVR);
+ str1, pkgNEVR);
break;
case RPMPROB_NEW_FILE_CONFLICT:
(void) snprintf(buf, nb,
_("file %s conflicts between attempted installs of %s and %s"),
- prob->str1, prob->pkgNEVR, prob->altNEVR);
+ str1, pkgNEVR, altNEVR);
break;
case RPMPROB_FILE_CONFLICT:
(void) snprintf(buf, nb,
_("file %s from install of %s conflicts with file from package %s"),
- prob->str1, prob->pkgNEVR, prob->altNEVR);
+ str1, pkgNEVR, altNEVR);
break;
case RPMPROB_OLDPACKAGE:
(void) snprintf(buf, nb,
_("package %s (which is newer than %s) is already installed"),
- prob->altNEVR, prob->pkgNEVR);
+ altNEVR, pkgNEVR);
break;
case RPMPROB_DISKSPACE:
(void) snprintf(buf, nb,
_("installing package %s needs %ld%cb on the %s filesystem"),
- prob->pkgNEVR,
+ pkgNEVR,
prob->ulong1 > (1024*1024)
? (prob->ulong1 + 1024 * 1024 - 1) / (1024 * 1024)
: (prob->ulong1 + 1023) / 1024,
prob->ulong1 > (1024*1024) ? 'M' : 'K',
- prob->str1);
+ str1);
break;
case RPMPROB_DISKNODES:
(void) snprintf(buf, nb,
_("installing package %s needs %ld inodes on the %s filesystem"),
- prob->pkgNEVR, (long)prob->ulong1, prob->str1);
+ pkgNEVR, (long)prob->ulong1, str1);
break;
case RPMPROB_BADPRETRANS:
(void) snprintf(buf, nb,
_("package %s pre-transaction syscall(s): %s failed: %s"),
- prob->pkgNEVR, prob->str1, strerror(prob->ulong1));
+ pkgNEVR, str1, strerror(prob->ulong1));
break;
case RPMPROB_REQUIRES:
case RPMPROB_CONFLICT:
default:
(void) snprintf(buf, nb,
_("unknown error %d encountered while manipulating package %s"),
- prob->type, prob->pkgNEVR);
+ prob->type, pkgNEVR);
break;
}
diff --git a/lib/psm.c b/lib/psm.c
index 6a58173da..a04ec56ee 100644
--- a/lib/psm.c
+++ b/lib/psm.c
@@ -212,6 +212,10 @@ void freeFi(TFI_t fi)
if (fi->h) {
headerFree(fi->h); fi->h = NULL;
}
+
+ /*@-nullstate@*/
+ return;
+ /*@=nullstate@*/
}
/*@observer@*/ const char *const fiTypeString(TFI_t fi) {
@@ -282,7 +286,7 @@ static int rpmInstallLoadMacros(TFI_t fi, Header h)
static int mergeFiles(TFI_t fi, Header h, Header newH)
{
HGE_t hge = (HGE_t)fi->hge;
- HFD_t hfd = fi->hfd;
+ HFD_t hfd = (fi->hfd ? fi->hfd : headerFreeData);
fileAction * actions = fi->actions;
int i, j, k, fc;
int_32 type = 0;
@@ -601,12 +605,16 @@ rpmRC rpmInstallSourcePackage(const char * rootDir, FD_t fd,
}
(void) rpmtransAddPackage(ts, h, fd, NULL, 0, NULL);
+ if (ts->addedPackages.list == NULL) { /* XXX can't happen */
+ rc = RPMRC_FAIL;
+ goto exit;
+ }
fi->type = TR_ADDED;
fi->ap = ts->addedPackages.list;
loadFi(h, fi);
hge = fi->hge;
- hfd = fi->hfd;
+ hfd = (fi->hfd ? fi->hfd : headerFreeData);
headerFree(h); /* XXX reference held by transaction set */
h = NULL;
@@ -780,7 +788,7 @@ static int runScript(PSM_t psm, Header h,
const rpmTransactionSet ts = psm->ts;
TFI_t fi = psm->fi;
HGE_t hge = fi->hge;
- HFD_t hfd = fi->hfd;
+ HFD_t hfd = (fi->hfd ? fi->hfd : headerFreeData);
const char ** argv = NULL;
int argc = 0;
const char ** prefixes = NULL;
@@ -879,6 +887,7 @@ static int runScript(PSM_t psm, Header h,
out = fdDup(STDOUT_FILENO);
out = fdLink(out, "runScript persist");
}
+ if (out == NULL) return 1; /* XXX can't happen */
if (!(child = fork())) {
const char * rootDir;
@@ -925,7 +934,7 @@ static int runScript(PSM_t psm, Header h,
}
}
- rootDir = ts->rootDir;
+ if ((rootDir = ts->rootDir) != NULL) /* XXX can't happen */
switch(urlIsURL(rootDir)) {
case URL_IS_PATH:
rootDir += sizeof("file://") - 1;
@@ -983,7 +992,7 @@ static rpmRC runInstScript(PSM_t psm)
{
TFI_t fi = psm->fi;
HGE_t hge = fi->hge;
- HFD_t hfd = fi->hfd;
+ HFD_t hfd = (fi->hfd ? fi->hfd : headerFreeData);
void ** programArgv;
int programArgc;
const char ** argv;
@@ -1027,7 +1036,7 @@ static int handleOneTrigger(PSM_t psm, Header sourceH, Header triggeredH,
const rpmTransactionSet ts = psm->ts;
TFI_t fi = psm->fi;
HGE_t hge = fi->hge;
- HFD_t hfd = fi->hfd;
+ HFD_t hfd = (fi->hfd ? fi->hfd : headerFreeData);
const char ** triggerNames;
const char ** triggerEVR;
const char ** triggerScripts;
@@ -1166,7 +1175,7 @@ static int runImmedTriggers(PSM_t psm)
const rpmTransactionSet ts = psm->ts;
TFI_t fi = psm->fi;
HGE_t hge = fi->hge;
- HFD_t hfd = fi->hfd;
+ HFD_t hfd = (fi->hfd ? fi->hfd : headerFreeData);
const char ** triggerNames;
int numTriggers;
int_32 * triggerIndices;
@@ -1255,7 +1264,7 @@ int psmStage(PSM_t psm, pkgStage stage)
const rpmTransactionSet ts = psm->ts;
TFI_t fi = psm->fi;
HGE_t hge = fi->hge;
- HFD_t hfd = fi->hfd;
+ HFD_t hfd = (fi->hfd ? fi->hfd : headerFreeData);
rpmRC rc = psm->rc;
int saveerrno;
@@ -1505,7 +1514,17 @@ assert(psm->mi == NULL);
/* Retrieve type of payload compression. */
rc = psmStage(psm, PSM_RPMIO_FLAGS);
+ if (alp->fd == NULL) { /* XXX can't happen */
+ rc = RPMRC_FAIL;
+ break;
+ }
+ /*@-nullpass@*/ /* LCL: alp->fd != NULL here. */
psm->cfd = Fdopen(fdDup(Fileno(alp->fd)), psm->rpmio_flags);
+ /*@=nullpass@*/
+ if (psm->cfd == NULL) { /* XXX can't happen */
+ rc = RPMRC_FAIL;
+ break;
+ }
rc = fsmSetup(fi->fsm, FSM_PKGINSTALL, ts, fi,
psm->cfd, NULL, &psm->failedFile);
@@ -1561,8 +1580,18 @@ assert(psm->mi == NULL);
fi->action = FA_COPYOUT;
fi->actions = NULL;
+ if (psm->fd == NULL) { /* XXX can't happen */
+ rc = RPMRC_FAIL;
+ break;
+ }
+ /*@-nullpass@*/ /* LCL: psm->fd != NULL here. */
(void) Fflush(psm->fd);
psm->cfd = Fdopen(fdDup(Fileno(psm->fd)), psm->rpmio_flags);
+ /*@=nullpass@*/
+ if (psm->cfd == NULL) { /* XXX can't happen */
+ rc = RPMRC_FAIL;
+ break;
+ }
/* XXX failedFile? */
rc = fsmSetup(fi->fsm, FSM_PKGBUILD, ts, fi, psm->cfd, NULL, NULL);
diff --git a/lib/psm.h b/lib/psm.h
index d04c365c8..d6a11373e 100644
--- a/lib/psm.h
+++ b/lib/psm.h
@@ -187,7 +187,7 @@ void freeFi(TFI_t fi)
* @param a package dispostion
* @return formatted string
*/
-/*@observer@*/ const char *const fiTypeString(TFI_t fi);
+/*@observer@*/ const char *const fiTypeString(/*@partial@*/TFI_t fi);
/**
* Package state machine driver.
@@ -195,7 +195,7 @@ void freeFi(TFI_t fi)
* @param stage next stage
* @return 0 on success
*/
-int psmStage(PSM_t psm, pkgStage stage)
+int psmStage(/*@partial@*/ PSM_t psm, pkgStage stage)
/*@modifies psm @*/;
#ifdef __cplusplus
diff --git a/lib/query.c b/lib/query.c
index 3adc0e126..74b82cc92 100644
--- a/lib/query.c
+++ b/lib/query.c
@@ -42,7 +42,7 @@ static void printFileInfo(char * te, const char * name,
if (now == 0) {
now = time(NULL);
tm = localtime(&now);
- nowtm = *tm; /* structure assignment */
+ if (tm) nowtm = *tm; /* structure assignment */
}
if (owner)
@@ -78,6 +78,8 @@ static void printFileInfo(char * te, const char * name,
/* Convert file mtime to display format */
tm = localtime(&when);
+ timefield[0] = '\0';
+ if (tm != NULL)
{ const char *fmt;
if (now > when + 6L * 30L * 24L * 60L * 60L || /* Old. */
now < when - 60L * 60L) /* In the future. */
@@ -103,7 +105,7 @@ static void printFileInfo(char * te, const char * name,
/**
*/
-static inline const char * queryHeader(Header h, const char * qfmt)
+static inline /*@null@*/ const char * queryHeader(Header h, const char * qfmt)
{
const char * errstr;
const char * str;
@@ -134,7 +136,7 @@ static int countLinks(int_16 * fileRdevList, int_32 * fileInodeList, int nfiles,
return nlink;
}
-int showQueryPackage(QVA_t *qva, /*@unused@*/rpmdb rpmdb, Header h)
+int showQueryPackage(QVA_t qva, /*@unused@*/rpmdb rpmdb, Header h)
{
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
HFD_t hfd = headerFreeData;
@@ -451,7 +453,7 @@ void rpmDisplayQueryTags(FILE * f)
}
}
-int showMatches(QVA_t *qva, rpmdbMatchIterator mi, QVF_t showPackage)
+int showMatches(QVA_t qva, rpmdbMatchIterator mi, QVF_t showPackage)
{
Header h;
int ec = 0;
@@ -476,7 +478,7 @@ int (*parseSpecVec) (Spec *specp, const char *specFile, const char *rootdir,
*/
void (*freeSpecVec) (Spec spec) = NULL;
-int rpmQueryVerify(QVA_t *qva, rpmQVSources source, const char * arg,
+int rpmQueryVerify(QVA_t qva, rpmQVSources source, const char * arg,
rpmdb rpmdb, QVF_t showPackage)
{
rpmdbMatchIterator mi = NULL;
@@ -676,7 +678,10 @@ restart:
if (*s == '\0') {
char fnbuf[PATH_MAX];
fn = /*@-unrecog@*/ realpath(arg, fnbuf) /*@=unrecog@*/;
- fn = xstrdup( (fn ? fn : arg) );
+ if (fn)
+ fn = xstrdup(fn);
+ else
+ fn = xstrdup(arg);
} else
fn = xstrdup(arg);
(void) rpmCleanPath(fn);
@@ -749,7 +754,7 @@ restart:
return retcode;
}
-int rpmQuery(QVA_t *qva, rpmQVSources source, const char * arg)
+int rpmQuery(QVA_t qva, rpmQVSources source, const char * arg)
{
rpmdb rpmdb = NULL;
int rc;
diff --git a/lib/rpmchecksig.c b/lib/rpmchecksig.c
index 82f9e0b6e..49340cd46 100644
--- a/lib/rpmchecksig.c
+++ b/lib/rpmchecksig.c
@@ -99,7 +99,7 @@ exit:
return rc;
}
-int rpmReSign(rpmResignFlags add, char *passPhrase, const char **argv)
+int rpmReSign(rpmResignFlags add, char * passPhrase, const char ** argv)
{
FD_t fd = NULL;
FD_t ofd = NULL;
@@ -112,6 +112,8 @@ int rpmReSign(rpmResignFlags add, char *passPhrase, const char **argv)
int res = EXIT_FAILURE;
rpmRC rc;
+ if (argv == NULL) return 0;
+
tmprpm[0] = '\0';
while ((rpm = *argv++) != NULL) {
@@ -246,6 +248,8 @@ int rpmCheckSig(rpmCheckSigFlags flags, const char **argv)
int res = 0;
rpmRC rc;
+ if (argv == NULL) return 0;
+
while ((rpm = *argv++) != NULL) {
if (manageFile(&fd, &rpm, O_RDONLY, 0)) {
@@ -318,6 +322,7 @@ int rpmCheckSig(rpmCheckSigFlags flags, const char **argv)
continue;
/*@notreached@*/ break;
}
+ if (ptr == NULL) continue; /* XXX can't happen */
if ((res3 = rpmVerifySignature(sigtarget, tag, ptr, count,
result))) {
diff --git a/lib/rpmdb.c b/lib/rpmdb.c
index c5fb6edc5..5bedc7972 100644
--- a/lib/rpmdb.c
+++ b/lib/rpmdb.c
@@ -35,7 +35,7 @@ int _filterDbDups = 0; /* Filter duplicate entries ? (bug in pre rpm-3.0.4) */
#define _DBI_MAJOR -1
static int dbiTagsMax = 0;
-/*@only@*/ static int *dbiTags = NULL;
+/*@only@*/ /*@null@*/ static int *dbiTags = NULL;
/**
* Return dbi index used for rpm tag.
@@ -46,7 +46,7 @@ static int dbiTagToDbix(int rpmtag)
{
int dbix;
- if (!(dbiTagsMax > 0 && dbiTags))
+ if (!(dbiTags != NULL && dbiTagsMax > 0))
return -1;
for (dbix = 0; dbix < dbiTagsMax; dbix++) {
if (rpmtag == dbiTags[dbix])
@@ -131,9 +131,11 @@ extern struct _dbiVec db3vec;
#define DB3vec NULL
#endif
+/*@-nullassign@*/
static struct _dbiVec *mydbvecs[] = {
DB1vec, DB1vec, DB2vec, DB3vec, NULL
};
+/*@=nullassign@*/
INLINE int dbiSync(dbiIndex dbi, unsigned int flags) {
if (_debug < 0 || dbi->dbi_debug)
@@ -222,7 +224,7 @@ INLINE int dbiPut(dbiIndex dbi, DBC * dbcursor, const void * keyp, size_t keylen
if (_debug < 0 || dbi->dbi_debug) {
int dataval = 0xdeadbeef;
if (datap) memcpy(&dataval, datap, sizeof(dataval));
-fprintf(stderr, " Put %s key (%p,%ld) data (%p,%ld) \"%s\" %x rc %d\n", tagName(dbi->dbi_rpmtag), keyp, (long)keylen, datap, (long)datalen, (dbi->dbi_rpmtag != RPMDBI_PACKAGES ? (char *)keyp : ""), (unsigned)dataval, rc);
+fprintf(stderr, " Put %s key (%p,%ld) data (%p,%ld) \"%s\" %x rc %d\n", tagName(dbi->dbi_rpmtag), keyp, (long)keylen, (datap ? datap : NULL), (long)datalen, (dbi->dbi_rpmtag != RPMDBI_PACKAGES ? (char *)keyp : ""), (unsigned)dataval, rc);
}
return rc;
@@ -241,10 +243,14 @@ dbiIndex dbiOpen(rpmdb rpmdb, int rpmtag, /*@unused@*/ unsigned int flags)
int _dbapi, _dbapi_rebuild, _dbapi_wanted;
int rc = 0;
+ if (rpmdb == NULL)
+ return NULL;
+
dbix = dbiTagToDbix(rpmtag);
if (dbix < 0 || dbix >= dbiTagsMax)
return NULL;
+
/* Is this index already open ? */
if ((dbi = rpmdb->_dbi[dbix]) != NULL)
return dbi;
@@ -385,6 +391,7 @@ static int dbiSearch(dbiIndex dbi, DBC * dbcursor,
set = xmalloc(sizeof(*set));
/* Convert to database internal format */
+ if (sdbir)
switch (dbi->dbi_jlen) {
default:
case 2*sizeof(int_32):
@@ -425,7 +432,7 @@ static int dbiSearch(dbiIndex dbi, DBC * dbcursor,
}
break;
}
- *setp = set;
+ if (setp) *setp = set;
}
return rc;
}
@@ -668,6 +675,9 @@ int rpmdbOpenAll (rpmdb rpmdb)
{
int dbix;
+ if (rpmdb == NULL) return -2;
+
+ if (dbiTags != NULL)
for (dbix = 0; dbix < dbiTagsMax; dbix++) {
if (rpmdb->_dbi[dbix] != NULL)
continue;
@@ -681,6 +691,7 @@ int rpmdbClose (rpmdb rpmdb)
{
int dbix;
+ if (rpmdb == NULL) return 0;
for (dbix = rpmdb->db_ndbi; --dbix >= 0; ) {
if (rpmdb->_dbi[dbix] == NULL)
continue;
@@ -701,6 +712,7 @@ int rpmdbSync(rpmdb rpmdb)
{
int dbix;
+ if (rpmdb == NULL) return 0;
for (dbix = 0; dbix < rpmdb->db_ndbi; dbix++) {
int xx;
if (rpmdb->_dbi[dbix] == NULL)
@@ -710,7 +722,7 @@ int rpmdbSync(rpmdb rpmdb)
return 0;
}
-static /*@only@*/ rpmdb newRpmdb(/*@kept@*/ const char * root,
+static /*@only@*/ rpmdb newRpmdb(/*@kept@*/ /*@null@*/ const char * root,
/*@kept@*/ const char * home,
int mode, int perms, int flags)
{
@@ -746,8 +758,10 @@ static /*@only@*/ rpmdb newRpmdb(/*@kept@*/ const char * root,
/*@-globstate@*/ return rpmdb; /*@=globstate@*/
}
-static int openDatabase(const char * prefix, const char * dbpath, int _dbapi,
- /*@out@*/ rpmdb *dbp, int mode, int perms, int flags)
+static int openDatabase(/*@null@*/ const char * prefix,
+ /*@null@*/ const char * dbpath,
+ int _dbapi, /*@null@*/ /*@out@*/ rpmdb *dbp,
+ int mode, int perms, int flags)
{
rpmdb rpmdb;
int rc;
@@ -777,6 +791,7 @@ static int openDatabase(const char * prefix, const char * dbpath, int _dbapi,
{ int dbix;
rc = 0;
+ if (dbiTags != NULL)
for (dbix = 0; rc == 0 && dbix < dbiTagsMax; dbix++) {
dbiIndex dbi;
int rpmtag;
@@ -794,6 +809,10 @@ static int openDatabase(const char * prefix, const char * dbpath, int _dbapi,
}
dbi = dbiOpen(rpmdb, rpmtag, 0);
+ if (dbi == NULL) {
+ rc = -2;
+ break;
+ }
switch (rpmtag) {
case RPMDBI_PACKAGES:
@@ -874,7 +893,7 @@ int rpmdbInit (const char * prefix, int perms)
return rc;
}
-static int rpmdbFindByFile(rpmdb rpmdb, const char * filespec,
+static int rpmdbFindByFile(rpmdb rpmdb, /*@null@*/ const char * filespec,
/*@out@*/ dbiIndexSet * matches)
{
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
@@ -893,6 +912,7 @@ static int rpmdbFindByFile(rpmdb rpmdb, const char * filespec,
int xx;
*matches = NULL;
+ if (filespec == NULL) return -2;
if ((baseName = strrchr(filespec, '/')) != NULL) {
char * t;
size_t len;
@@ -906,16 +926,22 @@ static int rpmdbFindByFile(rpmdb rpmdb, const char * filespec,
dirName = "";
baseName = filespec;
}
+ if (baseName == NULL)
+ return -2;
fpc = fpCacheCreate(20);
fp1 = fpLookup(fpc, dirName, baseName, 1);
dbi = dbiOpen(rpmdb, RPMTAG_BASENAMES, 0);
- dbcursor = NULL;
- xx = dbiCopen(dbi, &dbcursor, 0);
- rc = dbiSearch(dbi, dbcursor, baseName, strlen(baseName), &allMatches);
- xx = dbiCclose(dbi, dbcursor, 0);
- dbcursor = NULL;
+ if (dbi != NULL) {
+ dbcursor = NULL;
+ xx = dbiCopen(dbi, &dbcursor, 0);
+ rc = dbiSearch(dbi, dbcursor, baseName, strlen(baseName), &allMatches);
+ xx = dbiCclose(dbi, dbcursor, 0);
+ dbcursor = NULL;
+ } else
+ rc = -2;
+
if (rc) {
dbiFreeIndexSet(allMatches);
allMatches = NULL;
@@ -955,7 +981,9 @@ static int rpmdbFindByFile(rpmdb rpmdb, const char * filespec,
int num = dbiIndexRecordFileNumber(allMatches, i);
fp2 = fpLookup(fpc, dirNames[dirIndexes[num]], baseNames[num], 1);
+ /*@-nullpass@*/
if (FP_EQUAL(fp1, fp2)) {
+ /*@=nullpass@*/
rec->hdrNum = dbiIndexRecordOffset(allMatches, i);
rec->tagNum = dbiIndexRecordFileNumber(allMatches, i);
(void) dbiAppendSet(*matches, rec, 1, sizeof(*rec), 0);
@@ -1110,13 +1138,14 @@ exit:
* @param matches
* @return 0 on success, 1 on no mtches, 2 on error
*/
-static int dbiFindByLabel(dbiIndex dbi, DBC * dbcursor, const char * arg, dbiIndexSet * matches)
+static int dbiFindByLabel(dbiIndex dbi, DBC * dbcursor,
+ /*@null@*/ const char * arg, dbiIndexSet * matches)
{
char * localarg, * chptr;
char * release;
int rc;
- if (!strlen(arg)) return 1;
+ if (arg == NULL || strlen(arg) == 0) return 1;
/* did they give us just a name? */
rc = dbiFindMatches(dbi, dbcursor, arg, NULL, NULL, matches);
@@ -1192,7 +1221,7 @@ struct _rpmdbMatchIterator {
dbiIndexSet mi_set;
DBC * mi_dbc;
int mi_setx;
- Header mi_h;
+/*@null@*/ Header mi_h;
int mi_sorted;
int mi_modified;
unsigned int mi_prevoffset;
@@ -1200,8 +1229,8 @@ struct _rpmdbMatchIterator {
unsigned int mi_filenum;
unsigned int mi_fpnum;
unsigned int mi_dbnum;
-/*@only@*/ const char * mi_version;
-/*@only@*/ const char * mi_release;
+/*@only@*//*@null@*/ const char * mi_version;
+/*@only@*//*@null@*/ const char * mi_release;
};
rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi)
@@ -1214,7 +1243,7 @@ rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi)
dbi = dbiOpen(mi->mi_rpmdb, RPMDBI_PACKAGES, 0);
if (mi->mi_h) {
- if (mi->mi_modified && mi->mi_prevoffset) {
+ if (dbi && mi->mi_modified && mi->mi_prevoffset) {
DBC * dbcursor = NULL;
xx = dbiCopen(dbi, &dbcursor, 0);
(void) dbiUpdateRecord(dbi, dbcursor, mi->mi_prevoffset, mi->mi_h);
@@ -1224,21 +1253,20 @@ rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi)
headerFree(mi->mi_h);
mi->mi_h = NULL;
}
- if (dbi->dbi_rmw) {
- xx = dbiCclose(dbi, dbi->dbi_rmw, 0);
+ if (dbi) {
+ if (dbi->dbi_rmw)
+ xx = dbiCclose(dbi, dbi->dbi_rmw, 0);
dbi->dbi_rmw = NULL;
}
mi->mi_release = _free(mi->mi_release);
mi->mi_version = _free(mi->mi_version);
- if (mi->mi_dbc) {
+ if (dbi && mi->mi_dbc)
xx = dbiCclose(dbi, mi->mi_dbc, 1);
- mi->mi_dbc = NULL;
- }
- if (mi->mi_set) {
+ mi->mi_dbc = NULL;
+ if (mi->mi_set)
dbiFreeIndexSet(mi->mi_set);
- mi->mi_set = NULL;
- }
+ mi->mi_set = NULL;
mi->mi_keyp = _free(mi->mi_keyp);
mi = _free(mi);
return mi;
@@ -1246,7 +1274,7 @@ rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi)
rpmdb rpmdbGetIteratorRpmDB(rpmdbMatchIterator mi) {
if (mi == NULL)
- return 0;
+ return NULL;
return mi->mi_rpmdb;
}
@@ -1371,21 +1399,21 @@ if (dbi->dbi_api == 1 && dbi->dbi_rpmtag == RPMDBI_PACKAGES && rc == EFAULT) {
mi->mi_h = NULL;
}
- mi->mi_h = headerCopyLoad(uh);
+ mi->mi_h = (uh ? headerCopyLoad(uh) : NULL);
/* XXX db1 with hybrid, simulated db interface on falloc.c needs free. */
- if (dbi->dbi_api <= 1) free(uh);
+ if (dbi->dbi_api <= 1) uh = _free(uh);
- if (mi->mi_release) {
+ if (mi->mi_h && mi->mi_release) {
const char *release;
(void) headerNVR(mi->mi_h, NULL, NULL, &release);
- if (strcmp(mi->mi_release, release))
+ if (mi->mi_release && strcmp(mi->mi_release, release))
goto top;
}
- if (mi->mi_version) {
+ if (mi->mi_h && mi->mi_version) {
const char *version;
(void) headerNVR(mi->mi_h, NULL, &version, NULL);
- if (strcmp(mi->mi_version, version))
+ if (mi->mi_version && strcmp(mi->mi_version, version))
goto top;
}
@@ -1404,7 +1432,7 @@ exit:
/*@-compdef -usereleased@*/ return mi->mi_h; /*@=compdef =usereleased@*/
}
-static void rpmdbSortIterator(rpmdbMatchIterator mi) {
+static void rpmdbSortIterator(/*@null@*/ rpmdbMatchIterator mi) {
if (mi && mi->mi_set && mi->mi_set->recs && mi->mi_set->count > 0) {
qsort(mi->mi_set->recs, mi->mi_set->count, sizeof(*mi->mi_set->recs),
hdrNumCmp);
@@ -1412,7 +1440,7 @@ static void rpmdbSortIterator(rpmdbMatchIterator mi) {
}
}
-static int rpmdbGrowIterator(rpmdbMatchIterator mi,
+static int rpmdbGrowIterator(/*@null@*/ rpmdbMatchIterator mi,
const void * keyp, size_t keylen, int fpNum)
{
dbiIndex dbi = NULL;
@@ -1489,6 +1517,8 @@ rpmdbMatchIterator rpmdbInitIterator(rpmdb rpmdb, int rpmtag,
const void * mi_keyp = NULL;
int isLabel = 0;
+ if (rpmdb == NULL)
+ return NULL;
/* XXX HACK to remove rpmdbFindByLabel/findMatches from the API */
switch (rpmtag) {
case RPMDBI_LABEL:
@@ -1526,7 +1556,9 @@ fprintf(stderr, "*** RMW %s %p\n", tagName(rpmtag), dbi->dbi_rmw);
rc = rpmdbFindByFile(rpmdb, keyp, &set);
} else {
xx = dbiCopen(dbi, &dbcursor, 0);
+ /*@-nullpass@*/ /* LCL: kep != NULL here. */
rc = dbiSearch(dbi, dbcursor, keyp, keylen, &set);
+ /*@=nullpass@*/
xx = dbiCclose(dbi, dbcursor, 0);
dbcursor = NULL;
}
@@ -1644,6 +1676,7 @@ int rpmdbRemove(rpmdb rpmdb, int rid, unsigned int hdrNum)
{ int dbix;
dbiIndexItem rec = dbiIndexNewItem(hdrNum, 0);
+ if (dbiTags != NULL)
for (dbix = 0; dbix < dbiTagsMax; dbix++) {
dbiIndex dbi;
DBC * dbcursor = NULL;
@@ -1667,13 +1700,15 @@ int rpmdbRemove(rpmdb rpmdb, int rid, unsigned int hdrNum)
continue;
/*@notreached@*/ break;
case RPMDBI_PACKAGES:
- dbi = dbiOpen(rpmdb, rpmtag, 0);
+ dbi = dbiOpen(rpmdb, rpmtag, 0);
+ if (dbi != NULL) {
xx = dbiCopen(dbi, &dbcursor, 0);
xx = dbiDel(dbi, dbcursor, &hdrNum, sizeof(hdrNum), 0);
xx = dbiCclose(dbi, dbcursor, 0);
dbcursor = NULL;
if (!dbi->dbi_no_dbsync)
xx = dbiSync(dbi, 0);
+ }
continue;
/*@notreached@*/ break;
}
@@ -1681,7 +1716,8 @@ int rpmdbRemove(rpmdb rpmdb, int rid, unsigned int hdrNum)
if (!hge(h, rpmtag, &rpmtype, (void **) &rpmvals, &rpmcnt))
continue;
- dbi = dbiOpen(rpmdb, rpmtag, 0);
+ dbi = dbiOpen(rpmdb, rpmtag, 0);
+ if (dbi != NULL) {
xx = dbiCopen(dbi, &dbcursor, 0);
if (rpmtype == RPM_STRING_TYPE) {
@@ -1749,6 +1785,7 @@ int rpmdbRemove(rpmdb rpmdb, int rid, unsigned int hdrNum)
if (!dbi->dbi_no_dbsync)
xx = dbiSync(dbi, 0);
+ }
rpmvals = hfd(rpmvals, rpmtype);
rpmtype = 0;
@@ -1816,7 +1853,7 @@ int rpmdbAdd(rpmdb rpmdb, int iid, Header h)
int count = 0;
dbiIndex dbi;
int dbix;
- unsigned int hdrNum;
+ unsigned int hdrNum = 0;
int rc = 0;
int xx;
@@ -1847,7 +1884,8 @@ int rpmdbAdd(rpmdb rpmdb, int iid, Header h)
void * datap = NULL;
size_t datalen = 0;
- dbi = dbiOpen(rpmdb, RPMDBI_PACKAGES, 0);
+ dbi = dbiOpen(rpmdb, RPMDBI_PACKAGES, 0);
+ if (dbi != NULL) {
/* XXX db0: hack to pass sizeof header to fadAlloc */
datap = h;
@@ -1877,6 +1915,7 @@ int rpmdbAdd(rpmdb rpmdb, int iid, Header h)
xx = dbiCclose(dbi, dbcursor, 0);
dbcursor = NULL;
+ }
}
@@ -1888,8 +1927,10 @@ int rpmdbAdd(rpmdb rpmdb, int iid, Header h)
/* Now update the indexes */
+ if (hdrNum)
{ dbiIndexItem rec = dbiIndexNewItem(hdrNum, 0);
+ if (dbiTags != NULL)
for (dbix = 0; dbix < dbiTagsMax; dbix++) {
DBC * dbcursor = NULL;
const char *av[1];
@@ -1913,7 +1954,8 @@ int rpmdbAdd(rpmdb rpmdb, int iid, Header h)
continue;
/*@notreached@*/ break;
case RPMDBI_PACKAGES:
- dbi = dbiOpen(rpmdb, rpmtag, 0);
+ dbi = dbiOpen(rpmdb, rpmtag, 0);
+ if (dbi != NULL) {
xx = dbiCopen(dbi, &dbcursor, 0);
xx = dbiUpdateRecord(dbi, dbcursor, hdrNum, h);
xx = dbiCclose(dbi, dbcursor, 0);
@@ -1924,6 +1966,7 @@ int rpmdbAdd(rpmdb rpmdb, int iid, Header h)
(void) headerNVR(h, &n, &v, &r);
rpmMessage(RPMMESS_DEBUG, " +++ %10u %s-%s-%s\n", hdrNum, n, v, r);
}
+ }
continue;
/*@notreached@*/ break;
/* XXX preserve legacy behavior */
@@ -1951,7 +1994,8 @@ int rpmdbAdd(rpmdb rpmdb, int iid, Header h)
rpmcnt = 1;
}
- dbi = dbiOpen(rpmdb, rpmtag, 0);
+ dbi = dbiOpen(rpmdb, rpmtag, 0);
+ if (dbi != NULL) {
xx = dbiCopen(dbi, &dbcursor, 0);
if (rpmtype == RPM_STRING_TYPE) {
@@ -2040,6 +2084,7 @@ int rpmdbAdd(rpmdb rpmdb, int iid, Header h)
if (!dbi->dbi_no_dbsync)
xx = dbiSync(dbi, 0);
+ }
/*@-observertrans@*/
rpmvals = hfd(rpmvals, rpmtype);
@@ -2071,6 +2116,8 @@ int rpmdbFindFpList(rpmdb rpmdb, fingerPrint * fpList, dbiIndexSet * matchList,
Header h;
int i;
+ if (rpmdb == NULL) return 0;
+
mi = rpmdbInitIterator(rpmdb, RPMTAG_BASENAMES, NULL, 0);
/* Gather all matches from the database */
@@ -2089,6 +2136,7 @@ int rpmdbFindFpList(rpmdb rpmdb, fingerPrint * fpList, dbiIndexSet * matchList,
/* iterator is now sorted by (recnum, filenum) */
/* For each set of files matched in a package ... */
+ if (mi != NULL)
while ((h = rpmdbNextIterator(mi)) != NULL) {
const char ** dirNames;
const char ** baseNames;
@@ -2129,10 +2177,13 @@ 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]))
+ /*@-nullpass@*/
+ if (FP_EQUAL(fps[i], fpList[im->fpNum])) {
+ /*@=nullpass@*/
/*@-usedef@*/
(void) dbiAppendSet(matchList[im->fpNum], im, 1, sizeof(*im), 0);
/*@=usedef@*/
+ }
}
fps = _free(fps);
@@ -2192,6 +2243,7 @@ static int rpmdbRemoveDatabase(const char * rootdir,
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);
@@ -2207,6 +2259,7 @@ static int rpmdbRemoveDatabase(const char * rootdir,
case 2:
case 1:
case 0:
+ if (dbiTags != NULL)
for (i = 0; i < dbiTagsMax; i++) {
const char * base = db1basename(dbiTags[i]);
sprintf(filename, "%s/%s/%s", rootdir, dbpath, base);
@@ -2256,6 +2309,7 @@ static int rpmdbMoveDatabase(const char * rootdir,
switch (_olddbapi) {
case 3:
+ if (dbiTags != NULL)
for (i = 0; i < dbiTagsMax; i++) {
const char * base;
int rpmtag;
@@ -2296,6 +2350,7 @@ static int rpmdbMoveDatabase(const char * rootdir,
case 2:
case 1:
case 0:
+ if (dbiTags != NULL)
for (i = 0; i < dbiTagsMax; i++) {
const char * base;
int rpmtag;
@@ -2358,6 +2413,8 @@ int rpmdbRebuild(const char * rootdir)
int _dbapi;
int _dbapi_rebuild;
+ if (rootdir == NULL) rootdir = "/";
+
_dbapi = rpmExpandNumeric("%{_dbapi}");
_dbapi_rebuild = rpmExpandNumeric("%{_dbapi_rebuild}");
diff --git a/lib/rpmdb.h b/lib/rpmdb.h
index fa84aba51..5b5d5414b 100644
--- a/lib/rpmdb.h
+++ b/lib/rpmdb.h
@@ -155,10 +155,10 @@ struct _dbiVec {
* Describes an index database (implemented on Berkeley db[123] API).
*/
struct _dbiIndex {
- const char * dbi_root;
- const char * dbi_home;
- const char * dbi_file;
- const char * dbi_subfile;
+/*@null@*/ const char * dbi_root;
+/*@null@*/ const char * dbi_home;
+/*@null@*/ const char * dbi_file;
+/*@null@*/ const char * dbi_subfile;
int dbi_cflags; /*!< db_create/db_env_create flags */
int dbi_oeflags; /*!< common (db,dbenv}->open flags */
@@ -183,7 +183,7 @@ struct _dbiIndex {
/* dbenv parameters */
int dbi_lorder;
- void (*db_errcall) (const char *db_errpfx, char *buffer);
+/*@null@*/ void (*db_errcall) (const char *db_errpfx, char *buffer);
/*@shared@*/ FILE * dbi_errfile;
const char * dbi_errpfx;
int dbi_verbose;
@@ -208,19 +208,19 @@ struct _dbiIndex {
/* dbinfo parameters */
int dbi_cachesize; /*!< */
int dbi_pagesize; /*!< (fs blksize) */
- void * (*dbi_malloc) (size_t nbytes);
+/*@null@*/ void * (*dbi_malloc) (size_t nbytes);
/* hash access parameters */
unsigned int dbi_h_ffactor; /*!< */
- unsigned int (*dbi_h_hash_fcn) (const void *bytes, unsigned int length);
+/*@null@*/ unsigned int (*dbi_h_hash_fcn) (const void *bytes, unsigned int length);
unsigned int dbi_h_nelem; /*!< */
unsigned int dbi_h_flags; /*!< DB_DUP, DB_DUPSORT */
- int (*dbi_h_dup_compare_fcn) (const DBT *, const DBT *);
+/*@null@*/ int (*dbi_h_dup_compare_fcn) (const DBT *, const DBT *);
/* btree access parameters */
int dbi_bt_flags;
int dbi_bt_minkey;
- int (*dbi_bt_compare_fcn)(const DBT *, const DBT *);
- int (*dbi_bt_dup_compare_fcn) (const DBT *, const DBT *);
- size_t (*dbi_bt_prefix_fcn) (const DBT *, const DBT *);
+/*@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 *);
/* recno access parameters */
int dbi_re_flags;
int dbi_re_delim;
@@ -234,10 +234,10 @@ struct _dbiIndex {
unsigned int dbi_lastoffset; /*!< db1 with falloc.c needs this */
- void * dbi_db; /*!< dbi handle */
- void * dbi_dbenv;
- void * dbi_dbinfo;
- void * dbi_rmw; /*!< db cursor (with DB_WRITECURSOR) */
+/*@only@*//*@null@*/ void * dbi_db; /*!< dbi handle */
+/*@only@*//*@null@*/ void * dbi_dbenv;
+/*@only@*//*@null@*/ void * dbi_dbinfo;
+/*@only@*//*@null@*/ void * dbi_rmw; /*!< db cursor (with DB_WRITECURSOR) */
/*@observer@*/ const struct _dbiVec * dbi_vec; /*!< private methods */
@@ -295,7 +295,7 @@ void db3Free( /*@only@*/ /*@null@*/ dbiIndex dbi);
* @param print_dbenv_flags format db env flags instead?
* @return formatted flags (static buffer)
*/
-/*@exposed@*/ const char *const prDbiOpenFlags(int dbflags,
+/*@exposed@*/ extern const char *const prDbiOpenFlags(int dbflags,
int print_dbenv_flags);
/** \ingroup dbi
@@ -305,7 +305,7 @@ void db3Free( /*@only@*/ /*@null@*/ dbiIndex dbi);
* @param flags (unused)
* @return index database handle
*/
-/*@only@*/ /*@null@*/ dbiIndex dbiOpen(rpmdb rpmdb, int rpmtag,
+/*@only@*/ /*@null@*/ dbiIndex dbiOpen(/*@null@*/ rpmdb rpmdb, int rpmtag,
unsigned int flags);
/** \ingroup dbi
@@ -400,8 +400,8 @@ unsigned int rpmdbGetIteratorFileNum(rpmdbMatchIterator mi);
/** \ingroup rpmdb
* @param rpmdb rpm database
*/
-int rpmdbFindFpList(rpmdb rpmdb, fingerPrint * fpList, /*@out@*/dbiIndexSet * matchList,
- int numItems);
+int rpmdbFindFpList(/*@null@*/ rpmdb rpmdb, fingerPrint * fpList,
+ /*@out@*/dbiIndexSet * matchList, int numItems);
/** \ingroup dbi
* Destroy set of index database items.
diff --git a/lib/rpminstall.c b/lib/rpminstall.c
index 0debbbd0f..f411506c0 100644
--- a/lib/rpminstall.c
+++ b/lib/rpminstall.c
@@ -79,20 +79,24 @@ static void printHash(const unsigned long amount, const unsigned long total)
/**
*/
-static void * showProgress(const void * arg, const rpmCallbackType what,
- const unsigned long amount,
- const unsigned long total,
- const void * pkgKey, void * data)
+static /*@null@*/
+void * showProgress(/*@null@*/ const void * arg, const rpmCallbackType what,
+ const unsigned long amount,
+ const unsigned long total,
+ /*@null@*/ const void * pkgKey,
+ /*@null@*/ void * data)
{
Header h = (Header) arg;
char * s;
int flags = (int) ((long)data);
void * rc = NULL;
const char * filename = pkgKey;
- static FD_t fd;
+ static FD_t fd = NULL;
switch (what) {
case RPMCALLBACK_INST_OPEN_FILE:
+ if (filename == NULL || filename[0] == '\0')
+ return NULL;
fd = Fopen(filename, "r.ufdio");
if (fd)
fd = fdLink(fd, "persist (showProgress)");
@@ -109,10 +113,11 @@ static void * showProgress(const void * arg, const rpmCallbackType what,
case RPMCALLBACK_INST_START:
hashesPrinted = 0;
- if (!(flags & INSTALL_LABEL))
+ if (h == NULL || !(flags & INSTALL_LABEL))
break;
if (flags & INSTALL_HASH) {
- s = headerSprintf(h, "%{NAME}", rpmTagTable, rpmHeaderFormats,NULL);
+ s = headerSprintf(h, "%{NAME}",
+ rpmTagTable, rpmHeaderFormats, NULL);
#ifdef FANCY_HASH
if (isatty (STDOUT_FILENO))
fprintf(stdout, "%4d:%-23.23s", progressCurrent + 1, s);
@@ -121,13 +126,14 @@ static void * showProgress(const void * arg, const rpmCallbackType what,
fprintf(stdout, "%-28s", s);
#endif
(void) fflush(stdout);
+ s = _free(s);
} else {
s = headerSprintf(h, "%{NAME}-%{VERSION}-%{RELEASE}",
rpmTagTable, rpmHeaderFormats, NULL);
fprintf(stdout, "%s\n", s);
(void) fflush(stdout);
+ s = _free(s);
}
- s = _free(s);
break;
case RPMCALLBACK_TRANS_PROGRESS:
@@ -208,6 +214,8 @@ int rpmInstall(const char * rootdir, const char ** fileArgv,
int rc;
int i;
+ if (fileArgv == NULL) return 0;
+
while (defaultReloc && defaultReloc->oldPath)
defaultReloc++;
if (defaultReloc && !defaultReloc->newPath) defaultReloc = NULL;
@@ -299,7 +307,7 @@ restart:
if (numFailed) goto exit;
/* Continue processing file arguments, building transaction set. */
- for (fnp = pkgURL+prevx; *fnp; fnp++, prevx++) {
+ for (fnp = pkgURL+prevx; *fnp != NULL; fnp++, prevx++) {
const char * fileName;
rpmRC rpmrc;
int isSource;
@@ -452,7 +460,7 @@ restart:
rc = rpmReadPackageManifest(fd, &argc, &argv);
if (rc)
rpmError(RPMERR_MANIFEST, _("%s: read manifest failed: %s\n"),
- fileURL, Fstrerror(fd));
+ *fnp, Fstrerror(fd));
(void) Fclose(fd);
/* If successful, restart the query loop. */
@@ -565,6 +573,8 @@ int rpmErase(const char * rootdir, const char ** argv,
int numPackages = 0;
rpmProblemSet probs;
+ if (argv == NULL) return 0;
+
if (transFlags & RPMTRANS_FLAG_TEST)
mode = O_RDONLY;
else
@@ -649,8 +659,11 @@ int rpmInstallSource(const char * rootdir, const char * arg,
if (rpmIsVerbose())
fprintf(stdout, _("Installing %s\n"), arg);
- { rpmRC rpmrc = rpmInstallSourcePackage(rootdir, fd, specFile, NULL, NULL,
+ {
+ /*@-mayaliasunique@*/
+ rpmRC rpmrc = rpmInstallSourcePackage(rootdir, fd, specFile, NULL, NULL,
cookie);
+ /*@=mayaliasunique@*/
rc = (rpmrc == RPMRC_OK ? 0 : 1);
}
if (rc != 0) {
diff --git a/lib/rpmlib.h b/lib/rpmlib.h
index f3d0c3103..750c5da73 100644
--- a/lib/rpmlib.h
+++ b/lib/rpmlib.h
@@ -442,7 +442,7 @@ typedef enum rpmsenseFlags_e {
* @deprecated Use rpmExpand() with appropriate macro expression.
* @todo Eliminate from API.
*/
-const char * rpmGetVar(int var);
+/*@observer@*/ /*@null@*/ const char * rpmGetVar(int var) /*@*/;
/** \ingroup rpmrc
* Set value of an rpmrc variable.
@@ -476,7 +476,8 @@ enum rpm_machtable_e {
* @param target target platform (NULL uses default)
* @return 0 on success, -1 on error
*/
-int rpmReadConfigFiles(const char * file, const char * target);
+int rpmReadConfigFiles(/*@null@*/ const char * file,
+ /*@null@*/ const char * target);
/** \ingroup rpmrc
* Read rpmrc (and macro) configuration file(s).
@@ -491,7 +492,9 @@ int rpmReadRC(const char * file);
* @retval name address of arch name (or NULL)
* @retval num address of arch number (or NULL)
*/
-void rpmGetArchInfo( /*@out@*/ const char ** name, /*@out@*/ int * num);
+void rpmGetArchInfo( /*@null@*/ /*@out@*/ const char ** name,
+ /*@null@*/ /*@out@*/ int * num)
+ /*@modifies *name, *num @*/;
/** \ingroup rpmrc
* Return current os name and/or number.
@@ -499,7 +502,9 @@ void rpmGetArchInfo( /*@out@*/ const char ** name, /*@out@*/ int * num);
* @retval name address of os name (or NULL)
* @retval num address of os number (or NULL)
*/
-void rpmGetOsInfo( /*@out@*/ const char ** name, /*@out@*/ int * num);
+void rpmGetOsInfo( /*@null@*/ /*@out@*/ const char ** name,
+ /*@null@*/ /*@out@*/ int * num)
+ /*@modifies *name, *num @*/;
/** \ingroup rpmrc
* Return arch/os score of a name.
@@ -541,7 +546,7 @@ void rpmSetTables(int archTable, int osTable); /* only used by build code */
* @param arch arch name (or NULL)
* @param os os name (or NULL)
*/
-void rpmSetMachine(const char * arch, const char * os);
+void rpmSetMachine(/*@null@*/ const char * arch, /*@null@*/ const char * os);
/** \ingroup rpmrc
* Return current arch/os names.
@@ -551,7 +556,9 @@ void rpmSetMachine(const char * arch, const char * os);
* @retval arch address of arch name (or NULL)
* @retval os address of os name (or NULL)
*/
-void rpmGetMachine( /*@out@*/ const char **arch, /*@out@*/ const char **os);
+void rpmGetMachine( /*@null@*/ /*@out@*/ const char **arch,
+ /*@null@*/ /*@out@*/ const char **os)
+ /*@modifies *arch, *os @*/;
/** \ingroup rpmrc
* Destroy rpmrc arch/os compatibility tables.
@@ -579,7 +586,9 @@ typedef /*@abstract@*/ struct _dbiIndexSet * dbiIndexSet;
* @param perms database permissions
* @return 0 on success
*/
-int rpmdbOpen (const char * root, /*@out@*/ rpmdb * dbp, int mode, int perms);
+int rpmdbOpen (/*@null@*/ const char * root, /*@null@*/ /*@out@*/ rpmdb * dbp,
+ int mode, int perms)
+ /*@modifies *dbp, fileSystem @*/;
/** \ingroup rpmdb
* Initialize database.
@@ -587,28 +596,32 @@ int rpmdbOpen (const char * root, /*@out@*/ rpmdb * dbp, int mode, int perms);
* @param perms database permissions
* @return 0 on success
*/
-int rpmdbInit(const char * root, int perms);
+int rpmdbInit(/*@null@*/ const char * root, int perms)
+ /*@modifies fileSystem @*/;
/** \ingroup rpmdb
* Close all database indices and free rpmdb.
* @param rpmdb rpm database
* @return 0 always
*/
-int rpmdbClose ( /*@only@*/ rpmdb rpmdb);
+int rpmdbClose (/*@only@*/ /*@null@*/ rpmdb rpmdb)
+ /*@modifies fileSystem @*/;
/** \ingroup rpmdb
* Sync all database indices.
* @param rpmdb rpm database
* @return 0 always
*/
-int rpmdbSync (rpmdb rpmdb);
+int rpmdbSync (/*@null@*/ rpmdb rpmdb)
+ /*@modifies fileSystem @*/;
/** \ingroup rpmdb
* Open all database indices.
* @param rpmdb rpm database
* @return 0 always
*/
-int rpmdbOpenAll (rpmdb rpmdb);
+int rpmdbOpenAll (/*@null@*/ rpmdb rpmdb)
+ /*@modifies fileSystem @*/;
/** \ingroup rpmdb
* Return number of instances of package in rpm database.
@@ -616,7 +629,8 @@ int rpmdbOpenAll (rpmdb rpmdb);
* @param name rpm package name
* @return number of instances
*/
-int rpmdbCountPackages(rpmdb db, const char *name);
+int rpmdbCountPackages(rpmdb db, const char * name)
+ /*@*/;
/** \ingroup rpmdb
*/
@@ -627,7 +641,8 @@ typedef /*@abstract@*/ struct _rpmdbMatchIterator * rpmdbMatchIterator;
* @param mi rpm database iterator
* @return NULL always
*/
-rpmdbMatchIterator rpmdbFreeIterator(/*@only@*//*@null@*/rpmdbMatchIterator mi)
+/*@null@*/ rpmdbMatchIterator rpmdbFreeIterator(
+ /*@only@*//*@null@*/rpmdbMatchIterator mi)
/*@modifies mi @*/;
/** \ingroup rpmdb
@@ -635,21 +650,21 @@ rpmdbMatchIterator rpmdbFreeIterator(/*@only@*//*@null@*/rpmdbMatchIterator mi)
* @param mi rpm database iterator
* @return rpm database handle
*/
-/*@kept@*/ rpmdb rpmdbGetIteratorRpmDB(rpmdbMatchIterator mi) /*@*/;
+/*@kept@*/ rpmdb rpmdbGetIteratorRpmDB(/*@null@*/ rpmdbMatchIterator mi) /*@*/;
/** \ingroup rpmdb
* Return join key for current position of rpm database iterator.
* @param mi rpm database iterator
* @return current join key
*/
-unsigned int rpmdbGetIteratorOffset(rpmdbMatchIterator mi) /*@*/;
+unsigned int rpmdbGetIteratorOffset(/*@null@*/ rpmdbMatchIterator mi) /*@*/;
/** \ingroup rpmdb
* Return number of elements in rpm database iterator.
* @param mi rpm database iterator
* @return number of elements
*/
-int rpmdbGetIteratorCount(rpmdbMatchIterator mi) /*@*/;
+int rpmdbGetIteratorCount(/*@null@*/ rpmdbMatchIterator mi) /*@*/;
/** \ingroup rpmdb
* Append items to set of package instances to iterate.
@@ -658,8 +673,8 @@ int rpmdbGetIteratorCount(rpmdbMatchIterator mi) /*@*/;
* @param nHdrNums number of elements in array
* @return 0 on success, 1 on failure (bad args)
*/
-int rpmdbAppendIterator(rpmdbMatchIterator mi, const int * hdrNums,
- int nHdrNums)
+int rpmdbAppendIterator(/*@null@*/ rpmdbMatchIterator mi,
+ /*@null@*/ const int * hdrNums, int nHdrNums)
/*@modifies mi @*/;
/** \ingroup rpmdb
@@ -670,8 +685,8 @@ int rpmdbAppendIterator(rpmdbMatchIterator mi, const int * hdrNums,
* @param sorted is the array sorted? (array will be sorted on return)
* @return 0 on success, 1 on failure (bad args)
*/
-int rpmdbPruneIterator(rpmdbMatchIterator mi, int * hdrNums,
- int nHdrNums, int sorted)
+int rpmdbPruneIterator(/*@null@*/ rpmdbMatchIterator mi,
+ /*@null@*/ int * hdrNums, int nHdrNums, int sorted)
/*@modifies mi @*/;
/** \ingroup rpmdb
@@ -680,7 +695,8 @@ int rpmdbPruneIterator(rpmdbMatchIterator mi, int * hdrNums,
* @param mi rpm database iterator
* @param version version to check for
*/
-void rpmdbSetIteratorVersion(rpmdbMatchIterator mi, const char * version)
+void rpmdbSetIteratorVersion(/*@null@*/ rpmdbMatchIterator mi,
+ /*@null@*/ const char * version)
/*@modifies mi @*/;
/** \ingroup rpmdb
@@ -689,7 +705,8 @@ void rpmdbSetIteratorVersion(rpmdbMatchIterator mi, const char * version)
* @param mi rpm database iterator
* @param release release to check for
*/
-void rpmdbSetIteratorRelease(rpmdbMatchIterator mi, const char * release)
+void rpmdbSetIteratorRelease(/*@null@*/ rpmdbMatchIterator mi,
+ /*@null@*/ const char * release)
/*@modifies mi @*/;
/** \ingroup rpmdb
@@ -698,7 +715,7 @@ void rpmdbSetIteratorRelease(rpmdbMatchIterator mi, const char * release)
* @param modified new value of modified
* @return previous value
*/
-int rpmdbSetIteratorModified(rpmdbMatchIterator mi, int modified)
+int rpmdbSetIteratorModified(/*@null@*/ rpmdbMatchIterator mi, int modified)
/*@modifies mi @*/;
/** \ingroup rpmdb
@@ -723,8 +740,9 @@ int rpmdbSetIteratorModified(rpmdbMatchIterator mi, int modified)
* @return NULL on failure
*/
/*@only@*/ /*@null@*/ rpmdbMatchIterator rpmdbInitIterator(
- /*@kept@*/ rpmdb rpmdb, int rpmtag,
- const void * key, size_t keylen);
+ /*@kept@*/ /*@null@*/ rpmdb rpmdb, int rpmtag,
+ /*@null@*/ const void * key, size_t keylen)
+ /*@modifies fileSystem @*/;
/** \ingroup rpmdb
* Add package header to rpm database and indices.
@@ -734,7 +752,7 @@ int rpmdbSetIteratorModified(rpmdbMatchIterator mi, int modified)
* @return 0 on success
*/
int rpmdbAdd(rpmdb rpmdb, int iid, Header h)
- /*@modifies h @*/;
+ /*@modifies h, fileSystem @*/;
/** \ingroup rpmdb
* Remove package header from rpm database and indices.
@@ -743,13 +761,15 @@ int rpmdbAdd(rpmdb rpmdb, int iid, Header h)
* @param offset location in Packages dbi
* @return 0 on success
*/
-int rpmdbRemove(rpmdb db, int rid, unsigned int offset);
+int rpmdbRemove(rpmdb rpmdb, int rid, unsigned int offset)
+ /*@modifies fileSystem @*/;
/** \ingroup rpmdb
* Rebuild database indices from package headers.
* @param root path to top of install tree
*/
-int rpmdbRebuild(const char * root);
+int rpmdbRebuild(/*@null@*/ const char * root)
+ /*@modifies fileSystem @*/;
/*@}*/
/* ==================================================================== */
@@ -779,11 +799,11 @@ typedef enum rpmProblemType_e {
typedef /*@abstract@*/ struct rpmProblem_s {
/*@only@*/ /*@null@*/ const char * pkgNEVR;
/*@only@*/ /*@null@*/ const char * altNEVR;
-/*@kept@*/ const void * key;
- Header h;
+/*@kept@*/ /*@null@*/ const void * key;
+/*@null@*/ Header h;
rpmProblemType type;
int ignoreProblem;
-/*@only@*/ const char * str1;
+/*@only@*/ /*@null@*/ const char * str1;
unsigned long ulong1;
} * rpmProblem;
@@ -867,8 +887,9 @@ typedef /*@null@*/
/**
* Prototype for headerGetEntry() vector.
*/
-typedef int (*HGE_t) (Header h, int_32 tag, /*@out@*/ int_32 * type,
- /*@out@*/ void ** p, /*@out@*/int_32 * c)
+typedef int (*HGE_t) (Header h, int_32 tag, /*@null@*/ /*@out@*/ int_32 * type,
+ /*@null@*/ /*@out@*/ void ** p,
+ /*@null@*/ /*@out@*/int_32 * c)
/*@modifies *type, *p, *c @*/;
/**
@@ -1284,10 +1305,10 @@ int rpmGetFilesystemUsage(const char ** filelist, int_32 * fssizes,
/** \ingroup rpmcli
* Describe build command line request.
*/
-struct rpmBuildArguments {
+struct rpmBuildArguments_s {
int buildAmount; /*!< Bit(s) to control operation. */
- const char *buildRootOverride; /*!< from --buildroot */
- char *targets; /*!< Target platform(s), comma separated. */
+/*@null@*/ const char * buildRootOverride; /*!< from --buildroot */
+/*@null@*/ char * targets; /*!< Target platform(s), comma separated. */
int force; /*!< from --force */
int noBuild; /*!< from --nobuild */
int noDeps; /*!< from --nodeps */
@@ -1297,15 +1318,15 @@ struct rpmBuildArguments {
int useCatalog; /*!< from --usecatalog */
char buildMode; /*!< Build mode (one of "btBC") */
char buildChar; /*!< Build stage (one of "abcilps ") */
-/*@dependent@*/ const char *rootdir;
+/*@dependent@*/ /*@null@*/ const char * rootdir;
};
/** \ingroup rpmcli
*/
-typedef struct rpmBuildArguments BTA_t;
+typedef struct rpmBuildArguments_s * BTA_t;
/** \ingroup rpmcli
*/
-extern struct rpmBuildArguments rpmBTArgs;
+extern struct rpmBuildArguments_s rpmBTArgs;
/** \ingroup rpmcli
*/
@@ -1357,7 +1378,7 @@ int rpmVerifyFile(const char * root, Header h, int filenum,
* @param scriptFd file handle to use for stderr (or NULL)
* @return 0 on success
*/
-int rpmVerifyScript(const char * rootDir, Header h, FD_t scriptFd);
+int rpmVerifyScript(const char * rootDir, Header h, /*@null@*/ FD_t scriptFd);
/** \ingroup rpmcli
* The command line argument will be used to retrieve header(s) ...
@@ -1399,20 +1420,20 @@ typedef enum rpmVerifyFlags_e {
/** \ingroup rpmcli
* Describe query/verify command line request.
*/
-typedef struct rpmQVArguments {
+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) */
-/*@only@*/ const char *qva_queryFormat;/*!< Format for headerSprintf(). */
-/*@dependent@*/ const char *qva_prefix; /*!< Path to top of install tree. */
+/*@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. */
char qva_char; /*!< (unused) always ' ' */
-} QVA_t;
+} * QVA_t;
/** \ingroup rpmcli
*/
-extern QVA_t rpmQVArgs;
+extern struct rpmQVArguments_s rpmQVArgs;
/** \ingroup rpmcli
*/
@@ -1423,7 +1444,7 @@ 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);
/** \ingroup rpmcli
* Display query/verify information for each header in iterator.
@@ -1432,7 +1453,7 @@ typedef int (*QVF_t) (QVA_t *qva, rpmdb db, Header h);
* @param showPackage query/verify display routine
* @return result of last non-zero showPackage() return
*/
-int showMatches(QVA_t *qva, /*@only@*/ /*@null@*/ rpmdbMatchIterator mi,
+int showMatches(QVA_t qva, /*@only@*/ /*@null@*/ rpmdbMatchIterator mi,
QVF_t showPackage);
/** \ingroup rpmcli
@@ -1458,7 +1479,7 @@ void rpmDisplayQueryTags(FILE * f);
* @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,
+int rpmQueryVerify(QVA_t qva, rpmQVSources source, const char * arg,
rpmdb db, QVF_t showPackage);
/** \ingroup rpmcli
@@ -1469,7 +1490,7 @@ int rpmQueryVerify(QVA_t *qva, rpmQVSources source, const char * arg,
* @param h header to use for query
* @return 0 always
*/
-int showQueryPackage(QVA_t *qva, rpmdb db, Header h);
+int showQueryPackage(QVA_t qva, rpmdb db, Header h);
/** \ingroup rpmcli
* Display package information.
@@ -1478,7 +1499,7 @@ int showQueryPackage(QVA_t *qva, rpmdb db, Header h);
* @param arg name of source to query
* @return rpmQueryVerify() result, or 1 on rpmdbOpen() failure
*/
-int rpmQuery(QVA_t *qva, rpmQVSources source, const char * arg);
+int rpmQuery(QVA_t qva, rpmQVSources source, const char * arg);
/** \ingroup rpmcli
*/
@@ -1491,7 +1512,7 @@ extern struct poptOption rpmVerifyPoptTable[];
* @param h header to use for verify
* @return result of last non-zero verify return
*/
-int showVerifyPackage(QVA_t *qva, /*@only@*/ rpmdb db, Header h);
+int showVerifyPackage(QVA_t qva, /*@only@*/ rpmdb db, Header h);
/** \ingroup rpmcli
* Verify package install.
@@ -1500,7 +1521,7 @@ int showVerifyPackage(QVA_t *qva, /*@only@*/ rpmdb db, Header h);
* @param arg name of source to verify
* @return rpmQueryVerify() result, or 1 on rpmdbOpen() failure
*/
-int rpmVerify(QVA_t *qva, rpmQVSources source, const char *arg);
+int rpmVerify(QVA_t qva, rpmQVSources source, const char *arg);
/*@}*/
/* ==================================================================== */
@@ -1532,11 +1553,11 @@ typedef enum rpmInstallInterfaceFlags_e {
* @param relocations package file relocations
* @return 0 on success
*/
-int rpmInstall(const char * rootdir, const char ** argv,
+int rpmInstall(/*@null@*/ const char * rootdir, /*@null@*/ const char ** argv,
rpmtransFlags transFlags,
rpmInstallInterfaceFlags interfaceFlags,
rpmprobFilterFlags probFilter,
- rpmRelocation * relocations);
+ /*@null@*/ rpmRelocation * relocations);
/** \ingroup rpmcli
* Install source rpm package.
@@ -1566,7 +1587,7 @@ typedef enum rpmEraseInterfaceFlags_e {
* @param interfaceFlags bits to control rpmInstall()
* @return 0 on success
*/
-int rpmErase(const char * rootdir, const char ** argv,
+int rpmErase(/*@null@*/ const char * rootdir, /*@null@*/ const char ** argv,
rpmtransFlags transFlags,
rpmEraseInterfaceFlags interfaceFlags);
@@ -1656,7 +1677,8 @@ typedef enum rpmCheckSigFlags_e {
* @param argv array of package file names (NULL terminated)
* @return 0 on success
*/
-int rpmCheckSig(rpmCheckSigFlags flags, const char ** argv);
+int rpmCheckSig(rpmCheckSigFlags flags, /*@null@*/ const char ** argv)
+ /*@modifies fileSystem @*/;
/** \ingroup rpmcli
* Bit(s) to control rpmReSign() operation.
@@ -1673,7 +1695,9 @@ typedef enum rpmResignFlags_e {
* @param argv array of package file names (NULL terminated)
* @return 0 on success
*/
-int rpmReSign(rpmResignFlags add, char *passPhrase, const char ** argv);
+int rpmReSign(rpmResignFlags add, char * passPhrase,
+ /*@null@*/ const char ** argv)
+ /*@modifies fileSystem @*/;
/*@}*/
diff --git a/lib/rpmrc.c b/lib/rpmrc.c
index 5b3dead25..0caf493c6 100644
--- a/lib/rpmrc.c
+++ b/lib/rpmrc.c
@@ -22,27 +22,27 @@ const char * macrofiles = MACROFILES;
typedef /*@owned@*/ const char * cptr_t;
-struct machCacheEntry {
+typedef struct machCacheEntry_s {
const char * name;
int count;
cptr_t * equivs;
int visited;
-};
+} * machCacheEntry;
-struct machCache {
- struct machCacheEntry * cache;
+typedef struct machCache_s {
+ machCacheEntry cache;
int size;
-};
+} * machCache;
-struct machEquivInfo {
+typedef struct machEquivInfo_s {
const char * name;
int score;
-};
+} * machEquivInfo;
-struct machEquivTable {
+typedef struct machEquivTable_s {
int count;
- struct machEquivInfo * list;
-};
+ machEquivInfo list;
+} * machEquivTable;
struct rpmvarValue {
const char * value;
@@ -58,35 +58,35 @@ struct rpmOption {
struct rpmOptionValue * value;
};
-struct defaultEntry {
-/*@owned@*/ const char * name;
-/*@owned@*/ const char * defName;
-};
+typedef struct defaultEntry_s {
+/*@owned@*/ /*@null@*/ const char * name;
+/*@owned@*/ /*@null@*/ const char * defName;
+} * defaultEntry;
-struct canonEntry {
+typedef struct canonEntry_s {
/*@owned@*/ const char * name;
/*@owned@*/ const char * short_name;
short num;
-};
+} * canonEntry;
/* tags are 'key'canon, 'key'translate, 'key'compat
*
* for giggles, 'key'_canon, 'key'_compat, and 'key'_canon will also work
*/
-struct tableType {
+typedef struct tableType_s {
const char * const key;
const int hasCanon;
const int hasTranslate;
- struct machEquivTable equiv;
- struct machCache cache;
- struct defaultEntry * defaults;
- struct canonEntry * canons;
+ struct machEquivTable_s equiv;
+ struct machCache_s cache;
+ defaultEntry defaults;
+ canonEntry canons;
int defaultsLength;
int canonsLength;
-};
+} * tableType;
/*@-fullinitblock@*/
-static struct tableType tables[RPM_MACHTABLE_COUNT] = {
+static struct tableType_s tables[RPM_MACHTABLE_COUNT] = {
{ "arch", 1, 0 },
{ "os", 1, 0 },
{ "buildarch", 0, 1 },
@@ -115,18 +115,22 @@ static int defaultsInitialized = 0;
/* prototypes */
static int doReadRC( /*@killref@*/ FD_t fd, const char * urlfn);
-static void rpmSetVarArch(int var, const char * val, const char * arch);
-static void rebuildCompatTables(int type, const char *name);
+static void rpmSetVarArch(int var, const char * val,
+ /*@null@*/ const char * arch);
+static void rebuildCompatTables(int type, const char * name);
-static int optionCompare(const void * a, const void * b) {
+static int optionCompare(const void * a, const void * b)
+ /*@*/
+{
return xstrcasecmp(((struct rpmOption *) a)->name,
((struct rpmOption *) b)->name);
}
-static void rpmRebuildTargetVars(const char **target, const char ** canontarget);
+static void rpmRebuildTargetVars(/*@null@*/ const char **target, /*@null@*/ const char ** canontarget);
-static /*@observer@*/ struct machCacheEntry *
-machCacheFindEntry(struct machCache * cache, const char * key)
+static /*@observer@*/ /*@null@*/ machCacheEntry
+machCacheFindEntry(const machCache cache, const char * key)
+ /*@*/
{
int i;
@@ -137,12 +141,12 @@ machCacheFindEntry(struct machCache * cache, const char * key)
}
static int machCompatCacheAdd(char * name, const char * fn, int linenum,
- struct machCache * cache)
+ machCache cache)
{
char * chptr, * equivs;
int delEntry = 0;
int i;
- struct machCacheEntry * entry = NULL;
+ machCacheEntry entry = NULL;
while (*name && xisspace(*name)) name++;
@@ -203,8 +207,8 @@ static int machCompatCacheAdd(char * name, const char * fn, int linenum,
return 0;
}
-static /*@observer@*/ struct machEquivInfo *
- machEquivSearch(const struct machEquivTable * table, const char * name)
+static /*@observer@*/ /*@null@*/ machEquivInfo
+machEquivSearch(const machEquivTable table, const char * name)
{
int i;
@@ -215,10 +219,11 @@ static /*@observer@*/ struct machEquivInfo *
return NULL;
}
-static void machAddEquiv(struct machEquivTable * table, const char * name,
+static void machAddEquiv(machEquivTable table, const char * name,
int distance)
+ /*@modifies table->list, table->count @*/
{
- struct machEquivInfo * equiv;
+ machEquivInfo equiv;
equiv = machEquivSearch(table, name);
if (!equiv) {
@@ -233,12 +238,12 @@ static void machAddEquiv(struct machEquivTable * table, const char * name,
}
}
-static void machCacheEntryVisit(struct machCache * cache,
- struct machEquivTable * table,
+static void machCacheEntryVisit(machCache cache,
+ machEquivTable table,
const char * name,
int distance)
{
- struct machCacheEntry * entry;
+ machCacheEntry entry;
int i;
entry = machCacheFindEntry(cache, name);
@@ -255,9 +260,8 @@ static void machCacheEntryVisit(struct machCache * cache,
}
}
-static void machFindEquivs(struct machCache * cache,
- struct machEquivTable * table,
- const char * key)
+static void machFindEquivs(machCache cache, machEquivTable table,
+ const char * key)
{
int i;
@@ -276,14 +280,17 @@ static void machFindEquivs(struct machCache * cache,
* Yuck. We have to start at a point at traverse it, remembering how
* far away everything is.
*/
+ /*@-nullstate@*/ /* FIX: table->list may be NULL. */
machAddEquiv(table, key, 1);
machCacheEntryVisit(cache, table, key, 2);
+ return;
+ /*@=nullstate@*/
}
-static int addCanon(struct canonEntry ** table, int * tableLen, char * line,
+static int addCanon(canonEntry * table, int * tableLen, char * line,
const char * fn, int lineNum)
{
- struct canonEntry *t;
+ canonEntry t;
char *s, *s1;
const char * tname;
const char * tshort_name;
@@ -291,11 +298,11 @@ static int addCanon(struct canonEntry ** table, int * tableLen, char * line,
if (! *tableLen) {
*tableLen = 2;
- *table = xmalloc(2 * sizeof(struct canonEntry));
+ *table = xmalloc(2 * sizeof(struct canonEntry_s));
} else {
(*tableLen) += 2;
/*@-unqualifiedtrans@*/
- *table = xrealloc(*table, sizeof(struct canonEntry) * (*tableLen));
+ *table = xrealloc(*table, sizeof(struct canonEntry_s) * (*tableLen));
/*@=unqualifiedtrans@*/
}
t = & ((*table)[*tableLen - 2]);
@@ -314,38 +321,40 @@ static int addCanon(struct canonEntry ** table, int * tableLen, char * line,
return RPMERR_RPMRC;
}
+ /*@-nullpass@*/ /* LCL: s != NULL here. */
tnum = strtoul(s, &s1, 10);
if ((*s1) || (s1 == s) || (tnum == ULONG_MAX)) {
rpmError(RPMERR_RPMRC, _("Bad arch/os number: %s (%s:%d)\n"), s,
fn, lineNum);
return(RPMERR_RPMRC);
}
+ /*@=nullpass@*/
t[0].name = xstrdup(tname);
- t[0].short_name = xstrdup(tshort_name);
+ t[0].short_name = (tshort_name ? xstrdup(tshort_name) : xstrdup(""));
t[0].num = tnum;
/* From A B C entry */
/* Add B B C entry */
- t[1].name = xstrdup(tshort_name);
- t[1].short_name = xstrdup(tshort_name);
+ t[1].name = (tshort_name ? xstrdup(tshort_name) : xstrdup(""));
+ t[1].short_name = (tshort_name ? xstrdup(tshort_name) : xstrdup(""));
t[1].num = tnum;
return 0;
}
-static int addDefault(struct defaultEntry **table, int *tableLen, char *line,
+static int addDefault(defaultEntry *table, int *tableLen, char *line,
const char *fn, int lineNum)
{
- struct defaultEntry *t;
+ defaultEntry t;
if (! *tableLen) {
*tableLen = 1;
- *table = xmalloc(sizeof(struct defaultEntry));
+ *table = xmalloc(sizeof(struct defaultEntry_s));
} else {
(*tableLen)++;
/*@-unqualifiedtrans@*/
- *table = xrealloc(*table, sizeof(struct defaultEntry) * (*tableLen));
+ *table = xrealloc(*table, sizeof(struct defaultEntry_s) * (*tableLen));
/*@=unqualifiedtrans@*/
}
t = & ((*table)[*tableLen - 1]);
@@ -365,14 +374,15 @@ static int addDefault(struct defaultEntry **table, int *tableLen, char *line,
}
t->name = xstrdup(t->name);
- t->defName = xstrdup(t->defName);
+ t->defName = (t->defName ? xstrdup(t->defName) : NULL);
/*@=temptrans@*/
return 0;
}
-static /*@null@*/ const struct canonEntry *lookupInCanonTable(const char *name,
- const struct canonEntry *table, int tableLen)
+static /*@null@*/ const canonEntry lookupInCanonTable(const char *name,
+ const canonEntry table, int tableLen)
+ /*@*/
{
while (tableLen) {
tableLen--;
@@ -386,14 +396,14 @@ static /*@null@*/ const struct canonEntry *lookupInCanonTable(const char *name,
return NULL;
}
-static /*@observer@*/ const char * lookupInDefaultTable(const char *name,
- const struct defaultEntry *table, int tableLen)
+static /*@observer@*/ /*@null@*/
+const char * lookupInDefaultTable(const char *name,
+ const defaultEntry table, int tableLen)
{
while (tableLen) {
tableLen--;
- if (!strcmp(name, table[tableLen].name)) {
+ if (table[tableLen].name && !strcmp(name, table[tableLen].name))
return table[tableLen].defName;
- }
}
return name;
@@ -422,7 +432,8 @@ int rpmReadConfigFiles(const char * file, const char * target)
return 0;
}
-static void setVarDefault(int var, const char *macroname, const char *val, const char *body)
+static void setVarDefault(int var, const char *macroname, const char *val,
+ /*@null@*/ const char *body)
{
if (var >= 0) { /* XXX Dying ... */
if (rpmGetVar(var)) return;
@@ -530,7 +541,7 @@ int rpmReadRC(const char * rcfiles)
/* Read each file in rcfiles. */
rc = 0;
- for (r = myrcfiles = xstrdup(rcfiles); *r != '\0'; r = re) {
+ for (r = myrcfiles = xstrdup(rcfiles); r && *r != '\0'; r = re) {
char fn[4096];
FD_t fd;
@@ -959,21 +970,24 @@ static void defaultMachine(/*@out@*/ const char ** arch, /*@out@*/ const char **
static struct utsname un;
static int gotDefaults = 0;
char * chptr;
- const struct canonEntry * canon;
+ canonEntry canon;
+ int rc;
if (!gotDefaults) {
- (void) uname(&un);
+ rc = uname(&un);
+ if (rc) return;
#if !defined(__linux__)
#ifdef SNI
/* USUALLY un.sysname on sinix does start with the word "SINIX"
* let's be absolutely sure
*/
- sprintf(un.sysname,"SINIX");
+ strncpy(un.sysname, "SINIX", sizeof(un.sysname));
#endif
+ /*@-nullpass@*/
if (!strcmp(un.sysname, "AIX")) {
strcpy(un.machine, __power_pc() ? "ppc" : "rs6000");
- sprintf(un.sysname,"aix%s.%s",un.version,un.release);
+ sprintf(un.sysname,"aix%s.%s", un.version, un.release);
}
else if (!strcmp(un.sysname, "SunOS")) {
if (!strncmp(un.release,"4", 1)) /* SunOS 4.x */ {
@@ -995,10 +1009,10 @@ static void defaultMachine(/*@out@*/ const char ** arch, /*@out@*/ const char **
}
else if (!strcmp(un.sysname, "HP-UX"))
/*make un.sysname look like hpux9.05 for example*/
- sprintf(un.sysname, "hpux%s", strpbrk(un.release,"123456789"));
+ sprintf(un.sysname, "hpux%s", strpbrk(un.release, "123456789"));
else if (!strcmp(un.sysname, "OSF1"))
/*make un.sysname look like osf3.2 for example*/
- sprintf(un.sysname,"osf%s",strpbrk(un.release,"123456789"));
+ sprintf(un.sysname, "osf%s", strpbrk(un.release, "123456789"));
else if (!strncmp(un.sysname, "IP", 2))
un.sysname[2] = '\0';
else if (!strncmp(un.sysname, "SINIX", 5)) {
@@ -1014,7 +1028,7 @@ static void defaultMachine(/*@out@*/ const char ** arch, /*@out@*/ const char **
char * prelid = NULL;
FD_t fd = Fopen("/etc/.relid", "r.fdio");
int gotit = 0;
- if (!Ferror(fd)) {
+ if (fd != NULL && !Ferror(fd)) {
chptr = xcalloc(1, 256);
{ int irelid = Fread(chptr, sizeof(*chptr), 256, fd);
(void) Fclose(fd);
@@ -1034,6 +1048,7 @@ static void defaultMachine(/*@out@*/ const char ** arch, /*@out@*/ const char **
/* wrong, just for now, find out how to look for i586 later*/
strcpy(un.machine,"i486");
}
+ /*@=nullpass@*/
#endif /* __linux__ */
/* get rid of the hyphens in the sysname */
@@ -1169,10 +1184,12 @@ static void defaultMachine(/*@out@*/ const char ** arch, /*@out@*/ const char **
if (os) *os = un.sysname;
}
-static const char * rpmGetVarArch(int var, const char * arch) {
- struct rpmvarValue * next;
+static /*@observer@*/ /*@null@*/
+const char * rpmGetVarArch(int var, /*@null@*/ const char * arch)
+{
+ const struct rpmvarValue * next;
- if (!arch) arch = current[ARCH];
+ if (arch == NULL) arch = current[ARCH];
if (arch) {
next = &values[var];
@@ -1188,7 +1205,7 @@ static const char * rpmGetVarArch(int var, const char * arch) {
return next ? next->value : NULL;
}
-const char *rpmGetVar(int var)
+/*@observer@*/ /*@null@*/ const char *rpmGetVar(int var)
{
return rpmGetVarArch(var, NULL);
}
@@ -1230,7 +1247,9 @@ static void rpmSetVarArch(int var, const char * val, const char * arch) {
}
}
+ /*@-nullpass@*/ /* LCL: arch != NULL here. */
if (next->arch && arch && !strcmp(next->arch, arch)) {
+ /*@=nullpass@*/
next->value = _free(next->value);
next->arch = _free(next->arch);
} else if (next->arch || arch) {
@@ -1263,7 +1282,7 @@ void rpmSetTables(int archTable, int osTable) {
}
int rpmMachineScore(int type, const char * name) {
- struct machEquivInfo * info = machEquivSearch(&tables[type].equiv, name);
+ machEquivInfo info = machEquivSearch(&tables[type].equiv, name);
return (info != NULL ? info->score : 0);
}
@@ -1288,6 +1307,7 @@ void rpmSetMachine(const char * arch, const char * os) {
tables[currTables[ARCH]].defaults,
tables[currTables[ARCH]].defaultsLength);
}
+ if (arch == NULL) return; /* XXX can't happen */
if (os == NULL) {
os = host_os;
@@ -1296,6 +1316,7 @@ void rpmSetMachine(const char * arch, const char * os) {
tables[currTables[OS]].defaults,
tables[currTables[OS]].defaultsLength);
}
+ if (os == NULL) return; /* XXX can't happen */
if (!current[ARCH] || strcmp(arch, current[ARCH])) {
current[ARCH] = _free(current[ARCH]);
@@ -1328,10 +1349,11 @@ static void rebuildCompatTables(int type, const char * name) {
name);
}
-static void getMachineInfo(int type, /*@out@*/ const char ** name,
- /*@out@*/int * num)
+static void getMachineInfo(int type, /*@null@*/ /*@out@*/ const char ** name,
+ /*@null@*/ /*@out@*/int * num)
+ /*@modifies *name, *num @*/
{
- const struct canonEntry * canon;
+ canonEntry canon;
int which = currTables[type];
/* use the normal canon tables, even if we're looking up build stuff */
@@ -1462,7 +1484,7 @@ void rpmFreeRpmrc(void)
int i, j, k;
for (i = 0; i < RPM_MACHTABLE_COUNT; i++) {
- struct tableType *t;
+ tableType t;
t = tables + i;
if (t->equiv.list) {
for (j = 0; j < t->equiv.count; j++)
@@ -1472,7 +1494,7 @@ void rpmFreeRpmrc(void)
}
if (t->cache.cache) {
for (j = 0; j < t->cache.size; j++) {
- struct machCacheEntry *e;
+ machCacheEntry e;
e = t->cache.cache + j;
if (e == NULL) continue;
e->name = _free(e->name);
@@ -1524,7 +1546,7 @@ int rpmShowRC(FILE *fp)
{
struct rpmOption *opt;
int i;
- struct machEquivTable * equivTable;
+ machEquivTable equivTable;
/* the caller may set the build arch which should be printed here */
fprintf(fp, "ARCHITECTURE AND OS:\n");
diff --git a/lib/signature.c b/lib/signature.c
index 99eab6539..132b20258 100644
--- a/lib/signature.c
+++ b/lib/signature.c
@@ -27,6 +27,7 @@
#include "debug.h"
/*@access Header@*/ /* XXX compared with NULL */
+/*@access FD_t@*/ /* XXX compared with NULL */
typedef unsigned char byte;
@@ -98,7 +99,7 @@ const char * rpmDetectPGPVersion(pgpVersion * pgpVer)
saved_pgp_version = PGP_NOTDETECTED;
}
- if (pgpbin && pgpVer)
+ if (pgpVer && pgpbin)
*pgpVer = saved_pgp_version;
return pgpbin;
}
@@ -199,7 +200,9 @@ rpmRC rpmReadSignature(FD_t fd, Header * headerp, sigType sig_type)
}
if (rc == 0 && headerp)
+ /*@-nullderef@*/
*headerp = h;
+ /*@=nullderef@*/
else if (h)
headerFree(h);
@@ -238,7 +241,7 @@ void rpmFreeSignature(Header h)
}
static int makePGPSignature(const char * file, /*@out@*/ void ** sig,
- /*@out@*/ int_32 * size, const char * passPhrase)
+ /*@out@*/ int_32 * size, /*@null@*/ const char * passPhrase)
{
char * sigfile = alloca(1024);
int pid, status;
@@ -281,12 +284,14 @@ static int makePGPSignature(const char * file, /*@out@*/ void ** sig,
break;
}
}
- rpmError(RPMERR_EXEC, _("Couldn't exec pgp (%s)\n"), path);
+ rpmError(RPMERR_EXEC, _("Couldn't exec pgp (%s)\n"),
+ (path ? path : NULL));
_exit(RPMERR_EXEC);
}
(void) close(inpipe[0]);
- (void) write(inpipe[1], passPhrase, strlen(passPhrase));
+ if (passPhrase)
+ (void) write(inpipe[1], passPhrase, strlen(passPhrase));
(void) write(inpipe[1], "\n", 1);
(void) close(inpipe[1]);
@@ -298,7 +303,7 @@ static int makePGPSignature(const char * file, /*@out@*/ void ** sig,
if (stat(sigfile, &st)) {
/* PGP failed to write signature */
- (void) unlink(sigfile); /* Just in case */
+ if (sigfile) (void) unlink(sigfile); /* Just in case */
rpmError(RPMERR_SIGGEN, _("pgp failed to write signature\n"));
return 1;
}
@@ -308,11 +313,13 @@ static int makePGPSignature(const char * file, /*@out@*/ void ** sig,
*sig = xmalloc(*size);
{ FD_t fd;
- int rc;
+ int rc = 0;
fd = Fopen(sigfile, "r.fdio");
- rc = timedRead(fd, *sig, *size);
- (void) unlink(sigfile);
- (void) Fclose(fd);
+ if (fd != NULL && !Ferror(fd)) {
+ rc = timedRead(fd, *sig, *size);
+ if (sigfile) (void) unlink(sigfile);
+ (void) Fclose(fd);
+ }
if (rc != *size) {
*sig = _free(*sig);
rpmError(RPMERR_SIGGEN, _("unable to read the signature\n"));
@@ -331,7 +338,7 @@ static int makePGPSignature(const char * file, /*@out@*/ void ** sig,
* creation crop up.
*/
static int makeGPGSignature(const char * file, /*@out@*/ void ** sig,
- /*@out@*/ int_32 * size, const char * passPhrase)
+ /*@out@*/ int_32 * size, /*@null@*/ const char * passPhrase)
{
char * sigfile = alloca(1024);
int pid, status;
@@ -364,8 +371,10 @@ static int makeGPGSignature(const char * file, /*@out@*/ void ** sig,
fpipe = fdopen(inpipe[1], "w");
(void) close(inpipe[0]);
- fprintf(fpipe, "%s\n", passPhrase);
- (void) fclose(fpipe);
+ if (fpipe) {
+ fprintf(fpipe, "%s\n", (passPhrase ? passPhrase : ""));
+ (void) fclose(fpipe);
+ }
(void)waitpid(pid, &status, 0);
if (!WIFEXITED(status) || WEXITSTATUS(status)) {
@@ -375,7 +384,7 @@ static int makeGPGSignature(const char * file, /*@out@*/ void ** sig,
if (stat(sigfile, &st)) {
/* GPG failed to write signature */
- (void) unlink(sigfile); /* Just in case */
+ if (sigfile) (void) unlink(sigfile); /* Just in case */
rpmError(RPMERR_SIGGEN, _("gpg failed to write signature\n"));
return 1;
}
@@ -385,11 +394,13 @@ static int makeGPGSignature(const char * file, /*@out@*/ void ** sig,
*sig = xmalloc(*size);
{ FD_t fd;
- int rc;
+ int rc = 0;
fd = Fopen(sigfile, "r.fdio");
- rc = timedRead(fd, *sig, *size);
- (void) unlink(sigfile);
- (void) Fclose(fd);
+ if (fd != NULL && !Ferror(fd)) {
+ rc = timedRead(fd, *sig, *size);
+ if (sigfile) (void) unlink(sigfile);
+ (void) Fclose(fd);
+ }
if (rc != *size) {
*sig = _free(*sig);
rpmError(RPMERR_SIGGEN, _("unable to read the signature\n"));
@@ -500,7 +511,7 @@ verifyPGPSignature(const char * datafile, const void * sig, int count,
{
int pid, status, outpipe[2];
FD_t sfd;
- char *sigfile;
+/*@observer@*/ const char * sigfile;
byte buf[BUFSIZ];
FILE *file;
int res = RPMSIG_OK;
@@ -528,8 +539,10 @@ verifyPGPSignature(const char * datafile, const void * sig, int count,
tmppath = _free(tmppath);
}
sfd = Fopen(sigfile, "w.fdio");
- (void)Fwrite(sig, sizeof(char), count, sfd);
- (void) Fclose(sfd);
+ if (sfd != NULL && !Ferror(sfd)) {
+ (void) Fwrite(sig, sizeof(char), count, sfd);
+ (void) Fclose(sfd);
+ }
/* Now run PGP */
outpipe[0] = outpipe[1] = 0;
@@ -579,26 +592,28 @@ verifyPGPSignature(const char * datafile, const void * sig, int count,
(void) close(outpipe[1]);
file = fdopen(outpipe[0], "r");
result[0] = '\0';
- while (fgets(buf, 1024, file)) {
- if (strncmp("File '", buf, 6) &&
- strncmp("Text is assu", buf, 12) &&
- strncmp("This signature applies to another message", buf, 41) &&
- buf[0] != '\n') {
- strcat(result, buf);
+ if (file) {
+ while (fgets(buf, 1024, file)) {
+ if (strncmp("File '", buf, 6) &&
+ strncmp("Text is assu", buf, 12) &&
+ strncmp("This signature applies to another message", buf, 41) &&
+ buf[0] != '\n') {
+ strcat(result, buf);
+ }
+ if (!strncmp("WARNING: Can't find the right public key", buf, 40))
+ res = RPMSIG_NOKEY;
+ else if (!strncmp("Signature by unknown keyid:", buf, 27))
+ res = RPMSIG_NOKEY;
+ else if (!strncmp("WARNING: The signing key is not trusted", buf, 39))
+ res = RPMSIG_NOTTRUSTED;
+ else if (!strncmp("Good signature", buf, 14))
+ res = RPMSIG_OK;
}
- if (!strncmp("WARNING: Can't find the right public key", buf, 40))
- res = RPMSIG_NOKEY;
- else if (!strncmp("Signature by unknown keyid:", buf, 27))
- res = RPMSIG_NOKEY;
- else if (!strncmp("WARNING: The signing key is not trusted", buf, 39))
- res = RPMSIG_NOTTRUSTED;
- else if (!strncmp("Good signature", buf, 14))
- res = RPMSIG_OK;
+ (void) fclose(file);
}
- (void) fclose(file);
(void) waitpid(pid, &status, 0);
- (void) unlink(sigfile);
+ if (sigfile) (void) unlink(sigfile);
if (!res && (!WIFEXITED(status) || WEXITSTATUS(status))) {
res = RPMSIG_BAD;
}
@@ -623,8 +638,10 @@ verifyGPGSignature(const char * datafile, const void * sig, int count,
tmppath = _free(tmppath);
}
sfd = Fopen(sigfile, "w.fdio");
- (void) Fwrite(sig, sizeof(char), count, sfd);
- (void) Fclose(sfd);
+ if (sfd != NULL && !Ferror(sfd)) {
+ (void) Fwrite(sig, sizeof(char), count, sfd);
+ (void) Fclose(sfd);
+ }
/* Now run GPG */
outpipe[0] = outpipe[1] = 0;
@@ -652,16 +669,18 @@ verifyGPGSignature(const char * datafile, const void * sig, int count,
(void) close(outpipe[1]);
file = fdopen(outpipe[0], "r");
result[0] = '\0';
- while (fgets(buf, 1024, file)) {
- strcat(result, buf);
- if (!xstrncasecmp("gpg: Can't check signature: Public key not found", buf, 48)) {
- res = RPMSIG_NOKEY;
+ if (file) {
+ while (fgets(buf, 1024, file)) {
+ strcat(result, buf);
+ if (!xstrncasecmp("gpg: Can't check signature: Public key not found", buf, 48)) {
+ res = RPMSIG_NOKEY;
+ }
}
+ (void) fclose(file);
}
- (void) fclose(file);
(void) waitpid(pid, &status, 0);
- (void) unlink(sigfile);
+ if (sigfile) (void) unlink(sigfile);
if (!res && (!WIFEXITED(status) || WEXITSTATUS(status))) {
res = RPMSIG_BAD;
}
@@ -757,7 +776,7 @@ static int checkPassPhrase(const char * passPhrase, const int sigTag)
return 0;
}
-char *rpmGetPassPhrase(const char * prompt, const int sigTag)
+char * rpmGetPassPhrase(const char * prompt, const int sigTag)
{
char *pass;
int aok;
diff --git a/lib/signature.h b/lib/signature.h
index 10fd504c0..59d613d47 100644
--- a/lib/signature.h
+++ b/lib/signature.h
@@ -40,7 +40,7 @@ extern "C" {
* Return new, empty (signature) header instance.
* @return signature header
*/
-Header rpmNewSignature(void);
+Header rpmNewSignature(void) /*@*/;
/** \ingroup signature
* Read (and verify header+archive size) signature header.
@@ -50,21 +50,24 @@ Header rpmNewSignature(void);
* @param sig_type type of signature header to read (from lead).
* @return rpmRC return code
*/
-rpmRC rpmReadSignature(FD_t fd, /*@out@*/ Header *header, sigType sig_type);
+rpmRC rpmReadSignature(FD_t fd, /*@out@*/ Header *header, sigType sig_type)
+ /*@modifies fd, *header @*/;
/** \ingroup signature
* Write signature header.
* @param fd file handle
- * @param header (signature) header
+ * @param h (signature) header
* @return 0 on success, 1 on error
*/
-int rpmWriteSignature(FD_t fd, Header header);
+int rpmWriteSignature(FD_t fd, Header h)
+ /*@modifies fd, h @*/;
/** \ingroup signature
* Generate a signature of data in file, insert in header.
*/
-int rpmAddSignature(Header h, const char *file,
- int_32 sigTag, const char *passPhrase);
+int rpmAddSignature(Header h, const char * file,
+ int_32 sigTag, /*@null@*/ const char * passPhrase)
+ /*@modifies h @*/;
/******************************************************************/
@@ -76,17 +79,21 @@ int rpmAddSignature(Header h, const char *file,
/** \ingroup signature
* Return type of signature in effect for building.
*/
-int rpmLookupSignatureType(int action);
+int rpmLookupSignatureType(int action)
+ /*@modifies internalState @*/;
/** \ingroup signature
* Read a pass phrase from the user.
*/
-char * rpmGetPassPhrase(const char *prompt, const int sigTag);
+/*@null@*/ char * rpmGetPassPhrase(const char *prompt, const int sigTag)
+ /*@modifies fileSystem @*/;
/** \ingroup signature
* Return path to pgp executable of given type, or NULL when not found.
*/
-/*@null@*/ const char * rpmDetectPGPVersion( /*@out@*/ pgpVersion *pgpVersion);
+/*@null@*/ const char * rpmDetectPGPVersion(
+ /*@null@*/ /*@out@*/ pgpVersion *pgpVersion)
+ /*@modifies *pgpVersion, fileSystem @*/;
#ifdef __cplusplus
}
diff --git a/lib/transaction.c b/lib/transaction.c
index 3312f22d5..6e633db31 100644
--- a/lib/transaction.c
+++ b/lib/transaction.c
@@ -291,7 +291,7 @@ static Header relocateFileList(const rpmTransactionSet ts, TFI_t fi,
Header origH, fileAction * actions)
{
HGE_t hge = fi->hge;
- HFD_t hfd = fi->hfd;
+ HFD_t hfd = (fi->hfd ? fi->hfd : headerFreeData);
static int _printed = 0;
rpmProblemSet probs = ts->probs;
int allowBadRelocate = (ts->ignoreSet & RPMPROB_FILTER_FORCERELOCATE);
@@ -335,7 +335,7 @@ static Header relocateFileList(const rpmTransactionSet ts, TFI_t fi,
* should be added, but, since relocateFileList() can be called more
* than once for the same header, don't bother if already present.
*/
- if (numRelocations == 0) {
+ if (rawRelocations == NULL || numRelocations == 0) {
if (numValid) {
if (!headerIsEntry(origH, RPMTAG_INSTPREFIXES))
(void) headerAddEntry(origH, RPMTAG_INSTPREFIXES,
@@ -358,8 +358,11 @@ static Header relocateFileList(const rpmTransactionSet ts, TFI_t fi,
for (i = 0; i < numRelocations; i++) {
char * t;
- /* FIXME: default relocations (oldPath == NULL) need to be handled
- in the UI, not rpmlib */
+ /*
+ * Default relocations (oldPath == NULL) are handled in the UI,
+ * not rpmlib.
+ */
+ if (rawRelocations[i].oldPath == NULL) continue; /* XXX can't happen */
/* FIXME: Trailing /'s will confuse us greatly. Internal ones will
too, but those are more trouble to fix up. :-( */
@@ -399,7 +402,9 @@ static Header relocateFileList(const rpmTransactionSet ts, TFI_t fi,
madeSwap = 0;
for (j = 1; j < numRelocations; j++) {
rpmRelocation tmpReloc;
- if (strcmp(relocations[j - 1].oldPath, relocations[j].oldPath) <= 0)
+ if (relocations[j - 1].oldPath == NULL || /* XXX can't happen */
+ relocations[j ].oldPath == NULL || /* XXX can't happen */
+ strcmp(relocations[j - 1].oldPath, relocations[j].oldPath) <= 0)
continue;
tmpReloc = relocations[j - 1];
relocations[j - 1] = relocations[j];
@@ -413,6 +418,7 @@ static Header relocateFileList(const rpmTransactionSet ts, TFI_t fi,
_printed = 1;
rpmMessage(RPMMESS_DEBUG, _("========== relocations\n"));
for (i = 0; i < numRelocations; i++) {
+ if (relocations[i].oldPath == NULL) continue; /* XXX can't happen */
if (relocations[i].newPath == NULL)
rpmMessage(RPMMESS_DEBUG, _("%5d exclude %s\n"),
i, relocations[i].oldPath);
@@ -431,7 +437,8 @@ static Header relocateFileList(const rpmTransactionSet ts, TFI_t fi,
numActual = 0;
for (i = 0; i < numValid; i++) {
for (j = 0; j < numRelocations; j++) {
- if (strcmp(validRelocations[i], relocations[j].oldPath))
+ if (relocations[j].oldPath == NULL || /* XXX can't happen */
+ strcmp(validRelocations[i], relocations[j].oldPath))
continue;
/* On install, a relocate to NULL means skip the path. */
if (relocations[j].newPath) {
@@ -509,6 +516,7 @@ static Header relocateFileList(const rpmTransactionSet ts, TFI_t fi,
* relocation list be a good idea?
*/
for (j = numRelocations - 1; j >= 0; j--) {
+ if (relocations[j].oldPath == NULL) continue; /* XXX can't happen */
len = strcmp(relocations[j].oldPath, "/")
? strlen(relocations[j].oldPath)
: 0;
@@ -569,9 +577,11 @@ static Header relocateFileList(const rpmTransactionSet ts, TFI_t fi,
fnlen = te - fn;
} else
te = fn + strlen(fn);
+ /*@-nullpass -nullderef@*/ /* LCL: te != NULL here. */
if (strcmp(baseNames[i], te)) /* basename changed too? */
baseNames[i] = alloca_strdup(te);
*te = '\0'; /* terminate new directory name */
+ /*@=nullpass =nullderef@*/
}
/* Does this directory already exist in the directory list? */
@@ -612,6 +622,7 @@ static Header relocateFileList(const rpmTransactionSet ts, TFI_t fi,
for (i = dirCount - 1; i >= 0; i--) {
for (j = numRelocations - 1; j >= 0; j--) {
+ if (relocations[j].oldPath == NULL) continue; /* XXX can't happen */
len = strcmp(relocations[j].oldPath, "/")
? strlen(relocations[j].oldPath)
: 0;
@@ -704,9 +715,11 @@ static int psTrim(rpmProblemSet filter, rpmProblemSet target)
continue;
}
while ((t - target->probs) < target->numProblems) {
+ /*@-nullpass@*/ /* LCL: looks good to me */
if (f->h == t->h && f->type == t->type && t->key == f->key &&
XSTRCMP(f->str1, t->str1))
break;
+ /*@=nullpass@*/
t++;
gotProblems = 1;
}
@@ -851,14 +864,14 @@ static int filecmp(short mode1, const char * md51, const char * link1,
return 0;
}
-static int handleInstInstalledFiles(TFI_t fi, rpmdb db,
+static int handleInstInstalledFiles(TFI_t fi, /*@null@*/ rpmdb db,
struct sharedFileInfo * shared,
int sharedCount, int reportConflicts,
rpmProblemSet probs,
rpmtransFlags transFlags)
{
HGE_t hge = fi->hge;
- HFD_t hfd = fi->hfd;
+ HFD_t hfd = (fi->hfd ? fi->hfd : headerFreeData);
int oltype, omtype;
Header h;
int i;
@@ -945,7 +958,7 @@ static int handleInstInstalledFiles(TFI_t fi, rpmdb db,
return 0;
}
-static int handleRmvdInstalledFiles(TFI_t fi, rpmdb db,
+static int handleRmvdInstalledFiles(TFI_t fi, /*@null@*/ rpmdb db,
struct sharedFileInfo * shared,
int sharedCount)
{
@@ -1065,8 +1078,10 @@ static void handleOverlappedFiles(TFI_t fi, hashTable ht,
break;
/* Otherwise, compare fingerprints by value. */
+ /*@-nullpass@*/ /* LCL: looks good to me */
if (FP_EQUAL(fi->fps[i], recs[otherPkgNum]->fps[otherFileNum]))
- break;
+ break;
+ /*@=nullpass@*/
}
/* XXX is this test still necessary? */
@@ -1356,7 +1371,9 @@ static void skipFiles(const rpmTransactionSet ts, TFI_t fi)
}
if (netsharedPaths) freeSplitString(netsharedPaths);
+#ifdef DYING /* XXX freeFi will deal with this later. */
fi->flangs = _free(fi->flangs);
+#endif
if (languages) freeSplitString((char **)languages);
}
@@ -1559,6 +1576,7 @@ int rpmRunTransactions( rpmTransactionSet ts,
* - count files.
*/
/* The ordering doesn't matter here */
+ if (ts->addedPackages.list != NULL)
for (alp = ts->addedPackages.list;
(alp - ts->addedPackages.list) < ts->addedPackages.size;
alp++)
@@ -1879,7 +1897,9 @@ int rpmRunTransactions( rpmTransactionSet ts,
ts->flList = freeFl(ts, ts->flList);
ts->flEntries = 0;
+ /*@-nullstate@*/
return ts->orderCount;
+ /*@=nullstate@*/
}
/* ===============================================
@@ -1995,8 +2015,10 @@ assert(alp == fi->ap);
ts->flList = freeFl(ts, ts->flList);
ts->flEntries = 0;
+ /*@-nullstate@*/
if (ourrc)
return -1;
else
return 0;
+ /*@=nullstate@*/
}
diff --git a/lib/verify.c b/lib/verify.c
index 2dd413772..f302e5bf5 100644
--- a/lib/verify.c
+++ b/lib/verify.c
@@ -36,7 +36,7 @@ static void verifyArgCallback(/*@unused@*/poptContext con,
const struct poptOption * opt, /*@unused@*/const char * arg,
/*@unused@*/ const void * data)
{
- QVA_t *qva = &rpmQVArgs;
+ QVA_t qva = &rpmQVArgs;
switch (opt->val) {
case POPT_NODEPS: qva->qva_flags |= VERIFY_DEPS; break;
case POPT_NOFILES: qva->qva_flags |= VERIFY_FILES; break;
@@ -300,7 +300,7 @@ int rpmVerifyFile(const char * prefix, Header h, int filenum,
* @param scriptFd file handle to use for stderr (or NULL)
* @return 0 on success
*/
-int rpmVerifyScript(const char * rootDir, Header h, FD_t scriptFd)
+int rpmVerifyScript(const char * rootDir, Header h, /*@null@*/ FD_t scriptFd)
{
rpmdb rpmdb = NULL;
rpmTransactionSet ts = rpmtransCreateSet(rpmdb, rootDir);
@@ -326,7 +326,7 @@ int rpmVerifyScript(const char * rootDir, Header h, FD_t scriptFd)
}
/* ======================================================================== */
-static int verifyHeader(QVA_t *qva, Header h)
+static int verifyHeader(QVA_t qva, Header h)
{
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
char buf[BUFSIZ];
@@ -467,7 +467,7 @@ static int verifyDependencies(rpmdb rpmdb, Header h)
return rc;
}
-int showVerifyPackage(QVA_t *qva, rpmdb rpmdb, Header h)
+int showVerifyPackage(QVA_t qva, rpmdb rpmdb, Header h)
{
FD_t fdo;
int ec = 0;
@@ -483,11 +483,12 @@ int showVerifyPackage(QVA_t *qva, rpmdb rpmdb, Header h)
if ((qva->qva_flags & VERIFY_SCRIPT) &&
(rc = rpmVerifyScript(qva->qva_prefix, h, fdo)) != 0)
ec = rc;
- (void) Fclose(fdo);
+ if (fdo)
+ rc = Fclose(fdo);
return ec;
}
-int rpmVerify(QVA_t *qva, rpmQVSources source, const char *arg)
+int rpmVerify(QVA_t qva, rpmQVSources source, const char *arg)
{
rpmdb rpmdb = NULL;
int rc;