PatchSet 6883 Date: 2005/09/09 10:58:28 Author: robilad Branch: HEAD Tag: (none) Log: Fixed warnings in zip
2005-09-09 Dalibor Topic <[EMAIL PROTECTED]> * libraries/clib/zip/Deflater.c, libraries/clib/zip/Inflater.c: (GET_STREAM) Removed. (getStream, setStream) New inline functions. Replaced use of GET_STREAM by getStream or setStream. Added local variables to avoid casts and fix warnings. Reported by: Andreas Tobler <[EMAIL PROTECTED]> Members: ChangeLog:1.4404->1.4405 libraries/clib/zip/Deflater.c:1.17->1.18 libraries/clib/zip/Inflater.c:1.16->1.17 Index: kaffe/ChangeLog diff -u kaffe/ChangeLog:1.4404 kaffe/ChangeLog:1.4405 --- kaffe/ChangeLog:1.4404 Fri Sep 9 02:29:14 2005 +++ kaffe/ChangeLog Fri Sep 9 10:58:28 2005 @@ -1,5 +1,16 @@ 2005-09-09 Dalibor Topic <[EMAIL PROTECTED]> + * libraries/clib/zip/Deflater.c, + libraries/clib/zip/Inflater.c: + (GET_STREAM) Removed. + (getStream, setStream) New inline functions. + Replaced use of GET_STREAM by getStream or setStream. + Added local variables to avoid casts and fix warnings. + + Reported by: Andreas Tobler <[EMAIL PROTECTED]> + +2005-09-09 Dalibor Topic <[EMAIL PROTECTED]> + * test/jni/jniBase.c (main): Turned env into a void*. Added JNIEnv* jni_env. Set jni_env to env after VM is created. Use jni_env in the rest of function. Index: kaffe/libraries/clib/zip/Deflater.c diff -u kaffe/libraries/clib/zip/Deflater.c:1.17 kaffe/libraries/clib/zip/Deflater.c:1.18 --- kaffe/libraries/clib/zip/Deflater.c:1.17 Sat May 14 21:46:58 2005 +++ kaffe/libraries/clib/zip/Deflater.c Fri Sep 9 10:58:32 2005 @@ -22,7 +22,19 @@ #define WSIZE 0x8000 #define WSIZEBITS 15 -#define GET_STREAM(THIS) (*(z_stream**)&unhand(this)->strm) +static inline +z_stream* +getStream(struct Hjava_util_zip_Deflater* this) +{ + return *(z_stream**)&unhand(this)->strm; +} + +static inline +void +setStream(struct Hjava_util_zip_Deflater* this, z_stream* stream) +{ + *(z_stream**)&unhand(this)->strm = stream; +} void java_util_zip_Deflater_setDictionary(struct Hjava_util_zip_Deflater* this, HArrayOfByte* buf, jint from, jint len) @@ -30,11 +42,12 @@ int r; z_stream* dstream; - dstream = GET_STREAM(this); + dstream = getStream(this); // XXX What happens if out of bounds ? if (from >= 0 && len > 0 && from + len <= obj_length(buf)) { - r = deflateSetDictionary (dstream, &unhand_array(buf)->body[from], (unsigned)len); + void* dictionary = &unhand_array(buf)->body[from]; + r = deflateSetDictionary (dstream, dictionary, (unsigned)len); if (r < 0) { SignalError("java.lang.Error", dstream->msg ? dstream->msg : "unknown error"); } @@ -47,15 +60,17 @@ int r; int ilen; z_stream* dstream; + void* next_available_input = &unhand_array(unhand(this)->buf)->body[unhand(this)->off]; + void* next_available_output = &unhand_array(buf)->body[off]; - dstream = GET_STREAM(this); + dstream = getStream(this); ilen = unhand(this)->len; - dstream->next_in = &unhand_array(unhand(this)->buf)->body[unhand(this)->off]; + dstream->next_in = next_available_input; dstream->avail_in = ilen; - dstream->next_out = &unhand_array(buf)->body[off]; + dstream->next_out = next_available_output; dstream->avail_out = len; r = deflate(dstream, unhand(this)->finish ? Z_FINISH : Z_NO_FLUSH); @@ -90,25 +105,25 @@ jint java_util_zip_Deflater_getAdler(struct Hjava_util_zip_Deflater* this) { - return (GET_STREAM(this)->adler); + return (getStream(this)->adler); } jint java_util_zip_Deflater_getTotalIn(struct Hjava_util_zip_Deflater* this) { - return (GET_STREAM(this)->total_in); + return (getStream(this)->total_in); } jint java_util_zip_Deflater_getTotalOut(struct Hjava_util_zip_Deflater* this) { - return (GET_STREAM(this)->total_out); + return (getStream(this)->total_out); } void java_util_zip_Deflater_reset(struct Hjava_util_zip_Deflater* this) { - deflateReset(GET_STREAM(this)); + deflateReset(getStream(this)); unhand(this)->finish = 0; unhand(this)->finished = 0; @@ -119,8 +134,8 @@ { z_stream* dstream; - dstream = GET_STREAM(this); - GET_STREAM(this) = NULL; + dstream = getStream(this); + setStream(this, NULL); deflateEnd(dstream); KFREE(dstream); @@ -172,7 +187,7 @@ SignalError("java.lang.Error", dstream->msg ? dstream->msg : ""); } - GET_STREAM(this) = dstream; + setStream(this, dstream); } #else Index: kaffe/libraries/clib/zip/Inflater.c diff -u kaffe/libraries/clib/zip/Inflater.c:1.16 kaffe/libraries/clib/zip/Inflater.c:1.17 --- kaffe/libraries/clib/zip/Inflater.c:1.16 Sat May 14 21:46:58 2005 +++ kaffe/libraries/clib/zip/Inflater.c Fri Sep 9 10:58:32 2005 @@ -23,7 +23,19 @@ #define MAXSTREAM 16 -#define GET_STREAM(THIS) (*(z_stream**)&unhand(this)->strm) +static inline +z_stream* +getStream(struct Hjava_util_zip_Inflater* this) +{ + return *(z_stream**)&unhand(this)->strm; +} + +static inline +void +setStream(struct Hjava_util_zip_Inflater* this, z_stream* stream) +{ + *(z_stream**)&unhand(this)->strm = stream; +} void java_util_zip_Inflater_setDictionary(struct Hjava_util_zip_Inflater* this, HArrayOfByte* buf, jint from, jint len) @@ -31,10 +43,11 @@ int r; z_stream* dstream; - dstream = GET_STREAM(this); + dstream = getStream(this); // XXX What happens if out of bounds ? if (from >= 0 && len > 0 && from + len <= obj_length(buf)) { - r = inflateSetDictionary (dstream, &unhand_array(buf)->body[from], (unsigned)len); + void* dictionary = &unhand_array(buf)->body[from]; + r = inflateSetDictionary (dstream, dictionary, (unsigned)len); if (r < 0) { SignalError("java.lang.Error", dstream->msg ? dstream->msg : "unknown error"); } @@ -47,15 +60,17 @@ int r; int ilen; z_stream* dstream; + void* next_available_input = &unhand_array(unhand(this)->buf)->body[unhand(this)->off]; + void* next_available_output = &unhand_array(buf)->body[off]; - dstream = GET_STREAM(this); + dstream = getStream(this); ilen = unhand(this)->len; - dstream->next_in = &unhand_array(unhand(this)->buf)->body[unhand(this)->off]; + dstream->next_in = next_available_input; dstream->avail_in = ilen; - dstream->next_out = &unhand_array(buf)->body[off]; + dstream->next_out = next_available_output; dstream->avail_out = len; r = inflate(dstream, Z_SYNC_FLUSH); @@ -92,25 +107,25 @@ jint java_util_zip_Inflater_getAdler(struct Hjava_util_zip_Inflater* this) { - return (GET_STREAM(this)->adler); + return (getStream(this)->adler); } jint java_util_zip_Inflater_getTotalIn(struct Hjava_util_zip_Inflater* this) { - return (GET_STREAM(this)->total_in); + return (getStream(this)->total_in); } jint java_util_zip_Inflater_getTotalOut(struct Hjava_util_zip_Inflater* this) { - return (GET_STREAM(this)->total_out); + return (getStream(this)->total_out); } void java_util_zip_Inflater_reset(struct Hjava_util_zip_Inflater* this) { - inflateReset(GET_STREAM(this)); + inflateReset(getStream(this)); unhand(this)->finished = 0; unhand(this)->len = 0; @@ -121,7 +136,7 @@ { z_stream* dstream; - dstream = GET_STREAM(this); + dstream = getStream(this); inflateEnd(dstream); KFREE(dstream); } @@ -171,7 +186,7 @@ default: SignalError("java.lang.Error", dstream->msg ? dstream->msg : ""); } - GET_STREAM(this) = dstream; + setStream(this, dstream); } #else _______________________________________________ kaffe mailing list kaffe@kaffe.org http://kaffe.org/cgi-bin/mailman/listinfo/kaffe