summaryrefslogtreecommitdiff
path: root/lib/libalpm/sync.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2007-05-14 03:16:55 -0400
committerDan McGee <dan@archlinux.org>2007-05-14 03:16:55 -0400
commit2bcecbd62cb2bda681a3aba46bb0bbf690ba7219 (patch)
treecc7f9d60e04c65453527354bbd18312a9c323ed4 /lib/libalpm/sync.c
parent5c930c318e7b80af3a322ddc7ddf9fe100e9c16b (diff)
downloadpacman-2bcecbd62cb2bda681a3aba46bb0bbf690ba7219.tar.xz
Remove unnecessary casts on malloc and elsewhere
We had many unnecessary casts, most of them dealing with malloc and other memory allocations. The variable type should take care of it; no need to do it explicitly. In addition, I caught a const error while removing the casts. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/sync.c')
-rw-r--r--lib/libalpm/sync.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index ef8af5c6..87f8c720 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -60,7 +60,7 @@ pmsyncpkg_t *_alpm_sync_new(int type, pmpkg_t *spkg, void *data)
ALPM_LOG_FUNC;
- if((sync = (pmsyncpkg_t *)malloc(sizeof(pmsyncpkg_t))) == NULL) {
+ if((sync = malloc(sizeof(pmsyncpkg_t))) == NULL) {
_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmsyncpkg_t));
return(NULL);
}
@@ -615,7 +615,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
_alpm_log(PM_LOG_ERROR, _("unresolvable package conflicts detected"));
errorout = 1;
if(data) {
- if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) {
+ if((miss = malloc(sizeof(pmdepmissing_t))) == NULL) {
_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmdepmissing_t));
FREELIST(*data);
pm_errno = PM_ERR_MEMORY;
@@ -631,7 +631,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
_alpm_log(PM_LOG_ERROR, _("unresolvable package conflicts detected"));
errorout = 1;
if(data) {
- if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) {
+ if((miss = malloc(sizeof(pmdepmissing_t))) == NULL) {
_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmdepmissing_t));
FREELIST(*data);
pm_errno = PM_ERR_MEMORY;
@@ -729,7 +729,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
errorout = 1;
}
if(data) {
- if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) {
+ if((miss = malloc(sizeof(pmdepmissing_t))) == NULL) {
_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmdepmissing_t));
FREELIST(*data);
pm_errno = PM_ERR_MEMORY;
@@ -863,7 +863,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
if((md5sum1 == NULL) && (sha1sum1 == NULL)) {
/* TODO wtf is this? malloc'd strings for error messages? */
- if((ptr = (char *)malloc(512)) == NULL) {
+ if((ptr = calloc(512, sizeof(char))) == NULL) {
RET_ERR(PM_ERR_MEMORY, -1);
}
snprintf(ptr, 512, _("can't get md5 or sha1 checksum for package %s\n"), pkgname);
@@ -875,7 +875,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
md5sum2 = _alpm_MDFile(str);
sha1sum2 = _alpm_SHAFile(str);
if(md5sum2 == NULL && sha1sum2 == NULL) {
- if((ptr = (char *)malloc(512)) == NULL) {
+ if((ptr = calloc(512, sizeof(char))) == NULL) {
RET_ERR(PM_ERR_MEMORY, -1);
}
snprintf(ptr, 512, _("can't get md5 or sha1 checksum for package %s\n"), pkgname);
@@ -885,7 +885,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
}
if((strcmp(md5sum1, md5sum2) != 0) && (strcmp(sha1sum1, sha1sum2) != 0)) {
int doremove=0;
- if((ptr = (char *)malloc(512)) == NULL) {
+ if((ptr = calloc(512, sizeof(char))) == NULL) {
RET_ERR(PM_ERR_MEMORY, -1);
}
if(trans->flags & PM_TRANS_FLAG_ALLDEPS) {