8074821: Resolve disabled warnings for libnio
Summary: Enable the indicated warnings and correct the code which provoked them.
Reviewed-by: alanb
--- a/jdk/make/lib/NioLibraries.gmk Wed Aug 19 17:42:52 2015 +0100
+++ b/jdk/make/lib/NioLibraries.gmk Wed Aug 19 13:11:24 2015 -0700
@@ -69,9 +69,6 @@
OPTIMIZATION := HIGH, \
CFLAGS := $(CFLAGS_JDKLIB) \
$(BUILD_LIBNIO_CFLAGS), \
- DISABLED_WARNINGS_gcc := type-limits, \
- DISABLED_WARNINGS_clang := tautological-compare, \
- DISABLED_WARNINGS_microsoft := 4244 4996, \
MAPFILE := $(BUILD_LIBNIO_MAPFILE), \
LDFLAGS := $(LDFLAGS_JDKLIB) $(BUILD_LIBNIO_LDFLAGS) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
--- a/jdk/src/java.base/share/classes/sun/nio/ch/Net.java Wed Aug 19 17:42:52 2015 +0100
+++ b/jdk/src/java.base/share/classes/sun/nio/ch/Net.java Wed Aug 19 13:11:24 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -391,8 +391,7 @@
private static native boolean isIPv6Available0();
/*
- * Returns 1 for Windows versions that support exclusive binding by default, 0
- * for those that do not, and -1 for Solaris/Linux/Mac OS
+ * Returns 1 for Windows and -1 for Solaris/Linux/Mac OS
*/
private static native int isExclusiveBindAvailable();
--- a/jdk/src/java.base/unix/native/libnio/ch/IOUtil.c Wed Aug 19 17:42:52 2015 +0100
+++ b/jdk/src/java.base/unix/native/libnio/ch/IOUtil.c Wed Aug 19 13:11:24 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -129,7 +129,8 @@
JNU_ThrowIOExceptionWithLastError(env, "getrlimit failed");
return -1;
}
- if (rlp.rlim_max < 0 || rlp.rlim_max > java_lang_Integer_MAX_VALUE) {
+ if (rlp.rlim_max == RLIM_INFINITY ||
+ rlp.rlim_max > (rlim_t)java_lang_Integer_MAX_VALUE) {
return java_lang_Integer_MAX_VALUE;
} else {
return (jint)rlp.rlim_max;
--- a/jdk/src/java.base/windows/native/libnio/ch/Iocp.c Wed Aug 19 17:42:52 2015 +0100
+++ b/jdk/src/java.base/windows/native/libnio/ch/Iocp.c Wed Aug 19 13:11:24 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -57,16 +57,6 @@
CHECK_NULL(completionStatus_overlapped);
}
-JNIEXPORT jint JNICALL
-Java_sun_nio_ch_Iocp_osMajorVersion(JNIEnv* env, jclass this)
-{
- OSVERSIONINFOEX ver;
- ver.dwOSVersionInfoSize = sizeof(ver);
- GetVersionEx((OSVERSIONINFO *) &ver);
- return (ver.dwPlatformId == VER_PLATFORM_WIN32_NT) ?
- (jint)(ver.dwMajorVersion) : (jint)0;
-}
-
JNIEXPORT jlong JNICALL
Java_sun_nio_ch_Iocp_createIoCompletionPort(JNIEnv* env, jclass this,
jlong handle, jlong existingPort, jint completionKey, jint concurrency)
--- a/jdk/src/java.base/windows/native/libnio/ch/Net.c Wed Aug 19 17:42:52 2015 +0100
+++ b/jdk/src/java.base/windows/native/libnio/ch/Net.c Wed Aug 19 13:11:24 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -88,28 +88,14 @@
Java_sun_nio_ch_Net_isIPv6Available0(JNIEnv* env, jclass cl)
{
/*
- * Return true if Windows Vista or newer, and IPv6 is configured
+ * Return true if IPv6 is configured
*/
- OSVERSIONINFO ver;
- ver.dwOSVersionInfoSize = sizeof(ver);
- GetVersionEx(&ver);
- if ((ver.dwPlatformId == VER_PLATFORM_WIN32_NT) &&
- (ver.dwMajorVersion >= 6) && ipv6_available())
- {
- return JNI_TRUE;
- }
- return JNI_FALSE;
+ return ipv6_available() ? JNI_TRUE : JNI_FALSE;
}
JNIEXPORT jint JNICALL
Java_sun_nio_ch_Net_isExclusiveBindAvailable(JNIEnv *env, jclass clazz) {
- OSVERSIONINFO ver;
- int version;
- ver.dwOSVersionInfoSize = sizeof(ver);
- GetVersionEx(&ver);
- version = ver.dwMajorVersion * 10 + ver.dwMinorVersion;
- //if os <= xp exclusive binding is off by default
- return version >= 60 ? 1 : 0;
+ return 1;
}
@@ -567,7 +553,7 @@
fd_set rd, wr, ex;
jint fd = fdval(env, fdo);
- t.tv_sec = timeout / 1000;
+ t.tv_sec = (long)(timeout / 1000);
t.tv_usec = (timeout % 1000) * 1000;
FD_ZERO(&rd);