Skip to content

Commit 32912c4

Browse files
committed
Fix conversion warnings in gen, dfw, scl
+ add constexpr, remove unused vars, fix some other warnings
1 parent a3a5786 commit 32912c4

File tree

4 files changed

+47
-43
lines changed

4 files changed

+47
-43
lines changed

src/dsql/gen.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,9 @@ void GEN_port(DsqlCompilerScratch* dsqlScratch, dsql_msg* message)
232232
// But we flag it to describe as text.
233233
parameter->par_is_text = true;
234234
parameter->par_desc.dsc_dtype = dtype_varying;
235-
parameter->par_desc.dsc_length = dataTypeUtil.fixLength(
236-
&parameter->par_desc, parameter->par_desc.dsc_length) + sizeof(USHORT);
235+
parameter->par_desc.dsc_length = static_cast<USHORT>(
236+
dataTypeUtil.fixLength(&parameter->par_desc, parameter->par_desc.dsc_length)
237+
+ sizeof(USHORT));
237238
}
238239

239240
const USHORT align = type_alignments[parameter->par_desc.dsc_dtype];
@@ -534,6 +535,7 @@ static void gen_plan(DsqlCompilerScratch* dsqlScratch, const PlanNode* planNode)
534535
// ASF: The first item of a TYPE_NAVIGATIONAL is not for blr_indices.
535536
++idx_iter;
536537
--idx_count;
538+
[[fallthrough]];
537539

538540
case PlanNode::AccessType::TYPE_INDICES:
539541
{

src/jrd/dfw.epp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,11 @@
140140

141141
// Define range of user relation ids
142142

143-
const int MIN_RELATION_ID = rel_MAX;
144-
const int MAX_RELATION_ID = 32767;
143+
inline constexpr int MIN_RELATION_ID = rel_MAX;
144+
inline constexpr int MAX_RELATION_ID = 32767;
145145

146-
const int COMPUTED_FLAG = 128;
147-
const int WAIT_PERIOD = -1;
146+
inline constexpr int COMPUTED_FLAG = 128;
147+
inline constexpr int WAIT_PERIOD = -1;
148148

149149
DATABASE DB = FILENAME "ODS.RDB";
150150

@@ -300,7 +300,7 @@ public:
300300

301301
static FB_SIZE_T hash(const DeferredWork& work, FB_SIZE_T hashSize)
302302
{
303-
const int nameLimit = 32;
303+
constexpr int nameLimit = 32;
304304
char key[sizeof work.dfw_type + sizeof work.dfw_id + nameLimit + nameLimit];
305305
memset(key, 0, sizeof key);
306306
char* place = key;
@@ -663,7 +663,7 @@ void Jrd::ProtectRelations::relLock::releaseLock(thread_db* tdbb, jrd_tra* trans
663663
}
664664
}
665665

666-
static const UCHAR nonnull_validation_blr[] =
666+
static inline constexpr UCHAR nonnull_validation_blr[] =
667667
{
668668
blr_version5,
669669
blr_not,
@@ -1285,7 +1285,7 @@ namespace
12851285
}
12861286
} // namespace
12871287

1288-
static const deferred_task task_table[] =
1288+
static inline constexpr deferred_task task_table[] =
12891289
{
12901290
{ dfw_add_shadow, add_shadow },
12911291
{ dfw_delete_index, modify_index },
@@ -1912,9 +1912,7 @@ static bool add_shadow(thread_db* tdbb, SSHORT phase, DeferredWork* work, jrd_tr
19121912

19131913
AutoRequest handle;
19141914
Shadow* shadow;
1915-
USHORT sequence, add_sequence;
19161915
bool finished;
1917-
ULONG min_page;
19181916
Firebird::PathName expanded_fname;
19191917

19201918
SET_TDBB(tdbb);
@@ -3628,7 +3626,7 @@ static bool create_relation(thread_db* tdbb, SSHORT phase, DeferredWork* work, j
36283626
Jrd::Attachment* attachment = tdbb->getAttachment();
36293627
Database* dbb = tdbb->getDatabase();
36303628

3631-
const USHORT local_min_relation_id = USER_DEF_REL_INIT_ID;
3629+
constexpr USHORT local_min_relation_id = USER_DEF_REL_INIT_ID;
36323630

36333631
switch (phase)
36343632
{
@@ -4397,7 +4395,7 @@ static bool create_field(thread_db* tdbb, SSHORT phase, DeferredWork* work, jrd_
43974395
attachment->deletePool(new_pool);
43984396
}
43994397
}
4400-
// fall through
4398+
return true;
44014399

44024400
case 2:
44034401
case 3:
@@ -4568,7 +4566,7 @@ static bool modify_field(thread_db* tdbb, SSHORT phase, DeferredWork* work, jrd_
45684566
attachment->deletePool(new_pool);
45694567
}
45704568
}
4571-
// fall through
4569+
return true;
45724570

45734571
case 2:
45744572
case 3:
@@ -5221,6 +5219,7 @@ static bool delete_rfr(thread_db* tdbb, SSHORT phase, DeferredWork* work, jrd_tr
52215219
// Msg354: last column in a relation cannot be deleted
52225220
}
52235221
}
5222+
return true;
52245223

52255224
case 2:
52265225
return true;

src/jrd/scl.epp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
#include "../jrd/ResultSet.h"
6262

6363

64-
const int UIC_BASE = 10;
64+
inline constexpr int UIC_BASE = 10;
6565

6666
using namespace Jrd;
6767
using namespace Firebird;
@@ -90,7 +90,7 @@ namespace
9090
const TEXT* p_names_string;
9191
};
9292

93-
const P_NAMES p_names[] =
93+
inline constexpr P_NAMES p_names[] =
9494
{
9595
{ SCL_alter, priv_alter, "ALTER" },
9696
{ SCL_control, priv_control, "CONTROL" },
@@ -1407,7 +1407,7 @@ static void get_string(const UCHAR* acl, MetaName& string)
14071407
**************************************/
14081408
fb_assert(acl);
14091409

1410-
const size_t length = *acl++;
1410+
const FB_SIZE_T length = *acl++;
14111411
const TEXT* const ptr = (TEXT*) acl;
14121412
string.assign(ptr, length);
14131413
}

src/jrd/scl.h

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace Jrd {
3939

4040
class thread_db;
4141

42-
const size_t ACL_BLOB_BUFFER_SIZE = MAX_USHORT; // used to read/write acl blob
42+
inline constexpr size_t ACL_BLOB_BUFFER_SIZE = MAX_USHORT; // used to read/write acl blob
4343

4444
// Security class definition
4545

@@ -66,31 +66,31 @@ class SecurityClass
6666
typedef Firebird::BePlusTree<SecurityClass*, MetaNamePair, SecurityClass> SecurityClassList;
6767

6868

69-
const SecurityClass::flags_t SCL_select = 1; // SELECT access
70-
const SecurityClass::flags_t SCL_drop = 2; // DROP access
71-
const SecurityClass::flags_t SCL_control = 4; // Control access
72-
const SecurityClass::flags_t SCL_exists = 8; // At least ACL exists
73-
const SecurityClass::flags_t SCL_alter = 16; // ALTER access
74-
const SecurityClass::flags_t SCL_corrupt = 32; // ACL does look too good
75-
const SecurityClass::flags_t SCL_insert = 64; // INSERT access
76-
const SecurityClass::flags_t SCL_delete = 128; // DELETE access
77-
const SecurityClass::flags_t SCL_update = 256; // UPDATE access
78-
const SecurityClass::flags_t SCL_references = 512; // REFERENCES access
79-
const SecurityClass::flags_t SCL_execute = 1024; // EXECUTE access
80-
const SecurityClass::flags_t SCL_usage = 2048; // USAGE access
81-
const SecurityClass::flags_t SCL_create = 4096;
82-
83-
const SecurityClass::flags_t SCL_SELECT_ANY = SCL_select | SCL_references;
84-
const SecurityClass::flags_t SCL_ACCESS_ANY = SCL_insert | SCL_update | SCL_delete |
69+
inline constexpr SecurityClass::flags_t SCL_select = 1; // SELECT access
70+
inline constexpr SecurityClass::flags_t SCL_drop = 2; // DROP access
71+
inline constexpr SecurityClass::flags_t SCL_control = 4; // Control access
72+
inline constexpr SecurityClass::flags_t SCL_exists = 8; // At least ACL exists
73+
inline constexpr SecurityClass::flags_t SCL_alter = 16; // ALTER access
74+
inline constexpr SecurityClass::flags_t SCL_corrupt = 32; // ACL does look too good
75+
inline constexpr SecurityClass::flags_t SCL_insert = 64; // INSERT access
76+
inline constexpr SecurityClass::flags_t SCL_delete = 128; // DELETE access
77+
inline constexpr SecurityClass::flags_t SCL_update = 256; // UPDATE access
78+
inline constexpr SecurityClass::flags_t SCL_references = 512; // REFERENCES access
79+
inline constexpr SecurityClass::flags_t SCL_execute = 1024; // EXECUTE access
80+
inline constexpr SecurityClass::flags_t SCL_usage = 2048; // USAGE access
81+
inline constexpr SecurityClass::flags_t SCL_create = 4096;
82+
83+
inline constexpr SecurityClass::flags_t SCL_SELECT_ANY = SCL_select | SCL_references;
84+
inline constexpr SecurityClass::flags_t SCL_ACCESS_ANY = SCL_insert | SCL_update | SCL_delete |
8585
SCL_execute | SCL_usage | SCL_SELECT_ANY;
86-
const SecurityClass::flags_t SCL_MODIFY_ANY = SCL_create | SCL_alter | SCL_control | SCL_drop;
86+
inline constexpr SecurityClass::flags_t SCL_MODIFY_ANY = SCL_create | SCL_alter | SCL_control | SCL_drop;
8787

8888

8989
// information about the user
9090

91-
const USHORT USR_mapdown = 1; // Mapping failed when getting context
92-
const USHORT USR_newrole = 2; // usr_granted_roles array needs refresh
93-
const USHORT USR_sysdba = 4; // User detected as SYSDBA
91+
inline constexpr USHORT USR_mapdown = 1; // Mapping failed when getting context
92+
inline constexpr USHORT USR_newrole = 2; // usr_granted_roles array needs refresh
93+
inline constexpr USHORT USR_sysdba = 4; // User detected as SYSDBA
9494

9595
class UserId
9696
{
@@ -99,13 +99,13 @@ class UserId
9999
template <unsigned N>
100100
class Bits
101101
{
102-
static const unsigned shift = 3;
103-
static const unsigned bitmask = (1 << shift) - 1;
102+
static inline constexpr unsigned shift = 3;
103+
static inline constexpr unsigned bitmask = (1 << shift) - 1;
104104

105-
static const unsigned L = (N >> shift) + (N & bitmask ? 1 : 0);
105+
static inline constexpr unsigned L = (N >> shift) + (N & bitmask ? 1 : 0);
106106

107107
public:
108-
static const unsigned BYTES_COUNT = L;
108+
static inline constexpr unsigned BYTES_COUNT = L;
109109

110110
Bits()
111111
{
@@ -254,7 +254,10 @@ class UserId
254254
usr_project_name(p),
255255
usr_org_name(p),
256256
usr_auth_method(p),
257-
usr_auth_block(p)
257+
usr_auth_block(p),
258+
usr_user_id(0),
259+
usr_group_id(0),
260+
usr_flags(0)
258261
{
259262
}
260263

0 commit comments

Comments
 (0)