8196993: Resolve disabled warnings for libunpack
authorsdama
Tue, 12 Jun 2018 14:16:41 +0530
changeset 50514 2a524e603529
parent 50513 7f166e010af4
child 50515 1ce463f497ad
8196993: Resolve disabled warnings for libunpack Summary: captured return values and labelled as fall through to avoid unused-result and implicit-fallthrough gcc warnings Reviewed-by: mchung
make/launcher/Launcher-jdk.pack.gmk
src/jdk.pack/share/native/common-unpack/unpack.cpp
src/jdk.pack/share/native/common-unpack/zip.cpp
--- a/make/launcher/Launcher-jdk.pack.gmk	Mon Jun 11 22:35:07 2018 -0400
+++ b/make/launcher/Launcher-jdk.pack.gmk	Tue Jun 12 14:16:41 2018 +0530
@@ -90,7 +90,6 @@
     CFLAGS_linux := -fPIC, \
     CFLAGS_solaris := -KPIC, \
     CFLAGS_macosx := -fPIC, \
-    DISABLED_WARNINGS_gcc := unused-result implicit-fallthrough, \
     LDFLAGS := $(UNPACKEXE_ZIPOBJS) \
         $(LDFLAGS_JDKEXE) $(LDFLAGS_CXX_JDK) \
         $(call SET_SHARED_LIBRARY_ORIGIN), \
--- a/src/jdk.pack/share/native/common-unpack/unpack.cpp	Mon Jun 11 22:35:07 2018 -0400
+++ b/src/jdk.pack/share/native/common-unpack/unpack.cpp	Tue Jun 12 14:16:41 2018 +0530
@@ -1799,6 +1799,7 @@
     case 'B': case 'H': case 'I': case 'V': // unsigned_int
     case 'S': // signed_int
       --lp; // reparse
+      /* fall through */
     case 'F':
       lp = parseIntLayout(lp, b, EK_INT);
       break;
--- a/src/jdk.pack/share/native/common-unpack/zip.cpp	Mon Jun 11 22:35:07 2018 -0400
+++ b/src/jdk.pack/share/native/common-unpack/zip.cpp	Tue Jun 12 14:16:41 2018 +0530
@@ -533,6 +533,8 @@
   char* bufptr = (char*) buf;
   char* inbuf = u->gzin->inbuf;
   size_t inbuflen = sizeof(u->gzin->inbuf);
+  // capture return values from fread to avoid -Werror=unused-result issues
+  size_t ret = 0;
   unpacker::read_input_fn_t read_gzin_fn =
     (unpacker::read_input_fn_t) u->gzin->read_input_fn;
   z_stream& zs = *(z_stream*) u->gzin->zstream;
@@ -579,8 +581,8 @@
         fseek(u->infileptr, -TRAILER_LEN, SEEK_END);
         uint filecrc;
         uint filelen;
-        fread(&filecrc, sizeof(filecrc), 1, u->infileptr);
-        fread(&filelen, sizeof(filelen), 1, u->infileptr);
+        ret = fread(&filecrc, sizeof(filecrc), 1, u->infileptr);
+        ret = fread(&filelen, sizeof(filelen), 1, u->infileptr);
         filecrc = SWAP_INT(filecrc);
         filelen = SWAP_INT(filelen);
         if (u->gzin->gzcrc != filecrc ||