From 0cc50a21073c6b5cd595aef9df548583b6334a08 Mon Sep 17 00:00:00 2001 From: aph Date: Mon, 18 Nov 2002 15:46:34 +0000 Subject: [PATCH] 2002-11-14 Jens-Michael Hoffmann * buffer.c: Remove unnecessary casts. * check-init.c: Likewise. * class.c: Likewise. * constants.c: Likewise. * decl.c: Likewise. * except.c: Likewise. * gjavah.c: Likewise. * jcf-io.c: Likewise. * jcf-parse.c: Likewise. * jcf-path.c: Likewise. * jvspec.c: Likewise. * lang.c: Likewise. * lex.c: Likewise. * verify.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@59224 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/java/ChangeLog | 17 +++++++++++++++++ gcc/java/buffer.c | 4 ++-- gcc/java/check-init.c | 2 +- gcc/java/class.c | 9 ++++----- gcc/java/constants.c | 10 ++++------ gcc/java/decl.c | 4 ++-- gcc/java/except.c | 5 ++--- gcc/java/gjavah.c | 24 ++++++++++++------------ gcc/java/jcf-io.c | 4 ++-- gcc/java/jcf-parse.c | 4 ++-- gcc/java/jcf-path.c | 15 +++++++-------- gcc/java/jvspec.c | 8 ++++---- gcc/java/lang.c | 8 ++++---- gcc/java/lex.c | 19 +++++++++---------- gcc/java/verify.c | 2 +- 15 files changed, 73 insertions(+), 62 deletions(-) diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 74bb4e5..d0dd068 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,20 @@ +2002-11-14 Jens-Michael Hoffmann + + * buffer.c: Remove unnecessary casts. + * check-init.c: Likewise. + * class.c: Likewise. + * constants.c: Likewise. + * decl.c: Likewise. + * except.c: Likewise. + * gjavah.c: Likewise. + * jcf-io.c: Likewise. + * jcf-parse.c: Likewise. + * jcf-path.c: Likewise. + * jvspec.c: Likewise. + * lang.c: Likewise. + * lex.c: Likewise. + * verify.c: Likewise. + 2002-11-06 Tom Tromey * gjavah.c (print_stub_or_jni): Include JNIEXPORT and JNICALL in diff --git a/gcc/java/buffer.c b/gcc/java/buffer.c index 74bd5ad..170cc04 100644 --- a/gcc/java/buffer.c +++ b/gcc/java/buffer.c @@ -37,14 +37,14 @@ buffer_grow (bufp, size) { if (size < 120) size = 120; - bufp->data = (unsigned char*) xmalloc (size); + bufp->data = xmalloc (size); bufp->ptr = bufp->data; } else { int index = bufp->ptr - bufp->data; size += 2 * (bufp->limit - bufp->data); - bufp->data = (unsigned char *) xrealloc (bufp->data, size); + bufp->data = xrealloc (bufp->data, size); bufp->ptr = bufp->data + index; } bufp->limit = bufp->data + size; diff --git a/gcc/java/check-init.c b/gcc/java/check-init.c index e022376..6495a78 100644 --- a/gcc/java/check-init.c +++ b/gcc/java/check-init.c @@ -108,7 +108,7 @@ static tree get_variable_decl PARAMS ((tree)); static void final_assign_error PARAMS ((tree)); static void check_final_reassigned PARAMS ((tree, words)); -#define ALLOC_WORDS(NUM) ((word*) xmalloc ((NUM) * sizeof (word))) +#define ALLOC_WORDS(NUM) (xmalloc ((NUM) * sizeof (word))) #define FREE_WORDS(PTR) (free (PTR)) /* DECLARE_BUFFERS is used to allocate NUMBUFFER bit sets, each of diff --git a/gcc/java/class.c b/gcc/java/class.c index db4470c..5df0ffc 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -150,7 +150,7 @@ add_assume_compiled (ident, excludep) { assume_compiled_node *parent; assume_compiled_node *node = - (assume_compiled_node *) xmalloc (sizeof (assume_compiled_node)); + xmalloc (sizeof (assume_compiled_node)); node->ident = xstrdup (ident); node->excludep = excludep; @@ -160,8 +160,7 @@ add_assume_compiled (ident, excludep) if (NULL == assume_compiled_tree) { - assume_compiled_tree = - (assume_compiled_node *) xmalloc (sizeof (assume_compiled_node)); + assume_compiled_tree = xmalloc (sizeof (assume_compiled_node)); assume_compiled_tree->ident = ""; assume_compiled_tree->excludep = 0; assume_compiled_tree->sibling = NULL; @@ -232,7 +231,7 @@ ident_subst (old_name, old_length, prefix, old_char, new_char, suffix) #ifdef __GNUC__ char buffer[i]; #else - char *buffer = (char *)alloca (i); + char *buffer = alloca (i); #endif strcpy (buffer, prefix); for (i = 0; i < old_length; i++) @@ -613,7 +612,7 @@ add_method_1 (this_class, access_flags, name, function_type) DECL_CONTEXT (fndecl) = this_class; DECL_LANG_SPECIFIC (fndecl) - = (struct lang_decl *) ggc_alloc_cleared (sizeof (struct lang_decl)); + = ggc_alloc_cleared (sizeof (struct lang_decl)); DECL_LANG_SPECIFIC (fndecl)->desc = LANG_DECL_FUNC; /* Initialize the static initializer test table. */ diff --git a/gcc/java/constants.c b/gcc/java/constants.c index 83c2e55..23f9957 100644 --- a/gcc/java/constants.c +++ b/gcc/java/constants.c @@ -47,8 +47,8 @@ set_constant_entry (cpool, index, tag, value) if (cpool->data == NULL) { cpool->capacity = 100; - cpool->tags = (uint8*) xmalloc (sizeof(uint8) * cpool->capacity); - cpool->data = (jword*) xmalloc (sizeof(jword) * cpool->capacity); + cpool->tags = xmalloc (sizeof(uint8) * cpool->capacity); + cpool->data = xmalloc (sizeof(jword) * cpool->capacity); cpool->count = 1; } if (index >= cpool->capacity) @@ -56,10 +56,8 @@ set_constant_entry (cpool, index, tag, value) cpool->capacity *= 2; if (index >= cpool->capacity) cpool->capacity = index + 10; - cpool->tags = (uint8*) xrealloc (cpool->tags, - sizeof(uint8) * cpool->capacity); - cpool->data = (jword*) xrealloc (cpool->data, - sizeof(jword) * cpool->capacity); + cpool->tags = xrealloc (cpool->tags, sizeof(uint8) * cpool->capacity); + cpool->data = xrealloc (cpool->data, sizeof(jword) * cpool->capacity); } if (index >= cpool->count) cpool->count = index + 1; diff --git a/gcc/java/decl.c b/gcc/java/decl.c index 3d3665b..bcf30b3 100644 --- a/gcc/java/decl.c +++ b/gcc/java/decl.c @@ -1183,7 +1183,7 @@ static struct binding_level * make_binding_level () { /* NOSTRICT */ - return (struct binding_level *) xmalloc (sizeof (struct binding_level)); + return xmalloc (sizeof (struct binding_level)); } void @@ -1778,7 +1778,7 @@ start_java_method (fndecl) i = DECL_MAX_LOCALS(fndecl) + DECL_MAX_STACK(fndecl); decl_map = make_tree_vec (i); - type_map = (tree *) xrealloc (type_map, i * sizeof (tree)); + type_map = xrealloc (type_map, i * sizeof (tree)); #if defined(DEBUG_JAVA_BINDING_LEVELS) fprintf (stderr, "%s:\n", lang_printable_name (fndecl, 2)); diff --git a/gcc/java/except.c b/gcc/java/except.c index 614587d..0de4c8a 100644 --- a/gcc/java/except.c +++ b/gcc/java/except.c @@ -153,8 +153,7 @@ link_handler (range, outer) /* Handle overlapping ranges by splitting the new range. */ if (range->start_pc < outer->start_pc || range->end_pc > outer->end_pc) { - struct eh_range *h - = (struct eh_range *) xmalloc (sizeof (struct eh_range)); + struct eh_range *h = xmalloc (sizeof (struct eh_range)); if (range->start_pc < outer->start_pc) { h->start_pc = range->start_pc; @@ -286,7 +285,7 @@ add_handler (start_pc, end_pc, handler, type) prev = ptr; } - h = (struct eh_range *) xmalloc (sizeof (struct eh_range)); + h = xmalloc (sizeof (struct eh_range)); h->start_pc = start_pc; h->end_pc = end_pc; h->first_child = NULL; diff --git a/gcc/java/gjavah.c b/gcc/java/gjavah.c index 1e8c701..0c9d249 100644 --- a/gcc/java/gjavah.c +++ b/gcc/java/gjavah.c @@ -834,13 +834,13 @@ DEFUN(print_method_info, (stream, jcf, name_index, sig_index, flags), { struct method_name *nn; - nn = (struct method_name *) xmalloc (sizeof (struct method_name)); - nn->name = (char *) xmalloc (length); + nn = xmalloc (sizeof (struct method_name)); + nn->name = xmalloc (length); memcpy (nn->name, str, length); nn->length = length; nn->next = method_name_list; nn->sig_length = JPOOL_UTF_LENGTH (jcf, sig_index); - nn->signature = (char *) xmalloc (nn->sig_length); + nn->signature = xmalloc (nn->sig_length); memcpy (nn->signature, JPOOL_UTF_DATA (jcf, sig_index), nn->sig_length); method_name_list = nn; @@ -1151,7 +1151,7 @@ throwable_p (clname) for (length = 0; clname[length] != ';' && clname[length] != '\0'; ++length) ; - current = (unsigned char *) ALLOC (length); + current = ALLOC (length); for (i = 0; i < length; ++i) current[i] = clname[i] == '/' ? '.' : clname[i]; current[length] = '\0'; @@ -1189,7 +1189,7 @@ throwable_p (clname) jcf_parse_class (&jcf); tmp = (unsigned char *) super_class_name (&jcf, &super_length); - super = (unsigned char *) ALLOC (super_length + 1); + super = ALLOC (super_length + 1); memcpy (super, tmp, super_length); super[super_length] = '\0'; @@ -1733,7 +1733,7 @@ print_include (out, utf8, len) return; } - incl = (struct include *) xmalloc (sizeof (struct include)); + incl = xmalloc (sizeof (struct include)); incl->name = xmalloc (len + 1); strncpy (incl->name, utf8, len); incl->name[len] = '\0'; @@ -1820,7 +1820,7 @@ add_namelet (name, name_limit, parent) if (n == NULL) { - n = (struct namelet *) xmalloc (sizeof (struct namelet)); + n = xmalloc (sizeof (struct namelet)); n->name = xmalloc (p - name + 1); strncpy (n->name, name, p - name); n->name[p - name] = '\0'; @@ -2376,25 +2376,25 @@ DEFUN(main, (argc, argv), case OPT_PREPEND: if (prepend_count == 0) - prepend_specs = (char**) ALLOC (argc * sizeof (char*)); + prepend_specs = ALLOC (argc * sizeof (char*)); prepend_specs[prepend_count++] = optarg; break; case OPT_FRIEND: if (friend_count == 0) - friend_specs = (char**) ALLOC (argc * sizeof (char*)); + friend_specs = ALLOC (argc * sizeof (char*)); friend_specs[friend_count++] = optarg; break; case OPT_ADD: if (add_count == 0) - add_specs = (char**) ALLOC (argc * sizeof (char*)); + add_specs = ALLOC (argc * sizeof (char*)); add_specs[add_count++] = optarg; break; case OPT_APPEND: if (append_count == 0) - append_specs = (char**) ALLOC (argc * sizeof (char*)); + append_specs = ALLOC (argc * sizeof (char*)); append_specs[append_count++] = optarg; break; @@ -2481,7 +2481,7 @@ DEFUN(main, (argc, argv), { int dir_len = strlen (output_directory); int i, classname_length = strlen (classname); - current_output_file = (char*) ALLOC (dir_len + classname_length + 5); + current_output_file = ALLOC (dir_len + classname_length + 5); strcpy (current_output_file, output_directory); if (dir_len > 0 && output_directory[dir_len-1] != '/') current_output_file[dir_len++] = '/'; diff --git a/gcc/java/jcf-io.c b/gcc/java/jcf-io.c index a1af70a..7b0eaca 100644 --- a/gcc/java/jcf-io.c +++ b/gcc/java/jcf-io.c @@ -455,10 +455,10 @@ DEFUN(find_class, (classname, classname_length, jcf, source_ok), /* Allocate and zero out the buffer, since we don't explicitly put a null pointer when we're copying it below. */ buflen = jcf_path_max_len () + classname_length + 10; - buffer = (char *) ALLOC (buflen); + buffer = ALLOC (buflen); memset (buffer, 0, buflen); - java_buffer = (char *) alloca (buflen); + java_buffer = alloca (buflen); jcf->java_source = 0; diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c index 5141119..eeb262a 100644 --- a/gcc/java/jcf-parse.c +++ b/gcc/java/jcf-parse.c @@ -708,7 +708,7 @@ void init_outgoing_cpool () { current_constant_pool_data_ref = NULL_TREE; - outgoing_cpool = (struct CPool *)xmalloc (sizeof (struct CPool)); + outgoing_cpool = xmalloc (sizeof (struct CPool)); memset (outgoing_cpool, 0, sizeof (struct CPool)); } @@ -1059,7 +1059,7 @@ java_parse_file (set_yydebug) fatal_io_error ("can't open %s", IDENTIFIER_POINTER (name)); #ifdef IO_BUFFER_SIZE - setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), + setvbuf (finput, xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE); #endif input_filename = IDENTIFIER_POINTER (name); diff --git a/gcc/java/jcf-path.c b/gcc/java/jcf-path.c index ce05088..c9ed323 100644 --- a/gcc/java/jcf-path.c +++ b/gcc/java/jcf-path.c @@ -143,7 +143,7 @@ add_entry (entp, filename, is_system) int len; struct entry *n; - n = (struct entry *) ALLOC (sizeof (struct entry)); + n = ALLOC (sizeof (struct entry)); n->flags = is_system ? FLAG_SYSTEM : 0; n->next = NULL; @@ -165,7 +165,7 @@ add_entry (entp, filename, is_system) work more easily. Eww. */ if (filename[len - 1] != '/' && filename[len - 1] != DIR_SEPARATOR) { - char *f2 = (char *) alloca (len + 2); + char *f2 = alloca (len + 2); strcpy (f2, filename); f2[len] = DIR_SEPARATOR; f2[len + 1] = '\0'; @@ -191,7 +191,7 @@ add_path (entp, cp, is_system) if (cp) { - char *buf = (char *) alloca (strlen (cp) + 3); + char *buf = alloca (strlen (cp) + 3); startp = endp = cp; while (1) { @@ -299,7 +299,7 @@ jcf_path_init () /* Desperation: use the installed one. */ char *extdirs; add_entry (&sys_dirs, LIBGCJ_ZIP_FILE, 1); - extdirs = (char *) alloca (strlen (LIBGCJ_ZIP_FILE) + 1); + extdirs = alloca (strlen (LIBGCJ_ZIP_FILE) + 1); strcpy (extdirs, LIBGCJ_ZIP_FILE); strcpy (&extdirs[strlen (LIBGCJ_ZIP_FILE) - strlen ("libgcj-" DEFAULT_TARGET_VERSION ".jar")], @@ -346,7 +346,7 @@ jcf_path_extdirs_arg (cp) if (cp) { - char *buf = (char *) alloca (strlen (cp) + 3); + char *buf = alloca (strlen (cp) + 3); startp = endp = cp; while (1) { @@ -375,9 +375,8 @@ jcf_path_extdirs_arg (cp) if (direntp->d_name[0] != '.') { - char *name = - (char *) alloca (dirname_length - + strlen (direntp->d_name) + 2); + char *name = alloca (dirname_length + + strlen (direntp->d_name) + 2); strcpy (name, buf); if (name[dirname_length-1] != DIR_SEPARATOR) { diff --git a/gcc/java/jvspec.c b/gcc/java/jvspec.c index e531f7c..8638ac3 100644 --- a/gcc/java/jvspec.c +++ b/gcc/java/jvspec.c @@ -88,8 +88,8 @@ find_spec_file (dir) int x; struct stat sb; - spec = (char *) xmalloc (strlen (dir) + sizeof (SPEC_FILE) - + sizeof ("-specs=") + 4); + spec = xmalloc (strlen (dir) + sizeof (SPEC_FILE) + + sizeof ("-specs=") + 4); strcpy (spec, "-specs="); x = strlen (spec); strcat (spec, dir); @@ -251,7 +251,7 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries) argv = *in_argv; added_libraries = *in_added_libraries; - args = (int *) xcalloc (argc, sizeof (int)); + args = xcalloc (argc, sizeof (int)); for (i = 1; i < argc; i++) { @@ -496,7 +496,7 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries) num_args += shared_libgcc; - arglist = (const char **) xmalloc ((num_args + 1) * sizeof (char *)); + arglist = xmalloc ((num_args + 1) * sizeof (char *)); j = 0; for (i = 0; i < argc; i++, j++) diff --git a/gcc/java/lang.c b/gcc/java/lang.c index ca97f02..0d9605c 100644 --- a/gcc/java/lang.c +++ b/gcc/java/lang.c @@ -559,8 +559,8 @@ java_init (filename) error ("couldn't determine target name for dependency tracking"); else { - char *buf = (char *) xmalloc (dot - filename + - 3 + sizeof (TARGET_OBJECT_SUFFIX)); + char *buf = xmalloc (dot - filename + + 3 + sizeof (TARGET_OBJECT_SUFFIX)); strncpy (buf, filename, dot - filename); /* If emitting class files, we might have multiple @@ -633,12 +633,12 @@ put_decl_string (str, len) if (decl_buf == NULL) { decl_buflen = len + 100; - decl_buf = (char *) xmalloc (decl_buflen); + decl_buf = xmalloc (decl_buflen); } else { decl_buflen *= 2; - decl_buf = (char *) xrealloc (decl_buf, decl_buflen); + decl_buf = xrealloc (decl_buf, decl_buflen); } } strcpy (decl_buf + decl_bufpos, str); diff --git a/gcc/java/lex.c b/gcc/java/lex.c index 6c7866c..f1589db 100644 --- a/gcc/java/lex.c +++ b/gcc/java/lex.c @@ -128,8 +128,8 @@ java_init_lex (finput, encoding) CPC_INITIALIZER_LIST (ctxp) = CPC_STATIC_INITIALIZER_LIST (ctxp) = CPC_INSTANCE_INITIALIZER_LIST (ctxp) = NULL_TREE; - memset ((PTR) ctxp->modifier_ctx, 0, sizeof (ctxp->modifier_ctx)); - memset ((PTR) current_jcf, 0, sizeof (JCF)); + memset (ctxp->modifier_ctx, 0, sizeof (ctxp->modifier_ctx)); + memset (current_jcf, 0, sizeof (JCF)); ctxp->current_parsed_class = NULL; ctxp->package = NULL_TREE; #endif @@ -196,12 +196,11 @@ java_allocate_new_line () if (!ctxp->c_line) { - ctxp->c_line = (struct java_line *)xmalloc (sizeof (struct java_line)); + ctxp->c_line = xmalloc (sizeof (struct java_line)); ctxp->c_line->max = JAVA_LINE_MAX; - ctxp->c_line->line = (unicode_t *)xmalloc - (sizeof (unicode_t)*ctxp->c_line->max); + ctxp->c_line->line = xmalloc (sizeof (unicode_t)*ctxp->c_line->max); ctxp->c_line->unicode_escape_p = - (char *)xmalloc (sizeof (char)*ctxp->c_line->max); + xmalloc (sizeof (char)*ctxp->c_line->max); ctxp->c_line->white_space_only = 0; } @@ -226,7 +225,7 @@ java_new_lexer (finput, encoding) FILE *finput; const char *encoding; { - java_lexer *lex = (java_lexer *) xmalloc (sizeof (java_lexer)); + java_lexer *lex = xmalloc (sizeof (java_lexer)); int enc_error = 0; lex->finput = finput; @@ -522,9 +521,9 @@ java_store_unicode (l, c, unicode_escape_p) if (l->size == l->max) { l->max += JAVA_LINE_MAX; - l->line = (unicode_t *) xrealloc (l->line, sizeof (unicode_t)*l->max); - l->unicode_escape_p = (char *) xrealloc (l->unicode_escape_p, - sizeof (char)*l->max); + l->line = xrealloc (l->line, sizeof (unicode_t)*l->max); + l->unicode_escape_p = xrealloc (l->unicode_escape_p, + sizeof (char)*l->max); } l->line [l->size] = c; l->unicode_escape_p [l->size++] = unicode_escape_p; diff --git a/gcc/java/verify.c b/gcc/java/verify.c index 0811168..250e479 100644 --- a/gcc/java/verify.c +++ b/gcc/java/verify.c @@ -449,7 +449,7 @@ verify_jvm_instructions (jcf, byte_ops, length) /* We read the exception handlers in order of increasing start PC. To do this we first read and sort the start PCs. */ - starts = (struct pc_index *) xmalloc (eh_count * sizeof (struct pc_index)); + starts = xmalloc (eh_count * sizeof (struct pc_index)); for (i = 0; i < eh_count; ++i) { starts[i].start_pc = GET_u2 (jcf->read_ptr + 8 * i); -- 2.7.4