8074818: Resolve disabled warnings for libjava
8080007: Stop ignoring warnings for libjava
Reviewed-by: alanb, erikj
--- a/jdk/make/lib/CoreLibraries.gmk Fri May 22 16:13:00 2015 +0300
+++ b/jdk/make/lib/CoreLibraries.gmk Fri May 22 10:12:18 2015 -0400
@@ -146,11 +146,6 @@
OPTIMIZATION := HIGH, \
CFLAGS := $(CFLAGS_JDKLIB) \
$(LIBJAVA_CFLAGS), \
- DISABLED_WARNINGS_gcc := type-limits format-nonliteral, \
- DISABLED_WARNINGS_clang := int-conversion, \
- DISABLED_WARNINGS_solstudio := E_DECLARATION_IN_CODE, \
- DISABLED_WARNINGS_microsoft := 4022 4267 4996, \
- WARNINGS_AS_ERRORS_solstudio := false, \
MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjava/mapfile-vers, \
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
--- a/jdk/src/java.base/share/native/libjava/FileInputStream.c Fri May 22 16:13:00 2015 +0300
+++ b/jdk/src/java.base/share/native/libjava/FileInputStream.c Fri May 22 10:12:18 2015 -0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -23,6 +23,9 @@
* questions.
*/
+#include <fcntl.h>
+#include <limits.h>
+
#include "jni.h"
#include "jni_util.h"
#include "jlong.h"
@@ -32,9 +35,6 @@
#include "java_io_FileInputStream.h"
-#include <fcntl.h>
-#include <limits.h>
-
#include "io_util_md.h"
/*******************************************************************/
--- a/jdk/src/java.base/share/native/libjava/jdk_util.c Fri May 22 16:13:00 2015 +0300
+++ b/jdk/src/java.base/share/native/libjava/jdk_util.c Fri May 22 10:12:18 2015 -0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -58,9 +58,9 @@
/* If the JDK_BUILD_NUMBER is of format bXX and XX is an integer
* XX is the jdk_build_number.
*/
- int len = strlen(jdk_build_string);
+ size_t len = strlen(jdk_build_string);
if (jdk_build_string[0] == 'b' && len >= 2) {
- int i = 0;
+ size_t i = 0;
for (i = 1; i < len; i++) {
if (isdigit(jdk_build_string[i])) {
build_number[i-1] = jdk_build_string[i];
@@ -76,7 +76,7 @@
}
}
- assert(jdk_build_number >= 0 && jdk_build_number <= 255);
+ assert(jdk_build_number <= 255);
if (strlen(jdk_update_string) == 2 || strlen(jdk_update_string) == 3) {
if (isdigit(jdk_update_string[0]) && isdigit(jdk_update_string[1])) {
--- a/jdk/src/java.base/share/native/libjava/jni_util.c Fri May 22 16:13:00 2015 +0300
+++ b/jdk/src/java.base/share/native/libjava/jni_util.c Fri May 22 10:12:18 2015 -0400
@@ -157,7 +157,7 @@
const char *defaultDetail)
{
char buf[256];
- int n = getLastErrorString(buf, sizeof(buf));
+ size_t n = getLastErrorString(buf, sizeof(buf));
if (n > 0) {
jstring s = JNU_NewStringPlatform(env, buf);
@@ -448,7 +448,7 @@
static jstring
newString646_US(JNIEnv *env, const char *str)
{
- int len = strlen(str);
+ int len = (int)strlen(str);
jchar buf[512];
jchar *str1;
jstring result;
--- a/jdk/src/java.base/unix/native/libjava/ProcessImpl_md.c Fri May 22 16:13:00 2015 +0300
+++ b/jdk/src/java.base/unix/native/libjava/ProcessImpl_md.c Fri May 22 10:12:18 2015 -0400
@@ -286,12 +286,14 @@
(*env)->ReleaseByteArrayElements(env, arr, (jbyte*) parr, JNI_ABORT);
}
+#define IOE_FORMAT "error=%d, %s"
+
static void
throwIOException(JNIEnv *env, int errnum, const char *defaultDetail)
{
- static const char * const format = "error=%d, %s";
const char *detail = defaultDetail;
char *errmsg;
+ size_t fmtsize;
jstring s;
if (errnum != 0) {
@@ -300,11 +302,12 @@
detail = s;
}
/* ASCII Decimal representation uses 2.4 times as many bits as binary. */
- errmsg = NEW(char, strlen(format) + strlen(detail) + 3 * sizeof(errnum));
+ fmtsize = sizeof(IOE_FORMAT) + strlen(detail) + 3 * sizeof(errnum);
+ errmsg = NEW(char, fmtsize);
if (errmsg == NULL)
return;
- sprintf(errmsg, format, errnum, detail);
+ snprintf(errmsg, fmtsize, IOE_FORMAT, errnum, detail);
s = JNU_NewStringPlatform(env, errmsg);
if (s != NULL) {
jobject x = JNU_NewObjectByName(env, "java/io/IOException",
--- a/jdk/src/java.base/unix/native/libjava/TimeZone_md.c Fri May 22 16:13:00 2015 +0300
+++ b/jdk/src/java.base/unix/native/libjava/TimeZone_md.c Fri May 22 10:12:18 2015 -0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -735,10 +735,10 @@
local_tm = localtime(&clock);
if (local_tm->tm_gmtoff >= 0) {
offset = (time_t) local_tm->tm_gmtoff;
- sign = "+";
+ sign = '+';
} else {
offset = (time_t) -local_tm->tm_gmtoff;
- sign = "-";
+ sign = '-';
}
sprintf(buf, (const char *)"GMT%c%02d:%02d",
sign, (int)(offset/3600), (int)((offset%3600)/60));
--- a/jdk/src/java.base/windows/native/libjava/ConcurrentPReader_md.c Fri May 22 16:13:00 2015 +0300
+++ b/jdk/src/java.base/windows/native/libjava/ConcurrentPReader_md.c Fri May 22 10:12:18 2015 -0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -47,7 +47,7 @@
DWORD nread;
BOOL result;
- jlong handle = (*env)->GetLongField(env, fdo, handle_fdID);
+ HANDLE handle = (HANDLE)(*env)->GetLongField(env, fdo, handle_fdID);
void *buf = (void *)jlong_to_ptr(address);
ZeroMemory(&ov, sizeof(ov));
--- a/jdk/src/java.base/windows/native/libjava/ProcessImpl_md.c Fri May 22 16:13:00 2015 +0300
+++ b/jdk/src/java.base/windows/native/libjava/ProcessImpl_md.c Fri May 22 10:12:18 2015 -0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -90,7 +90,7 @@
CP_UTF8,
0,
utf16_javaMessage,
- n, /*by creation n <= MESSAGE_LENGTH*/
+ (int)n, /*by creation n <= MESSAGE_LENGTH*/
utf8_javaMessage,
MESSAGE_LENGTH*2,
NULL,
--- a/jdk/src/java.base/windows/native/libjava/java_props_md.c Fri May 22 16:13:00 2015 +0300
+++ b/jdk/src/java.base/windows/native/libjava/java_props_md.c Fri May 22 10:12:18 2015 -0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -345,6 +345,8 @@
return TRUE;
}
+// GetVersionEx is deprecated; disable the warning until a replacement is found
+#pragma warning(disable : 4996)
java_props_t *
GetJavaProperties(JNIEnv* env)
{
@@ -680,5 +682,5 @@
jstring
GetStringPlatform(JNIEnv *env, nchar* wcstr)
{
- return (*env)->NewString(env, wcstr, wcslen(wcstr));
+ return (*env)->NewString(env, wcstr, (jsize)wcslen(wcstr));
}
--- a/jdk/src/java.base/windows/native/libjava/jni_util_md.c Fri May 22 16:13:00 2015 +0300
+++ b/jdk/src/java.base/windows/native/libjava/jni_util_md.c Fri May 22 10:12:18 2015 -0400
@@ -124,9 +124,9 @@
CP_UTF8,
0,
utf16_osErrorMsg,
- n,
+ (int)n,
utf8_jvmErrorMsg,
- cbErrorMsg,
+ (int)cbErrorMsg,
NULL,
NULL);