Skip to content

Commit b11fd80

Browse files
committed
Fix -Wparentheses in btr
+ constexpr + misc warnings
1 parent 13e2dfe commit b11fd80

File tree

2 files changed

+56
-56
lines changed

2 files changed

+56
-56
lines changed

src/jrd/btr.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,21 +73,21 @@ using namespace Firebird;
7373

7474
namespace
7575
{
76-
const unsigned MAX_LEVELS = 16;
76+
constexpr unsigned MAX_LEVELS = 16;
7777

78-
const size_t OVERSIZE = (MAX_PAGE_SIZE + BTN_PAGE_SIZE + MAX_KEY + sizeof(SLONG) - 1) / sizeof(SLONG);
78+
constexpr size_t OVERSIZE = (MAX_PAGE_SIZE + BTN_PAGE_SIZE + MAX_KEY + sizeof(SLONG) - 1) / sizeof(SLONG);
7979

8080
// END_LEVEL (~0) is choosen here as a unknown/none value, because it's
8181
// already reserved as END_LEVEL marker for page number and record number.
8282
//
8383
// NO_VALUE_PAGE and NO_VALUE are the same constant, but with different size
8484
// Sign-extension mechanizm guaranties that they may be compared to each other safely
85-
const ULONG NO_VALUE_PAGE = END_LEVEL;
85+
constexpr ULONG NO_VALUE_PAGE = END_LEVEL;
8686
const RecordNumber NO_VALUE(END_LEVEL);
8787

8888
// A split page will never have the number 0, because that's the value
8989
// of the main page.
90-
const ULONG NO_SPLIT = 0;
90+
inline constexpr ULONG NO_SPLIT = 0;
9191

9292
// Thresholds for determing of a page should be garbage collected
9393
// Garbage collect if page size is below GARBAGE_COLLECTION_THRESHOLD
@@ -105,22 +105,22 @@ namespace
105105
};
106106

107107
// I assume this wasn't done sizeof(INT64_KEY) on purpose, since alignment might affect it.
108-
const size_t INT64_KEY_LENGTH = sizeof (double) + sizeof (SSHORT);
108+
constexpr size_t INT64_KEY_LENGTH = sizeof (double) + sizeof (SSHORT);
109109

110-
const double pow10_table[] =
110+
constexpr double pow10_table[] =
111111
{
112112
1.e00, 1.e01, 1.e02, 1.e03, 1.e04, 1.e05, 1.e06, 1.e07, 1.e08, 1.e09,
113113
1.e10, 1.e11, 1.e12, 1.e13, 1.e14, 1.e15, 1.e16, 1.e17, 1.e18, 1.e19,
114114
1.e20, 1.e21, 1.e22, 1.e23, 1.e24, 1.e25, 1.e26, 1.e27, 1.e28, 1.e29,
115115
1.e30, 1.e31, 1.e32, 1.e33, 1.e34, 1.e35, 1.e36
116116
};
117117

118-
inline double powerof10(int index)
118+
inline double powerof10(int index) noexcept
119119
{
120120
return (index <= 0) ? pow10_table[-index] : 1.0 / pow10_table[index];
121121
}
122122

123-
const struct // Used in make_int64_key()
123+
constexpr struct // Used in make_int64_key()
124124
{
125125
FB_UINT64 limit;
126126
SINT64 factor;
@@ -856,7 +856,7 @@ void BTR_complement_key(temporary_key* key)
856856
UCHAR* p = key->key_data;
857857
for (const UCHAR* const end = p + key->key_length; p < end; p++)
858858
*p ^= -1;
859-
} while (key = key->key_next.get());
859+
} while ((key = key->key_next.get()));
860860
}
861861

862862

@@ -2810,8 +2810,8 @@ static void compress(thread_db* tdbb,
28102810
// is needed to make a difference between a NULL state and a VALUE.
28112811
// Note! By descending index key is complemented after this compression routine.
28122812
// Further a NULL state is always returned as 1 byte 0xFF (descending index).
2813-
const UCHAR desc_end_value_prefix = 0x01; // ~0xFE
2814-
const UCHAR desc_end_value_check = 0x00; // ~0xFF;
2813+
constexpr UCHAR desc_end_value_prefix = 0x01; // ~0xFE
2814+
constexpr UCHAR desc_end_value_check = 0x00; // ~0xFF;
28152815

28162816
const Database* dbb = tdbb->getDatabase();
28172817
bool first_key = true;
@@ -6478,7 +6478,7 @@ string print_key(thread_db* tdbb, jrd_rel* relation, index_desc* idx, Record* re
64786478
MET_scan_relation(tdbb, relation);
64796479
}
64806480

6481-
const FB_SIZE_T MAX_KEY_STRING_LEN = 250;
6481+
constexpr FB_SIZE_T MAX_KEY_STRING_LEN = 250;
64826482
string key, value;
64836483

64846484
try

src/jrd/btr.h

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -83,50 +83,50 @@ struct index_desc
8383

8484
typedef Firebird::HalfStaticArray<index_desc, 16> IndexDescList;
8585

86-
const USHORT idx_invalid = USHORT(~0); // Applies to idx_id as special value
86+
inline constexpr USHORT idx_invalid = USHORT(~0); // Applies to idx_id as special value
8787

8888
// index types and flags
8989

9090
// See jrd/intl.h for notes on idx_itype and dsc_sub_type considerations
9191
// idx_numeric .. idx_byte_array values are compatible with VMS values
9292

93-
const int idx_numeric = 0;
94-
const int idx_string = 1;
93+
inline constexpr int idx_numeric = 0;
94+
inline constexpr int idx_string = 1;
9595
// value of 2 was used in ODS < 10
96-
const int idx_byte_array = 3;
97-
const int idx_metadata = 4;
98-
const int idx_sql_date = 5;
99-
const int idx_sql_time = 6;
100-
const int idx_timestamp = 7;
101-
const int idx_numeric2 = 8; // Introduced for 64-bit Integer support
102-
const int idx_boolean = 9;
103-
const int idx_decimal = 10;
104-
const int idx_sql_time_tz = 11;
105-
const int idx_timestamp_tz = 12;
106-
const int idx_bcd = 13; // 128-bit Integer support
96+
inline constexpr int idx_byte_array = 3;
97+
inline constexpr int idx_metadata = 4;
98+
inline constexpr int idx_sql_date = 5;
99+
inline constexpr int idx_sql_time = 6;
100+
inline constexpr int idx_timestamp = 7;
101+
inline constexpr int idx_numeric2 = 8; // Introduced for 64-bit Integer support
102+
inline constexpr int idx_boolean = 9;
103+
inline constexpr int idx_decimal = 10;
104+
inline constexpr int idx_sql_time_tz = 11;
105+
inline constexpr int idx_timestamp_tz = 12;
106+
inline constexpr int idx_bcd = 13; // 128-bit Integer support
107107

108108
// idx_itype space for future expansion
109-
const int idx_first_intl_string = 64; // .. MAX (short) Range of computed key strings
109+
inline constexpr int idx_first_intl_string = 64; // .. MAX (short) Range of computed key strings
110110

111-
const int idx_offset_intl_range = (0x7FFF + idx_first_intl_string);
111+
inline constexpr int idx_offset_intl_range = (0x7FFF + idx_first_intl_string);
112112

113113
// these flags must match the irt_flags (see ods.h)
114114

115-
const int idx_unique = 1;
116-
const int idx_descending = 2;
117-
const int idx_in_progress = 4;
118-
const int idx_foreign = 8;
119-
const int idx_primary = 16;
120-
const int idx_expression = 32;
121-
const int idx_condition = 64;
115+
inline constexpr int idx_unique = 1;
116+
inline constexpr int idx_descending = 2;
117+
inline constexpr int idx_in_progress = 4;
118+
inline constexpr int idx_foreign = 8;
119+
inline constexpr int idx_primary = 16;
120+
inline constexpr int idx_expression = 32;
121+
inline constexpr int idx_condition = 64;
122122

123123
// these flags are for idx_runtime_flags
124124

125-
const int idx_plan_dont_use = 1; // index is not mentioned in user-specified access plan
126-
const int idx_plan_navigate = 2; // plan specifies index to be used for ordering
127-
const int idx_used = 4; // index was in fact selected for retrieval
128-
const int idx_navigate = 8; // index was in fact selected for navigation
129-
const int idx_marker = 16; // marker used in procedure sort_indices
125+
inline constexpr int idx_plan_dont_use = 1; // index is not mentioned in user-specified access plan
126+
inline constexpr int idx_plan_navigate = 2; // plan specifies index to be used for ordering
127+
inline constexpr int idx_used = 4; // index was in fact selected for retrieval
128+
inline constexpr int idx_navigate = 8; // index was in fact selected for navigation
129+
inline constexpr int idx_marker = 16; // marker used in procedure sort_indices
130130

131131
// Index insertion block -- parameter block for index insertions
132132

@@ -146,7 +146,7 @@ struct index_insertion
146146

147147
// these flags are for the key_flags
148148

149-
const int key_empty = 1; // Key contains empty data / empty string
149+
inline constexpr int key_empty = 1; // Key contains empty data / empty string
150150

151151
// Temporary key block
152152

@@ -177,8 +177,8 @@ struct index_sort_record
177177
};
178178
#pragma pack()
179179

180-
const int ISR_secondary = 1; // Record is secondary version
181-
const int ISR_null = 2; // Record consists of NULL values only
180+
inline constexpr int ISR_secondary = 1; // Record is secondary version
181+
inline constexpr int ISR_null = 2; // Record consists of NULL values only
182182

183183

184184

@@ -227,21 +227,21 @@ class IndexRetrieval final
227227
};
228228

229229
// Flag values for irb_generic
230-
const int irb_partial = 1; // Partial match: not all segments or starting of key only
231-
const int irb_starting = 2; // Only compute "starting with" key for index segment
232-
const int irb_equality = 4; // Probing index for equality match
233-
const int irb_ignore_null_value_key = 8; // if lower bound is specified and upper bound unspecified,
234-
// ignore looking at null value keys
235-
const int irb_descending = 16; // Base index uses descending order
236-
const int irb_exclude_lower = 32; // exclude lower bound keys while scanning index
237-
const int irb_exclude_upper = 64; // exclude upper bound keys while scanning index
238-
const int irb_multi_starting = 128; // Use INTL_KEY_MULTI_STARTING
239-
const int irb_root_list_scan = 256; // Locate list items from the root
240-
const int irb_unique = 512; // Unique match (currently used only for plan output)
230+
inline constexpr int irb_partial = 1; // Partial match: not all segments or starting of key only
231+
inline constexpr int irb_starting = 2; // Only compute "starting with" key for index segment
232+
inline constexpr int irb_equality = 4; // Probing index for equality match
233+
inline constexpr int irb_ignore_null_value_key = 8; // if lower bound is specified and upper bound unspecified,
234+
// ignore looking at null value keys
235+
inline constexpr int irb_descending = 16; // Base index uses descending order
236+
inline constexpr int irb_exclude_lower = 32; // exclude lower bound keys while scanning index
237+
inline constexpr int irb_exclude_upper = 64; // exclude upper bound keys while scanning index
238+
inline constexpr int irb_multi_starting = 128; // Use INTL_KEY_MULTI_STARTING
239+
inline constexpr int irb_root_list_scan = 256; // Locate list items from the root
240+
inline constexpr int irb_unique = 512; // Unique match (currently used only for plan output)
241241

242242
// Force include flags - always include appropriate key while scanning index
243-
const int irb_force_lower = irb_exclude_lower;
244-
const int irb_force_upper = irb_exclude_upper;
243+
inline constexpr int irb_force_lower = irb_exclude_lower;
244+
inline constexpr int irb_force_upper = irb_exclude_upper;
245245

246246
typedef Firebird::HalfStaticArray<float, 4> SelectivityList;
247247

0 commit comments

Comments
 (0)