[PATCH] Fix compiler warnings with newer GCC 7.2.1
Indu Bhagat
indu.bhagat at oracle.com
Sat Feb 3 00:12:08 UTC 2018
This patch fixes a few of the compiler warnings when using gcc 7.2.1.
In general there are many other warnings (a majority of which are implicit fallthrough warnings in jdk.crypto.ec package's ecp_*.c files and java.desktop package's splashscreen_gfx_impl.h file).
I can post them if there is interest.
Most warnings, however, look benign (modulo some warnings about unintialized access that I cannot comment on; they need that the code be thoroughly understood).
libfdlibm misleading indentation warnings are already knownhttp://mail.openjdk.java.net/pipermail/jdk9-dev/2016-June/004494.html
Thanks
----------------------------------------------
The patch fixes the following warnings :
1. <jdk-dev>/jdk/src/jdk.jdwp.agent/share/native/libdt_socket/socketTransport.c: In function ‘mask_s2u’:
<jdk-dev>/jdk/src/jdk.jdwp.agent/share/native/libdt_socket/socketTransport.c:389:22: warning: left shift of negative value [-Wshift-negative-value]
*mask = htonl(-1 << (32 - m));
^
2. <jdk-dev>/jdk/src/java.desktop/share/native/libjavajpeg/jdphuff.c: In function ‘decode_mcu_AC_refine’:
<jdk-dev>/jdk/src/java.desktop/share/native/libjavajpeg/jdphuff.c:505:17: warning: left shift of negative value [-Wshift-negative-value]
int m1 = (-1) << cinfo->Al; /* -1 in the bit position being coded */
^~
3. <jdk-dev>/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-fallback.cc: In function ‘void position_mark(const hb_ot_shape_plan_t*, hb_font_t*, hb_buffer_t*, hb_glyph_extents_t&, unsigned int, unsigned int)’:
<jdk-dev>/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-fallback.cc:223:14: warning: this statement may fall through [-Wimplicit-fallthrough=]
} else if (buffer->props.direction == HB_DIRECTION_RTL) {
^~
<jdk-dev>/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-fallback.cc:229:5: note: here
default:
^~~~~~~
<jdk-dev>/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-fallback.cc:261:27: warning: this statement may fall through [-Wimplicit-fallthrough=]
base_extents.height -= y_gap;
~~~~~~~~~~~~~~~~~~~~^~~~~~~~
<jdk-dev>/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-fallback.cc:264:5: note: here
case HB_UNICODE_COMBINING_CLASS_ATTACHED_BELOW_LEFT:
^~~~
<jdk-dev>/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-fallback.cc:282:27: warning: this statement may fall through [-Wimplicit-fallthrough=]
base_extents.height -= y_gap;
~~~~~~~~~~~~~~~~~~~~^~~~~~~~
<jdk-dev>/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-fallback.cc:285:5: note: here
case HB_UNICODE_COMBINING_CLASS_ATTACHED_ABOVE:
^~~~
-----------
diff --git a/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-private.hh b/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-private.hh
--- a/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-private.hh
+++ b/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-private.hh
@@ -158,6 +158,9 @@
*/
# include <sal.h>
# define HB_FALLTHROUGH __fallthrough
+#elif __GNUC__ >= 7
+ /* GNU fallthrough attribute is available from GCC7 */
+# define HB_FALLTHROUGH __attribute__((fallthrough))
#else
# define HB_FALLTHROUGH /* FALLTHROUGH */
#endif
diff --git a/src/java.desktop/share/native/libjavajpeg/jdphuff.c b/src/java.desktop/share/native/libjavajpeg/jdphuff.c
--- a/src/java.desktop/share/native/libjavajpeg/jdphuff.c
+++ b/src/java.desktop/share/native/libjavajpeg/jdphuff.c
@@ -501,8 +501,10 @@
{
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
int Se = cinfo->Se;
- int p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
- int m1 = (-1) << cinfo->Al; /* -1 in the bit position being coded */
+ /* 1 in the bit position being coded */
+ int p1 = 1 << cinfo->Al;
+ /* -1 in the bit position being coded */
+ int m1 = (int)((unsigned)(~0) << cinfo->Al);
register int s, k, r;
unsigned int EOBRUN;
JBLOCKROW block;
diff --git a/src/jdk.jdwp.agent/share/native/libdt_socket/socketTransport.c b/src/jdk.jdwp.agent/share/native/libdt_socket/socketTransport.c
--- a/src/jdk.jdwp.agent/share/native/libdt_socket/socketTransport.c
+++ b/src/jdk.jdwp.agent/share/native/libdt_socket/socketTransport.c
@@ -386,7 +386,7 @@
return instr;
}
- *mask = htonl(-1 << (32 - m));
+ *mask = htonl((uint32_t)(~0) << (32 - m));
return s;
}
More information about the core-libs-dev
mailing list