8074819: Resolve disabled warnings for libzip
authorsherman
Fri, 03 Jun 2016 16:31:13 -0700
changeset 38783 0a5acb647700
parent 38782 ff27bc5c278e
child 38784 c0a88deb692a
8074819: Resolve disabled warnings for libzip Reviewed-by: naoto
jdk/make/lib/CoreLibraries.gmk
jdk/src/java.base/share/native/libzip/zip_util.c
--- a/jdk/make/lib/CoreLibraries.gmk	Fri Jun 03 12:26:45 2016 -0700
+++ b/jdk/make/lib/CoreLibraries.gmk	Fri Jun 03 16:31:13 2016 -0700
@@ -212,9 +212,6 @@
         -I$(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjava \
         -I$(SUPPORT_OUTPUTDIR)/headers/java.base, \
     CFLAGS_unix := $(BUILD_LIBZIP_MMAP) -UDEBUG, \
-    DISABLED_WARNINGS_gcc := parentheses, \
-    DISABLED_WARNINGS_clang := dangling-else, \
-    DISABLED_WARNINGS_microsoft := 4267, \
     MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libzip/mapfile-vers, \
     REORDER := $(BUILD_LIBZIP_REORDER), \
     LDFLAGS := $(LDFLAGS_JDKLIB) \
--- a/jdk/src/java.base/share/native/libzip/zip_util.c	Fri Jun 03 12:26:45 2016 -0700
+++ b/jdk/src/java.base/share/native/libzip/zip_util.c	Fri Jun 03 16:31:13 2016 -0700
@@ -582,16 +582,17 @@
         }
     }
 
-    if (cenlen > endpos)
+    if (cenlen > endpos) {
         ZIP_FORMAT_ERROR("invalid END header (bad central directory size)");
+    }
     cenpos = endpos - cenlen;
 
     /* Get position of first local file (LOC) header, taking into
      * account that there may be a stub prefixed to the zip file. */
     zip->locpos = cenpos - cenoff;
-    if (zip->locpos < 0)
+    if (zip->locpos < 0) {
         ZIP_FORMAT_ERROR("invalid END header (bad central directory offset)");
-
+    }
 #ifdef USE_MMAP
     if (zip->usemmap) {
       /* On Solaris & Linux prior to JDK 6, we used to mmap the whole jar file to
@@ -681,15 +682,18 @@
         method = CENHOW(cp);
         nlen   = CENNAM(cp);
 
-        if (!CENSIG_AT(cp))
+        if (!CENSIG_AT(cp)) {
             ZIP_FORMAT_ERROR("invalid CEN header (bad signature)");
-        if (CENFLG(cp) & 1)
+        }
+        if (CENFLG(cp) & 1) {
             ZIP_FORMAT_ERROR("invalid CEN header (encrypted entry)");
-        if (method != STORED && method != DEFLATED)
+        }
+        if (method != STORED && method != DEFLATED) {
             ZIP_FORMAT_ERROR("invalid CEN header (bad compression method)");
-        if (cp + CENHDR + nlen > cenend)
+        }
+        if (cp + CENHDR + nlen > cenend) {
             ZIP_FORMAT_ERROR("invalid CEN header (bad header size)");
-
+        }
         /* if the entry is metadata add it to our metadata names */
         if (isMetaName((char *)cp+CENHDR, nlen))
             if (addMetaName(zip, (char *)cp+CENHDR, nlen) != 0)
@@ -704,9 +708,9 @@
         entries[i].next = table[hsh];
         table[hsh] = i;
     }
-    if (cp != cenend)
+    if (cp != cenend) {
         ZIP_FORMAT_ERROR("invalid CEN header (bad header size)");
-
+    }
     zip->total = i;
     goto Finally;
 
@@ -1115,7 +1119,7 @@
 ZIP_GetEntry(jzfile *zip, char *name, jint ulen)
 {
     if (ulen == 0) {
-        return ZIP_GetEntry2(zip, name, strlen(name), JNI_FALSE);
+        return ZIP_GetEntry2(zip, name, (jint)strlen(name), JNI_FALSE);
     }
     return ZIP_GetEntry2(zip, name, ulen, JNI_TRUE);
 }
@@ -1441,7 +1445,7 @@
     jzentry *entry = ZIP_GetEntry(zip, name, 0);
     if (entry) {
         *sizeP = (jint)entry->size;
-        *nameLenP = strlen(entry->name);
+        *nameLenP = (jint)strlen(entry->name);
     }
     return entry;
 }