- more sanity checks

- alpm_pkg_free can now return an error code
This commit is contained in:
Aurelien Foret 2005-10-10 15:03:35 +00:00
parent 5d61a44759
commit 6b7b9787d5
3 changed files with 12 additions and 9 deletions

View file

@ -394,8 +394,7 @@ void *alpm_pkg_getinfo(pmpkg_t *pkg, unsigned char parm)
} }
break; break;
/* Depends entry */ /* Depends entry */
/* ORE /* not needed: the cache is loaded with DEPENDS by default
not needed: the cache is loaded with DEPENDS by default
case PM_PKG_DEPENDS: case PM_PKG_DEPENDS:
case PM_PKG_REQUIREDBY: case PM_PKG_REQUIREDBY:
case PM_PKG_CONFLICTS: case PM_PKG_CONFLICTS:
@ -473,9 +472,14 @@ int alpm_pkg_load(char *filename, pmpkg_t **pkg)
return(0); return(0);
} }
void alpm_pkg_free(pmpkg_t *pkg) int alpm_pkg_free(pmpkg_t *pkg)
{ {
ASSERT(pkg != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
ASSERT(pkg->origin != PKG_FROM_CACHE, RET_ERR(PM_ERR_XXX, -1));
pkg_free(pkg); pkg_free(pkg);
return(0);
} }
int alpm_pkg_vercmp(const char *ver1, const char *ver2) int alpm_pkg_vercmp(const char *ver1, const char *ver2)
@ -542,6 +546,7 @@ void *alpm_trans_getinfo(unsigned char parm)
/* Sanity checks */ /* Sanity checks */
ASSERT(handle != NULL, return(NULL)); ASSERT(handle != NULL, return(NULL));
ASSERT(handle->trans != NULL, return(NULL));
trans = handle->trans; trans = handle->trans;

View file

@ -156,7 +156,7 @@ enum {
void *alpm_pkg_getinfo(PM_PKG *pkg, unsigned char parm); void *alpm_pkg_getinfo(PM_PKG *pkg, unsigned char parm);
int alpm_pkg_load(char *filename, PM_PKG **pkg); int alpm_pkg_load(char *filename, PM_PKG **pkg);
void alpm_pkg_free(PM_PKG *pkg); int alpm_pkg_free(PM_PKG *pkg);
int alpm_pkg_vercmp(const char *ver1, const char *ver2); int alpm_pkg_vercmp(const char *ver1, const char *ver2);
/* /*

View file

@ -81,9 +81,7 @@ void trans_free(pmtrans_t *trans)
int trans_init(pmtrans_t *trans, unsigned char type, unsigned char flags, alpm_trans_cb_event event, alpm_trans_cb_conv conv) int trans_init(pmtrans_t *trans, unsigned char type, unsigned char flags, alpm_trans_cb_event event, alpm_trans_cb_conv conv)
{ {
/* Sanity checks */ /* Sanity checks */
if(trans == NULL) { ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
RET_ERR(PM_ERR_TRANS_NULL, -1);
}
/* ORE /* ORE
perform sanity checks on type and flags: perform sanity checks on type and flags:
@ -148,7 +146,7 @@ int trans_prepare(pmtrans_t *trans, PMList **data)
*data = NULL; *data = NULL;
/* Sanity checks */ /* Sanity checks */
ASSERT(trans != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
/* If there's nothing to do, return without complaining */ /* If there's nothing to do, return without complaining */
if(trans->packages == NULL) { if(trans->packages == NULL) {
@ -185,7 +183,7 @@ int trans_prepare(pmtrans_t *trans, PMList **data)
int trans_commit(pmtrans_t *trans) int trans_commit(pmtrans_t *trans)
{ {
/* Sanity checks */ /* Sanity checks */
ASSERT(trans != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
/* If there's nothing to do, return without complaining */ /* If there's nothing to do, return without complaining */
if(trans->packages == NULL) { if(trans->packages == NULL) {