[OpenJDK 2D-Dev] Fwd: [PATCH] Fix compiler warnings with newer GCC 7.2.1

Indu Bhagat indu.bhagat at oracle.com
Tue Feb 6 19:00:40 UTC 2018


Thanks. harfbuzz is now fixed upstream. libjpeg has acknowledged the 
patch for shift-negative-value warnings.

Can someone advise on the minor fix in libdt_socket component ?


On 02/03/2018 05:47 AM, Philip Race wrote:
> jpeg + harfbuzz are imported libraries. There's no point in a source 
> fix in JDK'scopy as
> it will get overwritten when we upgrade. No way we are tracking such 
> patches to reapply them.
>
> If warnings there are an issue either update the makefiles or use 
> disable-warnings-as-errors
> ... and perhaps report the issue upstream ..
>
> -phil.
>
> On 2/3/18, 1:35 AM, Alan Bateman wrote:
>>
>> This was sent to core-libs-dev, I assume it was meant for 2d-dev and 
>> serviceability-dev.
>>
>> -------- Forwarded Message --------
>> Subject: 	[PATCH] Fix compiler warnings with newer GCC 7.2.1
>> Date: 	Fri, 2 Feb 2018 16:12:08 -0800
>> From: 	Indu Bhagat <indu.bhagat at oracle.com>
>> To: 	core-libs-dev at openjdk.java.net
>>
>>
>>
>> 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;
>>   }
>>   
>>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/serviceability-dev/attachments/20180206/c64339fd/attachment.html>


More information about the serviceability-dev mailing list