From 0e7d217a97d7002639bad1e6af71cc1021a92ed0 Mon Sep 17 00:00:00 2001 From: Mike Stump Date: Sat, 24 Jul 2004 00:03:28 +0000 Subject: [PATCH] boehm.c (set_bit): Improve type safety wrt unsignedness. * boehm.c (set_bit): Improve type safety wrt unsignedness. * gjavah.c (throwable_p, decode_signature_piece, print_full_cxx_name, print_include, add_namelet, add_class_decl, process_file): Likewise. * jcf-dump.c (main): Likewise. * jcf-io.c (read_zip_member): Likewise. * jcf-parse.c (HANDLE_CONSTANT_Utf8, get_constant, give_name_to_class, get_class_constant): Likewise. * jcf-write.c (find_constant_wide, push_long_const, generate_classfile): Likewise. * lex.c (java_new_lexer, java_read_char, cxx_keyword_p): Likewise. * parse.y (read_import_dir): Likewise. * typeck.c (parse_signature_type): Likewise. * verify.c (verify_jvm_instructions): Likewise. * zextract.c (find_zip_file_start, read_zip_archive): Likewise. From-SVN: r85102 --- gcc/java/ChangeLog | 18 ++++++++++++++++++ gcc/java/boehm.c | 4 ++-- gcc/java/gjavah.c | 36 ++++++++++++++++++------------------ gcc/java/jcf-dump.c | 2 +- gcc/java/jcf-io.c | 2 +- gcc/java/jcf-parse.c | 11 ++++++----- gcc/java/jcf-write.c | 17 ++++++++++------- gcc/java/lex.c | 6 +++--- gcc/java/parse.y | 12 ++++++------ gcc/java/typeck.c | 2 +- gcc/java/verify.c | 2 +- gcc/java/zextract.c | 20 ++++++++++---------- 12 files changed, 77 insertions(+), 55 deletions(-) diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index f3daf2981ce..dc1ae7e19e2 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,21 @@ +2004-07-23 Mike Stump + + * boehm.c (set_bit): Improve type safety wrt unsignedness. + * gjavah.c (throwable_p, decode_signature_piece, + print_full_cxx_name, print_include, add_namelet, add_class_decl, + process_file): Likewise. + * jcf-dump.c (main): Likewise. + * jcf-io.c (read_zip_member): Likewise. + * jcf-parse.c (HANDLE_CONSTANT_Utf8, get_constant, + give_name_to_class, get_class_constant): Likewise. + * jcf-write.c (find_constant_wide, push_long_const, + generate_classfile): Likewise. + * lex.c (java_new_lexer, java_read_char, cxx_keyword_p): Likewise. + * parse.y (read_import_dir): Likewise. + * typeck.c (parse_signature_type): Likewise. + * verify.c (verify_jvm_instructions): Likewise. + * zextract.c (find_zip_file_start, read_zip_archive): Likewise. + 2004-07-23 Thomas Fitzsimmons * Make-lang.in: Replace rmic and rmiregistry references with diff --git a/gcc/java/boehm.c b/gcc/java/boehm.c index b806a32af25..00dc4904d5a 100644 --- a/gcc/java/boehm.c +++ b/gcc/java/boehm.c @@ -46,7 +46,7 @@ static void set_bit (unsigned HOST_WIDE_INT *low, unsigned HOST_WIDE_INT *high, unsigned int n) { - HOST_WIDE_INT *which; + unsigned HOST_WIDE_INT *which; if (n >= HOST_BITS_PER_WIDE_INT) { @@ -56,7 +56,7 @@ set_bit (unsigned HOST_WIDE_INT *low, unsigned HOST_WIDE_INT *high, else which = low; - *which |= (HOST_WIDE_INT) 1 << n; + *which |= (unsigned HOST_WIDE_INT) 1 << n; } /* Recursively mark reference fields. */ diff --git a/gcc/java/gjavah.c b/gcc/java/gjavah.c index 6765c161ff3..8f53df192ff 100644 --- a/gcc/java/gjavah.c +++ b/gcc/java/gjavah.c @@ -1144,11 +1144,11 @@ throwable_p (const unsigned char *clname) (htab_del) free); /* Make sure the root classes show up in the tables. */ - str = xstrdup ("java.lang.Throwable"); + str = (unsigned char *) xstrdup ("java.lang.Throwable"); slot = htab_find_slot (throw_hash, str, INSERT); *slot = str; - str = xstrdup ("java.lang.Object"); + str = (unsigned char *) xstrdup ("java.lang.Object"); slot = htab_find_slot (non_throw_hash, str, INSERT); *slot = str; @@ -1175,7 +1175,7 @@ throwable_p (const unsigned char *clname) void **slot; unsigned char *super, *tmp; int super_length = -1; - const char *classfile_name = find_class (current, strlen (current), + const char *classfile_name = find_class ((char *) current, strlen ((const char *) current), &jcf, 0); if (! classfile_name) @@ -1321,10 +1321,10 @@ decode_signature_piece (FILE *stream, const unsigned char *signature, if (flag_jni) { /* We know about certain types and special-case their names. */ - if (! strncmp (signature, "Ljava/lang/String;", + if (! strncmp ((const char *) signature, "Ljava/lang/String;", sizeof ("Ljava/lang/String;") -1)) ctype = "jstring"; - else if (! strncmp (signature, "Ljava/lang/Class;", + else if (! strncmp ((const char *) signature, "Ljava/lang/Class;", sizeof ("Ljava/lang/Class;") - 1)) ctype = "jclass"; /* Skip leading 'L' for throwable_p call. */ @@ -1469,7 +1469,7 @@ print_full_cxx_name (FILE* stream, JCF* jcf, int name_index, int sig_len = JPOOL_UTF_LENGTH (jcf, signature_index); if (overloaded_jni_method_exists_p (JPOOL_UTF_DATA (jcf, name_index), JPOOL_UTF_LENGTH (jcf, name_index), - signature, sig_len)) + (const char *) signature, sig_len)) { /* If this method is overloaded by another native method, then include the argument information in the mangled @@ -1743,19 +1743,19 @@ print_include (FILE *out, const unsigned char *utf8, int len) return; if (len == -1) - len = strlen (utf8); + len = strlen ((const char *) utf8); for (incl = all_includes; incl; incl = incl->next) { /* We check the length because we might have a proper prefix. */ if (len == (int) strlen (incl->name) - && ! strncmp (incl->name, utf8, len)) + && ! strncmp (incl->name, (const char *) utf8, len)) return; } incl = xmalloc (sizeof (struct include)); incl->name = xmalloc (len + 1); - strncpy (incl->name, utf8, len); + strncpy (incl->name, (const char *) utf8, len); incl->name[len] = '\0'; incl->next = all_includes; all_includes = incl; @@ -1814,11 +1814,11 @@ add_namelet (const unsigned char *name, const unsigned char *name_limit, #define JAVAIO "java/io/" #define JAVAUTIL "java/util/" if ((name_limit - name >= (int) sizeof (JAVALANG) - 1 - && ! strncmp (name, JAVALANG, sizeof (JAVALANG) - 1)) + && ! strncmp ((const char *) name, JAVALANG, sizeof (JAVALANG) - 1)) || (name_limit - name >= (int) sizeof (JAVAUTIL) - 1 - && ! strncmp (name, JAVAUTIL, sizeof (JAVAUTIL) - 1)) + && ! strncmp ((const char *) name, JAVAUTIL, sizeof (JAVAUTIL) - 1)) || (name_limit - name >= (int) sizeof (JAVAIO) - 1 - && ! strncmp (name, JAVAIO, sizeof (JAVAIO) - 1))) + && ! strncmp ((const char *) name, JAVAIO, sizeof (JAVAIO) - 1))) return; } @@ -1830,7 +1830,7 @@ add_namelet (const unsigned char *name, const unsigned char *name_limit, { /* We check the length because we might have a proper prefix. */ if ((int) strlen (np->name) == p - name && - ! strncmp (name, np->name, p - name)) + ! strncmp ((const char *) name, np->name, p - name)) { n = np; break; @@ -1841,7 +1841,7 @@ add_namelet (const unsigned char *name, const unsigned char *name_limit, { n = xmalloc (sizeof (struct namelet)); n->name = xmalloc (p - name + 1); - strncpy (n->name, name, p - name); + strncpy (n->name, (const char *) name, p - name); n->name[p - name] = '\0'; n->is_class = (p == name_limit); n->subnamelets = NULL; @@ -1923,7 +1923,7 @@ add_class_decl (FILE *out, JCF *jcf, JCF_u2 signature) /* If we see an array, then we include the array header. */ if (s[i] == '[') { - print_include (out, "gcj/array", -1); + print_include (out, (const unsigned char *) "gcj/array", -1); continue; } @@ -2094,13 +2094,13 @@ process_file (JCF *jcf, FILE *out) for (i = 0; i < len; ++i) name[i] = jcf->classname[i] == '.' ? '/' : jcf->classname[i]; name[i] = '\0'; - print_include (out, name, len); + print_include (out, (const unsigned char *) name, len); free (name); if (! flag_jni) { - print_include (out, "gcj/cni", -1); - print_include (out, "java/lang/UnsupportedOperationException", + print_include (out, (const unsigned char *) "gcj/cni", -1); + print_include (out, (const unsigned char *) "java/lang/UnsupportedOperationException", -1); } } diff --git a/gcc/java/jcf-dump.c b/gcc/java/jcf-dump.c index 3d5f0c513d9..98e5c924898 100644 --- a/gcc/java/jcf-dump.c +++ b/gcc/java/jcf-dump.c @@ -1080,7 +1080,7 @@ main (int argc, char** argv) if (jcf->read_end - jcf->read_ptr < total_length) jcf_trim_old_input (jcf); JCF_FILL (jcf, total_length); - filename = jcf->read_ptr; + filename = (const char *) jcf->read_ptr; JCF_SKIP (jcf, filename_length); JCF_SKIP (jcf, extra_length); if (filename_length > 0 diff --git a/gcc/java/jcf-io.c b/gcc/java/jcf-io.c index 2a22e0a4ca8..0b2109294f4 100644 --- a/gcc/java/jcf-io.c +++ b/gcc/java/jcf-io.c @@ -215,7 +215,7 @@ read_zip_member (JCF *jcf, ZipDirectory *zipd, ZipFile *zipf) jcf->read_ptr = jcf->buffer; jcf->read_end = jcf->buffer_end; buffer = ALLOC (zipd->size); - d_stream.next_in = buffer; + d_stream.next_in = (unsigned char *) buffer; d_stream.avail_in = zipd->size; if (lseek (zipf->fd, zipd->filestart, 0) < 0 || read (zipf->fd, buffer, zipd->size) != (long) zipd->size) diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c index 5a0a87f9b19..4e49b1ffcb1 100644 --- a/gcc/java/jcf-parse.c +++ b/gcc/java/jcf-parse.c @@ -64,7 +64,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */ text = (JCF)->read_ptr; \ save = text[LENGTH]; \ text[LENGTH] = 0; \ - (JCF)->cpool.data[INDEX].t = get_identifier (text); \ + (JCF)->cpool.data[INDEX].t = get_identifier ((const char *) text); \ text[LENGTH] = save; \ JCF_SKIP (JCF, LENGTH); } while (0) @@ -273,7 +273,8 @@ get_constant (JCF *jcf, int index) case CONSTANT_Long: { unsigned HOST_WIDE_INT num = JPOOL_UINT (jcf, index); - HOST_WIDE_INT lo, hi; + unsigned HOST_WIDE_INT lo; + HOST_WIDE_INT hi; lshift_double (num, 0, 32, 64, &lo, &hi, 0); num = JPOOL_UINT (jcf, index+1); add_double (lo, hi, num, 0, &lo, &hi); @@ -411,7 +412,7 @@ give_name_to_class (JCF *jcf, int i) tree this_class; int j = JPOOL_USHORT1 (jcf, i); /* verify_constant_pool confirmed that j is a CONSTANT_Utf8. */ - tree class_name = unmangle_classname (JPOOL_UTF_DATA (jcf, j), + tree class_name = unmangle_classname ((const char *) JPOOL_UTF_DATA (jcf, j), JPOOL_UTF_LENGTH (jcf, j)); this_class = lookup_class (class_name); input_filename = DECL_SOURCE_FILE (TYPE_NAME (this_class)); @@ -439,11 +440,11 @@ get_class_constant (JCF *jcf, int i) { int name_index = JPOOL_USHORT1 (jcf, i); /* verify_constant_pool confirmed that name_index is a CONSTANT_Utf8. */ - const char *name = JPOOL_UTF_DATA (jcf, name_index); + const char *name = (const char *) JPOOL_UTF_DATA (jcf, name_index); int nlength = JPOOL_UTF_LENGTH (jcf, name_index); if (name[0] == '[') /* Handle array "classes". */ - type = TREE_TYPE (parse_signature_string (name, nlength)); + type = TREE_TYPE (parse_signature_string ((const unsigned char *) name, nlength)); else { tree cname = unmangle_classname (name, nlength); diff --git a/gcc/java/jcf-write.c b/gcc/java/jcf-write.c index a73b7be83dc..d775a816ff2 100644 --- a/gcc/java/jcf-write.c +++ b/gcc/java/jcf-write.c @@ -772,7 +772,8 @@ static int find_constant_wide (HOST_WIDE_INT lo, HOST_WIDE_INT hi, struct jcf_partial *state) { - HOST_WIDE_INT w1, w2; + unsigned HOST_WIDE_INT w1; + HOST_WIDE_INT w2; lshift_double (lo, hi, -32, 64, &w1, &w2, 1); return find_constant2 (&state->cpool, CONSTANT_Long, (jword)(w1 & 0xFFFFFFFF), (jword)(lo & 0xFFFFFFFF)); @@ -822,7 +823,8 @@ find_constant_index (tree value, struct jcf_partial *state) static void push_long_const (HOST_WIDE_INT lo, HOST_WIDE_INT hi, struct jcf_partial *state) { - HOST_WIDE_INT highpart, dummy; + unsigned HOST_WIDE_INT highpart; + HOST_WIDE_INT dummy; jint lowpart = WORD_TO_INT (lo); rshift_double (lo, hi, 32, 64, &highpart, &dummy, 1); @@ -833,7 +835,8 @@ push_long_const (HOST_WIDE_INT lo, HOST_WIDE_INT hi, struct jcf_partial *state) OP1(OPCODE_lconst_0 + lowpart); } else if ((highpart == 0 && lowpart > 0 && lowpart < 32768) - || (highpart == -1 && lowpart < 0 && lowpart >= -32768)) + || (highpart == (unsigned HOST_WIDE_INT)-1 + && lowpart < 0 && lowpart >= -32768)) { push_int_const (lowpart, state); RESERVE (1); @@ -2929,11 +2932,11 @@ generate_classfile (tree clas, struct jcf_partial *state) { struct chunk *cpool_chunk; const char *source_file, *s; - char *ptr; + unsigned char *ptr; int i; - char *fields_count_ptr; + unsigned char *fields_count_ptr; int fields_count = 0; - char *methods_count_ptr; + unsigned char *methods_count_ptr; int methods_count = 0; tree part; int total_supers @@ -3079,7 +3082,7 @@ generate_classfile (tree clas, struct jcf_partial *state) int code_attributes_count = 0; static tree Code_node = NULL_TREE; tree t; - char *attr_len_ptr; + unsigned char *attr_len_ptr; struct jcf_handler *handler; if (Code_node == NULL_TREE) Code_node = get_identifier ("Code"); diff --git a/gcc/java/lex.c b/gcc/java/lex.c index de9b2222e0b..77e38f89848 100644 --- a/gcc/java/lex.c +++ b/gcc/java/lex.c @@ -264,7 +264,7 @@ java_new_lexer (FILE *finput, const char *encoding) in[1] = 0xbb; in[2] = 0xbf; - inp = in; + inp = (char *) in; inc = 3; outp = (char *) &result; outc = 2; @@ -377,7 +377,7 @@ java_read_char (java_lexer *lex) in_save = inbytesleft; out_save = out_count; inp = &lex->buffer[lex->first]; - outp = &lex->out_buffer[lex->out_last]; + outp = (char *) &lex->out_buffer[lex->out_last]; ir = iconv (lex->handle, (ICONV_CONST char **) &inp, &inbytesleft, &outp, &out_count); @@ -2031,7 +2031,7 @@ cxx_keyword_p (const char *name, int length) { int kwl = strlen (cxx_keywords[mid]); int min_length = kwl > length ? length : kwl; - int r = utf8_cmp (name, min_length, cxx_keywords[mid]); + int r = utf8_cmp ((const unsigned char *) name, min_length, cxx_keywords[mid]); if (r == 0) { diff --git a/gcc/java/parse.y b/gcc/java/parse.y index 2f41b1b4f3a..63dbf051ef6 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -6901,7 +6901,7 @@ read_import_dir (tree wfl) buffer_grow (filename, entry_length); memcpy (filename->data, entry_name, entry_length - 1); filename->data[entry_length-1] = '\0'; - zipf = opendir_in_zip (filename->data, jcf_path_is_system (entry)); + zipf = opendir_in_zip ((const char *) filename->data, jcf_path_is_system (entry)); if (zipf == NULL) error ("malformed .zip archive in CLASSPATH: %s", entry_name); else @@ -6921,7 +6921,7 @@ read_import_dir (tree wfl) int current_entry_len = zipd->filename_length; if (current_entry_len >= BUFFER_LENGTH (filename) - && strncmp (filename->data, current_entry, + && strncmp ((const char *) filename->data, current_entry, BUFFER_LENGTH (filename)) != 0) continue; found |= note_possible_classname (current_entry, @@ -6933,7 +6933,7 @@ read_import_dir (tree wfl) { BUFFER_RESET (filename); buffer_grow (filename, entry_length + package_length + 4); - strcpy (filename->data, entry_name); + strcpy ((char *) filename->data, entry_name); filename->ptr = filename->data + entry_length; for (k = 0; k < package_length; k++) { @@ -6942,7 +6942,7 @@ read_import_dir (tree wfl) } *filename->ptr = '\0'; - dirp = opendir (filename->data); + dirp = opendir ((const char *) filename->data); if (dirp == NULL) continue; *filename->ptr++ = '/'; @@ -6956,8 +6956,8 @@ read_import_dir (tree wfl) d_name = direntp->d_name; len = strlen (direntp->d_name); buffer_grow (filename, len+1); - strcpy (filename->ptr, d_name); - found |= note_possible_classname (filename->data + entry_length, + strcpy ((char *) filename->ptr, d_name); + found |= note_possible_classname ((const char *) filename->data + entry_length, package_length+len+1); } if (dirp) diff --git a/gcc/java/typeck.c b/gcc/java/typeck.c index 5c38bb842bf..1e1620acf52 100644 --- a/gcc/java/typeck.c +++ b/gcc/java/typeck.c @@ -504,7 +504,7 @@ parse_signature_type (const unsigned char **ptr, const unsigned char *limit) break; } *ptr = str+1; - type = lookup_class (unmangle_classname (start, str - start)); + type = lookup_class (unmangle_classname ((const char *) start, str - start)); break; } default: diff --git a/gcc/java/verify.c b/gcc/java/verify.c index 89b9d95bd57..9eae097bd93 100644 --- a/gcc/java/verify.c +++ b/gcc/java/verify.c @@ -1093,7 +1093,7 @@ verify_jvm_instructions (JCF* jcf, const unsigned char *byte_ops, long length) self_is_interface = CLASS_INTERFACE (TYPE_NAME (self_type)); method_name = COMPONENT_REF_NAME (¤t_jcf->cpool, index); - method_type = parse_signature_string (IDENTIFIER_POINTER (sig), + method_type = parse_signature_string ((const unsigned char *) IDENTIFIER_POINTER (sig), IDENTIFIER_LENGTH (sig)); if (TREE_CODE (method_type) != FUNCTION_TYPE) diff --git a/gcc/java/zextract.c b/gcc/java/zextract.c index ee464124d22..eeea9445795 100644 --- a/gcc/java/zextract.c +++ b/gcc/java/zextract.c @@ -264,7 +264,7 @@ find_zip_file_start (int fd, long offset) if (read (fd, buffer, LREC_SIZE + 4) != LREC_SIZE + 4) return -1; - if (buffer[0] != 'P' || strncmp (&buffer[1], LOCAL_HDR_SIG, 3)) + if (buffer[0] != 'P' || strncmp ((const char *) &buffer[1], LOCAL_HDR_SIG, 3)) return -1; filename_length = makeword (&buffer[4 + L_FILENAME_LENGTH]); @@ -287,8 +287,8 @@ read_zip_archive (ZipFile *zipf) return -1; if (read (zipf->fd, buffer, ECREC_SIZE+4) != ECREC_SIZE+4) return -2; - zipf->count = makeword(&buffer[TOTAL_ENTRIES_CENTRAL_DIR]); - zipf->dir_size = makelong(&buffer[SIZE_CENTRAL_DIRECTORY]); + zipf->count = makeword((const uch *) &buffer[TOTAL_ENTRIES_CENTRAL_DIR]); + zipf->dir_size = makelong((const uch *) &buffer[SIZE_CENTRAL_DIRECTORY]); #define ALLOC xmalloc /* Allocate 1 more to allow appending '\0' to last filename. */ zipf->central_directory = ALLOC (zipf->dir_size+1); @@ -306,9 +306,9 @@ read_zip_archive (ZipFile *zipf) printf ("total_entries_central_dir = %d\n", makeword(&buffer[TOTAL_ENTRIES_CENTRAL_DIR])); printf ("size_central_directory = %d\n", - makelong(&buffer[SIZE_CENTRAL_DIRECTORY])); + makelong((const uch *) &buffer[SIZE_CENTRAL_DIRECTORY])); printf ("offset_start_central_directory = %d\n", - makelong(&buffer[OFFSET_START_CENTRAL_DIRECTORY])); + makelong((const uch *) &buffer[OFFSET_START_CENTRAL_DIRECTORY])); printf ("zipfile_comment_length = %d\n", makeword(&buffer[ZIPFILE_COMMENT_LENGTH])); #endif @@ -319,11 +319,11 @@ read_zip_archive (ZipFile *zipf) { ZipDirectory *zipd = (ZipDirectory*)(dir_ptr + dir_last_pad); int compression_method = (int) dir_ptr[4+C_COMPRESSION_METHOD]; - long size = makelong (&dir_ptr[4+C_COMPRESSED_SIZE]); - long uncompressed_size = makelong (&dir_ptr[4+C_UNCOMPRESSED_SIZE]); - long filename_length = makeword (&dir_ptr[4+C_FILENAME_LENGTH]); - long extra_field_length = makeword (&dir_ptr[4+C_EXTRA_FIELD_LENGTH]); - long file_offset = makelong (&dir_ptr[4+C_RELATIVE_OFFSET_LOCAL_HEADER]); + long size = makelong ((const uch *) &dir_ptr[4+C_COMPRESSED_SIZE]); + long uncompressed_size = makelong ((const uch *) &dir_ptr[4+C_UNCOMPRESSED_SIZE]); + long filename_length = makeword ((const uch *) &dir_ptr[4+C_FILENAME_LENGTH]); + long extra_field_length = makeword ((const uch *) &dir_ptr[4+C_EXTRA_FIELD_LENGTH]); + long file_offset = makelong ((const uch *) &dir_ptr[4+C_RELATIVE_OFFSET_LOCAL_HEADER]); int unpadded_direntry_length; if ((dir_ptr-zipf->central_directory)+filename_length+CREC_SIZE+4>zipf->dir_size) return -1;