[kaffe] CVS kaffe (dalibor): Fixed a few splint warnings

Kaffe CVS cvs-commits at kaffe.org
Thu Jan 22 12:09:02 PST 2004


PatchSet 4362 
Date: 2004/01/22 19:54:21
Author: dalibor
Branch: HEAD
Tag: (none) 
Log:
Fixed a few splint warnings


2004-01-22  Dalibor Topic <robilad at kaffe.org>

        * kaffe/kaffeh/sigs.c:
        (translateSig) Changed type of k to size_t to fix splint
        warning. Explicitely assign '\0' as char.

        * kaffe/kaffevm/file.h:
        (checkBufSize, readu1, readu2, readu4, readm
        seekm) Made sure asserts are performed over
        boolean expressions.

        (readu2, readu4) Added casts to make sure
        shifts happen on a large enough data type.

        * kaffe/kaffevm/systems/unix-jthreads/jthread.h
        Commented meaningless size constant in prototype
        declaration out.

        * kaffe/kaffevm/utf8const.h:
        (utf8ConstEqual, utf8ConstHashValue) Made sure
        asserts are performed over boolean expressions.

        * kaffe/kaffeh/support.c:
        (Kaffe_SystemCallInterface) Added a few missing
        interfaces.
        (initInclude, startInclude, endInclude, initJniInclude
        endJniInclude, addField) Use NULL in FILE* comparisons.
        (jniType) Use EXIT_FAILURE to avoid implementation
        defined behaviour.
        (fprintfJni) Clarified loop condition.
        (setFieldValue) Made sure asserts are performed
        over boolean expressions.
        (setFieldValue) Use '\0' in char comparisons. Use
        NULL in pointer comparisons.
        (finishFields, finishMethods, setupClass)
        Use NULL in pointer comparisons.
        (kaffeh_findClass) Use '\0' in char comparisons.
        Use '\0' in char assignments. Use EXIT_FAILURE to
        avoid implementation defined behaviour.

Members: 
	ChangeLog:1.1947->1.1948 
	kaffe/kaffeh/sigs.c:1.5->1.6 
	kaffe/kaffeh/support.c:1.35->1.36 
	kaffe/kaffevm/file.h:1.4->1.5 
	kaffe/kaffevm/utf8const.h:1.2->1.3 
	kaffe/kaffevm/systems/unix-jthreads/jthread.h:1.49->1.50 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.1947 kaffe/ChangeLog:1.1948
--- kaffe/ChangeLog:1.1947	Thu Jan 22 19:27:20 2004
+++ kaffe/ChangeLog	Thu Jan 22 19:54:21 2004
@@ -1,5 +1,45 @@
 2004-01-22  Dalibor Topic <robilad at kaffe.org>
 
+	* kaffe/kaffeh/sigs.c: 
+	(translateSig) Changed type of k to size_t to fix splint 
+	warning. Explicitely assign '\0' as char.
+
+	* kaffe/kaffevm/file.h:
+	(checkBufSize, readu1, readu2, readu4, readm
+	seekm) Made sure asserts are performed over
+	boolean expressions.
+
+	(readu2, readu4) Added casts to make sure 
+	shifts happen on a large enough data type.
+
+	* kaffe/kaffevm/systems/unix-jthreads/jthread.h
+	Commented meaningless size constant in prototype
+	declaration out.
+
+	* kaffe/kaffevm/utf8const.h:
+	(utf8ConstEqual, utf8ConstHashValue) Made sure
+	asserts are performed over boolean expressions.
+
+	* kaffe/kaffeh/support.c:
+	(Kaffe_SystemCallInterface) Added a few missing 
+	interfaces.
+	(initInclude, startInclude, endInclude, initJniInclude
+	endJniInclude, addField) Use NULL in FILE* comparisons.
+	(jniType) Use EXIT_FAILURE to avoid implementation 
+	defined behaviour.
+	(fprintfJni) Clarified loop condition.
+	(setFieldValue) Made sure asserts are performed 
+	over boolean expressions.
+	(setFieldValue) Use '\0' in char comparisons. Use
+	NULL in pointer comparisons.
+	(finishFields, finishMethods, setupClass) 
+	Use NULL in pointer comparisons.
+	(kaffeh_findClass) Use '\0' in char comparisons.
+	Use '\0' in char assignments. Use EXIT_FAILURE to 
+	avoid implementation defined behaviour.
+	
+2004-01-22  Dalibor Topic <robilad at kaffe.org>
+
 	* config/m68k/netbsd1/jit-md.h:
 	Removed commented out code.
 
Index: kaffe/kaffe/kaffeh/sigs.c
diff -u kaffe/kaffe/kaffeh/sigs.c:1.5 kaffe/kaffe/kaffeh/sigs.c:1.6
--- kaffe/kaffe/kaffeh/sigs.c:1.5	Wed May 29 22:58:43 2002
+++ kaffe/kaffe/kaffeh/sigs.c	Thu Jan 22 19:54:23 2004
@@ -5,6 +5,9 @@
  * Copyright (c) 1996, 1997
  *	Transvirtual Technologies, Inc.  All rights reserved.
  *
+ * Copyright (c) 2004
+ *	Kaffe.org contributors, see ChangeLog for details.  All rights reserved.
+ *
  * See the file "license.terms" for information on usage and redistribution 
  * of this file. 
  */
@@ -24,7 +27,7 @@
 {
 	int j;
 	int arg = 0;
-	int k;
+	size_t k;
 
 	switch (*str++) {
 	case 'L':
@@ -43,7 +46,7 @@
 			}
 		}
 		fp[k] = '*';
-		fp[k+1] = 0;
+		fp[k+1] = '\0';
 		str += j + 1;
 		break;
 	case '[':
Index: kaffe/kaffe/kaffeh/support.c
diff -u kaffe/kaffe/kaffeh/support.c:1.35 kaffe/kaffe/kaffeh/support.c:1.36
--- kaffe/kaffe/kaffeh/support.c:1.35	Sat Jan 10 19:54:15 2004
+++ kaffe/kaffe/kaffeh/support.c	Thu Jan 22 19:54:23 2004
@@ -142,6 +142,12 @@
         NULL,		/* forkexec */
         NULL,		/* waitpid */
         NULL,		/* kill */
+	NULL,           /* mmap */
+        NULL,           /* munmap */
+        NULL,           /* msync */
+        NULL,           /* pipecreate */
+        NULL,           /* piperead */
+        NULL,           /* pipewrite */
 };
 
 
@@ -163,7 +169,7 @@
 void
 initInclude(void)
 {
-	if (include == 0) {
+	if (include == NULL) {
 		return;
 	}
 
@@ -184,7 +190,7 @@
 void
 startInclude(void)
 {
-	if (include == 0) {
+	if (include == NULL) {
 		return;
 	}
 
@@ -209,7 +215,7 @@
 void
 endInclude(void)
 {
-	if (include == 0) {
+	if (include == NULL) {
 		return;
 	}
 
@@ -224,7 +230,7 @@
 void
 initJniInclude(void)
 {
-	if (jni_include == 0) {
+	if (jni_include == NULL) {
 		return;
 	}
 
@@ -248,7 +254,7 @@
 void
 endJniInclude(void)
 {
-	if (jni_include == 0) {
+	if (jni_include == NULL) {
 		return;
 	}
 
@@ -315,7 +321,7 @@
 			return "jobjectArray";
 		default:
 			dprintf("bogus array type `%c'", sig[1]);
-			exit(1);
+			exit(EXIT_FAILURE);
 		}
 	case 'L':
 		if (strncmp(sig, "Ljava/lang/Class;", 17) == 0)
@@ -343,7 +349,7 @@
 		return "void";
 	default:
 		dprintf("bogus signature type `%c'", sig[0]);
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
 }
 
@@ -353,7 +359,7 @@
 static void
 fprintfJni (FILE *f, const char *s) 
 {
-	while (*s && *s != ')')
+	while (*s != '\0' && *s != ')')
 	{
 		switch (*s)
 		{
@@ -402,11 +408,11 @@
 
 	if (CLASS_CONST_TAG(this, name_index) != CONSTANT_Utf8) {
 		dprintf("addField(): no method name.\n"); /* XXX */
-		return (0);
+		return (NULL);
 	}
 	if (CLASS_CONST_TAG(this, signature_index) != CONSTANT_Utf8) {
 		dprintf("addField(): no signature name.\n"); /* XXX */
-		return (0);
+		return (NULL);
 	}
 
 	DBG(CLASSFILE,
@@ -426,7 +432,7 @@
 	f->bsize = 0; /* not used by kaffeh */
 	f->info.idx = 0; /* not used by kaffeh */
 
-	if (include != 0) {
+	if (include != NULL) {
 		/*
 		 * Non-static fields are represented in the struct.
 		 */
@@ -493,19 +499,19 @@
 void
 setFieldValue(Hjava_lang_Class* this, Field* f, u2 idx)
 {
-	assert(f);
+	assert(f != NULL);
 
 	if ((f->accflags & (ACC_STATIC|ACC_PUBLIC|ACC_FINAL)) == (ACC_STATIC|ACC_PUBLIC|ACC_FINAL)) {
 		char cval[512];
 			
 		constValueToString(this, idx, cval, sizeof(cval));
 
-		if (cval[0] != 0) {
-			if (include != 0) {
+		if (cval[0] != '\0') {
+			if (include != NULL) {
 				fprintf(include, "#define %s_%s %s\n",
 					className, f->name->data, cval);
 			}
-			if (jni_include != 0) {
+			if (jni_include != NULL) {
 				fprintf(jni_include, "#define %s_%s %s\n",
 					className, f->name->data, cval);
 			}
@@ -516,7 +522,7 @@
 void
 finishFields(Hjava_lang_Class* this)
 {
-	if (include == 0) {
+	if (include == NULL) {
 		return;
 	}
 
@@ -547,21 +553,21 @@
 	/* If we shouldn't generate method prototypes, quit now */
 	if (objectDepth > 0) {
 		/* XXX set einfo */
-		return 0;
+		return NULL;
 	}
 
-	assert(this);
-	assert(einfo);
+	assert(this != NULL);
+	assert(einfo != NULL);
 
 	cpool = CLASS_CONSTANTS(this);
 
 	if (cpool->tags[name_index] != CONSTANT_Utf8) {
 		dprintf("addMethod(): no method name.\n"); /* XXX */
-		return (0);
+		return (NULL);
 	}
 	if (cpool->tags[signature_index] != CONSTANT_Utf8) {
 		dprintf("addMethod(): no signature name.\n"); /* XXX */
-		return (0);
+		return (NULL);
 	}
 
 	name = WORD2UTF(cpool->data[name_index])->data;
@@ -650,7 +656,7 @@
 		ret = strchr(i->sig,')');
 	ret++;
 
-	if (include != 0) {
+	if (include != NULL) {
 		fprintf(include, "extern %s", translateSig(ret, 0, 0));
 			fprintf(include, " %s_%s(", className, i->name);
 			if (!(i->access_flags & ACC_STATIC)) {
@@ -663,7 +669,7 @@
 		}
 	}
 
-	if (jni_include != 0) {
+	if (jni_include != NULL) {
 			fprintf(jni_include, "JNIEXPORT %s JNICALL Java_%s_",
 				jniType(ret), className);
 			
@@ -689,20 +695,20 @@
 		str = i->sig + 1;
 	args++;
 	while (str[0] != ')') {
-		if (jni_include != 0)
+		if (jni_include != NULL)
 			fprintf(jni_include, ", %s", jniType(str));
 		tsig = translateSig(str, &str, &args);
-		if (include != 0) {
+		if (include != NULL) {
 			fprintf(include, "%s", tsig);
 			if (str[0] != ')') {
 				fprintf(include, ", ");
 			}
 		}
 	}
-	if (include != 0) {
+	if (include != NULL) {
 		fprintf(include, ");\n");
 	}
-	if (jni_include != 0) {
+	if (jni_include != NULL) {
 		fprintf(jni_include, ");\n");
 	}
 
@@ -768,14 +774,14 @@
 
 	if (super != 0) {
 		kaffeh_findClass(CLASS_CONST_UTF8(this, super)->data);
-		if (include != 0)
+		if (include != NULL)
 		{
 			/* Put a blank line between fields for each (super)class. */
 			fprintf(include, "\n");
 		}
 	}
 
-	if (include != 0) {
+	if (include != NULL) {
 		if (strcmp(CLASS_CNAME(this), "java/lang/Object")) {
 			fprintf(include, "  /* Fields from %s: */\n", CLASS_CNAME(this));
 		}
@@ -796,7 +802,7 @@
 void
 readMethod(classFile* fp, Hjava_lang_Class* this, constants* cpool)
 {
-	assert(0);
+	assert(false);
 }
 
 /*
@@ -816,26 +822,26 @@
 	errorInfo einfo; /* XXX initialize, and check! */
 
 	/* If classpath isn't set, get it from the environment */
-	if (realClassPath[0] == 0) {
+	if (realClassPath[0] == '\0') {
 		start = getenv("KAFFE_CLASSPATH");
-		if (start == 0) {
+		if (start == NULL) {
 			start = getenv("CLASSPATH");
 		}
-		if (start == 0) {
+		if (start == NULL) {
 			dprintf("CLASSPATH not set!\n");
-			exit(1);
+			exit(EXIT_FAILURE);
 		}
 		strcpy(realClassPath, start);
 	}
 
-	for (start = realClassPath; end != 0; start = end + 1) {
+	for (start = realClassPath; end != NULL; start = end + 1) {
 		end = strchr(start, PATHSEP);
-		if (end == 0) {
+		if (end == NULL) {
 			strcpy(superName, start);
 		}
 		else {
 			strncpy(superName, start, end-start);
-			superName[end-start] = 0;
+			superName[end-start] = '\0';
 		}
 
 		if (stat(superName, &sbuf) < 0) {
@@ -863,7 +869,7 @@
 			{
 				dprintf("kaffeh: Ran out of memory!");
 				close(fd);
-				exit(1);
+				exit(EXIT_FAILURE);
 			}
 
 			/* XXX this is a bit weak. */
@@ -935,5 +941,5 @@
 		}
 	}
 	dprintf("Failed to open object '%s'\n", nm);
-	exit(1);
+	exit(EXIT_FAILURE);
 }
Index: kaffe/kaffe/kaffevm/file.h
diff -u kaffe/kaffe/kaffevm/file.h:1.4 kaffe/kaffe/kaffevm/file.h:1.5
--- kaffe/kaffe/kaffevm/file.h:1.4	Wed May 29 22:58:44 2002
+++ kaffe/kaffe/kaffevm/file.h	Thu Jan 22 19:54:23 2004
@@ -77,7 +77,7 @@
 static inline bool 
 checkBufSize(classFile* cf, int need, const char* cfname, errorInfo* einfo)
 {
-	assert(cf);
+	assert(cf != NULL);
 	assert(need >= 0);
 	assert(cf->type != CP_INVALID);
 	
@@ -103,8 +103,8 @@
 static inline void 
 readu1(u1* c, classFile* cf)
 {
-	assert(c);
-	assert(cf);
+	assert(c != NULL);
+	assert(cf != NULL);
 	assert(cf->type != CP_INVALID);
 
 	*c = cf->cur[0];
@@ -114,25 +114,25 @@
 static inline void 
 readu2(u2* c, classFile* cf)
 {
-	assert(c);
-	assert(cf);
+	assert(c != NULL);
+	assert(cf != NULL);
 	assert(cf->type != CP_INVALID);
 
-	*c = (cf->cur[0] << 8) | (cf->cur[1]);
+	*c = (((u2) cf->cur[0]) << 8) | ((u2) cf->cur[1]);
 	cf->cur += 2;
 }
 
 static inline void 
 readu4(u4* c, classFile* cf)
 {
-	assert(c);
-	assert(cf);
+	assert(c != NULL);
+	assert(cf != NULL);
 	assert(cf->type != CP_INVALID);
 
-	*c = (cf->cur[0] << 24)
-		| (cf->cur[1] << 16)
-		| (cf->cur[2] << 8)
-		| (cf->cur[3]);
+	*c = (((u4) cf->cur[0]) << 24)
+		| (((u4) cf->cur[1]) << 16)
+		| (((u4) cf->cur[2]) << 8)
+		| ((u4) cf->cur[3]);
 	cf->cur += 4;
 }
 
@@ -142,8 +142,8 @@
 static inline void
 readm(void* dest, size_t len, size_t size, classFile* cf)
 {
-	assert(dest);
-	assert(cf);
+	assert(dest != NULL);
+	assert(cf != NULL);
 	assert(cf->type != CP_INVALID);
 
 	memcpy(dest, cf->cur, len*size);
@@ -153,7 +153,7 @@
 static inline void
 seekm(classFile* cf, size_t len)
 {
-	assert(cf);
+	assert(cf != NULL);
 	assert(cf->type != CP_INVALID);
 
 	cf->cur += len;
Index: kaffe/kaffe/kaffevm/utf8const.h
diff -u kaffe/kaffe/kaffevm/utf8const.h:1.2 kaffe/kaffe/kaffevm/utf8const.h:1.3
--- kaffe/kaffe/kaffevm/utf8const.h:1.2	Tue Mar 11 08:00:18 2003
+++ kaffe/kaffe/kaffevm/utf8const.h	Thu Jan 22 19:54:23 2004
@@ -56,9 +56,9 @@
 static inline bool utf8ConstEqual(Utf8Const* a, Utf8Const* b) __UNUSED__;
 static inline bool utf8ConstEqual(Utf8Const* a, Utf8Const* b)
 {
-	assert(a);
+	assert(a != NULL);
 	assert(a->nrefs >= 1);
-	assert(b);
+	assert(b != NULL);
 	assert(b->nrefs >= 1);
 
 #ifdef KAFFEH
@@ -81,7 +81,7 @@
 static inline int32 utf8ConstHashValue(Utf8Const* a) __UNUSED__;
 static inline int32 utf8ConstHashValue(Utf8Const* a)
 {
-	assert(a);
+	assert(a != NULL);
 	assert(a->nrefs >= 1);
 	return a->hash;
 }
Index: kaffe/kaffe/kaffevm/systems/unix-jthreads/jthread.h
diff -u kaffe/kaffe/kaffevm/systems/unix-jthreads/jthread.h:1.49 kaffe/kaffe/kaffevm/systems/unix-jthreads/jthread.h:1.50
--- kaffe/kaffe/kaffevm/systems/unix-jthreads/jthread.h:1.49	Thu Jan 15 02:29:35 2004
+++ kaffe/kaffe/kaffevm/systems/unix-jthreads/jthread.h	Thu Jan 22 19:54:24 2004
@@ -312,7 +312,7 @@
         struct sockaddr* from, int* fromlen, int timeout, ssize_t *);
 int jthreadedWaitpid(int wpid, int* status, int options, int *);
 int jthreadedForkExec(char **argv, char **arge,
-	int ioes[4], int *, const char *);
+		      int ioes[/* 4 */], int *, const char *);
 int
 jthreadedSelect(int a, fd_set* b, fd_set* c, fd_set* d, 
 		struct timeval* e, int* out);




More information about the kaffe mailing list