From e3761e244dce3c98157f5d30bbeb4189570e04f4 Mon Sep 17 00:00:00 2001 From: ewt Date: Mon, 19 Feb 1996 04:52:09 +0000 Subject: [PATCH] changed sense of a bunch of the functions to fit the rest of rpm CVS patchset: 319 CVS date: 1996/02/19 04:52:09 --- lib/rpmdb.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/rpmdb.c b/lib/rpmdb.c index 11d8b67..6eac664 100644 --- a/lib/rpmdb.c +++ b/lib/rpmdb.c @@ -27,14 +27,14 @@ int rpmdbOpen (char * prefix, rpmdb *rpmdbp, int mode, int perms) { filename = alloca(strlen(prefix) + 40); if (mode & O_WRONLY) - return 0; + return 1; strcpy(filename, prefix); strcat(filename, "/var/lib/rpm/packages.rpm"); db.pkgs = faOpen(filename, mode, 0644); if (!db.pkgs) { error(RPMERR_DBOPEN, "failed to open %s\n", filename); - return 0; + return 1; } strcpy(filename, prefix); @@ -42,7 +42,7 @@ int rpmdbOpen (char * prefix, rpmdb *rpmdbp, int mode, int perms) { db.nameIndex = openDBIndex(filename, mode, 0644); if (!db.nameIndex) { faClose(db.pkgs); - return 0; + return 1; } strcpy(filename, prefix); @@ -51,7 +51,7 @@ int rpmdbOpen (char * prefix, rpmdb *rpmdbp, int mode, int perms) { if (!db.fileIndex) { faClose(db.pkgs); closeDBIndex(db.nameIndex); - return 0; + return 1; } strcpy(filename, prefix); @@ -60,13 +60,13 @@ int rpmdbOpen (char * prefix, rpmdb *rpmdbp, int mode, int perms) { if (!db.groupIndex) { faClose(db.pkgs); closeDBIndex(db.nameIndex); - return 0; + return 1; } *rpmdbp = malloc(sizeof(struct rpmdb)); **rpmdbp = db; - return 1; + return 0; } int rpmdbCreate (rpmdb db, int mode, int perms); @@ -177,9 +177,7 @@ int rpmdbRemove(rpmdb db, unsigned int offset, int tolerant) { message(MESS_DEBUG, "package has no files\n"); } - if (!faFree(db->pkgs, offset)) { - printf("faFree failed!\n"); - } + faFree(db->pkgs, offset); return 0; } @@ -223,6 +221,10 @@ int rpmdbAdd(rpmdb db, Header dbentry) { } dboffset = faAlloc(db->pkgs, sizeofHeader(dbentry)); + if (!dboffset) { + error(RPMERR_DBCORRUPT, "cannot allocate space for database"); + return 1; + } lseek(db->pkgs->fd, dboffset, SEEK_SET); writeHeader(db->pkgs->fd, dbentry); -- 2.7.4