Skip to content

Commit c471ddf

Browse files
committed
Fix conversion warnings in validation
+ constexpr + fix possible out of bounds issue
1 parent 69de115 commit c471ddf

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

src/jrd/val.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class VaryingString : public pool_alloc_rpt<SCHAR, type_str>
4949
UCHAR str_data[2]; // one byte for ALLOC and one for the NULL
5050
};
5151

52-
const ULONG MAX_RECORD_SIZE = 65535;
52+
inline constexpr ULONG MAX_RECORD_SIZE = 65535;
5353

5454
namespace Jrd {
5555

@@ -269,10 +269,10 @@ struct impure_value_ex : public impure_value
269269
blb* vlu_blob;
270270
};
271271

272-
const int VLU_computed = 1; // An invariant sub-query has been computed
273-
const int VLU_null = 2; // An invariant sub-query computed to null
274-
const int VLU_checked = 4; // Constraint already checked in first read or assignment to argument/variable
275-
const int VLU_initialized = 8; // Variable initialized
272+
inline constexpr int VLU_computed = 1; // An invariant sub-query has been computed
273+
inline constexpr int VLU_null = 2; // An invariant sub-query computed to null
274+
inline constexpr int VLU_checked = 4; // Constraint already checked in first read or assignment to argument/variable
275+
inline constexpr int VLU_initialized = 8; // Variable initialized
276276

277277

278278
class Format : public pool_alloc<type_fmt>

src/jrd/val_proto.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@
2727
bool VAL_validate(Jrd::thread_db*, USHORT);
2828
int VAL_service(Firebird::UtilSvc*);
2929

30-
const int IN_SW_VAL_TAB_INCL = 1;
31-
const int IN_SW_VAL_TAB_EXCL = 2;
32-
const int IN_SW_VAL_IDX_INCL = 3;
33-
const int IN_SW_VAL_IDX_EXCL = 4;
34-
const int IN_SW_VAL_LOCK_TIMEOUT = 5;
35-
const int IN_SW_VAL_DATABASE = 6;
36-
const int IN_SW_VAL_SCH_INCL = 7;
37-
const int IN_SW_VAL_SCH_EXCL = 8;
30+
inline constexpr int IN_SW_VAL_TAB_INCL = 1;
31+
inline constexpr int IN_SW_VAL_TAB_EXCL = 2;
32+
inline constexpr int IN_SW_VAL_IDX_INCL = 3;
33+
inline constexpr int IN_SW_VAL_IDX_EXCL = 4;
34+
inline constexpr int IN_SW_VAL_LOCK_TIMEOUT = 5;
35+
inline constexpr int IN_SW_VAL_DATABASE = 6;
36+
inline constexpr int IN_SW_VAL_SCH_INCL = 7;
37+
inline constexpr int IN_SW_VAL_SCH_EXCL = 8;
3838

39-
static const Switches::in_sw_tab_t val_option_in_sw_table[] =
39+
static inline constexpr Switches::in_sw_tab_t val_option_in_sw_table[] =
4040
{
4141
{IN_SW_VAL_SCH_INCL, isc_spb_val_sch_incl, "SCH_INCLUDE", 0, 0, 0, false, false, 0, 5, NULL},
4242
{IN_SW_VAL_SCH_EXCL, isc_spb_val_sch_excl, "SCH_EXCLUDE", 0, 0, 0, false, false, 0, 5, NULL},

src/jrd/validation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ static SimilarToRegex* createPatternMatcher(thread_db* tdbb, const char* pattern
598598
{
599599
if (pattern)
600600
{
601-
const int len = strlen(pattern);
601+
const FB_SIZE_T len = fb_strlen(pattern);
602602

603603
//// TODO: Should this be different than trace and replication
604604
//// and use case sensitive matcher?
@@ -1152,7 +1152,7 @@ Validation::RTN Validation::corrupt(int err_code, const jrd_rel* relation, ...)
11521152
fprintf(stdout, "LOG:\tDatabase: %s\n\t%s\n", fn, s.c_str());
11531153
}
11541154
#endif
1155-
if (vdr_msg_table[err_code].error)
1155+
if (err_code >= VAL_MAX_ERROR || vdr_msg_table[err_code].error)
11561156
{
11571157
++vdr_errors;
11581158
s.insert(0, "Error: ");

src/jrd/validation.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ class Validation
5656
public:
5757
// vdr_flags
5858

59-
static const USHORT VDR_online = 0x01; // online validation (no exclusive attachment)
60-
static const USHORT VDR_update = 0x02; // fix simple things
61-
static const USHORT VDR_repair = 0x04; // fix non-simple things (-mend)
62-
static const USHORT VDR_records = 0x08; // Walk all records
63-
static const USHORT VDR_partial = 0x10; // Walk only (some) relations
59+
static inline constexpr USHORT VDR_online = 0x01; // online validation (no exclusive attachment)
60+
static inline constexpr USHORT VDR_update = 0x02; // fix simple things
61+
static inline constexpr USHORT VDR_repair = 0x04; // fix non-simple things (-mend)
62+
static inline constexpr USHORT VDR_records = 0x08; // Walk all records
63+
static inline constexpr USHORT VDR_partial = 0x10; // Walk only (some) relations
6464

6565
private:
6666

0 commit comments

Comments
 (0)