summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRuediger Meier2016-02-26 11:10:24 +0100
committerRuediger Meier2016-03-07 23:29:27 +0100
commitfea1cbf7484df23a6fe0b62ccd1de271bc1f931a (patch)
tree047a4504053a7b449bce7695346a3f7edf78a068
parentlibfdisk: remove ifdef HDIO_GETGEO (diff)
downloadkernel-qcow2-util-linux-fea1cbf7484df23a6fe0b62ccd1de271bc1f931a.tar.gz
kernel-qcow2-util-linux-fea1cbf7484df23a6fe0b62ccd1de271bc1f931a.tar.xz
kernel-qcow2-util-linux-fea1cbf7484df23a6fe0b62ccd1de271bc1f931a.zip
misc: never cast void* from malloc(3) and friends
Such cast could hide serious compiler warnings in case we are missing includes (e.g. <stdlib.h> or "xalloc.h"). See http://stackoverflow.com/questions/605845/do-i-cast-the-result-of-malloc Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
-rw-r--r--disk-utils/mkswap.c2
-rw-r--r--lib/setproctitle.c2
-rw-r--r--lib/strutils.c2
-rw-r--r--libblkid/src/cache.c2
-rw-r--r--libblkid/src/config.c2
-rw-r--r--libblkid/src/dev.c2
-rw-r--r--libblkid/src/tag.c2
-rw-r--r--login-utils/login.c2
-rw-r--r--misc-utils/test_uuidd.c4
-rw-r--r--sys-utils/swapon-common.c4
-rw-r--r--term-utils/agetty.c2
-rw-r--r--text-utils/col.c4
12 files changed, 15 insertions, 15 deletions
diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c
index 52ee8c65d..a7c6a709b 100644
--- a/disk-utils/mkswap.c
+++ b/disk-utils/mkswap.c
@@ -87,7 +87,7 @@ static void init_signature_page(struct mkswap_control *ctl)
} else
ctl->pagesize = kernel_pagesize;
- ctl->signature_page = (unsigned long *) xcalloc(1, ctl->pagesize);
+ ctl->signature_page = xcalloc(1, ctl->pagesize);
ctl->hdr = (struct swap_header_v1_2 *) ctl->signature_page;
}
diff --git a/lib/setproctitle.c b/lib/setproctitle.c
index 4bcf8c8a9..93bc82e47 100644
--- a/lib/setproctitle.c
+++ b/lib/setproctitle.c
@@ -33,7 +33,7 @@ void initproctitle (int argc, char **argv)
for (i = 0; envp[i] != NULL; i++)
continue;
- environ = (char **) malloc(sizeof(char *) * (i + 1));
+ environ = malloc(sizeof(char *) * (i + 1));
if (environ == NULL)
return;
diff --git a/lib/strutils.c b/lib/strutils.c
index 64a6b992e..2d7cb59ed 100644
--- a/lib/strutils.c
+++ b/lib/strutils.c
@@ -247,7 +247,7 @@ char *strnchr(const char *s, size_t maxlen, int c)
char *strndup(const char *s, size_t n)
{
size_t len = strnlen(s, n);
- char *new = (char *) malloc((len + 1) * sizeof(char));
+ char *new = malloc((len + 1) * sizeof(char));
if (!new)
return NULL;
new[len] = '\0';
diff --git a/libblkid/src/cache.c b/libblkid/src/cache.c
index b576df8b4..c6d02a48b 100644
--- a/libblkid/src/cache.c
+++ b/libblkid/src/cache.c
@@ -102,7 +102,7 @@ int blkid_get_cache(blkid_cache *ret_cache, const char *filename)
DBG(CACHE, ul_debug("creating blkid cache (using %s)",
filename ? filename : "default cache"));
- if (!(cache = (blkid_cache) calloc(1, sizeof(struct blkid_struct_cache))))
+ if (!(cache = calloc(1, sizeof(struct blkid_struct_cache))))
return -BLKID_ERR_MEM;
INIT_LIST_HEAD(&cache->bic_devs);
diff --git a/libblkid/src/config.c b/libblkid/src/config.c
index 3c7f3124c..1822f1c67 100644
--- a/libblkid/src/config.c
+++ b/libblkid/src/config.c
@@ -120,7 +120,7 @@ struct blkid_config *blkid_read_config(const char *filename)
if (!filename)
filename = BLKID_CONFIG_FILE;
- conf = (struct blkid_config *) calloc(1, sizeof(*conf));
+ conf = calloc(1, sizeof(*conf));
if (!conf)
return NULL;
conf->uevent = -1;
diff --git a/libblkid/src/dev.c b/libblkid/src/dev.c
index 99b70b682..8e5516bce 100644
--- a/libblkid/src/dev.c
+++ b/libblkid/src/dev.c
@@ -34,7 +34,7 @@ blkid_dev blkid_new_dev(void)
{
blkid_dev dev;
- if (!(dev = (blkid_dev) calloc(1, sizeof(struct blkid_struct_dev))))
+ if (!(dev = calloc(1, sizeof(struct blkid_struct_dev))))
return NULL;
INIT_LIST_HEAD(&dev->bid_devs);
diff --git a/libblkid/src/tag.c b/libblkid/src/tag.c
index bfc7bb782..4dc7da139 100644
--- a/libblkid/src/tag.c
+++ b/libblkid/src/tag.c
@@ -21,7 +21,7 @@ static blkid_tag blkid_new_tag(void)
{
blkid_tag tag;
- if (!(tag = (blkid_tag) calloc(1, sizeof(struct blkid_struct_tag))))
+ if (!(tag = calloc(1, sizeof(struct blkid_struct_tag))))
return NULL;
INIT_LIST_HEAD(&tag->bit_tags);
diff --git a/login-utils/login.c b/login-utils/login.c
index ac76f6563..236da9b3d 100644
--- a/login-utils/login.c
+++ b/login-utils/login.c
@@ -1039,7 +1039,7 @@ static void init_environ(struct login_context *cxt)
/* destroy environment unless user has requested preservation (-p) */
if (!cxt->keep_env) {
- environ = (char **) xmalloc(sizeof(char *));
+ environ = xmalloc(sizeof(char *));
memset(environ, 0, sizeof(char *));
}
diff --git a/misc-utils/test_uuidd.c b/misc-utils/test_uuidd.c
index 78399b91f..36f3b3db2 100644
--- a/misc-utils/test_uuidd.c
+++ b/misc-utils/test_uuidd.c
@@ -161,7 +161,7 @@ static void create_nthreads(process_t *proc, size_t index)
size_t i, ncreated = 0;
int rc;
- threads = (thread_t *) xcalloc(nthreads, sizeof(thread_t));
+ threads = xcalloc(nthreads, sizeof(thread_t));
for (i = 0; i < nthreads; i++) {
thread_t *th = &threads[i];
@@ -209,7 +209,7 @@ static void create_nprocesses(void)
process_t *process;
size_t i;
- process = (process_t *) xcalloc(nprocesses, sizeof(process_t));
+ process = xcalloc(nprocesses, sizeof(process_t));
for (i = 0; i < nprocesses; i++) {
process_t *proc = &process[i];
diff --git a/sys-utils/swapon-common.c b/sys-utils/swapon-common.c
index 75466a056..8b686c0cd 100644
--- a/sys-utils/swapon-common.c
+++ b/sys-utils/swapon-common.c
@@ -86,7 +86,7 @@ static size_t ulct;
void add_label(const char *label)
{
- llist = (const char **) xrealloc(llist, (++llct) * sizeof(char *));
+ llist = xrealloc(llist, (++llct) * sizeof(char *));
llist[llct - 1] = label;
}
@@ -102,7 +102,7 @@ size_t numof_labels(void)
void add_uuid(const char *uuid)
{
- ulist = (const char **) xrealloc(ulist, (++ulct) * sizeof(char *));
+ ulist = xrealloc(ulist, (++ulct) * sizeof(char *));
ulist[ulct - 1] = uuid;
}
diff --git a/term-utils/agetty.c b/term-utils/agetty.c
index 55a00e125..1df1bc861 100644
--- a/term-utils/agetty.c
+++ b/term-utils/agetty.c
@@ -1970,7 +1970,7 @@ static char *get_logname(struct options *op, struct termios *tp, struct chardata
if (len < 0)
log_err(_("%s: invalid character conversion for login name"), op->tty);
- wcs = (wchar_t *) malloc((len + 1) * sizeof(wchar_t));
+ wcs = malloc((len + 1) * sizeof(wchar_t));
if (!wcs)
log_err(_("failed to allocate memory: %m"));
diff --git a/text-utils/col.c b/text-utils/col.c
index 53f0556d3..0823573f4 100644
--- a/text-utils/col.c
+++ b/text-utils/col.c
@@ -362,7 +362,7 @@ int main(int argc, char **argv)
int need;
need = l->l_lsize ? l->l_lsize * 2 : 90;
- l->l_line = (CHAR *)xrealloc((void *) l->l_line,
+ l->l_line = xrealloc((void *) l->l_line,
(unsigned) need * sizeof(CHAR));
l->l_lsize = need;
}
@@ -472,7 +472,7 @@ void flush_line(LINE *l)
*/
if (l->l_lsize > sorted_size) {
sorted_size = l->l_lsize;
- sorted = (CHAR *)xrealloc((void *)sorted,
+ sorted = xrealloc((void *)sorted,
(unsigned)sizeof(CHAR) * sorted_size);
}
if (l->l_max_col >= count_size) {