Skip to content

Commit

Permalink
[EagerAppCDS] fix strlen usage (warnings: conversion from 'size_t' to…
Browse files Browse the repository at this point in the history
… 'int')

Summary: conversion from 'size_t' to 'int', possible loss of data

Test Plan: windows build

Reviewed-by: lei.yul, lingjun-cg

Issue: dragonwell-project#559

CR:
  • Loading branch information
jia-wei-tang committed Jul 12, 2023
1 parent 2d8d64e commit 18f1cc9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion hotspot/src/share/vm/classfile/sharedClassUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ ClassPathSegment* SharedPathsMiscInfoExt::to_sorted_segments(const char* path, i
}
ClassPathSegment *cps = NEW_RESOURCE_ARRAY(ClassPathSegment, max_seg_num + 1);

int len = strlen(path);
size_t len = strlen(path);
//not use i < len,but use i<= len for processing the last segment conveniently
for (int i = 0, j = 0; i <= len; i++) {
if (i == len || path[i] == os::path_separator()[0]) {
Expand Down
4 changes: 2 additions & 2 deletions hotspot/src/share/vm/classfile/sharedPathsMiscInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ bool SharedPathsMiscInfo::check(jint type, const char* path) {
case BOOT:
if (strcmp(path, Arguments::get_sysclasspath()) != 0) {
char* sys_cp = Arguments::get_sysclasspath();
int path_len = strlen(path);
int sys_cp_len = strlen(sys_cp);
size_t path_len = strlen(path);
size_t sys_cp_len = strlen(sys_cp);
if(path_len >= sys_cp_len || strncmp(path, sys_cp, path_len) != 0 || !EagerAppCDS || !CDSIgnoreBootClasspathAppend) {
return fail("[BOOT classpath mismatch, actual: -Dsun.boot.class.path=", sys_cp);
} else {
Expand Down

0 comments on commit 18f1cc9

Please sign in to comment.