From 1b78a6974da7731060a1e87f837c449e07f08941 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Fri, 9 Apr 2010 16:36:17 +0300 Subject: [PATCH] Clean up dbiOpen() a bit - eliminate now redundant rc-condition, move local variables to the scope their used in --- lib/backend/db3.c | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/lib/backend/db3.c b/lib/backend/db3.c index 46eb39e..651b086 100644 --- a/lib/backend/db3.c +++ b/lib/backend/db3.c @@ -450,11 +450,9 @@ int dbiOpen(rpmdb rpmdb, rpmTag rpmtag, dbiIndex * dbip) const char *dbhome = rpmdbHome(rpmdb); dbiIndex dbi = NULL; int rc = 0; - int xx; DB * db = NULL; uint32_t oflags; - int _printit; if (dbip) *dbip = NULL; @@ -508,29 +506,27 @@ int dbiOpen(rpmdb rpmdb, rpmTag rpmtag, dbiIndex * dbip) rc = db_init(dbi, dbhome); - { char *dbiflags = prDbiOpenFlags(oflags, 0); - rpmlog(RPMLOG_DEBUG, "opening db index %s/%s %s mode=0x%x\n", - dbhome, dbi->dbi_file, dbiflags, rpmdb->db_mode); - free(dbiflags); - } if (rc == 0) { - static int _lockdbfd = 0; rc = db_create(&db, rpmdb->db_dbenv, 0); rc = cvtdberr(dbi, "db_create", rc, _debug); if (rc == 0 && db != NULL) { - - if (rc == 0) { - rc = (db->open)(db, NULL, dbi->dbi_file, NULL, - dbi->dbi_dbtype, oflags, rpmdb->db_perms); - - if (rc == 0 && dbi->dbi_dbtype == DB_UNKNOWN) { - DBTYPE dbi_dbtype = DB_UNKNOWN; - xx = db->get_type(db, &dbi_dbtype); - if (xx == 0) - dbi->dbi_dbtype = dbi_dbtype; - } + static int _lockdbfd = 0; + int _printit, xx; + char *dbfs = prDbiOpenFlags(oflags, 0); + rpmlog(RPMLOG_DEBUG, "opening db index %s/%s %s mode=0x%x\n", + dbhome, dbi->dbi_file, dbfs, rpmdb->db_mode); + free(dbfs); + + rc = (db->open)(db, NULL, dbi->dbi_file, NULL, + dbi->dbi_dbtype, oflags, rpmdb->db_perms); + + if (rc == 0 && dbi->dbi_dbtype == DB_UNKNOWN) { + DBTYPE dbi_dbtype = DB_UNKNOWN; + xx = db->get_type(db, &dbi_dbtype); + if (xx == 0) + dbi->dbi_dbtype = dbi_dbtype; } /* XXX return rc == errno without printing */ -- 2.7.4