From 6c93bdeeaa8a322b76c48ffc17a2205f6c3f5271 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 11 Apr 2003 10:51:56 +0000 Subject: Remove anachronistic casts of xmalloc, xrealloc, and xcalloc return values and of xrealloc's first argument. --- src/copy.c | 2 +- src/cp-hash.c | 4 ++-- src/cp.c | 2 +- src/csplit.c | 16 ++++++++-------- src/cut.c | 9 ++++----- src/date.c | 4 ++-- src/df.c | 4 ++-- src/du.c | 2 +- src/expand.c | 7 +++---- src/expr.c | 6 +++--- src/id.c | 2 +- src/join.c | 14 +++++++------- src/md5sum.c | 4 ++-- src/nl.c | 4 ++-- src/od.c | 8 +++----- src/paste.c | 11 +++++------ src/pr.c | 20 ++++++++++---------- src/ptx.c | 26 +++++++++++++------------- src/sort.c | 12 ++++++------ src/split.c | 2 +- src/su.c | 10 +++++----- src/tail.c | 16 ++++++++-------- src/tee.c | 4 ++-- src/tr.c | 20 ++++++++++---------- src/unexpand.c | 3 +-- src/users.c | 4 ++-- 26 files changed, 105 insertions(+), 111 deletions(-) diff --git a/src/copy.c b/src/copy.c index 1f1403e1f..7b65f7ca2 100644 --- a/src/copy.c +++ b/src/copy.c @@ -756,7 +756,7 @@ record_file (Hash_table *ht, char const *filename, if (ht == NULL) return; - ent = (struct F_triple *) xmalloc (sizeof *ent); + ent = xmalloc (sizeof *ent); ent->name = xstrdup (filename); if (stats) { diff --git a/src/cp-hash.c b/src/cp-hash.c index 396fed182..5328d7712 100644 --- a/src/cp-hash.c +++ b/src/cp-hash.c @@ -1,5 +1,5 @@ /* cp-hash.c -- file copying (hash search routines) - Copyright (C) 89, 90, 91, 1995-2002 Free Software Foundation. + Copyright (C) 89, 90, 91, 1995-2003 Free Software Foundation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -126,7 +126,7 @@ remember_copied (const char *name, ino_t ino, dev_t dev) struct Src_to_dest *ent; struct Src_to_dest *ent_from_table; - ent = (struct Src_to_dest *) xmalloc (sizeof *ent); + ent = xmalloc (sizeof *ent); ent->name = xstrdup (name); ent->st_ino = ino; ent->st_dev = dev; diff --git a/src/cp.c b/src/cp.c index 1f8a975aa..a8da001a8 100644 --- a/src/cp.c +++ b/src/cp.c @@ -414,7 +414,7 @@ make_path_private (const char *const_dirpath, int src_offset, int mode, /* Add this directory to the list of directories whose modes need fixing later. */ struct dir_attr *new = - (struct dir_attr *) xmalloc (sizeof (struct dir_attr)); + xmalloc (sizeof (struct dir_attr)); new->slash_offset = slash - dirpath; new->next = *attr_list; *attr_list = new; diff --git a/src/csplit.c b/src/csplit.c index 441931966..0009d04fc 100644 --- a/src/csplit.c +++ b/src/csplit.c @@ -1,5 +1,5 @@ /* csplit - split a file into sections determined by context lines - Copyright (C) 91, 1995-2002 Free Software Foundation, Inc. + Copyright (C) 91, 1995-2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -321,7 +321,7 @@ new_line_control (void) { struct line *p; - p = (struct line *) xmalloc (sizeof (struct line)); + p = xmalloc (sizeof (struct line)); p->next = NULL; clear_line_control (p); @@ -423,7 +423,7 @@ create_new_buffer (unsigned int size) new_buffer = (struct buffer_record *) xmalloc (sizeof (struct buffer_record)); - new_buffer->buffer = (char *) xmalloc (size + 1); + new_buffer->buffer = xmalloc (size + 1); new_buffer->bytes_alloc = size; new_buffer->line_start = new_buffer->curr_line = NULL; @@ -1038,7 +1038,7 @@ new_control_record (void) { control_allocated += ALLOC_SIZE; controls = (struct control *) - xrealloc ((char *) controls, + xrealloc (controls, sizeof (struct control) * control_allocated); } p = &controls[control_used++]; @@ -1129,10 +1129,10 @@ extract_regexp (int argnum, boolean ignore, char *str) p->argnum = argnum; p->ignore = ignore; - p->regexpr = (char *) xmalloc ((unsigned) (len + 1)); + p->regexpr = xmalloc ((unsigned) (len + 1)); strncpy (p->regexpr, str + 1, len); p->re_compiled.allocated = len * 2; - p->re_compiled.buffer = (unsigned char *) xmalloc (p->re_compiled.allocated); + p->re_compiled.buffer = xmalloc (p->re_compiled.allocated); p->re_compiled.fastmap = xmalloc (256); p->re_compiled.translate = 0; err = re_compile_pattern (p->regexpr, len, &p->re_compiled); @@ -1466,9 +1466,9 @@ main (int argc, char **argv) } if (suffix) - filename_space = (char *) xmalloc (strlen (prefix) + max_out (suffix) + 2); + filename_space = xmalloc (strlen (prefix) + max_out (suffix) + 2); else - filename_space = (char *) xmalloc (strlen (prefix) + digits + 2); + filename_space = xmalloc (strlen (prefix) + digits + 2); set_input_file (argv[optind++]); diff --git a/src/cut.c b/src/cut.c index 960917394..96fa257ff 100644 --- a/src/cut.c +++ b/src/cut.c @@ -1,5 +1,5 @@ /* cut - remove parts of lines of files - Copyright (C) 1984, 1997, 1998, 1999, 2000, 2001, 2002, 2003 by David M. Ihnat + Copyright (C) 1984, 1997-2003 by David M. Ihnat This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -56,8 +56,7 @@ if (n_rp >= n_rp_allocated) \ { \ n_rp_allocated *= 2; \ - (rp) = (struct range_pair *) xrealloc ((char *) (rp), \ - n_rp_allocated * sizeof (*(rp))); \ + (rp) = xrealloc (rp, n_rp_allocated * sizeof (*(rp))); \ } \ rp[n_rp].lo = (low); \ rp[n_rp].hi = (high); \ @@ -274,7 +273,7 @@ set_fields (const char *fieldstr) n_rp = 0; n_rp_allocated = 16; - rp = (struct range_pair *) xmalloc (n_rp_allocated * sizeof (*rp)); + rp = xmalloc (n_rp_allocated * sizeof (*rp)); /* Collect and store in RP the range end points. It also sets EOL_RANGE_START if appropriate. */ @@ -390,7 +389,7 @@ set_fields (const char *fieldstr) the field numbers corresponding to all finite ranges (i.e. `2-6' or `-4', but not `5-') in FIELDSTR. */ - printable_field = (int *) xmalloc ((max_range_endpoint + 1) * sizeof (int)); + printable_field = xmalloc ((max_range_endpoint + 1) * sizeof (int)); memset (printable_field, 0, (max_range_endpoint + 1) * sizeof (int)); /* Set the array entries corresponding to integers in the ranges of RP. */ diff --git a/src/date.c b/src/date.c index 37295c70d..4f5a11208 100644 --- a/src/date.c +++ b/src/date.c @@ -1,5 +1,5 @@ /* date - print or set the system date and time - Copyright (C) 1989-2002 Free Software Foundation, Inc. + Copyright (C) 1989-2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -526,7 +526,7 @@ show_date (const char *format, struct timespec when) { int done; out_length += 200; - out = (char *) xrealloc (out, out_length); + out = xrealloc (out, out_length); /* Mark the first byte of the buffer so we can detect the case of nstrftime producing an empty string. Otherwise, this loop diff --git a/src/df.c b/src/df.c index fdeb14c8c..eb8a01b35 100644 --- a/src/df.c +++ b/src/df.c @@ -681,7 +681,7 @@ add_fs_type (const char *fstype) { struct fs_type_list *fsp; - fsp = (struct fs_type_list *) xmalloc (sizeof (struct fs_type_list)); + fsp = xmalloc (sizeof (struct fs_type_list)); fsp->fs_name = (char *) fstype; fsp->fs_next = fs_select_list; fs_select_list = fsp; @@ -694,7 +694,7 @@ add_excluded_fs_type (const char *fstype) { struct fs_type_list *fsp; - fsp = (struct fs_type_list *) xmalloc (sizeof (struct fs_type_list)); + fsp = xmalloc (sizeof (struct fs_type_list)); fsp->fs_name = (char *) fstype; fsp->fs_next = fs_exclude_list; fs_exclude_list = fsp; diff --git a/src/du.c b/src/du.c index 6445f8e8a..e3db36844 100644 --- a/src/du.c +++ b/src/du.c @@ -251,7 +251,7 @@ hash_ins (ino_t ino, dev_t dev) struct entry *ent; struct entry *ent_from_table; - ent = (struct entry *) xmalloc (sizeof *ent); + ent = xmalloc (sizeof *ent); ent->st_ino = ino; ent->st_dev = dev; diff --git a/src/expand.c b/src/expand.c index 84d14d924..eff48e826 100644 --- a/src/expand.c +++ b/src/expand.c @@ -1,5 +1,5 @@ /* expand - convert tabs to spaces - Copyright (C) 89, 91, 1995-2002 Free Software Foundation, Inc. + Copyright (C) 89, 91, 1995-2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -142,9 +142,8 @@ add_tabstop (int tabval) if (tabval == -1) return; if (first_free_tab % TABLIST_BLOCK == 0) - tab_list = (int *) xrealloc ((char *) tab_list, - (first_free_tab - + TABLIST_BLOCK * sizeof (tab_list[0]))); + tab_list = xrealloc (tab_list, (first_free_tab + + TABLIST_BLOCK * sizeof (tab_list[0]))); tab_list[first_free_tab++] = tabval; } diff --git a/src/expr.c b/src/expr.c index 3a8dbdc0a..ea4b16ea0 100644 --- a/src/expr.c +++ b/src/expr.c @@ -1,5 +1,5 @@ /* expr -- evaluate expressions. - Copyright (C) 86, 1991-1997, 1999-2002 Free Software Foundation, Inc. + Copyright (C) 86, 1991-1997, 1999-2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -393,7 +393,7 @@ of the basic regular expression is not portable; it is being ignored"), re_buffer.allocated = 2 * len; if (re_buffer.allocated < len) xalloc_die (); - re_buffer.buffer = (unsigned char *) xmalloc (re_buffer.allocated); + re_buffer.buffer = xmalloc (re_buffer.allocated); re_buffer.translate = 0; re_syntax_options = RE_SYNTAX_POSIX_BASIC; errmsg = re_compile_pattern (pv->u.s, len, &re_buffer); @@ -515,7 +515,7 @@ eval6 (void) { v = NEW (VALUE); v->type = string; - v->u.s = strncpy ((char *) xmalloc (i2->u.i + 1), + v->u.s = strncpy (xmalloc (i2->u.i + 1), l->u.s + i1->u.i - 1, i2->u.i); v->u.s[i2->u.i] = 0; } diff --git a/src/id.c b/src/id.c index bb5e0cafd..9d4b28668 100644 --- a/src/id.c +++ b/src/id.c @@ -262,7 +262,7 @@ xgetgroups (const char *username, gid_t gid, int *n_groups, max_n_groups = getugroups (0, NULL, username, gid); /* Add 1 just in case max_n_groups is zero. */ - g = (GETGROUPS_T *) xmalloc (max_n_groups * sizeof (GETGROUPS_T) + 1); + g = xmalloc (max_n_groups * sizeof (GETGROUPS_T) + 1); if (username == 0) ng = getgroups (max_n_groups, g); else diff --git a/src/join.c b/src/join.c index 77a7de962..8d3b95db0 100644 --- a/src/join.c +++ b/src/join.c @@ -189,9 +189,9 @@ ADD_FIELD (struct line *line, const unsigned char *field, size_t len) if (line->nfields >= line->nfields_allocated) { line->nfields_allocated = (3 * line->nfields_allocated) / 2 + 1; - line->fields = (struct field *) xrealloc ((char *) line->fields, - (line->nfields_allocated - * sizeof (struct field))); + line->fields = xrealloc (line->fields, + (line->nfields_allocated + * sizeof (struct field))); } line->fields[line->nfields].beg = field; line->fields[line->nfields].len = len; @@ -287,7 +287,7 @@ initseq (struct seq *seq) { seq->count = 0; seq->alloc = 1; - seq->lines = (struct line *) xmalloc (seq->alloc * sizeof (struct line)); + seq->lines = xmalloc (seq->alloc * sizeof (struct line)); } /* Read a line from FP and add it to SEQ. Return 0 if EOF, 1 otherwise. */ @@ -299,7 +299,7 @@ getseq (FILE *fp, struct seq *seq) { seq->alloc *= 2; seq->lines = (struct line *) - xrealloc ((char *) seq->lines, seq->alloc * sizeof (struct line)); + xrealloc (seq->lines, seq->alloc * sizeof (struct line)); } if (get_line (fp, &seq->lines[seq->count])) @@ -608,7 +608,7 @@ add_field (int file, int field) assert (file == 0 || file == 1 || file == 2); assert (file == 0 ? field < 0 : field >= 0); - o = (struct outlist *) xmalloc (sizeof (struct outlist)); + o = xmalloc (sizeof (struct outlist)); o->file = file; o->field = field; o->next = NULL; @@ -720,7 +720,7 @@ make_blank (struct line *blank, int count) blank->buf.buffer = xmalloc (blank->buf.size); buffer = (unsigned char *) blank->buf.buffer; blank->fields = fields = - (struct field *) xmalloc (sizeof (struct field) * count); + xmalloc (sizeof (struct field) * count); for (i = 0; i < count; i++) { buffer[i] = '\t'; diff --git a/src/md5sum.c b/src/md5sum.c index 270f0110e..32ead0dc3 100644 --- a/src/md5sum.c +++ b/src/md5sum.c @@ -1,5 +1,5 @@ /* Compute MD5 or SHA1 checksum of files or strings - Copyright (C) 1995-2002 Free Software Foundation, Inc. + Copyright (C) 1995-2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -524,7 +524,7 @@ main (int argc, char **argv) case 1: /* --string */ { if (string == NULL) - string = (char **) xmalloc ((argc - 1) * sizeof (char *)); + string = xmalloc ((argc - 1) * sizeof (char *)); if (optarg == NULL) optarg = ""; diff --git a/src/nl.c b/src/nl.c index 8e227607f..d9011242f 100644 --- a/src/nl.c +++ b/src/nl.c @@ -1,5 +1,5 @@ /* nl -- number lines of files - Copyright (C) 89, 92, 1995-2002 Free Software Foundation, Inc. + Copyright (C) 89, 92, 1995-2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -274,7 +274,7 @@ build_type_arg (char **typep, struct re_pattern_buffer *regexp) *typep = optarg++; optlen = strlen (optarg); regexp->allocated = optlen * 2; - regexp->buffer = (unsigned char *) xmalloc (regexp->allocated); + regexp->buffer = xmalloc (regexp->allocated); regexp->translate = NULL; regexp->fastmap = xmalloc (256); regexp->fastmap_accurate = 0; diff --git a/src/od.c b/src/od.c index 734ba876d..585628e1f 100644 --- a/src/od.c +++ b/src/od.c @@ -1,5 +1,5 @@ /* od -- dump files in octal and other formats - Copyright (C) 92, 1995-2002 Free Software Foundation, Inc. + Copyright (C) 92, 1995-2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1041,9 +1041,7 @@ decode_format_string (const char *s) if (n_specs >= n_specs_allocated) { n_specs_allocated = 1 + (3 * n_specs_allocated) / 2; - spec = (struct tspec *) xrealloc ((char *) spec, - (n_specs_allocated - * sizeof (struct tspec))); + spec = xrealloc (spec, (n_specs_allocated * sizeof (struct tspec))); } memcpy ((char *) &spec[n_specs], (char *) &tspec, @@ -1662,7 +1660,7 @@ main (int argc, char **argv) n_specs = 0; n_specs_allocated = 5; - spec = (struct tspec *) xmalloc (n_specs_allocated * sizeof (struct tspec)); + spec = xmalloc (n_specs_allocated * sizeof (struct tspec)); format_address = format_address_std; address_base = 8; diff --git a/src/paste.c b/src/paste.c index d94e80652..336e15bf4 100644 --- a/src/paste.c +++ b/src/paste.c @@ -1,5 +1,5 @@ /* paste - merge lines of files - Copyright (C) 1984, 1997-2002 by David M. Ihnat + Copyright (C) 1984, 1997-2003 by David M. Ihnat This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -171,8 +171,8 @@ paste_parallel (int nfiles, char **fnamptr) int i; /* Loop index. */ int opened_stdin = 0; /* Nonzero if any fopen got fd 0. */ - delbuf = (char *) xmalloc (file_list_size + 2); - fileptr = (FILE **) xmalloc ((file_list_size + 1) * sizeof (FILE *)); + delbuf = xmalloc (file_list_size + 2); + fileptr = xmalloc ((file_list_size + 1) * sizeof (FILE *)); /* Attempt to open all files. This could be expanded to an infinite number of files, but at the (considerable) expense of remembering @@ -183,9 +183,8 @@ paste_parallel (int nfiles, char **fnamptr) if (files_open == file_list_size - 2) { file_list_size += 12; - delbuf = (char *) xrealloc (delbuf, file_list_size + 2); - fileptr = (FILE **) xrealloc ((char *) fileptr, (file_list_size + 1) - * sizeof (FILE *)); + delbuf = xrealloc (delbuf, file_list_size + 2); + fileptr = xrealloc (fileptr, (file_list_size + 1) * sizeof (FILE *)); } if (STREQ (fnamptr[files_open], "-")) { diff --git a/src/pr.c b/src/pr.c index 13d5d7eae..a3fc06384 100644 --- a/src/pr.c +++ b/src/pr.c @@ -1,5 +1,5 @@ /* pr -- convert text files for printing. - Copyright (C) 88, 91, 1995-2002 Free Software Foundation, Inc. + Copyright (C) 88, 91, 1995-2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -842,7 +842,7 @@ static void separator_string (const char *optarg_S) { col_sep_length = (int) strlen (optarg_S); - col_sep_string = (char *) xmalloc (col_sep_length + 1); + col_sep_string = xmalloc (col_sep_length + 1); strcpy (col_sep_string, optarg_S); } @@ -869,7 +869,7 @@ main (int argc, char **argv) n_files = 0; file_names = (argc > 1 - ? (char **) xmalloc ((argc - 1) * sizeof (char *)) + ? xmalloc ((argc - 1) * sizeof (char *)) : NULL); while ((c = getopt_long (argc, argv, short_options, long_options, NULL)) @@ -1302,7 +1302,7 @@ init_parameters (int number_of_files) { if (number_buff != NULL) free (number_buff); - number_buff = (char *) xmalloc (2 * chars_per_number); + number_buff = xmalloc (2 * chars_per_number); } /* Pick the maximum between the tab width and the width of an @@ -1312,7 +1312,7 @@ init_parameters (int number_of_files) to expand a tab which is not an input_tab-char. */ if (clump_buff != NULL) free (clump_buff); - clump_buff = (int *) xmalloc ((chars_per_input_tab > 8 + clump_buff = xmalloc ((chars_per_input_tab > 8 ? chars_per_input_tab : 8) * sizeof (int)); } @@ -1339,7 +1339,7 @@ init_fps (int number_of_files, char **av) if (column_vector != NULLCOL) free ((char *) column_vector); - column_vector = (COLUMN *) xmalloc (columns * sizeof (COLUMN)); + column_vector = xmalloc (columns * sizeof (COLUMN)); if (parallel_files) { @@ -1909,18 +1909,18 @@ init_store_cols (void) if (line_vector != NULL) free ((int *) line_vector); /* FIXME: here's where it was allocated. */ - line_vector = (int *) xmalloc ((total_lines + 1) * sizeof (int *)); + line_vector = xmalloc ((total_lines + 1) * sizeof (int *)); if (end_vector != NULL) free ((int *) end_vector); - end_vector = (int *) xmalloc (total_lines * sizeof (int *)); + end_vector = xmalloc (total_lines * sizeof (int *)); if (buff != NULL) free (buff); buff_allocated = (use_col_separator ? 2 * chars_if_truncate : chars_if_truncate); /* Tune this. */ - buff = (char *) xmalloc (buff_allocated); + buff = xmalloc (buff_allocated); } /* Store all but the rightmost column. @@ -2015,7 +2015,7 @@ store_char (int c) { /* May be too generous. */ buff_allocated = 2 * buff_allocated; - buff = (char *) xrealloc (buff, buff_allocated * sizeof (char)); + buff = xrealloc (buff, buff_allocated * sizeof (char)); } buff[buff_current++] = (char) c; } diff --git a/src/ptx.c b/src/ptx.c index 75c815bfc..cbccb4e86 100644 --- a/src/ptx.c +++ b/src/ptx.c @@ -403,7 +403,7 @@ alloc_and_compile_regex (const char *string) pattern->buffer = NULL; pattern->allocated = 0; pattern->translate = ignore_case ? (char *) folded_chars : NULL; - pattern->fastmap = (char *) xmalloc ((size_t) CHAR_SET_SIZE); + pattern->fastmap = xmalloc ((size_t) CHAR_SET_SIZE); message = re_compile_pattern (string, (int) strlen (string), pattern); if (message) @@ -420,7 +420,7 @@ alloc_and_compile_regex (const char *string) if (pattern->allocated > pattern->used) { pattern->buffer - = (unsigned char *) xrealloc (pattern->buffer, (size_t) pattern->used); + = xrealloc (pattern->buffer, (size_t) pattern->used); pattern->allocated = pattern->used; } @@ -543,7 +543,7 @@ swallow_file_in_memory (const char *file_name, BLOCK *block) { size_t in_memory_size; - block->start = (char *) xmalloc ((size_t) stat_block.st_size); + block->start = xmalloc ((size_t) stat_block.st_size); if ((in_memory_size = read (file_handle, block->start, (size_t) stat_block.st_size)) @@ -557,7 +557,7 @@ swallow_file_in_memory (const char *file_name, BLOCK *block) CR+LF. */ if (in_memory_size != (size_t)-1 && in_memory_size >= stat_block.st_size / 2) - block->start = (char *) xrealloc (block->start, in_memory_size); + block->start = xrealloc (block->start, in_memory_size); else #endif /* not MSDOS */ @@ -567,7 +567,7 @@ swallow_file_in_memory (const char *file_name, BLOCK *block) } else { - block->start = (char *) xmalloc ((size_t) 1 << SWALLOW_REALLOC_LOG); + block->start = xmalloc ((size_t) 1 << SWALLOW_REALLOC_LOG); used_length = 0; allocated_length = (1 << SWALLOW_REALLOC_LOG); @@ -581,7 +581,7 @@ swallow_file_in_memory (const char *file_name, BLOCK *block) { allocated_length += (1 << SWALLOW_REALLOC_LOG); block->start - = (char *) xrealloc (block->start, allocated_length); + = xrealloc (block->start, allocated_length); } } @@ -1267,7 +1267,7 @@ fix_output_parameters (void) reference_max_width = reference_width; } reference_max_width++; - reference.start = (char *) xmalloc ((size_t) reference_max_width + 1); + reference.start = xmalloc ((size_t) reference_max_width + 1); } /* If the reference appears to the left of the output line, reserve some @@ -2090,8 +2090,8 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n"), /* No more argument simply means: read standard input. */ - input_file_name = (const char **) xmalloc (sizeof (const char *)); - file_line_count = (int *) xmalloc (sizeof (int)); + input_file_name = xmalloc (sizeof (const char *)); + file_line_count = xmalloc (sizeof (int)); number_input_files = 1; input_file_name[0] = NULL; } @@ -2099,9 +2099,9 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n"), { number_input_files = argc - optind; input_file_name - = (const char **) xmalloc (number_input_files * sizeof (const char *)); + = xmalloc (number_input_files * sizeof (const char *)); file_line_count - = (int *) xmalloc (number_input_files * sizeof (int)); + = xmalloc (number_input_files * sizeof (int)); for (file_index = 0; file_index < number_input_files; file_index++) { @@ -2119,8 +2119,8 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n"), /* There is one necessary input file. */ number_input_files = 1; - input_file_name = (const char **) xmalloc (sizeof (const char *)); - file_line_count = (int *) xmalloc (sizeof (int)); + input_file_name = xmalloc (sizeof (const char *)); + file_line_count = xmalloc (sizeof (int)); if (!*argv[optind] || strcmp (argv[optind], "-") == 0) input_file_name[0] = NULL; else diff --git a/src/sort.c b/src/sort.c index 3138dcedd..ede496026 100644 --- a/src/sort.c +++ b/src/sort.c @@ -1,5 +1,5 @@ /* sort - sort lines of text (with all kinds of options). - Copyright (C) 88, 1991-2002 Free Software Foundation, Inc. + Copyright (C) 88, 1991-2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -422,7 +422,7 @@ create_temp_file (FILE **pfp) char const *temp_dir = temp_dirs[temp_dir_index]; size_t len = strlen (temp_dir); struct tempnode *node = - (struct tempnode *) xmalloc (sizeof node->next + len + sizeof slashbase); + xmalloc (sizeof node->next + len + sizeof slashbase); char *file = node->name; memcpy (file, temp_dir, len); @@ -572,7 +572,7 @@ inittables (void) s = (char *) nl_langinfo (ABMON_1 + i); s_len = strlen (s); - monthtab[i].name = name = (char *) xmalloc (s_len + 1); + monthtab[i].name = name = xmalloc (s_len + 1); monthtab[i].val = i + 1; for (j = 0; j < s_len; j++) @@ -2001,7 +2001,7 @@ sort (char **files, int nfiles, char const *output_file) { int i = n_temp_files; struct tempnode *node; - char **tempfiles = (char **) xmalloc (n_temp_files * sizeof (char *)); + char **tempfiles = xmalloc (n_temp_files * sizeof (char *)); for (node = temphead; i > 0; node = node->next) tempfiles[--i] = node->name; merge (tempfiles, n_temp_files, NMERGE, output_file); @@ -2147,7 +2147,7 @@ set_ordering (register const char *s, struct keyfield *key, static struct keyfield * new_key (void) { - struct keyfield *key = (struct keyfield *) xcalloc (1, sizeof *key); + struct keyfield *key = xcalloc (1, sizeof *key); key->eword = -1; return key; } @@ -2245,7 +2245,7 @@ main (int argc, char **argv) gkey.numeric = gkey.general_numeric = gkey.month = gkey.reverse = 0; gkey.skipsblanks = gkey.skipeblanks = 0; - files = (char **) xmalloc (sizeof (char *) * argc); + files = xmalloc (sizeof (char *) * argc); for (;;) { diff --git a/src/split.c b/src/split.c index 70a3d9ad7..1b1ff2a7c 100644 --- a/src/split.c +++ b/src/split.c @@ -301,7 +301,7 @@ line_bytes_split (size_t n_bytes) char *bp; int eof = 0; size_t n_buffered = 0; - char *buf = (char *) xmalloc (n_bytes); + char *buf = xmalloc (n_bytes); do { diff --git a/src/su.c b/src/su.c index ae67bf9f3..13b754add 100644 --- a/src/su.c +++ b/src/su.c @@ -1,5 +1,5 @@ /* su for GNU. Run a shell with substitute user and group IDs. - Copyright (C) 1992-2002 Free Software Foundation, Inc. + Copyright (C) 1992-2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -193,7 +193,7 @@ static char * concat (const char *s1, const char *s2, const char *s3) { int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3); - char *result = (char *) xmalloc (len1 + len2 + len3 + 1); + char *result = xmalloc (len1 + len2 + len3 + 1); strcpy (result, s1); strcpy (result + len1, s2); @@ -310,7 +310,7 @@ modify_environment (const struct passwd *pw, const char *shell) /* Leave TERM unchanged. Set HOME, SHELL, USER, LOGNAME, PATH. Unset all other environment variables. */ term = getenv ("TERM"); - environ = (char **) xmalloc (2 * sizeof (char *)); + environ = xmalloc (2 * sizeof (char *)); environ[0] = 0; if (term) xputenv (concat ("TERM", "=", term)); @@ -368,10 +368,10 @@ run_shell (const char *shell, const char *command, char **additional_args) int argno = 1; if (additional_args) - args = (const char **) xmalloc (sizeof (char *) + args = xmalloc (sizeof (char *) * (10 + elements (additional_args))); else - args = (const char **) xmalloc (sizeof (char *) * 10); + args = xmalloc (sizeof (char *) * 10); if (simulate_login) { char *arg0; diff --git a/src/tail.c b/src/tail.c index dad6da484..c5fa75737 100644 --- a/src/tail.c +++ b/src/tail.c @@ -1,5 +1,5 @@ /* tail -- output the last part of file(s) - Copyright (C) 1989, 90, 91, 1995-2002 Free Software Foundation, Inc. + Copyright (C) 1989, 90, 91, 1995-2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -514,10 +514,10 @@ pipe_lines (const char *pretty_filename, int fd, long int n_lines) int errors = 0; int nbytes; /* Size of most recent read */ - first = last = (LBUFFER *) xmalloc (sizeof (LBUFFER)); + first = last = xmalloc (sizeof (LBUFFER)); first->nbytes = first->nlines = 0; first->next = NULL; - tmp = (LBUFFER *) xmalloc (sizeof (LBUFFER)); + tmp = xmalloc (sizeof (LBUFFER)); /* Input is always read into a fresh buffer. */ while ((nbytes = tmp->nbytes = safe_read (fd, tmp->buffer, BUFSIZ)) > 0) @@ -555,7 +555,7 @@ pipe_lines (const char *pretty_filename, int fd, long int n_lines) first = first->next; } else - tmp = (LBUFFER *) xmalloc (sizeof (LBUFFER)); + tmp = xmalloc (sizeof (LBUFFER)); } } @@ -637,10 +637,10 @@ pipe_bytes (const char *pretty_filename, int fd, off_t n_bytes) int total_bytes = 0; /* Total characters in all buffers. */ int errors = 0; - first = last = (CBUFFER *) xmalloc (sizeof (CBUFFER)); + first = last = xmalloc (sizeof (CBUFFER)); first->nbytes = 0; first->next = NULL; - tmp = (CBUFFER *) xmalloc (sizeof (CBUFFER)); + tmp = xmalloc (sizeof (CBUFFER)); /* Input is always read into a fresh buffer. */ while ((tmp->nbytes = safe_read (fd, tmp->buffer, BUFSIZ)) > 0) @@ -672,7 +672,7 @@ pipe_bytes (const char *pretty_filename, int fd, off_t n_bytes) } else { - tmp = (CBUFFER *) xmalloc (sizeof (CBUFFER)); + tmp = xmalloc (sizeof (CBUFFER)); } } } @@ -1641,7 +1641,7 @@ main (int argc, char **argv) file = &dummy_stdin; } - F = (struct File_spec *) xmalloc (n_files * sizeof (F[0])); + F = xmalloc (n_files * sizeof (F[0])); for (i = 0; i < n_files; i++) F[i].name = file[i]; diff --git a/src/tee.c b/src/tee.c index 5c11dccef..fdf99d614 100644 --- a/src/tee.c +++ b/src/tee.c @@ -1,5 +1,5 @@ /* tee - read from standard input and write to standard output and files. - Copyright (C) 85,1990-2002 Free Software Foundation, Inc. + Copyright (C) 85,1990-2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -166,7 +166,7 @@ tee (int nfiles, const char **files) int ret = 0; const char *mode_string = (append ? "a" : "w"); - descriptors = (FILE **) xmalloc ((nfiles + 1) * sizeof (descriptors[0])); + descriptors = xmalloc ((nfiles + 1) * sizeof (descriptors[0])); /* Move all the names `up' one in the argv array to make room for the entry for standard output. This writes into argv[argc]. */ diff --git a/src/tr.c b/src/tr.c index ee21b2f88..5e1761689 100644 --- a/src/tr.c +++ b/src/tr.c @@ -1,5 +1,5 @@ /* tr -- a filter to translate characters - Copyright (C) 91, 1995-2002 Free Software Foundation, Inc. + Copyright (C) 91, 1995-2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -484,8 +484,8 @@ unquote (const unsigned char *s, struct E_string *es) len = strlen ((char *) s); - es->s = (unsigned char *) xmalloc (len); - es->escaped = (int *) xmalloc (len * sizeof (es->escaped[0])); + es->s = xmalloc (len); + es->escaped = xmalloc (len * sizeof (es->escaped[0])); for (i = 0; i < len; i++) es->escaped[i] = 0; @@ -697,7 +697,7 @@ append_normal_char (struct Spec_list *list, unsigned int c) { struct List_element *new; - new = (struct List_element *) xmalloc (sizeof (struct List_element)); + new = xmalloc (sizeof (struct List_element)); new->next = NULL; new->type = RE_NORMAL_CHAR; new->u.normal_char = c; @@ -728,7 +728,7 @@ append_range (struct Spec_list *list, unsigned int first, unsigned int last) free (tmp2); return 1; } - new = (struct List_element *) xmalloc (sizeof (struct List_element)); + new = xmalloc (sizeof (struct List_element)); new->next = NULL; new->type = RE_RANGE; new->u.range.first_char = first; @@ -754,7 +754,7 @@ append_char_class (struct Spec_list *list, char_class = look_up_char_class (char_class_str, len); if (char_class == CC_NO_CLASS) return 1; - new = (struct List_element *) xmalloc (sizeof (struct List_element)); + new = xmalloc (sizeof (struct List_element)); new->next = NULL; new->type = RE_CHAR_CLASS; new->u.char_class = char_class; @@ -775,7 +775,7 @@ append_repeated_char (struct Spec_list *list, unsigned int the_char, { struct List_element *new; - new = (struct List_element *) xmalloc (sizeof (struct List_element)); + new = xmalloc (sizeof (struct List_element)); new->next = NULL; new->type = RE_REPEATED_CHAR; new->u.repeated_char.the_repeated_char = the_char; @@ -799,7 +799,7 @@ append_equiv_class (struct Spec_list *list, if (len != 1) return 1; - new = (struct List_element *) xmalloc (sizeof (struct List_element)); + new = xmalloc (sizeof (struct List_element)); new->next = NULL; new->type = RE_EQUIV_CLASS; new->u.equiv_code = *equiv_class_str; @@ -815,7 +815,7 @@ append_equiv_class (struct Spec_list *list, static unsigned char * xmemdup (const unsigned char *p, size_t len) { - unsigned char *tmp = (unsigned char *) xmalloc (len); + unsigned char *tmp = xmalloc (len); /* Use memcpy rather than strncpy because `p' may contain zero-bytes. */ memcpy (tmp, p, len); @@ -1394,7 +1394,7 @@ static void spec_init (struct Spec_list *spec_list) { spec_list->head = spec_list->tail = - (struct List_element *) xmalloc (sizeof (struct List_element)); + xmalloc (sizeof (struct List_element)); spec_list->head->next = NULL; } diff --git a/src/unexpand.c b/src/unexpand.c index 9c1e751f6..b9e95d972 100644 --- a/src/unexpand.c +++ b/src/unexpand.c @@ -123,8 +123,7 @@ add_tabstop (int tabval) if (tabval == -1) return; if (first_free_tab % TABLIST_BLOCK == 0) - tab_list = (int *) xrealloc ((char *) tab_list, - first_free_tab + TABLIST_BLOCK); + tab_list = xrealloc (tab_list, first_free_tab + TABLIST_BLOCK); tab_list[first_free_tab++] = tabval; } diff --git a/src/users.c b/src/users.c index 341c5c06d..67f8f4110 100644 --- a/src/users.c +++ b/src/users.c @@ -1,5 +1,5 @@ /* GNU's users. - Copyright (C) 1992-2002 Free Software Foundation, Inc. + Copyright (C) 1992-2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -58,7 +58,7 @@ list_entries_users (int n, const STRUCT_UTMP *this) int n_entries; n_entries = 0; - u = (char **) xmalloc (n * sizeof (u[0])); + u = xmalloc (n * sizeof (u[0])); for (i = 0; i < n; i++) { if (UT_USER (this) [0] -- cgit v1.2.3-54-g00ecf