summaryrefslogtreecommitdiffstats
path: root/lib
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
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')
-rw-r--r--lib/libalpm/alpm_list.c2
-rw-r--r--lib/libalpm/deps.c8
-rw-r--r--lib/libalpm/handle.c2
-rw-r--r--lib/libalpm/package.c4
-rw-r--r--lib/libalpm/server.c2
-rw-r--r--lib/libalpm/sync.c14
-rw-r--r--lib/libalpm/trans.c6
-rw-r--r--lib/libalpm/util.c2
8 files changed, 20 insertions, 20 deletions
diff --git a/lib/libalpm/alpm_list.c b/lib/libalpm/alpm_list.c
index 4977f1ac..037f57ba 100644
--- a/lib/libalpm/alpm_list.c
+++ b/lib/libalpm/alpm_list.c
@@ -50,7 +50,7 @@ alpm_list_t *alpm_list_new()
{
alpm_list_t *list = NULL;
- list = (alpm_list_t *)malloc(sizeof(alpm_list_t));
+ list = malloc(sizeof(alpm_list_t));
if(list) {
list->data = NULL;
list->prev = NULL;
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index 51b3207f..b6f8cc80 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -54,7 +54,7 @@ pmdepmissing_t *_alpm_depmiss_new(const char *target, pmdeptype_t type,
ALPM_LOG_FUNC;
- miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t));
+ miss = malloc(sizeof(pmdepmissing_t));
if(miss == NULL) {
_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmdepmissing_t));
RET_ERR(PM_ERR_MEMORY, NULL);
@@ -431,7 +431,7 @@ pmdepend_t SYMEXPORT *alpm_splitdep(const char *depstring)
return(NULL);
}
- depend = (pmdepend_t *)malloc(sizeof(pmdepend_t));
+ depend = malloc(sizeof(pmdepend_t));
if(depend == NULL) {
_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmdepend_t));
return(NULL);
@@ -628,7 +628,7 @@ int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg,
_alpm_log(PM_LOG_ERROR, _("cannot resolve dependencies for \"%s\" (\"%s\" is not in the package set)"),
miss->target, miss->depend.name);
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;
@@ -668,7 +668,7 @@ int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg,
} else {
_alpm_log(PM_LOG_ERROR, _("cannot resolve dependencies for \"%s\""), miss->target);
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;
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index cbbdeff5..47abcb32 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -45,7 +45,7 @@ pmhandle_t *_alpm_handle_new()
{
pmhandle_t *handle;
- handle = (pmhandle_t *)malloc(sizeof(pmhandle_t));
+ handle = malloc(sizeof(pmhandle_t));
if(handle == NULL) {
_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmhandle_t));
RET_ERR(PM_ERR_MEMORY, NULL);
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index d0aba7ba..e8dd5d60 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -230,7 +230,7 @@ static int parse_descfile(const char *descfile, pmpkg_t *info)
/*
char *lang_tmp;
info->desc_localized = alpm_list_add(info->desc_localized, strdup(ptr));
- if((lang_tmp = (char *)malloc(strlen(setlocale(LC_ALL, "")))) == NULL) {
+ if((lang_tmp = malloc(strlen(setlocale(LC_ALL, "")))) == NULL) {
RET_ERR(PM_ERR_MEMORY, -1);
}
strncpy(lang_tmp, setlocale(LC_ALL, ""), strlen(setlocale(LC_ALL, "")));
@@ -373,7 +373,7 @@ pmpkg_t *_alpm_pkg_load(const char *pkgfile)
char *str;
int fd;
- if((str = (char *)malloc(PATH_MAX)) == NULL) {
+ if((str = malloc(PATH_MAX)) == NULL) {
RET_ERR(PM_ERR_MEMORY, (pmpkg_t *)-1);
}
fn = strdup("/tmp/alpm_XXXXXX");
diff --git a/lib/libalpm/server.c b/lib/libalpm/server.c
index c34c9215..1d972bdb 100644
--- a/lib/libalpm/server.c
+++ b/lib/libalpm/server.c
@@ -49,7 +49,7 @@ pmserver_t *_alpm_server_new(const char *url)
ALPM_LOG_FUNC;
- server = (pmserver_t *)malloc(sizeof(pmserver_t));
+ server = malloc(sizeof(pmserver_t));
if(server == NULL) {
_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmserver_t));
RET_ERR(PM_ERR_MEMORY, NULL);
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) {
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index cb873e7a..2637197c 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -59,7 +59,7 @@ pmtrans_t *_alpm_trans_new()
ALPM_LOG_FUNC;
- if((trans = (pmtrans_t *)malloc(sizeof(pmtrans_t))) == NULL) {
+ if((trans = malloc(sizeof(pmtrans_t))) == NULL) {
_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmtrans_t));
return(NULL);
}
@@ -594,14 +594,14 @@ int _alpm_check_freespace(pmtrans_t *trans, alpm_list_t **data)
if(pkgsize > freespace) {
if(data) {
long long *ptr;
- if((ptr = (long long*)malloc(sizeof(long long)))==NULL) {
+ if((ptr = malloc(sizeof(long long)))==NULL) {
_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(long long));
pm_errno = PM_ERR_MEMORY;
return(-1);
}
*ptr = pkgsize;
*data = alpm_list_add(*data, ptr);
- if((ptr = (long long*)malloc(sizeof(long long)))==NULL) {
+ if((ptr = malloc(sizeof(long long)))==NULL) {
_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(long long));
FREELIST(*data);
pm_errno = PM_ERR_MEMORY;
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index f821beb2..15e69b79 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -196,7 +196,7 @@ char *_alpm_strtrim(char *str)
return(str);
}
- pch = (char *)(str + (strlen(str) - 1));
+ pch = (str + (strlen(str) - 1));
while(isspace((int)*pch)) {
pch--;
}