Check local database status flag in db_write sanity check block

Do all the checks at once; this also avoids the 'return' call after we
have allocated memory for "pkgpath" as well as tweaked the umask.

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2011-08-28 19:46:09 -05:00
parent 455ca55f4e
commit a12a4ea396

View file

@ -750,7 +750,7 @@ int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq
int retval = 0; int retval = 0;
char *pkgpath = NULL; char *pkgpath = NULL;
if(db == NULL || info == NULL) { if(db == NULL || info == NULL || !(db->status & DB_STATUS_LOCAL)) {
return -1; return -1;
} }
@ -759,10 +759,6 @@ int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq
/* make sure we have a sane umask */ /* make sure we have a sane umask */
oldmask = umask(0022); oldmask = umask(0022);
if(strcmp(db->treename, "local") != 0) {
return -1;
}
/* DESC */ /* DESC */
if(inforeq & INFRQ_DESC) { if(inforeq & INFRQ_DESC) {
_alpm_log(db->handle, ALPM_LOG_DEBUG, "writing %s-%s DESC information back to db\n", _alpm_log(db->handle, ALPM_LOG_DEBUG, "writing %s-%s DESC information back to db\n",