commit-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

fix const/non-const warnings in jcl.c, jcl.h


From: Steven Augart
Subject: fix const/non-const warnings in jcl.c, jcl.h
Date: Mon, 21 Jun 2004 13:38:25 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031007


--
Steven Augart

Jikes RVM, a free, open source, Virtual Machine:
http://oss.software.ibm.com/jikesrvm
Due to the massive re-indentation changes, I've made this patch by
giving diff the "-w" flag.  

2004-06-20  Steven Augart <address@hidden>

        * native/jni/classpath/jcl.c, native/jni/classpath/jcl.h
        (JCL_FindClass): Fixed const/non-const warning in function prototype.
        (JCL_ThrowException): Ditto.
        (JCL_free_cstring): Fixed logical const/non-const problem in
        function prototype.

        * native/jni/classpath/jcl.c: Reformatted according to GNU standards.

Index: native/jni/classpath/jcl.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/classpath/jcl.c,v
retrieving revision 1.8
diff -I*.class -w -u -r1.8 jcl.c
--- native/jni/classpath/jcl.c  29 Mar 2004 07:07:26 -0000      1.8
+++ native/jni/classpath/jcl.c  21 Jun 2004 17:35:11 -0000
@@ -46,18 +46,26 @@
 #define __attribute__(x) /* nothing */
 #endif
 
-JNIEXPORT void JNICALL JCL_ThrowException(JNIEnv * env, char * className, char 
* errMsg) {
+
+JNIEXPORT void JNICALL
+JCL_ThrowException (JNIEnv * env, const char *className, const char *errMsg)
+{
        jclass excClass;
-       if((*env)->ExceptionOccurred(env)) {
+  if ((*env)->ExceptionOccurred (env))
+    {
                (*env)->ExceptionClear(env);
        }
        excClass = (*env)->FindClass(env, className);
-       if(excClass == NULL) {
+  if (excClass == NULL)
+    {
                jclass errExcClass;
-               errExcClass = (*env)->FindClass(env, 
"java/lang/ClassNotFoundException");
-               if(errExcClass == NULL) {
+      errExcClass =
+       (*env)->FindClass (env, "java/lang/ClassNotFoundException");
+      if (errExcClass == NULL)
+       {
                        errExcClass = (*env)->FindClass(env, 
"java/lang/InternalError");
-                       if(errExcClass == NULL) {
+         if (errExcClass == NULL)
+           {
                                fprintf(stderr, "JCL: Utterly failed to throw 
exeption ");
                                fprintf(stderr, className);
                                fprintf(stderr, " with message ");
@@ -65,9 +73,9 @@
                                return;
                        }
                }
-               /* Removed this (more comprehensive) error string to avoid the 
need for a 
-                * static variable or allocation of a buffer for this message 
in this (unlikely) 
-                * error case. --Fridi. 
+      /* Removed this (more comprehensive) error string to avoid the need for
+       * a static variable or allocation of a buffer for this message in this
+       * (unlikely) error case. --Fridi. 
                 *
                 * sprintf(errstr,"JCL: Failed to throw exception %s with 
message %s: could not find exception class.", className, errMsg); 
                 */
@@ -76,16 +84,23 @@
        (*env)->ThrowNew(env, excClass, errMsg);
 }
 
-JNIEXPORT void * JNICALL JCL_malloc(JNIEnv * env, size_t size) {
+
+JNIEXPORT void *JNICALL
+JCL_malloc (JNIEnv * env, size_t size)
+{
        void * mem = malloc(size);
-       if(mem == NULL) {
-               JCL_ThrowException(env, "java/lang/OutOfMemoryError", "malloc() 
failed.");
+  if (mem == NULL)
+    {
+      JCL_ThrowException (env, "java/lang/OutOfMemoryError",
+                         "malloc() failed.");
                return NULL;
        }
        return mem;
 }
 
-JNIEXPORT void * JNICALL JCL_realloc(JNIEnv *env, void *ptr, size_t size)
+
+JNIEXPORT void *JNICALL
+JCL_realloc (JNIEnv * env, void *ptr, size_t size)
 {
   ptr = realloc(ptr, size);
   if (ptr == 0)
@@ -97,51 +112,77 @@
   return(ptr);
 }
 
-JNIEXPORT void JNICALL JCL_free(JNIEnv * env __attribute__((unused)),
-                               void * p)
+
+JNIEXPORT void JNICALL
+JCL_free (JNIEnv * env __attribute__ ((unused)), void *p)
+{
+  if (p != NULL)
 {
-       if(p != NULL) {
                free(p);
        }
 }
 
-JNIEXPORT const char * JNICALL JCL_jstring_to_cstring(JNIEnv * env, jstring s) 
{
+
+JNIEXPORT const char *JNICALL
+JCL_jstring_to_cstring (JNIEnv * env, jstring s)
+{
        const char* cstr;
-       if(s == NULL) {
-               JCL_ThrowException(env, "java/lang/NullPointerException","Null 
string");
+  if (s == NULL)
+    {
+      JCL_ThrowException (env, "java/lang/NullPointerException",
+                         "Null string");
                return NULL;
        }
        cstr = (const char*)(*env)->GetStringUTFChars(env, s, NULL);
-       if(cstr == NULL) {
-               JCL_ThrowException(env, "java/lang/InternalError", 
"GetStringUTFChars() failed.");
+  if (cstr == NULL)
+    {
+      JCL_ThrowException (env, "java/lang/InternalError",
+                         "GetStringUTFChars() failed.");
                return NULL;
        }
        return cstr;
 }
 
-JNIEXPORT void JNICALL JCL_free_cstring(JNIEnv * env, jstring s, const char * 
cstr) {
+
+JNIEXPORT void JNICALL
+JCL_free_cstring (JNIEnv * env, jstring s, char *cstr)
+{
        (*env)->ReleaseStringUTFChars(env, s, cstr);
 }
 
-JNIEXPORT jint JNICALL JCL_MonitorEnter(JNIEnv * env, jobject o) {
+
+JNIEXPORT jint JNICALL
+JCL_MonitorEnter (JNIEnv * env, jobject o)
+{
        jint retval = (*env)->MonitorEnter(env,o);
-       if(retval != 0) {
-               JCL_ThrowException(env, "java/lang/InternalError", 
"MonitorEnter() failed.");
+  if (retval != 0)
+    {
+      JCL_ThrowException (env, "java/lang/InternalError",
+                         "MonitorEnter() failed.");
        }
        return retval;
 }
 
-JNIEXPORT jint JNICALL JCL_MonitorExit(JNIEnv * env, jobject o) {
+
+JNIEXPORT jint JNICALL
+JCL_MonitorExit (JNIEnv * env, jobject o)
+{
        jint retval = (*env)->MonitorExit(env,o);
-       if(retval != 0) {
-               JCL_ThrowException(env, "java/lang/InternalError", 
"MonitorExit() failed.");
+  if (retval != 0)
+    {
+      JCL_ThrowException (env, "java/lang/InternalError",
+                         "MonitorExit() failed.");
        }
        return retval;
 }
 
-JNIEXPORT jclass JNICALL JCL_FindClass(JNIEnv * env, char * className) {
+
+JNIEXPORT jclass JNICALL
+JCL_FindClass (JNIEnv * env, const char *className)
+{
        jclass retval = (*env)->FindClass(env,className);
-       if(retval == NULL) {
+  if (retval == NULL)
+    {
                JCL_ThrowException(env, "java/lang/ClassNotFoundException", 
className);
        }
        return retval;
Index: native/jni/classpath/jcl.h
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/classpath/jcl.h,v
retrieving revision 1.6
diff -I*.class -w -u -r1.6 jcl.h
--- native/jni/classpath/jcl.h  29 Mar 2004 07:07:26 -0000      1.6
+++ native/jni/classpath/jcl.h  21 Jun 2004 17:35:11 -0000
@@ -48,7 +48,7 @@
 JNIEXPORT void * JNICALL JCL_realloc(JNIEnv *env, void *ptr, size_t size);
 JNIEXPORT void JNICALL JCL_free(JNIEnv *env, void * p);
 JNIEXPORT const char * JNICALL JCL_jstring_to_cstring(JNIEnv *env, jstring s);
-JNIEXPORT void JNICALL JCL_free_cstring(JNIEnv *env, jstring s, const char * 
cstr);
+JNIEXPORT void JNICALL JCL_free_cstring(JNIEnv *env, jstring s, char * cstr);
 JNIEXPORT jint JNICALL JCL_MonitorEnter(JNIEnv *env, jobject o);
 JNIEXPORT jint JNICALL JCL_MonitorExit(JNIEnv *env, jobject o);
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]