8074817: Resolve disabled warnings for libverify

Reviewed-by: erikj, alanb
This commit is contained in:
Aleksey Shipilev 2019-03-11 12:39:51 +01:00
parent 164fcbbec9
commit 5c0f32e4b7
3 changed files with 18 additions and 8 deletions

View File

@ -78,8 +78,6 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBVERIFY, \
NAME := verify, \ NAME := verify, \
OPTIMIZATION := $(LIBVERIFY_OPTIMIZATION), \ OPTIMIZATION := $(LIBVERIFY_OPTIMIZATION), \
CFLAGS := $(CFLAGS_JDKLIB), \ CFLAGS := $(CFLAGS_JDKLIB), \
DISABLED_WARNINGS_gcc := implicit-fallthrough unused-function, \
DISABLED_WARNINGS_microsoft := 4244 4267, \
LDFLAGS := $(LDFLAGS_JDKLIB) \ LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \ $(call SET_SHARED_LIBRARY_ORIGIN), \
LIBS_unix := -ljvm, \ LIBS_unix := -ljvm, \

View File

@ -707,6 +707,7 @@ done:
return *pID; return *pID;
} }
#ifdef DEBUG
static const char * static const char *
ID_to_class_name(context_type *context, unsigned short ID) ID_to_class_name(context_type *context, unsigned short ID)
{ {
@ -714,6 +715,7 @@ ID_to_class_name(context_type *context, unsigned short ID)
hash_bucket_type *bucket = GET_BUCKET(class_hash, ID); hash_bucket_type *bucket = GET_BUCKET(class_hash, ID);
return bucket->name; return bucket->name;
} }
#endif
static jclass static jclass
ID_to_class(context_type *context, unsigned short ID) ID_to_class(context_type *context, unsigned short ID)
@ -1390,7 +1392,7 @@ verify_opcode_operands(context_type *context, unsigned int inumber, int offset)
case JVM_OPC_invokedynamic: case JVM_OPC_invokedynamic:
CCerror(context, CCerror(context,
"invokedynamic bytecode is not supported in this class file version"); "invokedynamic bytecode is not supported in this class file version");
break;
case JVM_OPC_instanceof: case JVM_OPC_instanceof:
case JVM_OPC_checkcast: case JVM_OPC_checkcast:
case JVM_OPC_new: case JVM_OPC_new:
@ -1699,7 +1701,9 @@ static int instruction_length(unsigned char *iptr, unsigned char *end)
if ((index < 0) || (index > 65535)) { if ((index < 0) || (index > 65535)) {
return -1; /* illegal */ return -1; /* illegal */
} else { } 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 @@ static int instruction_length(unsigned char *iptr, unsigned char *end)
*/ */
if (npairs < 0 || npairs >= 65536) if (npairs < 0 || npairs >= 65536)
return -1; return -1;
else else {
return (unsigned char *)(&lpc[2 * (npairs + 1)]) - iptr; unsigned char *finish = (unsigned char *)(&lpc[2 * (npairs + 1)]);
assert(finish >= iptr);
return (int)(finish - iptr);
}
} }
case JVM_OPC_wide: case JVM_OPC_wide:
@ -3828,7 +3835,8 @@ signature_to_fieldtype(context_type *context,
result = 0; result = 0;
break; break;
} }
length = finish - p; assert(finish >= p);
length = (int)(finish - p);
if (length + 1 > (int)sizeof(buffer_space)) { if (length + 1 > (int)sizeof(buffer_space)) {
buffer = malloc(length + 1); buffer = malloc(length + 1);
check_and_push(context, buffer, VM_MALLOC_BLK); check_and_push(context, buffer, VM_MALLOC_BLK);

View File

@ -23,6 +23,8 @@
* questions. * questions.
*/ */
#include <assert.h>
#include <limits.h>
#include <setjmp.h> #include <setjmp.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -232,7 +234,9 @@ skip_over_field_signature(char *name, jboolean void_okay,
JNIEXPORT jboolean JNIEXPORT jboolean
VerifyClassname(char *name, jboolean allowArrayClass) 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; char *p;
if (length > 0 && name[0] == JVM_SIGNATURE_ARRAY) { if (length > 0 && name[0] == JVM_SIGNATURE_ARRAY) {