8310920: Fix -Wconversion warnings in command line flags

Reviewed-by: iklam, dholmes
This commit is contained in:
Coleen Phillimore 2023-06-28 12:24:39 +00:00
parent c2e9485481
commit 08c51f25d2
4 changed files with 18 additions and 18 deletions

View File

@ -579,10 +579,10 @@ JVMFlag* JVMFlag::find_flag(const char* name, size_t length, bool allow_locked,
}
JVMFlag* JVMFlag::fuzzy_match(const char* name, size_t length, bool allow_locked) {
float VMOptionsFuzzyMatchSimilarity = 0.7f;
double VMOptionsFuzzyMatchSimilarity = 0.7;
JVMFlag* match = nullptr;
float score;
float max_score = -1;
double score;
double max_score = -1;
for (JVMFlag* current = &flagTable[0]; current->_name != nullptr; current++) {
score = StringUtils::similarity(current->_name, strlen(current->_name), name, length);

View File

@ -64,7 +64,7 @@ public:
verbose |= (origin == JVMFlagOrigin::ERGONOMIC);
T value = *((T*)value_addr);
const JVMTypedFlagLimit<T>* constraint = (const JVMTypedFlagLimit<T>*)JVMFlagLimit::get_constraint(flag);
if (constraint != nullptr && constraint->phase() <= static_cast<int>(JVMFlagLimit::validating_phase())) {
if (constraint != nullptr && constraint->phase() <= JVMFlagLimit::validating_phase()) {
JVMFlag::Error err = typed_check_constraint(constraint->constraint_func(), value, verbose);
if (err != JVMFlag::SUCCESS) {
if (origin == JVMFlagOrigin::ERGONOMIC) {

View File

@ -79,13 +79,13 @@ public:
static constexpr const JVMFlagLimit* get_limit(const JVMTypedFlagLimit<T>* p, int dummy, T min, T max) {
return p;
}
static constexpr const JVMFlagLimit* get_limit(const JVMTypedFlagLimit<T>* p, int dummy, ConstraintMarker dummy2, short func, int phase) {
static constexpr const JVMFlagLimit* get_limit(const JVMTypedFlagLimit<T>* p, int dummy, ConstraintMarker dummy2, short func, JVMFlagConstraintPhase phase) {
return p;
}
static constexpr const JVMFlagLimit* get_limit(const JVMTypedFlagLimit<T>* p, int dummy, T min, T max, ConstraintMarker dummy2, short func, int phase) {
static constexpr const JVMFlagLimit* get_limit(const JVMTypedFlagLimit<T>* p, int dummy, T min, T max, ConstraintMarker dummy2, short func, JVMFlagConstraintPhase phase) {
return p;
}
static constexpr const JVMFlagLimit* get_limit(const JVMTypedFlagLimit<T>* p, int dummy, ConstraintMarker dummy2, short func, int phase, T min, T max) {
static constexpr const JVMFlagLimit* get_limit(const JVMTypedFlagLimit<T>* p, int dummy, ConstraintMarker dummy2, short func, JVMFlagConstraintPhase phase, T min, T max) {
return p;
}
};
@ -98,7 +98,7 @@ public:
#define FLAG_LIMIT_PTR( type, name, ...) ), LimitGetter<type>::get_limit(&limit_##name, 0
#define FLAG_LIMIT_PTR_NONE( type, name, ...) ), LimitGetter<type>::no_limit(0
#define APPLY_FLAG_RANGE(...) , __VA_ARGS__
#define APPLY_FLAG_CONSTRAINT(func, phase) , next_two_args_are_constraint, (short)CONSTRAINT_ENUM(func), int(JVMFlagConstraintPhase::phase)
#define APPLY_FLAG_CONSTRAINT(func, phase) , next_two_args_are_constraint, (short)CONSTRAINT_ENUM(func), JVMFlagConstraintPhase::phase
constexpr JVMTypedFlagLimit<int> limit_dummy
(
@ -179,7 +179,7 @@ bool JVMFlagLimit::check_all_constraints(JVMFlagConstraintPhase phase) {
for (int i = 0; i < NUM_JVMFlagsEnum; i++) {
JVMFlagsEnum flag_enum = static_cast<JVMFlagsEnum>(i);
const JVMFlagLimit* constraint = get_constraint_at(flag_enum);
if (constraint != nullptr && constraint->phase() == static_cast<int>(phase) &&
if (constraint != nullptr && constraint->phase() == phase &&
JVMFlagAccess::check_constraint(JVMFlag::flag_from_enum(flag_enum),
constraint->constraint_func(), true) != JVMFlag::SUCCESS) {
status = false;

View File

@ -30,7 +30,7 @@
class outputStream;
template <typename T> class JVMTypedFlagLimit;
enum class JVMFlagConstraintPhase : int {
enum class JVMFlagConstraintPhase : char {
// Will be validated during argument processing (Arguments::parse_argument).
AtParse = 0,
// Will be validated inside Threads::create_vm(), right after Arguments::apply_ergo().
@ -67,7 +67,7 @@ template <typename T> class JVMTypedFlagLimit;
class JVMFlagLimit {
short _constraint_func;
char _phase;
JVMFlagConstraintPhase _phase;
char _kind;
#ifdef ASSERT
@ -100,10 +100,10 @@ private:
public:
void* constraint_func() const;
char phase() const { return _phase; }
JVMFlagConstraintPhase phase() const { return _phase; }
char kind() const { return _kind; }
constexpr JVMFlagLimit(int type_enum, short func, short phase, short kind)
constexpr JVMFlagLimit(int type_enum, short func, JVMFlagConstraintPhase phase, char kind)
: _constraint_func(func), _phase(phase), _kind(kind) DEBUG_ONLY(COMMA _type_enum(type_enum)) {}
static const JVMFlagLimit* get_range(const JVMFlag* flag) {
@ -155,22 +155,22 @@ public:
// dummy - no range or constraint. This object will not be emitted into the .o file
// because we declare it as "const" but has no reference to it.
constexpr JVMTypedFlagLimit(int type_enum) :
JVMFlagLimit(0, 0, 0, 0), _min(0), _max(0) {}
JVMFlagLimit(0, 0, JVMFlagConstraintPhase::AtParse, 0), _min(0), _max(0) {}
// range only
constexpr JVMTypedFlagLimit(int type_enum, T min, T max) :
JVMFlagLimit(type_enum, 0, 0, HAS_RANGE), _min(min), _max(max) {}
JVMFlagLimit(type_enum, 0, JVMFlagConstraintPhase::AtParse, HAS_RANGE), _min(min), _max(max) {}
// constraint only
constexpr JVMTypedFlagLimit(int type_enum, ConstraintMarker dummy2, short func, int phase) :
constexpr JVMTypedFlagLimit(int type_enum, ConstraintMarker dummy2, short func, JVMFlagConstraintPhase phase) :
JVMFlagLimit(type_enum, func, phase, HAS_CONSTRAINT), _min(0), _max(0) {}
// range and constraint
constexpr JVMTypedFlagLimit(int type_enum, T min, T max, ConstraintMarker dummy2, short func, int phase) :
constexpr JVMTypedFlagLimit(int type_enum, T min, T max, ConstraintMarker dummy2, short func, JVMFlagConstraintPhase phase) :
JVMFlagLimit(type_enum, func, phase, HAS_RANGE | HAS_CONSTRAINT), _min(min), _max(max) {}
// constraint and range
constexpr JVMTypedFlagLimit(int type_enum, ConstraintMarker dummy2, short func, int phase, T min, T max) :
constexpr JVMTypedFlagLimit(int type_enum, ConstraintMarker dummy2, short func, JVMFlagConstraintPhase phase, T min, T max) :
JVMFlagLimit(type_enum, func, phase, HAS_RANGE | HAS_CONSTRAINT), _min(min), _max(max) {}
T min() const { return _min; }