Skip to content

Commit 2697f5e

Browse files
committed
Fix -Wparentheses warning in lock
+ constexpr
1 parent b34101f commit 2697f5e

File tree

2 files changed

+73
-73
lines changed

2 files changed

+73
-73
lines changed

src/lock/lock.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -137,18 +137,18 @@ using namespace Firebird;
137137
// CVC: Unlike other definitions, SRQ_PTR is not a pointer to something in lowercase.
138138
// It's LONG.
139139

140-
const SRQ_PTR DUMMY_OWNER = -1;
140+
constexpr SRQ_PTR DUMMY_OWNER = -1;
141141

142-
const SLONG HASH_MIN_SLOTS = 101;
143-
const SLONG HASH_MAX_SLOTS = 65521;
144-
const USHORT HISTORY_BLOCKS = 256;
142+
constexpr SLONG HASH_MIN_SLOTS = 101;
143+
constexpr SLONG HASH_MAX_SLOTS = 65521;
144+
constexpr USHORT HISTORY_BLOCKS = 256;
145145

146-
const ULONG MAX_TABLE_LENGTH = SLONG_MAX;
146+
constexpr ULONG MAX_TABLE_LENGTH = SLONG_MAX;
147147

148148
// SRQ_ABS_PTR uses this macro.
149149
#define SRQ_BASE ((UCHAR*) m_sharedMemory->getHeader())
150150

151-
static const bool compatibility[LCK_max][LCK_max] =
151+
static constexpr bool compatibility[LCK_max][LCK_max] =
152152
{
153153
/* Shared Prot Shared Prot
154154
none null Read Read Write Write Exclusive */
@@ -1984,7 +1984,7 @@ lrq* LockManager::deadlock_walk(lrq* request, bool* maybe_deadlock)
19841984

19851985
// Check who is blocking the request whose owner is blocking the input request
19861986

1987-
if (target = deadlock_walk(target, maybe_deadlock))
1987+
if ((target = deadlock_walk(target, maybe_deadlock)))
19881988
{
19891989
#ifdef DEBUG_TRACE_DEADLOCKS
19901990
const own* const owner2 = (own*) SRQ_ABS_PTR(request->lrq_owner);
@@ -3222,11 +3222,11 @@ bool LockManager::signal_owner(thread_db* tdbb, own* blocking_owner)
32223222
}
32233223

32243224

3225-
const USHORT EXPECT_inuse = 0;
3226-
const USHORT EXPECT_freed = 1;
3225+
constexpr USHORT EXPECT_inuse = 0;
3226+
constexpr USHORT EXPECT_freed = 1;
32273227

3228-
const USHORT RECURSE_yes = 0;
3229-
const USHORT RECURSE_not = 1;
3228+
constexpr USHORT RECURSE_yes = 0;
3229+
constexpr USHORT RECURSE_not = 1;
32303230

32313231
void LockManager::validate_history(const SRQ_PTR history_header)
32323232
{
@@ -4007,7 +4007,7 @@ bool LockManager::checkHeader(const MemoryHeader* header, bool raiseError)
40074007
(header->mhb_version & ~PLATFORM_LHB_VERSION) == BASE_LHB_VERSION)
40084008
{
40094009
// @1-bit engine can't open database already opened by @2-bit engine
4010-
if (LHB_VERSION == BASE_LHB_VERSION)
4010+
if constexpr (LHB_VERSION == BASE_LHB_VERSION)
40114011
(Arg::Gds(isc_wrong_shmem_bitness) << Arg::Num(32) << Arg::Num(64)).raise();
40124012
else
40134013
(Arg::Gds(isc_wrong_shmem_bitness) << Arg::Num(64) << Arg::Num(32)).raise();

src/lock/lock_proto.h

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -53,53 +53,53 @@ typedef SINT64 LOCK_DATA_T;
5353

5454
// Maximum lock series for gathering statistics and querying data
5555

56-
const int LCK_MAX_SERIES = 7;
56+
inline constexpr int LCK_MAX_SERIES = 7;
5757

5858
// Lock query data aggregates
5959

60-
const int LCK_MIN = 1;
61-
const int LCK_MAX = 2;
62-
const int LCK_CNT = 3;
63-
const int LCK_SUM = 4;
64-
const int LCK_AVG = 5;
65-
const int LCK_ANY = 6;
60+
inline constexpr int LCK_MIN = 1;
61+
inline constexpr int LCK_MAX = 2;
62+
inline constexpr int LCK_CNT = 3;
63+
inline constexpr int LCK_SUM = 4;
64+
inline constexpr int LCK_AVG = 5;
65+
inline constexpr int LCK_ANY = 6;
6666

6767
// Lock states
6868
// in LCK_convert the type of level is USHORT instead of UCHAR
69-
const UCHAR LCK_none = 0;
70-
const UCHAR LCK_null = 1;
71-
const UCHAR LCK_SR = 2; // Shared Read
72-
const UCHAR LCK_PR = 3; // Protected Read
73-
const UCHAR LCK_SW = 4; // Shared Write
74-
const UCHAR LCK_PW = 5; // Protected Write
75-
const UCHAR LCK_EX = 6; // Exclusive
76-
const UCHAR LCK_max = 7;
69+
inline constexpr UCHAR LCK_none = 0;
70+
inline constexpr UCHAR LCK_null = 1;
71+
inline constexpr UCHAR LCK_SR = 2; // Shared Read
72+
inline constexpr UCHAR LCK_PR = 3; // Protected Read
73+
inline constexpr UCHAR LCK_SW = 4; // Shared Write
74+
inline constexpr UCHAR LCK_PW = 5; // Protected Write
75+
inline constexpr UCHAR LCK_EX = 6; // Exclusive
76+
inline constexpr UCHAR LCK_max = 7;
7777

7878
enum locklevel_t {LCK_read = LCK_PR, LCK_write = LCK_EX};
7979

80-
const SSHORT LCK_WAIT = 1;
81-
const SSHORT LCK_NO_WAIT = 0;
80+
inline constexpr SSHORT LCK_WAIT = 1;
81+
inline constexpr SSHORT LCK_NO_WAIT = 0;
8282

8383
// Lock block types
8484

85-
const UCHAR type_null = 0;
86-
const UCHAR type_lhb = 1;
87-
const UCHAR type_lrq = 2;
88-
const UCHAR type_lbl = 3;
89-
const UCHAR type_his = 4;
90-
const UCHAR type_shb = 5;
91-
const UCHAR type_own = 6;
92-
const UCHAR type_lpr = 7;
85+
inline constexpr UCHAR type_null = 0;
86+
inline constexpr UCHAR type_lhb = 1;
87+
inline constexpr UCHAR type_lrq = 2;
88+
inline constexpr UCHAR type_lbl = 3;
89+
inline constexpr UCHAR type_his = 4;
90+
inline constexpr UCHAR type_shb = 5;
91+
inline constexpr UCHAR type_own = 6;
92+
inline constexpr UCHAR type_lpr = 7;
9393

9494
// Version number of the lock table.
9595
// Must be increased every time the shmem layout is changed.
96-
const USHORT BASE_LHB_VERSION = 19;
97-
const USHORT PLATFORM_LHB_VERSION = 128; // 64-bit target
96+
inline constexpr USHORT BASE_LHB_VERSION = 19;
97+
inline constexpr USHORT PLATFORM_LHB_VERSION = 128; // 64-bit target
9898

9999
#if SIZEOF_VOID_P == 8
100-
const USHORT LHB_VERSION = PLATFORM_LHB_VERSION | BASE_LHB_VERSION;
100+
inline constexpr USHORT LHB_VERSION = PLATFORM_LHB_VERSION | BASE_LHB_VERSION;
101101
#else
102-
const USHORT LHB_VERSION = BASE_LHB_VERSION;
102+
inline constexpr USHORT LHB_VERSION = BASE_LHB_VERSION;
103103
#endif
104104

105105

@@ -197,15 +197,15 @@ struct lrq
197197
};
198198

199199
// lrq_flags
200-
const USHORT LRQ_blocking = 1; // Request is blocking
201-
const USHORT LRQ_pending = 2; // Request is pending
202-
const USHORT LRQ_rejected = 4; // Request is rejected
203-
const USHORT LRQ_deadlock = 8; // Request has been seen by the deadlock-walk
204-
const USHORT LRQ_repost = 16; // Request block used for repost
205-
const USHORT LRQ_scanned = 32; // Request already scanned for deadlock
206-
const USHORT LRQ_blocking_seen = 64; // Blocking notification received by owner
207-
const USHORT LRQ_just_granted = 128; // Request is just granted and blocked owners still have not sent blocking AST
208-
const USHORT LRQ_wait_timeout = 256; // Request is being waited on with a timeout
200+
inline constexpr USHORT LRQ_blocking = 1; // Request is blocking
201+
inline constexpr USHORT LRQ_pending = 2; // Request is pending
202+
inline constexpr USHORT LRQ_rejected = 4; // Request is rejected
203+
inline constexpr USHORT LRQ_deadlock = 8; // Request has been seen by the deadlock-walk
204+
inline constexpr USHORT LRQ_repost = 16; // Request block used for repost
205+
inline constexpr USHORT LRQ_scanned = 32; // Request already scanned for deadlock
206+
inline constexpr USHORT LRQ_blocking_seen = 64; // Blocking notification received by owner
207+
inline constexpr USHORT LRQ_just_granted = 128; // Request is just granted and blocked owners still have not sent blocking AST
208+
inline constexpr USHORT LRQ_wait_timeout = 256; // Request is being waited on with a timeout
209209

210210
// Process block
211211

@@ -242,9 +242,9 @@ struct own
242242
};
243243

244244
// Flags in own_flags
245-
const USHORT OWN_scanned = 1; // Owner has been deadlock scanned
246-
const USHORT OWN_wakeup = 2; // Owner has been awoken
247-
const USHORT OWN_signaled = 4; // Signal is thought to be delivered
245+
inline constexpr USHORT OWN_scanned = 1; // Owner has been deadlock scanned
246+
inline constexpr USHORT OWN_wakeup = 2; // Owner has been awoken
247+
inline constexpr USHORT OWN_signaled = 4; // Signal is thought to be delivered
248248

249249
// Lock manager history block
250250

@@ -260,26 +260,26 @@ struct his
260260

261261
// his_operation definitions
262262
// should be UCHAR according to his_operation but is USHORT in lock.cpp:post_operation
263-
const UCHAR his_enq = 1;
264-
const UCHAR his_deq = 2;
265-
const UCHAR his_convert = 3;
266-
const UCHAR his_signal = 4;
267-
const UCHAR his_post_ast = 5;
268-
const UCHAR his_wait = 6;
269-
const UCHAR his_del_process = 7;
270-
const UCHAR his_del_lock = 8;
271-
const UCHAR his_del_request = 9;
272-
const UCHAR his_deny = 10;
273-
const UCHAR his_grant = 11;
274-
const UCHAR his_leave_ast = 12;
275-
const UCHAR his_scan = 13;
276-
const UCHAR his_dead = 14;
277-
const UCHAR his_enter = 15;
278-
const UCHAR his_bug = 16;
279-
const UCHAR his_active = 17;
280-
const UCHAR his_cleanup = 18;
281-
const UCHAR his_del_owner = 19;
282-
const UCHAR his_MAX = his_del_owner;
263+
inline constexpr UCHAR his_enq = 1;
264+
inline constexpr UCHAR his_deq = 2;
265+
inline constexpr UCHAR his_convert = 3;
266+
inline constexpr UCHAR his_signal = 4;
267+
inline constexpr UCHAR his_post_ast = 5;
268+
inline constexpr UCHAR his_wait = 6;
269+
inline constexpr UCHAR his_del_process = 7;
270+
inline constexpr UCHAR his_del_lock = 8;
271+
inline constexpr UCHAR his_del_request = 9;
272+
inline constexpr UCHAR his_deny = 10;
273+
inline constexpr UCHAR his_grant = 11;
274+
inline constexpr UCHAR his_leave_ast = 12;
275+
inline constexpr UCHAR his_scan = 13;
276+
inline constexpr UCHAR his_dead = 14;
277+
inline constexpr UCHAR his_enter = 15;
278+
inline constexpr UCHAR his_bug = 16;
279+
inline constexpr UCHAR his_active = 17;
280+
inline constexpr UCHAR his_cleanup = 18;
281+
inline constexpr UCHAR his_del_owner = 19;
282+
inline constexpr UCHAR his_MAX = his_del_owner;
283283

284284
namespace Firebird {
285285
class AtomicCounter;

0 commit comments

Comments
 (0)