From 08c51f25d2a42fd7a1dae60127d9306f6a54df99 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Wed, 28 Jun 2023 12:24:39 +0000 Subject: [PATCH] 8310920: Fix -Wconversion warnings in command line flags Reviewed-by: iklam, dholmes --- src/hotspot/share/runtime/flags/jvmFlag.cpp | 6 +++--- .../share/runtime/flags/jvmFlagAccess.cpp | 2 +- .../share/runtime/flags/jvmFlagLimit.cpp | 10 +++++----- .../share/runtime/flags/jvmFlagLimit.hpp | 18 +++++++++--------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/hotspot/share/runtime/flags/jvmFlag.cpp b/src/hotspot/share/runtime/flags/jvmFlag.cpp index 6393c68007e..eb41f2ccb4b 100644 --- a/src/hotspot/share/runtime/flags/jvmFlag.cpp +++ b/src/hotspot/share/runtime/flags/jvmFlag.cpp @@ -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); diff --git a/src/hotspot/share/runtime/flags/jvmFlagAccess.cpp b/src/hotspot/share/runtime/flags/jvmFlagAccess.cpp index f4df0ff25b9..386c3bab7f5 100644 --- a/src/hotspot/share/runtime/flags/jvmFlagAccess.cpp +++ b/src/hotspot/share/runtime/flags/jvmFlagAccess.cpp @@ -64,7 +64,7 @@ public: verbose |= (origin == JVMFlagOrigin::ERGONOMIC); T value = *((T*)value_addr); const JVMTypedFlagLimit* constraint = (const JVMTypedFlagLimit*)JVMFlagLimit::get_constraint(flag); - if (constraint != nullptr && constraint->phase() <= static_cast(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) { diff --git a/src/hotspot/share/runtime/flags/jvmFlagLimit.cpp b/src/hotspot/share/runtime/flags/jvmFlagLimit.cpp index e73f4a75856..d0fbb2691c4 100644 --- a/src/hotspot/share/runtime/flags/jvmFlagLimit.cpp +++ b/src/hotspot/share/runtime/flags/jvmFlagLimit.cpp @@ -79,13 +79,13 @@ public: static constexpr const JVMFlagLimit* get_limit(const JVMTypedFlagLimit* p, int dummy, T min, T max) { return p; } - static constexpr const JVMFlagLimit* get_limit(const JVMTypedFlagLimit* p, int dummy, ConstraintMarker dummy2, short func, int phase) { + static constexpr const JVMFlagLimit* get_limit(const JVMTypedFlagLimit* p, int dummy, ConstraintMarker dummy2, short func, JVMFlagConstraintPhase phase) { return p; } - static constexpr const JVMFlagLimit* get_limit(const JVMTypedFlagLimit* p, int dummy, T min, T max, ConstraintMarker dummy2, short func, int phase) { + static constexpr const JVMFlagLimit* get_limit(const JVMTypedFlagLimit* p, int dummy, T min, T max, ConstraintMarker dummy2, short func, JVMFlagConstraintPhase phase) { return p; } - static constexpr const JVMFlagLimit* get_limit(const JVMTypedFlagLimit* p, int dummy, ConstraintMarker dummy2, short func, int phase, T min, T max) { + static constexpr const JVMFlagLimit* get_limit(const JVMTypedFlagLimit* 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::get_limit(&limit_##name, 0 #define FLAG_LIMIT_PTR_NONE( type, name, ...) ), LimitGetter::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 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(i); const JVMFlagLimit* constraint = get_constraint_at(flag_enum); - if (constraint != nullptr && constraint->phase() == static_cast(phase) && + if (constraint != nullptr && constraint->phase() == phase && JVMFlagAccess::check_constraint(JVMFlag::flag_from_enum(flag_enum), constraint->constraint_func(), true) != JVMFlag::SUCCESS) { status = false; diff --git a/src/hotspot/share/runtime/flags/jvmFlagLimit.hpp b/src/hotspot/share/runtime/flags/jvmFlagLimit.hpp index f8e58474284..69df96f226d 100644 --- a/src/hotspot/share/runtime/flags/jvmFlagLimit.hpp +++ b/src/hotspot/share/runtime/flags/jvmFlagLimit.hpp @@ -30,7 +30,7 @@ class outputStream; template 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 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; }