[pacman-dev] [PATCH] Fix error handling in _alpm_resolvedeps
From 816e0ec31278ff9e94b0d8dcdea24dadb5e4fa1b Mon Sep 17 00:00:00 2001 From: Nagy Gabor <ngaba@bibl.u-szeged.hu> Date: Fri, 6 Mar 2009 17:02:19 +0100 Subject: [PATCH] Fix error handling in _alpm_resolvedeps
Now resolvedeps is just a helper function for sync_prepare, so we set pm_errno in sync_prepare. We free *data list, when user decided to remove unresolvable targets. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> --- lib/libalpm/deps.c | 1 - lib/libalpm/sync.c | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c index 36f4d35..7a46692 100644 --- a/lib/libalpm/deps.c +++ b/lib/libalpm/deps.c @@ -635,7 +635,6 @@ int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *pkg, /* find a satisfier package in the given repositories */ pmpkg_t *spkg = _alpm_resolvedep(missdep, dbs_sync, *packages, 0); if(!spkg) { - pm_errno = PM_ERR_UNSATISFIED_DEPS; char *missdepstring = alpm_dep_compute_string(missdep); _alpm_log(PM_LOG_WARNING, _("cannot resolve \"%s\", a dependency of \"%s\"\n"), missdepstring, tpkg->name); diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 84a18e2..14cf42e 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -456,9 +456,14 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync dependency-reordered list below */ alpm_list_free(unresolvable); unresolvable = NULL; + if(data) { + alpm_list_free_inner(*data, (alpm_list_fn_free)_alpm_depmiss_free); + alpm_list_free(*data); + *data = NULL; + } } else { - /* pm_errno is set by resolvedeps */ + pm_errno = PM_ERR_UNSATISFIED_DEPS; ret = -1; goto cleanup; } -- 1.6.0.3
From 9cfe60f495dfabe29d92e426f9c823fedd315ca6 Mon Sep 17 00:00:00 2001 From: Nagy Gabor <ngaba@bibl.u-szeged.hu> Date: Sat, 7 Mar 2009 16:25:29 +0100 Subject: [PATCH] Free *data list when user removes unresolvable packages
Resolvedeps reports error when it cannot resolve some dependencies, puts them into the *data list, and set pm_errno. If user removes the unresolvable packages from the target list, we have no error anymore, so from now on we free *data list (we eliminate a memleak) and unset pm_errno. (Additionally I removed two needless lines from the code, unresolvable list is always freed in cleanup.) Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> --- lib/libalpm/sync.c | 16 +++++++++------- 1 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 84a18e2..f100fb6 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -450,14 +450,16 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync NULL, NULL, &remove_unresolvable); if (remove_unresolvable) { /* User wants to remove the unresolvable packages from the - transaction, so simply drop the unresolvable list. The - packages will be removed from the actual transaction when - the transaction packages are replaced with a + transaction. The packages will be removed from the actual + transaction when the transaction packages are replaced with a dependency-reordered list below */ - alpm_list_free(unresolvable); - unresolvable = NULL; - } - else { + pm_errno = 0; /* pm_errno was set by resolvedeps */ + if(data) { + alpm_list_free_inner(*data, (alpm_list_fn_free)_alpm_depmiss_free); + alpm_list_free(*data); + *data = NULL; + } + } else { /* pm_errno is set by resolvedeps */ ret = -1; goto cleanup; -- 1.6.0.3
participants (1)
-
Nagy Gabor