6989466: Miscellaneous compiler warnings in java/lang, java/util, java/io, sun/misc native code

Reviewed-by: andrew, mchung, ohair
This commit is contained in:
Alan Bateman 2010-10-07 14:36:17 +01:00
parent 1550d01979
commit 14a7edc2ad
23 changed files with 57 additions and 55 deletions

View File

@ -76,7 +76,7 @@ JDK_GetVersionInfo0(jdk_version_info* info, size_t info_size) {
}
memset(info, 0, sizeof(info_size));
memset(info, 0, info_size);
info->jdk_version = ((jdk_major_version & 0xFF) << 24) |
((jdk_minor_version & 0xFF) << 16) |
((jdk_micro_version & 0xFF) << 8) |

View File

@ -433,7 +433,7 @@ getString8859_1Chars(JNIEnv *env, jstring jstr)
for (i=0; i<len; i++) {
jchar unicode = str[i];
if (unicode <= 0x00ff)
result[i] = unicode;
result[i] = (char)unicode;
else
result[i] = '?';
}
@ -498,7 +498,7 @@ getString646_USChars(JNIEnv *env, jstring jstr)
for (i=0; i<len; i++) {
jchar unicode = str[i];
if (unicode <= 0x007f )
result[i] = unicode;
result[i] = (char)unicode;
else
result[i] = '?';
}
@ -569,7 +569,7 @@ getStringCp1252Chars(JNIEnv *env, jstring jstr)
for (i=0; i<len; i++) {
jchar c = str[i];
if (c < 256)
result[i] = c;
result[i] = (char)c;
else switch(c) {
case 0x20AC: result[i] = (char)0x80; break;
case 0x201A: result[i] = (char)0x82; break;

View File

@ -102,8 +102,8 @@ Java_java_lang_Class_forName0(JNIEnv *env, jclass this, jstring classname,
char *clname;
jclass cls = 0;
char buf[128];
int len;
int unicode_len;
jsize len;
jsize unicode_len;
if (classname == NULL) {
JNU_ThrowNullPointerException(env, 0);
@ -112,7 +112,7 @@ Java_java_lang_Class_forName0(JNIEnv *env, jclass this, jstring classname,
len = (*env)->GetStringUTFLength(env, classname);
unicode_len = (*env)->GetStringLength(env, classname);
if (len >= sizeof(buf)) {
if (len >= (jsize)sizeof(buf)) {
clname = malloc(len + 1);
if (clname == NULL) {
JNU_ThrowOutOfMemoryError(env, NULL);

View File

@ -331,7 +331,7 @@ Java_java_lang_ClassLoader_00024NativeLibrary_load
if (handle) {
const char *onLoadSymbols[] = JNI_ONLOAD_SYMBOLS;
JNI_OnLoad_t JNI_OnLoad;
int i;
unsigned int i;
for (i = 0; i < sizeof(onLoadSymbols) / sizeof(char *); i++) {
JNI_OnLoad = (JNI_OnLoad_t)
JVM_FindLibraryEntry(handle, onLoadSymbols[i]);
@ -369,7 +369,7 @@ Java_java_lang_ClassLoader_00024NativeLibrary_load
cause = (*env)->ExceptionOccurred(env);
if (cause) {
(*env)->ExceptionClear(env);
(*env)->SetLongField(env, this, handleID, (jlong)NULL);
(*env)->SetLongField(env, this, handleID, (jlong)0);
(*env)->Throw(env, cause);
}
goto done;
@ -392,7 +392,7 @@ Java_java_lang_ClassLoader_00024NativeLibrary_unload
const char *onUnloadSymbols[] = JNI_ONUNLOAD_SYMBOLS;
void *handle;
JNI_OnUnload_t JNI_OnUnload;
int i;
unsigned int i;
if (!initIDs(env))
return;

View File

@ -109,7 +109,7 @@ Java_java_lang_System_identityHashCode(JNIEnv *env, jobject this, jobject x)
#error "ERROR: No override of JAVA_SPECIFICATION_VENDOR is allowed"
#else
#define JAVA_SPECIFICATION_VENDOR "Oracle Corporation"
#endif
#endif
static int fmtdefault; // boolean value
jobject fillI18nProps(JNIEnv *env, jobject props, char *baseKey,

View File

@ -46,11 +46,13 @@
#define __LOp(x) *(1+(int*)x)
#endif
#ifndef __P
#ifdef __STDC__
#define __P(p) p
#else
#define __P(p) ()
#endif
#endif
/*
* ANSI/POSIX

View File

@ -82,9 +82,9 @@ Java_java_lang_reflect_Proxy_defineClass0(JNIEnv *env,
goto free_body;
if (name != NULL) {
int len = (*env)->GetStringUTFLength(env, name);
int unicode_len = (*env)->GetStringLength(env, name);
if (len >= sizeof(buf)) {
jsize len = (*env)->GetStringUTFLength(env, name);
jsize unicode_len = (*env)->GetStringLength(env, name);
if (len >= (jsize)sizeof(buf)) {
utfName = malloc(len + 1);
if (utfName == NULL) {
JNU_ThrowOutOfMemoryError(env, NULL);

View File

@ -72,7 +72,7 @@ Java_java_nio_Bits_copyFromShortArray(JNIEnv *env, jobject this, jobject src,
jlong srcPos, jlong dstAddr, jlong length)
{
jbyte *bytes;
size_t i, size;
size_t size;
jshort *srcShort, *dstShort, *endShort;
jshort tmpShort;
@ -83,7 +83,7 @@ Java_java_nio_Bits_copyFromShortArray(JNIEnv *env, jobject this, jobject src,
if (length > MBYTE)
size = MBYTE;
else
size = length;
size = (size_t)length;
GETCRITICAL(bytes, env, src);
@ -107,7 +107,7 @@ Java_java_nio_Bits_copyToShortArray(JNIEnv *env, jobject this, jlong srcAddr,
jobject dst, jlong dstPos, jlong length)
{
jbyte *bytes;
size_t i, size;
size_t size;
jshort *srcShort, *dstShort, *endShort;
jshort tmpShort;
@ -118,7 +118,7 @@ Java_java_nio_Bits_copyToShortArray(JNIEnv *env, jobject this, jlong srcAddr,
if (length > MBYTE)
size = MBYTE;
else
size = length;
size = (size_t)length;
GETCRITICAL(bytes, env, dst);
@ -142,7 +142,7 @@ Java_java_nio_Bits_copyFromIntArray(JNIEnv *env, jobject this, jobject src,
jlong srcPos, jlong dstAddr, jlong length)
{
jbyte *bytes;
size_t i, size;
size_t size;
jint *srcInt, *dstInt, *endInt;
jint tmpInt;
@ -153,7 +153,7 @@ Java_java_nio_Bits_copyFromIntArray(JNIEnv *env, jobject this, jobject src,
if (length > MBYTE)
size = MBYTE;
else
size = length;
size = (size_t)length;
GETCRITICAL(bytes, env, src);
@ -177,7 +177,7 @@ Java_java_nio_Bits_copyToIntArray(JNIEnv *env, jobject this, jlong srcAddr,
jobject dst, jlong dstPos, jlong length)
{
jbyte *bytes;
size_t i, size;
size_t size;
jint *srcInt, *dstInt, *endInt;
jint tmpInt;
@ -188,7 +188,7 @@ Java_java_nio_Bits_copyToIntArray(JNIEnv *env, jobject this, jlong srcAddr,
if (length > MBYTE)
size = MBYTE;
else
size = length;
size = (size_t)length;
GETCRITICAL(bytes, env, dst);
@ -212,7 +212,7 @@ Java_java_nio_Bits_copyFromLongArray(JNIEnv *env, jobject this, jobject src,
jlong srcPos, jlong dstAddr, jlong length)
{
jbyte *bytes;
size_t i, size;
size_t size;
jlong *srcLong, *dstLong, *endLong;
jlong tmpLong;
@ -223,7 +223,7 @@ Java_java_nio_Bits_copyFromLongArray(JNIEnv *env, jobject this, jobject src,
if (length > MBYTE)
size = MBYTE;
else
size = length;
size = (size_t)length;
GETCRITICAL(bytes, env, src);
@ -247,7 +247,7 @@ Java_java_nio_Bits_copyToLongArray(JNIEnv *env, jobject this, jlong srcAddr,
jobject dst, jlong dstPos, jlong length)
{
jbyte *bytes;
size_t i, size;
size_t size;
jlong *srcLong, *dstLong, *endLong;
jlong tmpLong;
@ -258,7 +258,7 @@ Java_java_nio_Bits_copyToLongArray(JNIEnv *env, jobject this, jlong srcAddr,
if (length > MBYTE)
size = MBYTE;
else
size = length;
size = (size_t)length;
GETCRITICAL(bytes, env, dst);

View File

@ -25,6 +25,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <jni.h>
#include "management.h"
#include "sun_management_Flag.h"
@ -80,8 +81,6 @@ JNIEXPORT jint JNICALL
Java_sun_management_Flag_getFlags
(JNIEnv *env, jclass cls, jobjectArray names, jobjectArray flags, jint count)
{
char errmsg[128];
jint num_flags, i, index;
jmmVMGlobal* globals;
size_t gsize;

View File

@ -23,6 +23,8 @@
* questions.
*/
#include <string.h>
#include "jni.h"
#include "jni_util.h"
#include "jlong.h"
@ -113,7 +115,6 @@ typedef void (JNICALL *GetJvmVersionInfo_fp)(JNIEnv*, jvm_version_info*, size_t)
JNIEXPORT void JNICALL
Java_sun_misc_VM_initialize(JNIEnv *env, jclass cls) {
char errmsg[128];
GetJvmVersionInfo_fp func_p;
if (!JDK_InitJvmHandle()) {
@ -123,8 +124,6 @@ Java_sun_misc_VM_initialize(JNIEnv *env, jclass cls) {
func_p = (GetJvmVersionInfo_fp) JDK_FindJvmEntry("JVM_GetVersionInfo");
if (func_p != NULL) {
char errmsg[100];
jfieldID fid;
jvm_version_info info;
memset(&info, 0, sizeof(info));

View File

@ -38,8 +38,6 @@ static INIT_AGENT_PROPERTIES_FN InitAgentProperties_fp = NULL;
JNIEXPORT jobject JNICALL
Java_sun_misc_VMSupport_initAgentProperties(JNIEnv *env, jclass cls, jobject props)
{
char errmsg[128];
if (InitAgentProperties_fp == NULL) {
if (!JDK_InitJvmHandle()) {
JNU_ThrowInternalError(env,

View File

@ -119,7 +119,7 @@ Java_java_io_UnixFileSystem_checkAccess(JNIEnv *env, jobject this,
jobject file, jint a)
{
jboolean rv = JNI_FALSE;
int mode;
int mode = 0;
switch (a) {
case java_io_FileSystem_ACCESS_READ:
mode = R_OK;
@ -151,7 +151,8 @@ Java_java_io_UnixFileSystem_setPermission(JNIEnv *env, jobject this,
jboolean rv = JNI_FALSE;
WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) {
int amode, mode;
int amode = 0;
int mode;
switch (access) {
case java_io_FileSystem_ACCESS_READ:
if (owneronly)

View File

@ -246,7 +246,7 @@ canonicalize(char *original, char *resolved, int len)
if (r != NULL) {
/* Append unresolved subpath to resolved subpath */
int rn = strlen(r);
if (rn + strlen(p) >= len) {
if (rn + (int)strlen(p) >= len) {
/* Buffer overflow */
errno = ENAMETOOLONG;
return -1;

View File

@ -46,7 +46,9 @@
#include "java_props.h"
#ifdef __linux__
#define CODESET _NL_CTYPE_CODESET_NAME
#ifndef CODESET
#define CODESET _NL_CTYPE_CODESET_NAME
#endif
#else
#ifdef ALT_CODESET_KEY
#define CODESET ALT_CODESET_KEY
@ -289,7 +291,7 @@ static int ParseLocale(int cat, char ** std_language, char ** std_country, char
java_props_t *
GetJavaProperties(JNIEnv *env)
{
static java_props_t sprops = {0};
static java_props_t sprops;
char *v; /* tmp var */
if (sprops.user_dir) {

View File

@ -68,7 +68,7 @@ static int create(JNIEnv* env)
*/
if (ipv6_available()) {
JNU_ThrowIOException(env, "IPv6 not supported");
return;
return -1;
}
s = socket(AF_INET_SDP, SOCK_STREAM, 0);
#else

View File

@ -298,7 +298,8 @@ Java_sun_nio_ch_Net_getIntOption0(JNIEnv *env, jclass clazz, jobject fdo,
struct linger linger;
u_char carg;
void *arg;
int arglen, n;
socklen_t arglen;
int n;
/* Option value is an int except for a few specific cases */
@ -317,7 +318,7 @@ Java_sun_nio_ch_Net_getIntOption0(JNIEnv *env, jclass clazz, jobject fdo,
}
if (mayNeedConversion) {
n = NET_GetSockOpt(fdval(env, fdo), level, opt, arg, &arglen);
n = NET_GetSockOpt(fdval(env, fdo), level, opt, arg, (int*)&arglen);
} else {
n = getsockopt(fdval(env, fdo), level, opt, arg, &arglen);
}
@ -527,7 +528,7 @@ JNIEXPORT jint JNICALL
Java_sun_nio_ch_Net_getInterface4(JNIEnv* env, jobject this, jobject fdo)
{
struct in_addr in;
int arglen = sizeof(struct in_addr);
socklen_t arglen = sizeof(struct in_addr);
int n;
n = getsockopt(fdval(env, fdo), IPPROTO_IP, IP_MULTICAST_IF, (void*)&in, &arglen);
@ -556,7 +557,7 @@ JNIEXPORT jint JNICALL
Java_sun_nio_ch_Net_getInterface6(JNIEnv* env, jobject this, jobject fdo)
{
int index;
int arglen = sizeof(index);
socklen_t arglen = sizeof(index);
int n;
n = getsockopt(fdval(env, fdo), IPPROTO_IPV6, IPV6_MULTICAST_IF, (void*)&index, &arglen);

View File

@ -537,7 +537,7 @@ JNIEXPORT int JNICALL Java_sun_nio_ch_SctpNet_getIntOption0
int result;
struct linger linger;
void *arg;
unsigned int arglen;
int arglen;
if (mapSocketOption(opt, &klevel, &kopt) < 0) {
JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",

View File

@ -40,10 +40,10 @@ Java_sun_nio_ch_UnixAsynchronousSocketChannelImpl_checkConnect(JNIEnv *env,
jobject this, int fd)
{
int error = 0;
int n = sizeof(error);
socklen_t arglen = sizeof(error);
int result;
result = getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &n);
result = getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &arglen);
if (result < 0) {
JNU_ThrowIOExceptionWithLastError(env, "getsockopt");
} else {

View File

@ -79,7 +79,7 @@ BOOL useNativeConverter(JNIEnv *env) {
}
jstring nativeNewStringPlatform(JNIEnv *env, const char *str) {
static String_char_constructor = NULL;
static jmethodID String_char_constructor;
if (useNativeConverter(env)) {
// use native Unicode conversion so Kernel isn't required during
// System.initProperties

View File

@ -489,7 +489,7 @@ GetJavaProperties(JNIEnv* env)
break;
}
sprintf(buf, "%d.%d", ver.dwMajorVersion, ver.dwMinorVersion);
sprops.os_version = strdup(buf);
sprops.os_version = _strdup(buf);
#if _M_IA64
sprops.os_arch = "ia64";
#elif _M_AMD64
@ -500,7 +500,7 @@ GetJavaProperties(JNIEnv* env)
sprops.os_arch = "unknown";
#endif
sprops.patch_level = strdup(ver.szCSDVersion);
sprops.patch_level = _strdup(ver.szCSDVersion);
sprops.desktop = "windows";
}

View File

@ -26,6 +26,7 @@
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include "jvm.h"
#include "TimeZone_md.h"
#define VALUE_UNKNOWN 0
@ -463,7 +464,7 @@ static char *matchJavaTZ(const char *java_home_dir, int value_type, char *tzName
/*
* Found the time zone in the mapping table.
*/
javaTZName = strdup(items[TZ_JAVA_NAME]);
javaTZName = _strdup(items[TZ_JAVA_NAME]);
break;
}
/*
@ -473,7 +474,7 @@ static char *matchJavaTZ(const char *java_home_dir, int value_type, char *tzName
strncpy(bestMatch, items[TZ_JAVA_NAME], MAX_ZONE_CHAR);
} else if (country != NULL && strcmp(items[TZ_REGION], country) == 0) {
if (value_type == VALUE_MAPID) {
javaTZName = strdup(items[TZ_JAVA_NAME]);
javaTZName = _strdup(items[TZ_JAVA_NAME]);
break;
}
strncpy(bestMatch, items[TZ_JAVA_NAME], MAX_ZONE_CHAR);
@ -490,7 +491,7 @@ static char *matchJavaTZ(const char *java_home_dir, int value_type, char *tzName
fclose(fp);
if (javaTZName == NULL && bestMatch[0] != '\0') {
javaTZName = strdup(bestMatch);
javaTZName = _strdup(bestMatch);
}
return javaTZName;
@ -515,7 +516,7 @@ char *findJavaTZ_md(const char *java_home_dir, const char *country)
if (result != VALUE_UNKNOWN) {
if (result == VALUE_GMTOFFSET) {
std_timezone = strdup(winZoneName);
std_timezone = _strdup(winZoneName);
} else {
std_timezone = matchJavaTZ(java_home_dir, result,
winZoneName, winMapID, country);

View File

@ -84,7 +84,6 @@ Java_sun_nio_ch_ServerSocketChannelImpl_accept0(JNIEnv *env, jobject this,
jobject remote_ia;
int remote_port;
jobject isa;
jobject ia;
int addrlen = sizeof(sa);
memset((char *)&sa, 0, sizeof(sa));

View File

@ -223,7 +223,7 @@ Java_sun_nio_ch_WindowsSelectorImpl_discardUrgentData(JNIEnv* env, jobject this,
jboolean discarded = JNI_FALSE;
int n;
do {
n = recv(s, &data, sizeof(data), MSG_OOB);
n = recv(s, (char*)&data, sizeof(data), MSG_OOB);
if (n > 0) {
discarded = JNI_TRUE;
}