From 4cccc03768ecde58e8acd5e4f40e51227e3c14cc Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Fri, 22 Dec 2006 18:37:07 +0000 Subject: [PATCH] remove useless casts (type*) xzalloc(...) --- archival/dpkg.c | 4 ++-- archival/gzip.c | 2 +- archival/libunarchive/decompress_unzip.c | 2 +- editors/awk.c | 13 ++++++------- findutils/grep.c | 2 +- networking/traceroute.c | 4 +--- shell/lash.c | 2 +- 7 files changed, 13 insertions(+), 16 deletions(-) diff --git a/archival/dpkg.c b/archival/dpkg.c index 3ff6249d9..5535c15a1 100644 --- a/archival/dpkg.c +++ b/archival/dpkg.c @@ -582,7 +582,7 @@ static unsigned fill_package_struct(char *control_buffer) "Conflicts", "Suggests", "Recommends", "Enhances", 0 }; - common_node_t *new_node = (common_node_t *) xzalloc(sizeof(common_node_t)); + common_node_t *new_node = xzalloc(sizeof(common_node_t)); char *field_name; char *field_value; int field_start = 0; @@ -981,7 +981,7 @@ static int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count) package_hashtable[package_num]->edge[j]->operator); if (package_hashtable[conflicts_package_num] == NULL) { /* create a new package */ - common_node_t *new_node = (common_node_t *) xzalloc(sizeof(common_node_t)); + common_node_t *new_node = xzalloc(sizeof(common_node_t)); new_node->name = package_hashtable[package_num]->edge[j]->name; new_node->version = package_hashtable[package_num]->edge[j]->version; package_hashtable[conflicts_package_num] = new_node; diff --git a/archival/gzip.c b/archival/gzip.c index 5966c08e4..f4aea3f59 100644 --- a/archival/gzip.c +++ b/archival/gzip.c @@ -92,7 +92,7 @@ typedef unsigned long ulg; # define DECLARE(type, array, size) static type * array # define ALLOC(type, array, size) { \ - array = (type*)xzalloc((size_t)(((size)+1L)/2) * 2*sizeof(type)); \ + array = xzalloc((size_t)(((size)+1L)/2) * 2*sizeof(type)); \ } # define FREE(array) {free(array), array=NULL;} diff --git a/archival/libunarchive/decompress_unzip.c b/archival/libunarchive/decompress_unzip.c index 621d84c2d..38262608d 100644 --- a/archival/libunarchive/decompress_unzip.c +++ b/archival/libunarchive/decompress_unzip.c @@ -275,7 +275,7 @@ int huft_build(unsigned int *b, const unsigned int n, ws[htl+1] = w + j; /* set bits decoded in stack */ /* allocate and link in new table */ - q = (huft_t *) xzalloc((z + 1) * sizeof(huft_t)); + q = xzalloc((z + 1) * sizeof(huft_t)); *t = q + 1; /* link to list for huft_free() */ t = &(q->v.t); u[htl] = ++q; /* table starts after link */ diff --git a/editors/awk.c b/editors/awk.c index 81ca9daf7..2fea55113 100644 --- a/editors/awk.c +++ b/editors/awk.c @@ -469,9 +469,9 @@ static xhash *hash_init(void) { xhash *newhash; - newhash = (xhash *)xzalloc(sizeof(xhash)); + newhash = xzalloc(sizeof(xhash)); newhash->csize = FIRST_PRIME; - newhash->items = (hash_item **)xzalloc(newhash->csize * sizeof(hash_item *)); + newhash->items = xzalloc(newhash->csize * sizeof(hash_item *)); return newhash; } @@ -500,7 +500,7 @@ static void hash_rebuild(xhash *hash) return; newsize = PRIMES[hash->nprime++]; - newitems = (hash_item **)xzalloc(newsize * sizeof(hash_item *)); + newitems = xzalloc(newsize * sizeof(hash_item *)); for (i=0; icsize; i++) { hi = hash->items[i]; @@ -988,7 +988,7 @@ static node *new_node(uint32_t info) { node *n; - n = (node *)xzalloc(sizeof(node)); + n = xzalloc(sizeof(node)); n->info = info; n->lineno = lineno; return n; @@ -1098,8 +1098,7 @@ static node *parse_expr(uint32_t iexp) break; case TC_REGEXP: - mk_re_node(t.string, cn, - (regex_t *)xzalloc(sizeof(regex_t)*2)); + mk_re_node(t.string, cn, xzalloc(sizeof(regex_t)*2)); break; case TC_FUNCTION: @@ -1585,7 +1584,7 @@ static void hashwalk_init(var *v, xhash *array) free(v->x.walker); v->type |= VF_WALK; - w = v->x.walker = (char **)xzalloc(2 + 2*sizeof(char *) + array->glen); + w = v->x.walker = xzalloc(2 + 2*sizeof(char *) + array->glen); *w = *(w+1) = (char *)(w + 2); for (i=0; icsize; i++) { hi = array->items[i]; diff --git a/findutils/grep.c b/findutils/grep.c index 8bb38f95c..76f656237 100644 --- a/findutils/grep.c +++ b/findutils/grep.c @@ -360,7 +360,7 @@ int grep_main(int argc, char **argv) lines_before = 0; lines_after = 0; } else if (lines_before > 0) - before_buf = (char **)xzalloc(lines_before * sizeof(char *)); + before_buf = xzalloc(lines_before * sizeof(char *)); #else /* with auto sanity checks */ opt_complementary = "H-h:e::f::c-n:q-n:l-n"; diff --git a/networking/traceroute.c b/networking/traceroute.c index 1462543f1..adb9ef0b4 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c @@ -1118,7 +1118,7 @@ traceroute_main(int argc, char *argv[]) xsetgid(getgid()); xsetuid(getuid()); - outip = (struct ip *)xzalloc(packlen); + outip = xzalloc(packlen); outip->ip_v = IPVERSION; if (tos_str) @@ -1133,7 +1133,6 @@ traceroute_main(int argc, char *argv[]) #if ENABLE_FEATURE_TRACEROUTE_USE_ICMP if (useicmp) { outip->ip_p = IPPROTO_ICMP; - outicmp = (struct icmp *)outp; outicmp->icmp_type = ICMP_ECHO; outicmp->icmp_id = htons(ident); @@ -1142,7 +1141,6 @@ traceroute_main(int argc, char *argv[]) #endif { outip->ip_p = IPPROTO_UDP; - outudp = (struct udphdr *)outp; outudp->source = htons(ident); outudp->len = htons((uint16_t)(packlen - (sizeof(*outip) + optlen))); diff --git a/shell/lash.c b/shell/lash.c index 3b51e98a9..525767190 100644 --- a/shell/lash.c +++ b/shell/lash.c @@ -1377,7 +1377,7 @@ static int busy_loop(FILE * input) } else { free(command); - command = (char *) xzalloc(BUFSIZ); + command = xzalloc(BUFSIZ); next_command = NULL; } } else { -- 2.25.1