8037825: Fix warnings and enable "warnings as errors" in serviceability native libraries

Reviewed-by: alanb
This commit is contained in:
Staffan Larsen 2014-03-21 09:38:04 +01:00
parent f60c942caa
commit 966f3bc845
10 changed files with 46 additions and 38 deletions

View File

@ -49,7 +49,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBATTACH, \
EXCLUDE_FILES := $(LIBATTACH_EXCLUDE_FILES), \
LANG := C, \
OPTIMIZATION := LOW, \
CFLAGS := $(CFLAGS_JDKLIB), \
CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_WARNINGS_ARE_ERRORS), \
CFLAGS_windows := /Gy, \
MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libattach/mapfile-$(OPENJDK_TARGET_OS), \
VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \
@ -79,7 +79,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBDT_SOCKET, \
$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/transport/socket, \
LANG := C, \
OPTIMIZATION := LOW, \
CFLAGS := $(CFLAGS_JDKLIB) -DUSE_MMAP \
CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_CFLAGS_WARNINGS_ARE_ERRORS) -DUSE_MMAP \
-I$(INCLUDEDIR) -I$(JDK_OUTPUTDIR)/include/$(OPENJDK_TARGET_OS) \
-I$(JDK_TOPDIR)/src/share/transport/socket \
-I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/transport/socket \
@ -115,7 +115,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/transport/shmem, \
LANG := C, \
OPTIMIZATION := LOW, \
CFLAGS := $(CFLAGS_JDKLIB) -DUSE_MMAP \
CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_WARNINGS_ARE_ERRORS) -DUSE_MMAP \
-I$(INCLUDEDIR) -I$(JDK_OUTPUTDIR)/include/$(OPENJDK_TARGET_OS) \
-I$(JDK_TOPDIR)/src/share/transport/shmem \
-I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/transport/shmem \
@ -144,7 +144,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJDWP, \
SRC := $(JDK_TOPDIR)/src/share/back $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/back, \
LANG := C, \
OPTIMIZATION := LOW, \
CFLAGS := $(CFLAGS_JDKLIB) -DJDWP_LOGGING \
CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_WARNINGS_ARE_ERRORS) -DJDWP_LOGGING \
-I$(JDK_TOPDIR)/src/share/transport/export \
-I$(JDK_TOPDIR)/src/share/back/export \
-I$(JDK_TOPDIR)/src/share/npt \
@ -179,7 +179,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJSDT, \
$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/tracing/dtrace, \
LANG := C, \
OPTIMIZATION := LOW, \
CFLAGS := $(CFLAGS_JDKLIB) \
CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_WARNINGS_ARE_ERRORS) \
-I$(JDK_TOPDIR)/src/share/native/sun/tracing/dtrace, \
MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjsdt/mapfile-vers, \
LDFLAGS := $(LDFLAGS_JDKLIB) \
@ -248,7 +248,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBINSTRUMENT, \
INCLUDE_FILES := $(LIBINSTRUMENT_FILES), \
LANG := C, \
OPTIMIZATION := LOW, \
CFLAGS := $(LIBINSTRUMENT_CFLAGS), \
CFLAGS := $(LIBINSTRUMENT_CFLAGS) $(CFLAGS_WARNINGS_ARE_ERRORS), \
CFLAGS_debug := -DJPLIS_LOGGING, \
CFLAGS_release := -DNO_JPLIS_LOGGING, \
MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libinstrument/mapfile-vers, \
@ -316,7 +316,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBMANAGEMENT, \
EXCLUDE_FILES := $(BUILD_LIBMANAGEMENT_EXCLUDES), \
LANG := C, \
OPTIMIZATION := $(LIBMANAGEMENT_OPTIMIZATION), \
CFLAGS := $(CFLAGS_JDKLIB) $(BUILD_LIBMANAGEMENT_CFLAGS), \
CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_WARNINGS_ARE_ERRORS) $(BUILD_LIBMANAGEMENT_CFLAGS), \
MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libmanagement/mapfile-vers, \
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
@ -364,7 +364,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBHPROF, \
SRC := $(BUILD_LIBHPROF_SRC), \
LANG := C, \
OPTIMIZATION := $(LIBHPROF_OPTIMIZATION), \
CFLAGS := $(CFLAGS_JDKLIB) \
CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_WARNINGS_ARE_ERRORS) \
$(BUILD_LIBHPROF_CFLAGS), \
CFLAGS_debug := -DHPROF_LOGGING, \
MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libhprof/mapfile-vers, \
@ -392,7 +392,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJAVA_CRW_DEMO, \
SRC := $(JDK_TOPDIR)/src/share/demo/jvmti/java_crw_demo, \
LANG := C, \
OPTIMIZATION := LOW, \
CFLAGS := $(CFLAGS_JDKLIB) \
CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_WARNINGS_ARE_ERRORS) \
-I$(JDK_TOPDIR)/src/share/demo/jvmti/java_crw_demo, \
MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjava_crw_demo/mapfile-vers, \
LDFLAGS := $(LDFLAGS_JDKLIB) \
@ -419,7 +419,7 @@ ifndef OPENJDK
SRC := $(JDK_TOPDIR)/src/closed/share/native/oracle/jfr, \
LANG := C, \
OPTIMIZATION := LOW, \
CFLAGS := $(CFLAGS_JDKLIB) \
CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_WARNINGS_ARE_ERRORS) \
-I$(JDK_TOPDIR)/src/closed/share/javavm/export, \
MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjfr/mapfile-vers, \
LDFLAGS := $(LDFLAGS_JDKLIB) \

View File

@ -48,8 +48,6 @@
#define BASE_STRATUM_NAME "Java"
#define null NULL
#define true JNI_TRUE
#define false JNI_FALSE
#define String char *
#define private static
@ -147,7 +145,7 @@ private jboolean isValid(void);
defaultStratumId = null;
defaultStratumIndex = -1;
baseStratumIndex = -2; /* so as not to match -1 above */
sourceMapIsValid = false;
sourceMapIsValid = JNI_FALSE;
if (getSourceDebugExtension(clazz, &sourceDebugExtension) ==
JVMTI_ERROR_NONE) {
@ -667,7 +665,7 @@ private jboolean isValid(void);
jplsFilename = readLine();
defaultStratumId = readLine();
createJavaStratum();
while (true) {
while (1) {
if (sdeRead() != '*') {
syntax("expected '*'");
}
@ -684,7 +682,7 @@ private jboolean isValid(void);
case 'E':
/* set end points */
storeStratum("*terminator*");
sourceMapIsValid = true;
sourceMapIsValid = JNI_TRUE;
return;
default:
ignoreSection();

View File

@ -1682,7 +1682,7 @@ HandlerNode *
eventHandler_createPermanentInternal(EventIndex ei, HandlerFunction func)
{
return createInternal(ei, func, NULL,
NULL, NULL, (jlocation)NULL, JNI_TRUE);
NULL, NULL, 0, JNI_TRUE);
}
HandlerNode *
@ -1691,7 +1691,7 @@ eventHandler_createInternalThreadOnly(EventIndex ei,
jthread thread)
{
return createInternal(ei, func, thread,
NULL, NULL, (jlocation)NULL, JNI_FALSE);
NULL, NULL, 0, JNI_FALSE);
}
HandlerNode *

View File

@ -56,17 +56,24 @@ static int open_count;
static void
get_time_stamp(char *tbuf, size_t ltbuf)
{
char format[MAXLEN_TIMESTAMP+1];
char timestamp_prefix[MAXLEN_TIMESTAMP+1];
char timestamp_postfix[MAXLEN_TIMESTAMP+1];
unsigned millisecs = 0;
time_t t = 0;
GETMILLSECS(millisecs);
if ( time(&t) == (time_t)(-1) )
if ( time(&t) == (time_t)(-1) ) {
t = 0;
(void)strftime(format, sizeof(format),
/* Break this string up for SCCS's sake */
"%" "d.%" "m.%" "Y %" "T.%%.3d %" "Z", localtime(&t));
(void)snprintf(tbuf, ltbuf, format, (int)(millisecs));
}
/* Break this up so that the format strings are string literals
and we avoid a compiler warning. */
(void)strftime(timestamp_prefix, sizeof(timestamp_prefix),
"%d.%m.%Y %T", localtime(&t));
(void)strftime(timestamp_postfix, sizeof(timestamp_postfix),
"%Z", localtime(&t));
(void)snprintf(tbuf, ltbuf,
"%s.%.3d %s", timestamp_prefix,
(int)(millisecs), timestamp_postfix);
}
/* Get basename of filename */
@ -175,7 +182,7 @@ log_message_end(const char *format, ...)
"LOC=%s;PID=%d;THR=t@%d",
location_stamp,
(int)processPid,
(int)tid);
(int)(intptr_t)tid);
/* Construct message string. */
va_start(ap, format);

View File

@ -359,7 +359,7 @@ Agent_OnAttach(JavaVM* vm, char *args, void * reserved) {
* class name. The manifest is in UTF8 so need to convert to
* modified UTF8 (see JNI spec).
*/
oldLen = strlen(agentClass);
oldLen = (int)strlen(agentClass);
newLen = modifiedUtf8LengthOfUtf8(agentClass, oldLen);
if (newLen == oldLen) {
agentClass = strdup(agentClass);

View File

@ -46,9 +46,9 @@ static jlong H_PATH;
/* Compute the low-order mask for the characters in the given string */
static jlong lowMask(char* s) {
int n = strlen(s);
size_t n = strlen(s);
jlong m = 0;
int i;
size_t i;
for (i = 0; i < n; i++) {
int c = (int)s[i];
if (c < 64)
@ -59,9 +59,9 @@ static jlong lowMask(char* s) {
/* Compute the high-order mask for the characters in the given string */
static jlong highMask(char* s) {
int n = strlen(s);
size_t n = strlen(s);
jlong m = 0;
int i;
size_t i;
for (i = 0; i < n; i++) {
int c = (int)s[i];
if ((c >= 64) && (c < 128))
@ -168,7 +168,7 @@ static void initialize() {
* illegal characters. Returns 0 if only validate characters are present.
*/
int validatePathChars(const char* path) {
int i, n;
size_t i, n;
/* initialize on first usage */
if (L_HEX == 0) {

View File

@ -62,13 +62,13 @@ typedef unsigned long UNSIGNED_JINT;
(((UNSIGNED_JINT)(x & 0xff000000)) >> 24))
#define HOST_TO_JAVA_LONG(x) \
((x << 56) | \
((x & 0x000000000000ff00) << 40) | \
((x & 0x0000000000ff0000) << 24) | \
((x & 0x00000000ff000000) << 8) | \
((x & 0x000000ff00000000) >> 8) | \
((x & 0x0000ff0000000000) >> 24) | \
((x & 0x00ff000000000000) >> 40) | \
(((UNSIGNED_JLONG)(x & 0xff00000000000000)) >> 56))
((x & 0x000000000000ff00LL) << 40) | \
((x & 0x0000000000ff0000LL) << 24) | \
((x & 0x00000000ff000000LL) << 8) | \
((x & 0x000000ff00000000LL) >> 8) | \
((x & 0x0000ff0000000000LL) >> 24) | \
((x & 0x00ff000000000000LL) >> 40) | \
(((UNSIGNED_JLONG)(x & 0xff00000000000000ULL)) >> 56))
#define HOST_TO_JAVA_FLOAT(x) stream_encodeFloat(x)
#define HOST_TO_JAVA_DOUBLE(x) stream_encodeDouble(x)

View File

@ -29,6 +29,7 @@
#include <mach/mach.h>
#include <mach/task_info.h>
#include "jvm.h"
JNIEXPORT jdouble JNICALL
Java_sun_management_OperatingSystemImpl_getSystemCpuLoad0

View File

@ -33,6 +33,7 @@
#include <string.h>
#include <errno.h>
#include <io.h>
#include <stdlib.h>
#include "sys.h"

View File

@ -27,6 +27,7 @@
#include <process.h>
#include <time.h>
#include <Windows.h>
#define MUTEX_T int
#define MUTEX_INIT 0
@ -40,4 +41,4 @@
#define popen _popen
#define pclose _pclose
#define sleep _sleep
#define sleep(s) Sleep((s)*1000)