# HG changeset patch # User shade # Date 1551870115 -3600 # Wed Mar 06 12:01:55 2019 +0100 # Node ID f88fbb5fc0854eff4e3535ea0d8bd85e6da46b94 # Parent 13acb433989549d83c6d50223a1751857f2c6fbc 8074817: Resolve disabled warnings for libverify Reviewed-by: XXX diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk --- a/make/lib/CoreLibraries.gmk +++ b/make/lib/CoreLibraries.gmk @@ -78,8 +78,6 @@ NAME := verify, \ OPTIMIZATION := $(LIBVERIFY_OPTIMIZATION), \ CFLAGS := $(CFLAGS_JDKLIB), \ - DISABLED_WARNINGS_gcc := implicit-fallthrough unused-function, \ - DISABLED_WARNINGS_microsoft := 4244 4267, \ LDFLAGS := $(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ LIBS_unix := -ljvm, \ diff --git a/src/java.base/share/native/libverify/check_code.c b/src/java.base/share/native/libverify/check_code.c --- a/src/java.base/share/native/libverify/check_code.c +++ b/src/java.base/share/native/libverify/check_code.c @@ -707,6 +707,7 @@ return *pID; } +#ifdef DEBUG static const char * ID_to_class_name(context_type *context, unsigned short ID) { @@ -714,6 +715,7 @@ hash_bucket_type *bucket = GET_BUCKET(class_hash, ID); return bucket->name; } +#endif static jclass ID_to_class(context_type *context, unsigned short ID) @@ -1390,7 +1392,7 @@ case JVM_OPC_invokedynamic: CCerror(context, "invokedynamic bytecode is not supported in this class file version"); - + break; case JVM_OPC_instanceof: case JVM_OPC_checkcast: case JVM_OPC_new: @@ -1699,7 +1701,9 @@ if ((index < 0) || (index > 65535)) { return -1; /* illegal */ } else { - return (unsigned char *)(&lpc[index + 4]) - iptr; + unsigned char *finish = (unsigned char *)(&lpc[index + 4]); + assert(finish >= iptr); + return (int)(finish - iptr); } } @@ -1714,8 +1718,11 @@ */ if (npairs < 0 || npairs >= 65536) return -1; - else - return (unsigned char *)(&lpc[2 * (npairs + 1)]) - iptr; + else { + unsigned char *finish = (unsigned char *)(&lpc[2 * (npairs + 1)]); + assert(finish >= iptr); + return (int)(finish - iptr); + } } case JVM_OPC_wide: @@ -3828,7 +3835,8 @@ result = 0; break; } - length = finish - p; + assert(finish >= p); + length = (int)(finish - p); if (length + 1 > (int)sizeof(buffer_space)) { buffer = malloc(length + 1); check_and_push(context, buffer, VM_MALLOC_BLK); diff --git a/src/java.base/share/native/libverify/check_format.c b/src/java.base/share/native/libverify/check_format.c --- a/src/java.base/share/native/libverify/check_format.c +++ b/src/java.base/share/native/libverify/check_format.c @@ -23,6 +23,8 @@ * questions. */ +#include +#include #include #include #include @@ -232,7 +234,9 @@ JNIEXPORT jboolean VerifyClassname(char *name, jboolean allowArrayClass) { - unsigned int length = strlen(name); + size_t s = strlen(name); + assert(s <= UINT_MAX); + unsigned int length = (unsigned int)s; char *p; if (length > 0 && name[0] == JVM_SIGNATURE_ARRAY) {