* Patch: Fix "string constant to char * conversion" warnings
@ 2006-02-08 20:35 Bryce McKinlay
0 siblings, 0 replies; only message in thread
From: Bryce McKinlay @ 2006-02-08 20:35 UTC (permalink / raw)
To: Java Patches
[-- Attachment #1: Type: text/plain, Size: 126 bytes --]
This patch fixes a bunch of conversion warnings encountered while
building libgcj. I'm checking it in to the trunk.
Bryce
[-- Attachment #2: libjava-const-char-warnings.patch --]
[-- Type: text/x-patch, Size: 10152 bytes --]
2006-02-08 Bryce McKinlay <mckinlay@redhat.com>
* link.cc (_Jv_Linker::print_class_loaded): Declare string constants
as "const char *".
* verify.cc (verify_fail): Likewise.
* gnu/classpath/natSystemProperties.cc (file_encoding): Likewise.
* interpret.cc (throw_internal_error, throw_class_format_error):
Likewise.
* gcj/javaprims.h (_Jv_hashUtf8String, _Jv_Utf8Const::space_needed,
_Jv_Utf8Const::init, _Jv_makeUtf8Const): Likewise.
* java/lang/Class.h (_Jv_InitPrimClass): Likewise.
* include/jvm.h (_Jv_strLengthUtf8, _Jv_makeUtf8Const): Likewise.
* defineclass.cc (throw_internal_error, throw_no_class_def_found_error,
is_attribute_name): Likewise.
* prims.cc (_Jv_strLengthUtf8, _Jv_hashUtf8String, _Jv_Utf8Const::init,
_Jv_makeUtf8Const, _Jv_InitPrimClass): Likewise.
Index: link.cc
===================================================================
--- link.cc (revision 110757)
+++ link.cc (working copy)
@@ -1832,9 +1832,9 @@
}
}
if (codesource == NULL)
- codesource = "<no code source>";
+ codesource = (char *) "<no code source>";
- char *abi;
+ const char *abi;
if (_Jv_IsInterpretedClass (klass))
abi = "bytecode";
else if (_Jv_IsBinaryCompatibilityABI (klass))
Index: verify.cc
===================================================================
--- verify.cc (revision 110757)
+++ verify.cc (working copy)
@@ -206,7 +206,7 @@
return r;
}
- __attribute__ ((__noreturn__)) void verify_fail (char *s, jint pc = -1)
+ __attribute__ ((__noreturn__)) void verify_fail (const char *s, jint pc = -1)
{
using namespace java::lang;
StringBuffer *buf = new StringBuffer ();
Index: gnu/classpath/natSystemProperties.cc
===================================================================
--- gnu/classpath/natSystemProperties.cc (revision 110757)
+++ gnu/classpath/natSystemProperties.cc (working copy)
@@ -62,11 +62,11 @@
#if ! defined (DEFAULT_FILE_ENCODING) && defined (HAVE_ICONV) \
&& defined (HAVE_NL_LANGINFO)
-static char *
+static const char *
file_encoding ()
{
setlocale (LC_CTYPE, "");
- char *e = nl_langinfo (CODESET);
+ const char *e = nl_langinfo (CODESET);
if (e == NULL || *e == '\0')
e = "8859_1";
return e;
@@ -80,7 +80,7 @@
#define DEFAULT_FILE_ENCODING "8859_1"
#endif
-static char *default_file_encoding = DEFAULT_FILE_ENCODING;
+static const char *default_file_encoding = DEFAULT_FILE_ENCODING;
#if HAVE_GETPWUID_R
/* Use overload resolution to find out the signature of getpwuid_r. */
Index: interpret.cc
===================================================================
--- interpret.cc (revision 110757)
+++ interpret.cc (working copy)
@@ -47,7 +47,7 @@
using namespace gcj;
-static void throw_internal_error (char *msg)
+static void throw_internal_error (const char *msg)
__attribute__ ((__noreturn__));
static void throw_incompatible_class_change_error (jstring msg)
__attribute__ ((__noreturn__));
@@ -58,7 +58,7 @@
static void throw_class_format_error (jstring msg)
__attribute__ ((__noreturn__));
-static void throw_class_format_error (char *msg)
+static void throw_class_format_error (const char *msg)
__attribute__ ((__noreturn__));
#ifdef DIRECT_THREADED
@@ -3294,7 +3294,7 @@
}
static void
-throw_internal_error (char *msg)
+throw_internal_error (const char *msg)
{
throw new java::lang::InternalError (JvNewStringLatin1 (msg));
}
@@ -3817,7 +3817,7 @@
}
static void
-throw_class_format_error (char *msg)
+throw_class_format_error (const char *msg)
{
throw_class_format_error (JvNewStringLatin1 (msg));
}
Index: gcj/javaprims.h
===================================================================
--- gcj/javaprims.h (revision 110757)
+++ gcj/javaprims.h (working copy)
@@ -487,7 +487,7 @@
__attribute__((__malloc__));
extern "C" jsize _Jv_GetStringUTFLength (jstring);
extern "C" jsize _Jv_GetStringUTFRegion (jstring, jsize, jsize, char *);
-extern "C" jint _Jv_hashUtf8String (char*, int);
+extern "C" jint _Jv_hashUtf8String (const char*, int);
struct _Jv_VMOption
{
@@ -559,17 +559,17 @@
jstring toString() { return _Jv_NewStringUTF(data); }
/** Given an UTF8 string, how many bytes needed for a UTF8Const,
including struct header, and final NUL. I.e. what to pas to malloc. */
- static int space_needed (char *, int len)
+ static int space_needed (const char *, int len)
{ return sizeof (_Jv_Utf8Const) + len + 1; }
/** Given an allocated _Jv_Utf8Const, copy / fill it in. */
- void init (char *s, int len);
+ void init (const char *s, int len);
friend jboolean _Jv_equalUtf8Consts (const _Jv_Utf8Const*, const _Jv_Utf8Const *);
friend jboolean _Jv_equal (_Jv_Utf8Const*, jstring, jint);
friend jboolean _Jv_equaln (_Jv_Utf8Const*, jstring, jint);
friend jboolean _Jv_equalUtf8Classnames (const _Jv_Utf8Const*,
const _Jv_Utf8Const*);
friend jboolean _Jv_isPrimitiveOrDerived (const _Jv_Utf8Const*);
- friend _Jv_Utf8Const *_Jv_makeUtf8Const (char*, int);
+ friend _Jv_Utf8Const *_Jv_makeUtf8Const (const char*, int);
friend _Jv_Utf8Const *_Jv_makeUtf8Const (jstring);
friend jstring _Jv_NewStringUtf8Const (_Jv_Utf8Const*);
};
Index: java/lang/Class.h
===================================================================
--- java/lang/Class.h (revision 110757)
+++ java/lang/Class.h (working copy)
@@ -261,7 +261,7 @@
void _Jv_InitNewClassFields (jclass klass);
// Friend functions and classes in prims.cc
-void _Jv_InitPrimClass (jclass, char *, char, int);
+void _Jv_InitPrimClass (jclass, const char *, char, int);
jstring _Jv_GetMethodString (jclass, _Jv_Method *, jclass = NULL);
jboolean _Jv_CheckAccess (jclass self_klass, jclass other_klass,
@@ -494,7 +494,7 @@
friend void ::_Jv_InitNewClassFields (jclass klass);
// in prims.cc
- friend void ::_Jv_InitPrimClass (jclass, char *, char, int);
+ friend void ::_Jv_InitPrimClass (jclass, const char *, char, int);
friend jstring (::_Jv_GetMethodString) (jclass, _Jv_Method *, jclass);
Index: include/jvm.h
===================================================================
--- include/jvm.h (revision 110757)
+++ include/jvm.h (working copy)
@@ -131,10 +131,10 @@
? (((PTR)[-3]&0x0F) << 12) + (((PTR)[-2]&0x3F) << 6) + ((PTR)[-1]&0x3F) \
: ((PTR)++, -1))
-extern int _Jv_strLengthUtf8(char* str, int len);
+extern int _Jv_strLengthUtf8(const char* str, int len);
typedef struct _Jv_Utf8Const Utf8Const;
-_Jv_Utf8Const *_Jv_makeUtf8Const (char *s, int len);
+_Jv_Utf8Const *_Jv_makeUtf8Const (const char *s, int len);
_Jv_Utf8Const *_Jv_makeUtf8Const (jstring string);
extern jboolean _Jv_equalUtf8Consts (const _Jv_Utf8Const *, const _Jv_Utf8Const *);
extern jboolean _Jv_equal (_Jv_Utf8Const *, jstring, jint);
Index: defineclass.cc
===================================================================
--- defineclass.cc (revision 110757)
+++ defineclass.cc (working copy)
@@ -47,11 +47,11 @@
// these go in some separate functions, to avoid having _Jv_InitClass
// inserted all over the place.
-static void throw_internal_error (char *msg)
+static void throw_internal_error (const char *msg)
__attribute__ ((__noreturn__));
static void throw_no_class_def_found_error (jstring msg)
__attribute__ ((__noreturn__));
-static void throw_no_class_def_found_error (char *msg)
+static void throw_no_class_def_found_error (const char *msg)
__attribute__ ((__noreturn__));
static void throw_class_format_error (jstring msg)
__attribute__ ((__noreturn__));
@@ -258,10 +258,10 @@
void read_one_method_attribute (int method);
void read_one_code_attribute (int method);
void read_one_field_attribute (int field);
- void throw_class_format_error (char *msg);
+ void throw_class_format_error (const char *msg);
/** check an utf8 entry, without creating a Utf8Const object */
- bool is_attribute_name (int index, char *name);
+ bool is_attribute_name (int index, const char *name);
/** here goes the class-loader members defined out-of-line */
void handleConstantPool ();
@@ -470,7 +470,7 @@
}
bool
-_Jv_ClassReader::is_attribute_name (int index, char *name)
+_Jv_ClassReader::is_attribute_name (int index, const char *name)
{
check_tag (index, JV_CONSTANT_Utf8);
int len = get2u (bytes+offsets[index]);
@@ -1421,7 +1421,7 @@
}
}
-void _Jv_ClassReader::throw_class_format_error (char *msg)
+void _Jv_ClassReader::throw_class_format_error (const char *msg)
{
jstring str;
if (def->name != NULL)
@@ -1463,7 +1463,7 @@
}
static void
-throw_no_class_def_found_error (char *msg)
+throw_no_class_def_found_error (const char *msg)
{
throw_no_class_def_found_error (JvNewStringLatin1 (msg));
}
@@ -1477,7 +1477,7 @@
}
static void
-throw_internal_error (char *msg)
+throw_internal_error (const char *msg)
{
throw new java::lang::InternalError (JvNewStringLatin1 (msg));
}
Index: prims.cc
===================================================================
--- prims.cc (revision 110757)
+++ prims.cc (working copy)
@@ -353,7 +353,7 @@
/* Count the number of Unicode chars encoded in a given Ut8 string. */
int
-_Jv_strLengthUtf8(char* str, int len)
+_Jv_strLengthUtf8(const char* str, int len)
{
unsigned char* ptr;
unsigned char* limit;
@@ -374,7 +374,7 @@
* This returns the same hash value as specified or java.lang.String.hashCode.
*/
jint
-_Jv_hashUtf8String (char* str, int len)
+_Jv_hashUtf8String (const char* str, int len)
{
unsigned char* ptr = (unsigned char*) str;
unsigned char* limit = ptr + len;
@@ -391,7 +391,7 @@
}
void
-_Jv_Utf8Const::init(char *s, int len)
+_Jv_Utf8Const::init(const char *s, int len)
{
::memcpy (data, s, len);
data[len] = 0;
@@ -400,7 +400,7 @@
}
_Jv_Utf8Const *
-_Jv_makeUtf8Const (char* s, int len)
+_Jv_makeUtf8Const (const char* s, int len)
{
if (len < 0)
len = strlen (s);
@@ -794,7 +794,7 @@
DECLARE_PRIM_TYPE(void)
void
-_Jv_InitPrimClass (jclass cl, char *cname, char sig, int len)
+_Jv_InitPrimClass (jclass cl, const char *cname, char sig, int len)
{
using namespace java::lang::reflect;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-02-08 20:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-08 20:35 Patch: Fix "string constant to char * conversion" warnings Bryce McKinlay
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).