8074840: Resolve disabled warnings for libjli and libjli_static
authormikael
Thu, 02 Apr 2015 11:54:33 -0700
changeset 29742 b73f38796859
parent 29741 da2598cb299e
child 29743 981893a47bec
8074840: Resolve disabled warnings for libjli and libjli_static Reviewed-by: dholmes, ksrini
jdk/make/lib/CoreLibraries.gmk
jdk/src/java.base/macosx/native/libjli/java_md_macosx.c
jdk/src/java.base/share/native/libjli/java.c
jdk/src/java.base/share/native/libjli/java.h
jdk/src/java.base/share/native/libjli/parse_manifest.c
jdk/src/java.base/share/native/libjli/splashscreen_stubs.c
jdk/src/java.base/share/native/libjli/wildcard.c
jdk/src/java.base/unix/native/libjli/java_md.h
jdk/src/java.base/unix/native/libjli/java_md_common.c
jdk/src/java.base/unix/native/libjli/java_md_solinux.c
jdk/src/java.base/windows/native/libjli/cmdtoargs.c
jdk/src/java.base/windows/native/libjli/java_md.c
jdk/src/java.base/windows/native/libjli/java_md.h
--- a/jdk/make/lib/CoreLibraries.gmk	Thu Apr 02 14:25:27 2015 -0400
+++ b/jdk/make/lib/CoreLibraries.gmk	Thu Apr 02 11:54:33 2015 -0700
@@ -269,7 +269,7 @@
 LIBJLI_EXCLUDE_FILES += $(notdir $(LIBJLI_EXCLUDE_ERGO))
 
 ifeq ($(OPENJDK_TARGET_OS), macosx)
-  LIBJLI_EXCLUDE_FILES += java_md_solinux.c ergo.c
+  LIBJLI_EXCLUDE_FILES += java_md_solinux.c ergo.c ergo_i586.c
 
   BUILD_LIBJLI_java_md_macosx.c_CFLAGS := -x objective-c
   BUILD_LIBJLI_STATIC_java_md_macosx.c_CFLAGS := -x objective-c
@@ -317,12 +317,7 @@
     LANG := C, \
     OPTIMIZATION := HIGH, \
     CFLAGS := $(LIBJLI_CFLAGS), \
-    DISABLED_WARNINGS_gcc := pointer-to-int-cast sign-compare format-nonliteral \
-        parentheses, \
-    DISABLED_WARNINGS_clang := implicit-function-declaration parentheses \
-        int-conversion, \
-    DISABLED_WARNINGS_solstudio := E_ASM_DISABLES_OPTIMIZATION E_NEWLINE_NOT_LAST, \
-    DISABLED_WARNINGS_microsoft := 4244 4047 4267, \
+    DISABLED_WARNINGS_solstudio := E_ASM_DISABLES_OPTIMIZATION, \
     MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjli/mapfile-vers, \
     LDFLAGS := $(LDFLAGS_JDKLIB) \
         $(call SET_SHARED_LIBRARY_ORIGIN), \
@@ -371,7 +366,6 @@
       LANG := C, \
       OPTIMIZATION := HIGH, \
       CFLAGS := $(STATIC_LIBRARY_FLAGS) $(LIBJLI_CFLAGS), \
-      DISABLED_WARNINGS_microsoft := 4244 4047 4267, \
       ARFLAGS := $(ARFLAGS), \
       OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjli_static, \
       DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))
@@ -392,8 +386,6 @@
       LANG := C, \
       OPTIMIZATION := HIGH, \
       CFLAGS := $(CFLAGS_JDKLIB) $(LIBJLI_CFLAGS), \
-      DISABLED_WARNINGS_clang := implicit-function-declaration parentheses \
-          int-conversion, \
       LDFLAGS := -nostdlib -r, \
       OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjli_static, \
       DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))
--- a/jdk/src/java.base/macosx/native/libjli/java_md_macosx.c	Thu Apr 02 14:25:27 2015 -0400
+++ b/jdk/src/java.base/macosx/native/libjli/java_md_macosx.c	Thu Apr 02 11:54:33 2015 -0700
@@ -852,7 +852,7 @@
     if (pthread_create(&tid, &attr, (void *(*)(void*))continuation, (void*)args) == 0) {
       void * tmp;
       pthread_join(tid, &tmp);
-      rslt = (int)tmp;
+      rslt = (int)(intptr_t)tmp;
     } else {
      /*
       * Continue execution in current thread if for some reason (e.g. out of
--- a/jdk/src/java.base/share/native/libjli/java.c	Thu Apr 02 14:25:27 2015 -0400
+++ b/jdk/src/java.base/share/native/libjli/java.c	Thu Apr 02 11:54:33 2015 -0700
@@ -730,7 +730,7 @@
 static int
 parse_size(const char *s, jlong *result) {
   jlong n = 0;
-  int args_read = sscanf(s, jlong_format_specifier(), &n);
+  int args_read = sscanf(s, JLONG_FORMAT_SPECIFIER, &n);
   if (args_read != 1) {
     return 0;
   }
@@ -798,7 +798,7 @@
              * overflow before the JVM startup code can check to make sure the stack
              * is big enough.
              */
-            if (threadStackSize < STACK_SIZE_MINIMUM) {
+            if (threadStackSize < (jlong)STACK_SIZE_MINIMUM) {
                 threadStackSize = STACK_SIZE_MINIMUM;
             }
         }
--- a/jdk/src/java.base/share/native/libjli/java.h	Thu Apr 02 14:25:27 2015 -0400
+++ b/jdk/src/java.base/share/native/libjli/java.h	Thu Apr 02 11:54:33 2015 -0700
@@ -144,8 +144,6 @@
 void JLI_ReportExceptionDescription(JNIEnv * env);
 void PrintMachineDependentOptions();
 
-const char *jlong_format_specifier();
-
 /*
  * Block current thread and continue execution in new thread
  */
--- a/jdk/src/java.base/share/native/libjli/parse_manifest.c	Thu Apr 02 14:25:27 2015 -0400
+++ b/jdk/src/java.base/share/native/libjli/parse_manifest.c	Thu Apr 02 11:54:33 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -133,7 +133,7 @@
 
 /** Reads count bytes from fd at position pos into given buffer. */
 static jboolean
-readAt(int fd, jlong pos, size_t count, void *buf) {
+readAt(int fd, jlong pos, unsigned int count, void *buf) {
     return (pos >= 0
             && JLI_Lseek(fd, pos, SEEK_SET) == pos
             && read(fd, buf, count) == (jlong) count);
@@ -249,7 +249,7 @@
      */
     if ((pos = JLI_Lseek(fd, -ENDHDR, SEEK_END)) < (jlong)0)
         return (-1);
-    if ((bytes = read(fd, eb, ENDHDR)) < 0)
+    if (read(fd, eb, ENDHDR) < 0)
         return (-1);
     if (ENDSIG_AT(eb)) {
         return find_positions64(fd, eb, pos, base_offset, censtart);
@@ -268,7 +268,13 @@
         return (-1);
     if ((buffer = malloc(END_MAXLEN)) == NULL)
         return (-1);
-    if ((bytes = read(fd, buffer, len)) < 0) {
+
+    /*
+     * read() on windows takes an unsigned int for count. Casting len
+     * to an unsigned int here is safe since it is guaranteed to be
+     * less than END_MAXLEN.
+     */
+    if ((bytes = read(fd, buffer, (unsigned int)len)) < 0) {
         free(buffer);
         return (-1);
     }
@@ -591,7 +597,7 @@
     info->jre_version = NULL;
     info->jre_restrict_search = 0;
     info->splashscreen_image_file_name = NULL;
-    if (rc = find_file(fd, &entry, manifest_name) != 0) {
+    if ((rc = find_file(fd, &entry, manifest_name)) != 0) {
         close(fd);
         return (-2);
     }
@@ -692,7 +698,7 @@
         return (-1);
     }
 
-    if (rc = find_file(fd, &entry, manifest_name) != 0) {
+    if ((rc = find_file(fd, &entry, manifest_name)) != 0) {
         close(fd);
         return (-2);
     }
--- a/jdk/src/java.base/share/native/libjli/splashscreen_stubs.c	Thu Apr 02 14:25:27 2015 -0400
+++ b/jdk/src/java.base/share/native/libjli/splashscreen_stubs.c	Thu Apr 02 11:54:33 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -61,11 +61,11 @@
 #define INVOKEV(name) _INVOKE(name, ,;)
 
 int     DoSplashLoadMemory(void* pdata, int size) {
-    INVOKE(SplashLoadMemory, NULL)(pdata, size);
+    INVOKE(SplashLoadMemory, 0)(pdata, size);
 }
 
 int     DoSplashLoadFile(const char* filename) {
-    INVOKE(SplashLoadFile, NULL)(filename);
+    INVOKE(SplashLoadFile, 0)(filename);
 }
 
 void    DoSplashInit(void) {
@@ -87,4 +87,4 @@
 char*    DoSplashGetScaledImageName(const char* fileName, const char* jarName,
                                     float* scaleFactor) {
     INVOKE(SplashGetScaledImageName, NULL)(fileName, jarName, scaleFactor);
-}
\ No newline at end of file
+}
--- a/jdk/src/java.base/share/native/libjli/wildcard.c	Thu Apr 02 14:25:27 2015 -0400
+++ b/jdk/src/java.base/share/native/libjli/wildcard.c	Thu Apr 02 11:54:33 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, 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
@@ -274,7 +274,7 @@
 }
 
 static void
-FileList_addSubstring(FileList fl, const char *beg, int len)
+FileList_addSubstring(FileList fl, const char *beg, size_t len)
 {
     char *filename = (char *) JLI_MemAlloc(len+1);
     memcpy(filename, beg, len);
@@ -310,7 +310,7 @@
 FileList_split(const char *path, char sep)
 {
     const char *p, *q;
-    int len = (int)JLI_StrLen(path);
+    size_t len = JLI_StrLen(path);
     int count;
     FileList fl;
     for (count = 1, p = path; p < path + len; p++)
--- a/jdk/src/java.base/unix/native/libjli/java_md.h	Thu Apr 02 14:25:27 2015 -0400
+++ b/jdk/src/java.base/unix/native/libjli/java_md.h	Thu Apr 02 11:54:33 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2014, 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
@@ -43,6 +43,12 @@
 #define MAXNAMELEN              PATH_MAX
 #endif
 
+#ifdef _LP64
+#define JLONG_FORMAT_SPECIFIER "%ld"
+#else
+#define JLONG_FORMAT_SPECIFIER "%lld"
+#endif
+
 int UnsetEnv(char *name);
 char *FindExecName(char *program);
 const char *SetExecname(char **argv);
--- a/jdk/src/java.base/unix/native/libjli/java_md_common.c	Thu Apr 02 14:25:27 2015 -0400
+++ b/jdk/src/java.base/unix/native/libjli/java_md_common.c	Thu Apr 02 11:54:33 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -269,11 +269,6 @@
     return(borrowed_unsetenv(name));
 }
 
-const char *
-jlong_format_specifier() {
-    return "%lld";
-}
-
 jboolean
 IsJavaw()
 {
--- a/jdk/src/java.base/unix/native/libjli/java_md_solinux.c	Thu Apr 02 14:25:27 2015 -0400
+++ b/jdk/src/java.base/unix/native/libjli/java_md_solinux.c	Thu Apr 02 11:54:33 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2014, 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
@@ -888,7 +888,7 @@
     if (pthread_create(&tid, &attr, (void *(*)(void*))continuation, (void*)args) == 0) {
       void * tmp;
       pthread_join(tid, &tmp);
-      rslt = (int)tmp;
+      rslt = (int)(intptr_t)tmp;
     } else {
      /*
       * Continue execution in current thread if for some reason (e.g. out of
@@ -906,7 +906,7 @@
     if (thr_create(NULL, stack_size, (void *(*)(void *))continuation, args, flags, &tid) == 0) {
       void * tmp;
       thr_join(tid, NULL, &tmp);
-      rslt = (int)tmp;
+      rslt = (int)(intptr_t)tmp;
     } else {
       /* See above. Continue in current thread if thr_create() failed */
       rslt = continuation(args);
--- a/jdk/src/java.base/windows/native/libjli/cmdtoargs.c	Thu Apr 02 14:25:27 2015 -0400
+++ b/jdk/src/java.base/windows/native/libjli/cmdtoargs.c	Thu Apr 02 11:54:33 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -77,7 +77,7 @@
     USHORT ch = 0;
     int i;
     jboolean done = JNI_FALSE;
-    int charLength;
+    ptrdiff_t charLength;
 
     *wildcard = JNI_FALSE;
     while (!done) {
@@ -208,10 +208,12 @@
         argv = (StdArg*) JLI_MemRealloc(argv, (nargs+1) * sizeof(StdArg));
         argv[nargs].arg = JLI_StringDup(arg);
         argv[nargs].has_wildcard = wildcard;
-        *arg = NULL;
+        *arg = '\0';
         nargs++;
     } while (src != NULL);
 
+    JLI_MemFree(arg);
+
     stdargc = nargs;
     stdargs = argv;
 }
--- a/jdk/src/java.base/windows/native/libjli/java_md.c	Thu Apr 02 14:25:27 2015 -0400
+++ b/jdk/src/java.base/windows/native/libjli/java_md.c	Thu Apr 02 11:54:33 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, 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
@@ -107,7 +107,7 @@
  * GetParamValue("theParam", "theParam=value") returns pointer to "value".
  */
 const char * GetParamValue(const char *paramName, const char *arg) {
-    int nameLen = JLI_StrLen(paramName);
+    size_t nameLen = JLI_StrLen(paramName);
     if (JLI_StrNCmp(paramName, arg, nameLen) == 0) {
         /* arg[nameLen] is valid (may contain final NULL) */
         if (arg[nameLen] == '=') {
@@ -561,7 +561,7 @@
     if (rc < 0) {
         /* apply ansi semantics */
         buffer[size - 1] = '\0';
-        return size;
+        return (int)size;
     } else if (rc == size) {
         /* force a null terminator */
         buffer[size - 1] = '\0';
@@ -728,11 +728,6 @@
     }
 }
 
-const char *
-jlong_format_specifier() {
-    return "%I64d";
-}
-
 /*
  * Block current thread and continue execution in a new thread
  */
@@ -882,7 +877,7 @@
     if (hPreloadAwt == NULL) {
         /* awt.dll is not loaded yet */
         char libraryPath[MAXPATHLEN];
-        int jrePathLen = 0;
+        size_t jrePathLen = 0;
         HMODULE hJava = NULL;
         HMODULE hVerify = NULL;
 
@@ -1004,7 +999,8 @@
 jobjectArray
 CreateApplicationArgs(JNIEnv *env, char **strv, int argc)
 {
-    int i, j, idx, tlen;
+    int i, j, idx;
+    size_t tlen;
     jobjectArray outArray, inArray;
     char *ostart, *astart, **nargv;
     jboolean needs_expansion = JNI_FALSE;
--- a/jdk/src/java.base/windows/native/libjli/java_md.h	Thu Apr 02 14:25:27 2015 -0400
+++ b/jdk/src/java.base/windows/native/libjli/java_md.h	Thu Apr 02 11:54:33 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2014, 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
@@ -39,6 +39,7 @@
 #define MAXPATHLEN      MAX_PATH
 #define MAXNAMELEN      MAX_PATH
 
+#define JLONG_FORMAT_SPECIFIER "%I64d"
 
 /*
  * Support for doing cheap, accurate interval timing.