summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-12-19 23:36:04 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-12-19 23:36:04 +0000
commitb95636c52fbb058a39548bcbc4e86456ebbd7b7b (patch)
tree0f82f8e3d225f3bcefdbf7070ae0716f1b309630
parent2375d75f3267e6e4370f221fea485eac8e73d402 (diff)
remove casts from xmalloc()
-rw-r--r--archival/dpkg.c6
-rw-r--r--console-tools/loadfont.c2
-rw-r--r--coreutils/tail.c2
-rw-r--r--e2fsprogs/blkid/probe.c4
-rw-r--r--e2fsprogs/e2p/iod.c2
-rw-r--r--editors/awk.c6
-rw-r--r--editors/sed.c2
-rw-r--r--editors/vi.c8
-rw-r--r--libbb/dump.c4
-rw-r--r--libbb/inet_common.c2
-rw-r--r--miscutils/nmeter.c2
-rw-r--r--modutils/insmod.c2
-rw-r--r--networking/ifupdown.c6
-rw-r--r--sysklogd/logread.c2
-rw-r--r--util-linux/fdisk.c2
15 files changed, 25 insertions, 27 deletions
diff --git a/archival/dpkg.c b/archival/dpkg.c
index 9024d41d2..6ef04522d 100644
--- a/archival/dpkg.c
+++ b/archival/dpkg.c
@@ -442,7 +442,7 @@ static void add_split_dependencies(common_node_t *parent_node, const char *whole
field2 = strtok_r(line2, "|", &line_ptr2);
if ((edge_type == EDGE_DEPENDS || edge_type == EDGE_PRE_DEPENDS) &&
(strcmp(field, field2) != 0)) {
- or_edge = (edge_t *)xmalloc(sizeof(edge_t));
+ or_edge = xmalloc(sizeof(edge_t));
or_edge->type = edge_type + 1;
} else {
or_edge = NULL;
@@ -456,7 +456,7 @@ static void add_split_dependencies(common_node_t *parent_node, const char *whole
}
do {
- edge = (edge_t *) xmalloc(sizeof(edge_t));
+ edge = xmalloc(sizeof(edge_t));
edge->type = edge_type;
/* Skip any extra leading spaces */
@@ -1708,7 +1708,7 @@ int dpkg_main(int argc, char **argv)
/* If no previous entry was found initialise a new entry */
if ((status_hashtable[status_num] == NULL) ||
(status_hashtable[status_num]->status == 0)) {
- status_node = (status_node_t *) xmalloc(sizeof(status_node_t));
+ status_node = xmalloc(sizeof(status_node_t));
status_node->package = deb_file[deb_count]->package;
/* reinstreq isnt changed to "ok" until the package control info
* is written to the status file*/
diff --git a/console-tools/loadfont.c b/console-tools/loadfont.c
index 36f0e6da9..6aa739ba4 100644
--- a/console-tools/loadfont.c
+++ b/console-tools/loadfont.c
@@ -84,7 +84,7 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
uint16_t unicode;
maxct = tailsz; /* more than enough */
- up = (struct unipair *) xmalloc(maxct * sizeof(struct unipair));
+ up = xmalloc(maxct * sizeof(struct unipair));
for (glyph = 0; glyph < fontsize; glyph++) {
while (tailsz >= 2) {
diff --git a/coreutils/tail.c b/coreutils/tail.c
index 505a8fd6b..643c0f3c9 100644
--- a/coreutils/tail.c
+++ b/coreutils/tail.c
@@ -152,7 +152,7 @@ int tail_main(int argc, char **argv)
}
/* open all the files */
- fds = (int *)xmalloc(sizeof(int) * (argc - optind + 1));
+ fds = xmalloc(sizeof(int) * (argc - optind + 1));
argv += optind;
nfiles = i = 0;
diff --git a/e2fsprogs/blkid/probe.c b/e2fsprogs/blkid/probe.c
index ea9a619ee..8c6e2aa33 100644
--- a/e2fsprogs/blkid/probe.c
+++ b/e2fsprogs/blkid/probe.c
@@ -349,7 +349,7 @@ static int probe_swap1(int fd,
* pagesize).
*/
if (lseek(fd, 1024, SEEK_SET) < 0) return 1;
- sws = (struct swap_id_block *)xmalloc(1024);
+ sws = xmalloc(1024);
if (read(fd, sws, 1024) != 1024) {
free(sws);
return 1;
@@ -620,7 +620,7 @@ try_again:
if (lseek(fd, idx << 10, SEEK_SET) < 0)
continue;
- buf = (unsigned char *)xmalloc(1024);
+ buf = xmalloc(1024);
if (read(fd, buf, 1024) != 1024) {
free(buf);
diff --git a/e2fsprogs/e2p/iod.c b/e2fsprogs/e2p/iod.c
index 8d4c5cdcb..23ab8d5b5 100644
--- a/e2fsprogs/e2p/iod.c
+++ b/e2fsprogs/e2p/iod.c
@@ -29,7 +29,7 @@ int iterate_on_dir (const char * dir_name,
int max_len, len;
max_len = PATH_MAX + sizeof(struct dirent);
- de = (struct dirent *)xmalloc(max_len+1);
+ de = xmalloc(max_len+1);
memset(de, 0, max_len+1);
dir = opendir (dir_name);
diff --git a/editors/awk.c b/editors/awk.c
index 147c621ab..81ca9daf7 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -781,7 +781,7 @@ static var *nvalloc(int n)
if (! cb) {
size = (n <= MINNVBLOCK) ? MINNVBLOCK : n;
- cb = (nvblock *)xmalloc(sizeof(nvblock) + size * sizeof(var));
+ cb = xmalloc(sizeof(nvblock) + size * sizeof(var));
cb->size = size;
cb->pos = cb->nv;
cb->prev = pb;
@@ -2463,7 +2463,7 @@ re_cont:
case XC( OC_CONCAT ):
case XC( OC_COMMA ):
opn = strlen(L.s) + strlen(R.s) + 2;
- X.s = (char *)xmalloc(opn);
+ X.s = xmalloc(opn);
strcpy(X.s, L.s);
if ((opinfo & OPCLSMASK) == OC_COMMA) {
L.s = getvar_s(V[SUBSEP]);
@@ -2702,7 +2702,7 @@ keep_going:
/* one byte is reserved for some trick in next_token */
if (fseek(F, 0, SEEK_END) == 0) {
flen = ftell(F);
- s = (char *)xmalloc(flen+4);
+ s = xmalloc(flen+4);
fseek(F, 0, SEEK_SET);
i = 1 + fread(s+1, 1, flen, F);
} else {
diff --git a/editors/sed.c b/editors/sed.c
index 8d372abe4..95ced1ceb 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -382,7 +382,7 @@ out:
/* compile the match string into a regex */
if (*match != '\0') {
/* If match is empty, we use last regex used at runtime */
- sed_cmd->sub_match = (regex_t *) xmalloc(sizeof(regex_t));
+ sed_cmd->sub_match = xmalloc(sizeof(regex_t));
xregcomp(sed_cmd->sub_match, match, cflags);
}
free(match);
diff --git a/editors/vi.c b/editors/vi.c
index 0bb2b23ef..1122f9919 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -1370,7 +1370,7 @@ static Byte *new_screen(int ro, int co)
free(screen);
screensize = ro * co + 8;
- screen = (Byte *) xmalloc(screensize);
+ screen = xmalloc(screensize);
// initialize the new screen. assume this will be a empty file.
screen_erase();
// non-existent text[] lines start with a tilde (~).
@@ -1385,7 +1385,7 @@ static Byte *new_text(int size)
if (size < 10240)
size = 10240; // have a minimum size for new files
free(text);
- text = (Byte *) xmalloc(size + 8);
+ text = xmalloc(size + 8);
memset(text, '\0', size); // clear new text[]
//text += 4; // leave some room for "oops"
return text;
@@ -1901,7 +1901,7 @@ static void start_new_cmd_q(Byte c)
// release old cmd
free(last_modifying_cmd);
// get buffer for new cmd
- last_modifying_cmd = (Byte *) xmalloc(BUFSIZ);
+ last_modifying_cmd = xmalloc(BUFSIZ);
memset(last_modifying_cmd, '\0', BUFSIZ); // clear new cmd queue
// if there is a current cmd count put it in the buffer first
if (cmdcnt > 0)
@@ -1954,7 +1954,7 @@ static Byte *text_yank(Byte * p, Byte * q, int dest) // copy text into a registe
cnt = q - p + 1;
t = reg[dest];
free(t); // if already a yank register, free it
- t = (Byte *) xmalloc(cnt + 1); // get a new register
+ t = xmalloc(cnt + 1); // get a new register
memset(t, '\0', cnt + 1); // clear new text[]
strncpy((char *) t, (char *) p, cnt); // copy text[] into bufer
reg[dest] = t;
diff --git a/libbb/dump.c b/libbb/dump.c
index 10710894e..d6e31b9b1 100644
--- a/libbb/dump.c
+++ b/libbb/dump.c
@@ -358,8 +358,8 @@ static unsigned char *get(void)
if (!curp) {
address = (off_t)0; /*DBU:[dave@cray.com] initialize,initialize..*/
- curp = (unsigned char *) xmalloc(bb_dump_blocksize);
- savp = (unsigned char *) xmalloc(bb_dump_blocksize);
+ curp = xmalloc(bb_dump_blocksize);
+ savp = xmalloc(bb_dump_blocksize);
} else {
tmpp = curp;
curp = savp;
diff --git a/libbb/inet_common.c b/libbb/inet_common.c
index d8e00353e..9cdcb11de 100644
--- a/libbb/inet_common.c
+++ b/libbb/inet_common.c
@@ -158,7 +158,7 @@ int INET_rresolve(char *name, size_t len, struct sockaddr_in *s_in,
if ((ent == NULL) && (np == NULL)) {
safe_strncpy(name, inet_ntoa(s_in->sin_addr), len);
}
- pn = (struct addr *) xmalloc(sizeof(struct addr));
+ pn = xmalloc(sizeof(struct addr));
pn->addr = *s_in;
pn->next = INET_nn;
pn->host = host;
diff --git a/miscutils/nmeter.c b/miscutils/nmeter.c
index b09877137..0c9485350 100644
--- a/miscutils/nmeter.c
+++ b/miscutils/nmeter.c
@@ -104,7 +104,7 @@ static const char* get_file(proc_file *pf)
// but allows us to allocate only once (at first sample)
// per proc file, and reuse buffer for each sample
if (!pf->file)
- pf->file = (char*)xmalloc(proc_file_size);
+ pf->file = xmalloc(proc_file_size);
readfile_z(pf->file, proc_file_size, pf->name);
}
return pf->file;
diff --git a/modutils/insmod.c b/modutils/insmod.c
index 7b715b9c3..19066972a 100644
--- a/modutils/insmod.c
+++ b/modutils/insmod.c
@@ -1131,7 +1131,7 @@ arch_apply_relocation(struct obj_file *f,
/* We cannot relocate this one now because we don't know the value
of the carry we need to add. Save the information, and let LO16
do the actual relocation. */
- n = (struct mips_hi16 *) xmalloc(sizeof *n);
+ n = xmalloc(sizeof *n);
n->addr = loc;
n->value = v;
n->next = ifile->mips_hi16_list;
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index b53d2330d..adbc37e43 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -1048,7 +1048,7 @@ static char *run_mapping(char *physical, struct mapping_defn_t * map)
/* If the mapping script exited successfully, try to
* grab a line of output and use that as the name of the
* logical interface. */
- char *new_logical = (char *)xmalloc(MAX_INTERFACE_LENGTH);
+ char *new_logical = xmalloc(MAX_INTERFACE_LENGTH);
if (fgets(new_logical, MAX_INTERFACE_LENGTH, out)) {
/* If we are able to read a line of output from the script,
@@ -1139,7 +1139,6 @@ int ifupdown_main(int argc, char **argv)
llist_add_to_end(&target_list, argv[optind]);
}
-
/* Update the interfaces */
while (target_list) {
llist_t *iface_list;
@@ -1255,8 +1254,7 @@ int ifupdown_main(int argc, char **argv)
state_fp = xfopen("/var/run/ifstate", "w");
while (state_list) {
if (state_list->data) {
- fputs(state_list->data, state_fp);
- fputc('\n', state_fp);
+ fprintf(state_fp, "%s\n", state_list->data);
}
state_list = state_list->link;
}
diff --git a/sysklogd/logread.c b/sysklogd/logread.c
index 9cc6561a4..745f97629 100644
--- a/sysklogd/logread.c
+++ b/sysklogd/logread.c
@@ -117,7 +117,7 @@ int logread_main(int argc, char **argv)
log_len = buf->tail - i;
if (log_len < 0)
log_len += buf->size;
- buf_data = (char *)xmalloc(log_len);
+ buf_data = xmalloc(log_len);
if (buf->tail < i) {
memcpy(buf_data, buf->data+i, buf->size-i);
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c
index e4f7e5455..84538af99 100644
--- a/util-linux/fdisk.c
+++ b/util-linux/fdisk.c
@@ -680,7 +680,7 @@ static void
read_pte(struct pte *pe, off_t offset)
{
pe->offset = offset;
- pe->sectorbuffer = (char *) xmalloc(sector_size);
+ pe->sectorbuffer = xmalloc(sector_size);
seek_sector(offset);
if (read(fd, pe->sectorbuffer, sector_size) != sector_size)
fdisk_fatal(unable_to_read);