Skip to content

Commit 08c51f2

Browse files
committed
8310920: Fix -Wconversion warnings in command line flags
Reviewed-by: iklam, dholmes
1 parent c2e9485 commit 08c51f2

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

src/hotspot/share/runtime/flags/jvmFlag.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -579,10 +579,10 @@ JVMFlag* JVMFlag::find_flag(const char* name, size_t length, bool allow_locked,
579579
}
580580

581581
JVMFlag* JVMFlag::fuzzy_match(const char* name, size_t length, bool allow_locked) {
582-
float VMOptionsFuzzyMatchSimilarity = 0.7f;
582+
double VMOptionsFuzzyMatchSimilarity = 0.7;
583583
JVMFlag* match = nullptr;
584-
float score;
585-
float max_score = -1;
584+
double score;
585+
double max_score = -1;
586586

587587
for (JVMFlag* current = &flagTable[0]; current->_name != nullptr; current++) {
588588
score = StringUtils::similarity(current->_name, strlen(current->_name), name, length);

src/hotspot/share/runtime/flags/jvmFlagAccess.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class TypedFlagAccessImpl : public FlagAccessImpl {
6464
verbose |= (origin == JVMFlagOrigin::ERGONOMIC);
6565
T value = *((T*)value_addr);
6666
const JVMTypedFlagLimit<T>* constraint = (const JVMTypedFlagLimit<T>*)JVMFlagLimit::get_constraint(flag);
67-
if (constraint != nullptr && constraint->phase() <= static_cast<int>(JVMFlagLimit::validating_phase())) {
67+
if (constraint != nullptr && constraint->phase() <= JVMFlagLimit::validating_phase()) {
6868
JVMFlag::Error err = typed_check_constraint(constraint->constraint_func(), value, verbose);
6969
if (err != JVMFlag::SUCCESS) {
7070
if (origin == JVMFlagOrigin::ERGONOMIC) {

src/hotspot/share/runtime/flags/jvmFlagLimit.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ class LimitGetter {
7979
static constexpr const JVMFlagLimit* get_limit(const JVMTypedFlagLimit<T>* p, int dummy, T min, T max) {
8080
return p;
8181
}
82-
static constexpr const JVMFlagLimit* get_limit(const JVMTypedFlagLimit<T>* p, int dummy, ConstraintMarker dummy2, short func, int phase) {
82+
static constexpr const JVMFlagLimit* get_limit(const JVMTypedFlagLimit<T>* p, int dummy, ConstraintMarker dummy2, short func, JVMFlagConstraintPhase phase) {
8383
return p;
8484
}
85-
static constexpr const JVMFlagLimit* get_limit(const JVMTypedFlagLimit<T>* p, int dummy, T min, T max, ConstraintMarker dummy2, short func, int phase) {
85+
static constexpr const JVMFlagLimit* get_limit(const JVMTypedFlagLimit<T>* p, int dummy, T min, T max, ConstraintMarker dummy2, short func, JVMFlagConstraintPhase phase) {
8686
return p;
8787
}
88-
static constexpr const JVMFlagLimit* get_limit(const JVMTypedFlagLimit<T>* p, int dummy, ConstraintMarker dummy2, short func, int phase, T min, T max) {
88+
static constexpr const JVMFlagLimit* get_limit(const JVMTypedFlagLimit<T>* p, int dummy, ConstraintMarker dummy2, short func, JVMFlagConstraintPhase phase, T min, T max) {
8989
return p;
9090
}
9191
};
@@ -98,7 +98,7 @@ class LimitGetter {
9898
#define FLAG_LIMIT_PTR( type, name, ...) ), LimitGetter<type>::get_limit(&limit_##name, 0
9999
#define FLAG_LIMIT_PTR_NONE( type, name, ...) ), LimitGetter<type>::no_limit(0
100100
#define APPLY_FLAG_RANGE(...) , __VA_ARGS__
101-
#define APPLY_FLAG_CONSTRAINT(func, phase) , next_two_args_are_constraint, (short)CONSTRAINT_ENUM(func), int(JVMFlagConstraintPhase::phase)
101+
#define APPLY_FLAG_CONSTRAINT(func, phase) , next_two_args_are_constraint, (short)CONSTRAINT_ENUM(func), JVMFlagConstraintPhase::phase
102102

103103
constexpr JVMTypedFlagLimit<int> limit_dummy
104104
(
@@ -179,7 +179,7 @@ bool JVMFlagLimit::check_all_constraints(JVMFlagConstraintPhase phase) {
179179
for (int i = 0; i < NUM_JVMFlagsEnum; i++) {
180180
JVMFlagsEnum flag_enum = static_cast<JVMFlagsEnum>(i);
181181
const JVMFlagLimit* constraint = get_constraint_at(flag_enum);
182-
if (constraint != nullptr && constraint->phase() == static_cast<int>(phase) &&
182+
if (constraint != nullptr && constraint->phase() == phase &&
183183
JVMFlagAccess::check_constraint(JVMFlag::flag_from_enum(flag_enum),
184184
constraint->constraint_func(), true) != JVMFlag::SUCCESS) {
185185
status = false;

src/hotspot/share/runtime/flags/jvmFlagLimit.hpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
class outputStream;
3131
template <typename T> class JVMTypedFlagLimit;
3232

33-
enum class JVMFlagConstraintPhase : int {
33+
enum class JVMFlagConstraintPhase : char {
3434
// Will be validated during argument processing (Arguments::parse_argument).
3535
AtParse = 0,
3636
// Will be validated inside Threads::create_vm(), right after Arguments::apply_ergo().
@@ -67,7 +67,7 @@ template <typename T> class JVMTypedFlagLimit;
6767

6868
class JVMFlagLimit {
6969
short _constraint_func;
70-
char _phase;
70+
JVMFlagConstraintPhase _phase;
7171
char _kind;
7272

7373
#ifdef ASSERT
@@ -100,10 +100,10 @@ class JVMFlagLimit {
100100

101101
public:
102102
void* constraint_func() const;
103-
char phase() const { return _phase; }
103+
JVMFlagConstraintPhase phase() const { return _phase; }
104104
char kind() const { return _kind; }
105105

106-
constexpr JVMFlagLimit(int type_enum, short func, short phase, short kind)
106+
constexpr JVMFlagLimit(int type_enum, short func, JVMFlagConstraintPhase phase, char kind)
107107
: _constraint_func(func), _phase(phase), _kind(kind) DEBUG_ONLY(COMMA _type_enum(type_enum)) {}
108108

109109
static const JVMFlagLimit* get_range(const JVMFlag* flag) {
@@ -155,22 +155,22 @@ class JVMTypedFlagLimit : public JVMFlagLimit {
155155
// dummy - no range or constraint. This object will not be emitted into the .o file
156156
// because we declare it as "const" but has no reference to it.
157157
constexpr JVMTypedFlagLimit(int type_enum) :
158-
JVMFlagLimit(0, 0, 0, 0), _min(0), _max(0) {}
158+
JVMFlagLimit(0, 0, JVMFlagConstraintPhase::AtParse, 0), _min(0), _max(0) {}
159159

160160
// range only
161161
constexpr JVMTypedFlagLimit(int type_enum, T min, T max) :
162-
JVMFlagLimit(type_enum, 0, 0, HAS_RANGE), _min(min), _max(max) {}
162+
JVMFlagLimit(type_enum, 0, JVMFlagConstraintPhase::AtParse, HAS_RANGE), _min(min), _max(max) {}
163163

164164
// constraint only
165-
constexpr JVMTypedFlagLimit(int type_enum, ConstraintMarker dummy2, short func, int phase) :
165+
constexpr JVMTypedFlagLimit(int type_enum, ConstraintMarker dummy2, short func, JVMFlagConstraintPhase phase) :
166166
JVMFlagLimit(type_enum, func, phase, HAS_CONSTRAINT), _min(0), _max(0) {}
167167

168168
// range and constraint
169-
constexpr JVMTypedFlagLimit(int type_enum, T min, T max, ConstraintMarker dummy2, short func, int phase) :
169+
constexpr JVMTypedFlagLimit(int type_enum, T min, T max, ConstraintMarker dummy2, short func, JVMFlagConstraintPhase phase) :
170170
JVMFlagLimit(type_enum, func, phase, HAS_RANGE | HAS_CONSTRAINT), _min(min), _max(max) {}
171171

172172
// constraint and range
173-
constexpr JVMTypedFlagLimit(int type_enum, ConstraintMarker dummy2, short func, int phase, T min, T max) :
173+
constexpr JVMTypedFlagLimit(int type_enum, ConstraintMarker dummy2, short func, JVMFlagConstraintPhase phase, T min, T max) :
174174
JVMFlagLimit(type_enum, func, phase, HAS_RANGE | HAS_CONSTRAINT), _min(min), _max(max) {}
175175

176176
T min() const { return _min; }

0 commit comments

Comments
 (0)