MacOS 10.10.2 : jdk logic/lint cleanup : compiledMethodLoad parse_manifest zip_util TimeZone_md InetAddressImpl Inet6AddressImpl IOUtil AWTWindow ImageSurfaceData imageioJPEG cmsplugin mlib_c_ImageCopy awt_Mlib AS_NS_ConversionUtils jni
Joel Buckley
mail2leoj at gmail.com
Sun Mar 8 10:17:18 UTC 2015
Hello,
Running jdk9 build on MacOS 10.10.2 resulted in several warnings.
Below are changes to eliminate the most basic warnings, that also my introduce
logic incorrectness (e.g. bugs).
Please review below changes for correctness and commit to avoid possible issues.
Thanks,
Joel.
Proposed Changes:
$ hg diff
diff -r c517009905c5 src/demo/share/jvmti/compiledMethodLoad/compiledMethodLoad.c
--- a/src/demo/share/jvmti/compiledMethodLoad/compiledMethodLoad.c Thu Mar 05 11:26:17 2015 -0800
+++ b/src/demo/share/jvmti/compiledMethodLoad/compiledMethodLoad.c Sun Mar 08 03:15:41 2015 -0600
@@ -143,7 +143,7 @@
for (i = 0; i < numpcs; i++) {
PCStackInfo pcrecord = (record->pcinfo[i]);
- fprintf(fp, "PcDescriptor(pc=0x%lx):\n", (jint)(pcrecord.pc));
+ fprintf(fp, "PcDescriptor(pc=0x%x):\n", (jint)(pcrecord.pc));
print_stack_frames(&pcrecord, jvmti, fp);
}
}
diff -r c517009905c5 src/java.base/share/native/libjli/parse_manifest.c
--- a/src/java.base/share/native/libjli/parse_manifest.c Thu Mar 05 11:26:17 2015 -0800
+++ b/src/java.base/share/native/libjli/parse_manifest.c Sun Mar 08 03:15:41 2015 -0600
@@ -577,7 +577,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);
}
@@ -678,7 +678,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);
}
diff -r c517009905c5 src/java.base/share/native/libzip/zip_util.c
--- a/src/java.base/share/native/libzip/zip_util.c Thu Mar 05 11:26:17 2015 -0800
+++ b/src/java.base/share/native/libzip/zip_util.c Sun Mar 08 03:15:41 2015 -0600
@@ -523,7 +523,7 @@
}
#define ZIP_FORMAT_ERROR(message) \
-if (1) { zip->msg = message; goto Catch; } else ((void)0)
+{ if (1) { zip->msg = message; goto Catch; } else { ((void)0); } }
/*
* Reads zip file central directory. Returns the file position of first
diff -r c517009905c5 src/java.base/unix/native/libjava/TimeZone_md.c
--- a/src/java.base/unix/native/libjava/TimeZone_md.c Thu Mar 05 11:26:17 2015 -0800
+++ b/src/java.base/unix/native/libjava/TimeZone_md.c Sun Mar 08 03:15:41 2015 -0600
@@ -735,10 +735,10 @@
local_tm = localtime(&clock);
if (local_tm->tm_gmtoff >= 0) {
offset = (time_t) local_tm->tm_gmtoff;
- sign = "+";
+ sign = '+';
} else {
offset = (time_t) -local_tm->tm_gmtoff;
- sign = "-";
+ sign = '-';
}
sprintf(buf, (const char *)"GMT%c%02d:%02d",
sign, (int)(offset/3600), (int)((offset%3600)/60));
diff -r c517009905c5 src/java.base/unix/native/libnet/Inet4AddressImpl.c
--- a/src/java.base/unix/native/libnet/Inet4AddressImpl.c Thu Mar 05 11:26:17 2015 -0800
+++ b/src/java.base/unix/native/libnet/Inet4AddressImpl.c Sun Mar 08 03:15:41 2015 -0600
@@ -651,7 +651,7 @@
*/
if (icmplen >= 8 && icmp->icmp_type == ICMP_ECHOREPLY
&& (ntohs(icmp->icmp_id) == pid)) {
- if ((him->sin_addr.s_addr == sa_recv.sin_addr.s_addr)) {
+ if (him->sin_addr.s_addr == sa_recv.sin_addr.s_addr) {
close(fd);
return JNI_TRUE;
}
diff -r c517009905c5 src/java.base/unix/native/libnet/Inet6AddressImpl.c
--- a/src/java.base/unix/native/libnet/Inet6AddressImpl.c Thu Mar 05 11:26:17 2015 -0800
+++ b/src/java.base/unix/native/libnet/Inet6AddressImpl.c Sun Mar 08 03:15:41 2015 -0600
@@ -789,7 +789,7 @@
&optlen) <0) {
connect_rv = errno;
}
- if (connect_rv == 0 || ECONNREFUSED) {
+ if (connect_rv == 0 || errno == ECONNREFUSED) {
close(fd);
return JNI_TRUE;
}
diff -r c517009905c5 src/java.base/unix/native/libnio/ch/IOUtil.c
--- a/src/java.base/unix/native/libnio/ch/IOUtil.c Thu Mar 05 11:26:17 2015 -0800
+++ b/src/java.base/unix/native/libnio/ch/IOUtil.c Sun Mar 08 03:15:41 2015 -0600
@@ -129,7 +129,8 @@
JNU_ThrowIOExceptionWithLastError(env, "getrlimit failed");
return -1;
}
- if (rlp.rlim_max < 0 || rlp.rlim_max > java_lang_Integer_MAX_VALUE) {
+ // rlp.rlim_max is unsigned, so only max range check required.
+ if (rlp.rlim_max > java_lang_Integer_MAX_VALUE) {
return java_lang_Integer_MAX_VALUE;
} else {
return (jint)rlp.rlim_max;
diff -r c517009905c5 src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.h
--- a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.h Thu Mar 05 11:26:17 2015 -0800
+++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.h Sun Mar 08 03:15:41 2015 -0600
@@ -94,4 +94,4 @@
contentView:(NSView *)view;
@end
-#endif _AWTWINDOW_H
+#endif /* _AWTWINDOW_H */
diff -r c517009905c5 src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m
--- a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m Thu Mar 05 11:26:17 2015 -0800
+++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m Sun Mar 08 03:15:41 2015 -0600
@@ -827,7 +827,7 @@
// scans the bit field, and only updates the values requested by the mask
// (this implicity handles the _CALLBACK_PROP_BITMASK case, since those are passive reads)
- jint newBits = window.styleBits & ~mask | bits & mask;
+ jint newBits = ((window.styleBits & ~mask) | (bits & mask));
// resets the NSWindow's style mask if the mask intersects any of those bits
if (mask & MASK(_STYLE_PROP_BITMASK)) {
diff -r c517009905c5 src/java.desktop/macosx/native/libawt_lwawt/awt/ImageSurfaceData.m
--- a/src/java.desktop/macosx/native/libawt_lwawt/awt/ImageSurfaceData.m Thu Mar 05 11:26:17 2015 -0800
+++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/ImageSurfaceData.m Sun Mar 08 03:15:41 2015 -0600
@@ -1910,7 +1910,7 @@
jint mask = 0x00000000;
// <rdar://4224874> If the color model is OPAQUE than we need to create an opaque image for performance purposes.
// the default alphaInfo for INDEXED images is kCGImageAlphaFirst. Therefore we need to special case this.
- if ((transparency == java_awt_Transparency_OPAQUE))
+ if (transparency == java_awt_Transparency_OPAQUE)
{
isdo->imageInfo.alphaInfo = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host;
mask = 0xff000000; // this is just a safeguard to make sure we fill the alpha
diff -r c517009905c5 src/java.desktop/share/native/libjavajpeg/imageioJPEG.c
--- a/src/java.desktop/share/native/libjavajpeg/imageioJPEG.c Thu Mar 05 11:26:17 2015 -0800
+++ b/src/java.desktop/share/native/libjavajpeg/imageioJPEG.c Sun Mar 08 03:15:41 2015 -0600
@@ -1770,8 +1770,8 @@
v_samp1 = cinfo->comp_info[1].v_samp_factor;
v_samp2 = cinfo->comp_info[2].v_samp_factor;
- if ((h_samp1 > h_samp0) && (h_samp2 > h_samp0) ||
- (v_samp1 > v_samp0) && (v_samp2 > v_samp0))
+ if (((h_samp1 > h_samp0) && (h_samp2 > h_samp0)) ||
+ ((v_samp1 > v_samp0) && (v_samp2 > v_samp0)))
{
cinfo->jpeg_color_space = JCS_YCCK;
/* Leave the output space as CMYK */
diff -r c517009905c5 src/java.desktop/share/native/liblcms/cmsplugin.c
--- a/src/java.desktop/share/native/liblcms/cmsplugin.c Thu Mar 05 11:26:17 2015 -0800
+++ b/src/java.desktop/share/native/liblcms/cmsplugin.c Sun Mar 08 03:15:41 2015 -0600
@@ -718,7 +718,8 @@
struct _cmsContext_struct* ctx;
void *ptr;
- if (mc < 0 || mc >= MemoryClientMax) {
+ // mc is unsigned enum expression, so only max range testing required.
+ if (mc >= MemoryClientMax) {
cmsSignalError(ContextID, cmsERROR_RANGE, "Bad context client");
return NULL;
}
diff -r c517009905c5 src/java.desktop/share/native/libmlib_image/mlib_c_ImageCopy.c
--- a/src/java.desktop/share/native/libmlib_image/mlib_c_ImageCopy.c Thu Mar 05 11:26:17 2015 -0800
+++ b/src/java.desktop/share/native/libmlib_image/mlib_c_ImageCopy.c Sun Mar 08 03:15:41 2015 -0600
@@ -182,7 +182,7 @@
#define STRIP(pd, ps, w, h, data_type) { \
data_type s0, s1; \
for ( i = 0; i < h; i++ ) { \
- if (j = w & 1) \
+ if ((j = (w & 1)) != 0) \
pd[i * dst_stride] = ps[i * src_stride]; \
for (; j < w; j += 2) { \
s0 = ps[i * src_stride + j]; \
@@ -546,7 +546,7 @@
mlib_u32 *psrc_row = psrc + i * src_stride, *pdst_row = pdst + i * dst_stride;
if (!(((mlib_addr) psrc_row ^ (mlib_addr) pdst_row) & 7)) {
- if (j = ((mlib_s32) ((mlib_addr) psrc_row & 4) >> 2)) {
+ if ((j = ((mlib_s32) ((mlib_addr) psrc_row & 4) >> 2)) != 0) {
pdst_row[0] = psrc_row[0];
}
@@ -575,7 +575,7 @@
{
mlib_u64 *ps, src0, src1;
- if (j = ((mlib_s32) ((mlib_addr) pdst_row & 4) >> 2))
+ if ((j = ((mlib_s32) ((mlib_addr) pdst_row & 4) >> 2)) != 0)
pdst_row[0] = psrc_row[0];
ps = (mlib_u64 *) (psrc_row + j - 1);
src1 = ps[0];
diff -r c517009905c5 src/java.desktop/unix/native/libawt/awt/awt_Mlib.c
--- a/src/java.desktop/unix/native/libawt/awt/awt_Mlib.c Thu Mar 05 11:26:17 2015 -0800
+++ b/src/java.desktop/unix/native/libawt/awt/awt_Mlib.c Sun Mar 08 03:15:41 2015 -0600
@@ -64,9 +64,9 @@
* can use the vis library
*/
if ((uname(&name) >= 0) && (getenv("NO_VIS") == NULL) &&
- (strncmp(name.machine, "sun4u" , 5) == 0) ||
+ ((strncmp(name.machine, "sun4u" , 5) == 0) ||
((strncmp(name.machine, "sun4v" , 5) == 0) &&
- (getenv("USE_VIS_ON_SUN4V") != NULL)))
+ (getenv("USE_VIS_ON_SUN4V") != NULL))))
{
handle = dlopen(JNI_LIB_NAME("mlib_image_v"), RTLD_LAZY);
}
diff -r c517009905c5 src/jdk.deploy.osx/macosx/native/libapplescriptengine/AS_NS_ConversionUtils.m
--- a/src/jdk.deploy.osx/macosx/native/libapplescriptengine/AS_NS_ConversionUtils.m Thu Mar 05 11:26:17 2015 -0800
+++ b/src/jdk.deploy.osx/macosx/native/libapplescriptengine/AS_NS_ConversionUtils.m Sun Mar 08 03:15:41 2015 -0600
@@ -511,7 +511,7 @@
}
[NSException raise:@"jaseUnsupportedAEDescriptorConversion"
- format:@"JavaAppleScriptEngineAdditions: conversion of an NSAppleEventDescriptor with objCType '%s' to an aeDescriptor is not supported.", type];
+ format:@"JavaAppleScriptEngineAdditions: conversion of an NSAppleEventDescriptor with objCType '%u' to an aeDescriptor is not supported.", type];
return nil;
}
diff -r c517009905c5 src/jdk.runtime/share/native/libunpack/jni.cpp
--- a/src/jdk.runtime/share/native/libunpack/jni.cpp Thu Mar 05 11:26:17 2015 -0800
+++ b/src/jdk.runtime/share/native/libunpack/jni.cpp Sun Mar 08 03:15:41 2015 -0600
@@ -292,7 +292,7 @@
if (uPtr->aborting()) {
THROW_IOE(uPtr->get_abort_message());
- return false;
+ return null;
}
// We have fetched all the files.
More information about the jdk9-dev
mailing list