[pacman-dev] [PATCH 1/4] sync.c: remove duplicated code for integrity check failures
Rémy Oudompheng
remyoudompheng at gmail.com
Thu Apr 21 02:36:47 EDT 2011
Signed-off-by: Rémy Oudompheng <remy at archlinux.org>
---
This is a cleanup patch is preparation for some code moving.
lib/libalpm/sync.c | 21 +++++++++------------
1 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index cb73c7e..b6c64af 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -844,10 +844,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
/* check md5sum first */
if(test_md5sum(trans, filepath, md5sum) != 0) {
- errors++;
- *data = alpm_list_add(*data, strdup(filename));
- FREE(filepath);
- continue;
+ goto integrity_check_fail;
}
/* check PGP signature next */
pmdb_t *sdb = alpm_pkg_get_db(spkg);
@@ -865,10 +862,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
int ret = _alpm_gpgme_checksig(filepath, pgpsig);
if((check_sig == PM_PGP_VERIFY_ALWAYS && ret != 0) ||
(check_sig == PM_PGP_VERIFY_OPTIONAL && ret == 1)) {
- errors++;
- *data = alpm_list_add(*data, strdup(filename));
- FREE(filepath);
- continue;
+ goto integrity_check_fail;
}
}
/* load the package file and replace pkgcache entry with it in the target list */
@@ -877,15 +871,18 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
pmpkg_t *pkgfile;
if(alpm_pkg_load(filepath, 1, &pkgfile) != 0) {
_alpm_pkg_free(pkgfile);
- errors++;
- *data = alpm_list_add(*data, strdup(filename));
- FREE(filepath);
- continue;
+ goto integrity_check_fail;
}
FREE(filepath);
pkgfile->reason = spkg->reason; /* copy over install reason */
i->data = pkgfile;
_alpm_pkg_free_trans(spkg); /* spkg has been removed from the target list */
+ continue;
+
+integrity_check_fail:
+ errors++;
+ *data = alpm_list_add(*data, strdup(filename));
+ FREE(filepath);
}
PROGRESS(trans, PM_TRANS_PROGRESS_INTEGRITY_START, "", 100,
--
1.7.4.4
More information about the pacman-dev
mailing list