Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm
diff options
context:
space:
mode:
authorAurelien Foret <aurelien@archlinux.org>2006-01-07 18:25:28 +0000
committerAurelien Foret <aurelien@archlinux.org>2006-01-07 18:25:28 +0000
commite405204915600340180cef61471471929fb0c275 (patch)
tree1f9aa6460524b97772b95c8b50db358eaa665f27 /lib/libalpm
parentfce68beaafade3453b89ade29d95e99ac172de01 (diff)
removed a restriction: the data parameter of XXX_prepare functions can be NULL
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/add.c37
-rw-r--r--lib/libalpm/alpm.c1
-rw-r--r--lib/libalpm/remove.c5
-rw-r--r--lib/libalpm/sync.c51
4 files changed, 55 insertions, 39 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index 8f3d03ce..d683877d 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -196,9 +196,10 @@ int add_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data)
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
- ASSERT(data != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
- *data = NULL;
+ if(data) {
+ *data = NULL;
+ }
/* Check dependencies
*/
@@ -220,13 +221,15 @@ int add_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data)
if(!errorout) {
errorout = 1;
}
- if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) {
- FREELIST(lp);
- FREELIST(*data);
- RET_ERR(PM_ERR_MEMORY, -1);
+ if(data) {
+ if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) {
+ FREELIST(lp);
+ FREELIST(*data);
+ RET_ERR(PM_ERR_MEMORY, -1);
+ }
+ *miss = *(pmdepmissing_t*)i->data;
+ *data = pm_list_add(*data, miss);
}
- *miss = *(pmdepmissing_t*)i->data;
- *data = pm_list_add(*data, miss);
}
}
if(errorout) {
@@ -242,13 +245,15 @@ int add_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data)
if(!errorout) {
errorout = 1;
}
- if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) {
- FREELIST(lp);
- FREELIST(*data);
- RET_ERR(PM_ERR_MEMORY, -1);
+ if(data) {
+ if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) {
+ FREELIST(lp);
+ FREELIST(*data);
+ RET_ERR(PM_ERR_MEMORY, -1);
+ }
+ *miss = *(pmdepmissing_t*)i->data;
+ *data = pm_list_add(*data, miss);
}
- *miss = *(pmdepmissing_t*)i->data;
- *data = pm_list_add(*data, miss);
}
}
FREELIST(lp);
@@ -277,7 +282,9 @@ int add_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data)
_alpm_log(PM_LOG_FLOW1, "looking for file conflicts");
lp = db_find_conflicts(db, trans->packages, handle->root, &skiplist);
if(lp != NULL) {
- *data = lp;
+ if(data) {
+ *data = lp;
+ }
FREELIST(skiplist);
RET_ERR(PM_ERR_FILE_CONFLICTS, -1);
}
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c
index 7dca7ffd..819807c6 100644
--- a/lib/libalpm/alpm.c
+++ b/lib/libalpm/alpm.c
@@ -611,7 +611,6 @@ int alpm_trans_prepare(PMList **data)
/* Sanity checks */
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
- ASSERT(data != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
trans = handle->trans;
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index f6b85b8c..5b7fd418 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -78,7 +78,6 @@ int remove_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data)
ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
- ASSERT(data != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
if(!(trans->flags & (PM_TRANS_FLAG_NODEPS)) && (trans->type != PM_TRANS_TYPE_UPGRADE)) {
EVENT(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL);
@@ -100,7 +99,9 @@ int remove_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data)
lp = checkdeps(db, trans->type, trans->packages);
}
} else {
- *data = lp;
+ if(data) {
+ *data = lp;
+ }
RET_ERR(PM_ERR_UNSATISFIED_DEPS, -1);
}
}
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 7cbcf8a0..fc962a36 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -346,9 +346,10 @@ int sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PMList **
ASSERT(db_local != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
- ASSERT(data != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
- *data = NULL;
+ if(data) {
+ *data = NULL;
+ }
if(!(trans->flags & PM_TRANS_FLAG_NODEPS)) {
for(i = trans->packages; i; i = i->next) {
@@ -395,13 +396,15 @@ int sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PMList **
if(!errorout) {
errorout = 1;
}
- if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) {
- FREELIST(*data);
- pm_errno = PM_ERR_MEMORY;
- goto error;
+ if(data) {
+ if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) {
+ FREELIST(*data);
+ pm_errno = PM_ERR_MEMORY;
+ goto error;
+ }
+ *miss = *(pmdepmissing_t *)i->data;
+ *data = pm_list_add(*data, miss);
}
- *miss = *(pmdepmissing_t *)i->data;
- *data = pm_list_add(*data, miss);
}
}
if(errorout) {
@@ -527,25 +530,29 @@ int sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PMList **
/* abort */
_alpm_log(PM_LOG_ERROR, "package conflicts detected");
errorout = 1;
- if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) {
- FREELIST(*data);
- pm_errno = PM_ERR_MEMORY;
- goto error;
+ if(data) {
+ if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) {
+ FREELIST(*data);
+ pm_errno = PM_ERR_MEMORY;
+ goto error;
+ }
+ *miss = *(pmdepmissing_t *)i->data;
+ *data = pm_list_add(*data, miss);
}
- *miss = *(pmdepmissing_t *)i->data;
- *data = pm_list_add(*data, miss);
}
}
} else {
_alpm_log(PM_LOG_ERROR, "%s conflicts with %s", miss->target, miss->depend.name);
errorout = 1;
- if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) {
- FREELIST(*data);
- pm_errno = PM_ERR_MEMORY;
- goto error;
+ if(data) {
+ if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) {
+ FREELIST(*data);
+ pm_errno = PM_ERR_MEMORY;
+ goto error;
+ }
+ *miss = *(pmdepmissing_t *)i->data;
+ *data = pm_list_add(*data, miss);
}
- *miss = *(pmdepmissing_t *)i->data;
- *data = pm_list_add(*data, miss);
}
}
}
@@ -588,7 +595,9 @@ int sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PMList **
_alpm_log(PM_LOG_DEBUG, "checking dependencies of packages designated for removal");
deps = checkdeps(db_local, PM_TRANS_TYPE_REMOVE, list);
if(deps) {
- *data = deps;
+ if(data) {
+ *data = deps;
+ }
pm_errno = PM_ERR_UNSATISFIED_DEPS;
goto error;
}