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: #559

CR:
  • Loading branch information
jia-wei-tang committed Jul 13, 2023
1 parent 2d8d64e commit 9a3e5ce
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions hotspot/src/share/vm/classfile/sharedClassUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ 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++) {
for (uint i = 0, j = 0; i <= len; i++) {
if (i == len || path[i] == os::path_separator()[0]) {
//i == j mean a empty string
if (i != j) {
Expand Down
8 changes: 4 additions & 4 deletions hotspot/src/share/vm/classfile/sharedPathsMiscInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ 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 {
int start = path_len;
int end = start + 1;
uint start = path_len;
uint end = start + 1;
while(end <= sys_cp_len) {
if(end == sys_cp_len || sys_cp[end] == os::path_separator()[0]) {
if (!SharedClassUtil::is_appended_boot_cp(sys_cp + start + 1, end - start - 1)) {
Expand Down

0 comments on commit 9a3e5ce

Please sign in to comment.