Skip to content

Commit 7b3a813

Browse files
committed
constexpr in alice
+ some misc other changes
1 parent 6e435c9 commit 7b3a813

File tree

6 files changed

+67
-67
lines changed

6 files changed

+67
-67
lines changed

src/alice/alice.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
using MsgFormat::SafeArg;
6464

6565

66-
static const USHORT val_err_table[] =
66+
static constexpr USHORT val_err_table[] =
6767
{
6868
0,
6969
55, // msg 55: \n\tNumber of record level errors\t: %ld
@@ -85,9 +85,9 @@ static const USHORT val_err_table[] =
8585
};
8686

8787

88-
const int ALICE_MSG_FAC = 3;
88+
constexpr int ALICE_MSG_FAC = FB_IMPL_MSG_FACILITY_GFIX;
8989

90-
void ALICE_exit(int code, AliceGlobals* tdgbl)
90+
[[noreturn]] void ALICE_exit(int code, AliceGlobals* tdgbl)
9191
{
9292
tdgbl->exit_code = code;
9393
Firebird::LongJump::raise();
@@ -622,7 +622,7 @@ int alice(Firebird::UtilSvc* uSvc)
622622
// Copy a string, uppercasing as we go.
623623
//
624624

625-
void ALICE_upper_case(const TEXT* in, TEXT* out, const size_t buf_size)
625+
void ALICE_upper_case(const TEXT* in, TEXT* out, const size_t buf_size) noexcept
626626
{
627627
const TEXT* const end = out + buf_size - 1;
628628
for (TEXT c = *in++; c && out < end; c = *in++) {
@@ -692,7 +692,7 @@ void ALICE_print_status(bool error, const ISC_STATUS* status_vector)
692692
// Format and print an error message, then punt.
693693
//
694694

695-
void ALICE_error(USHORT number, const SafeArg& arg)
695+
[[noreturn]] void ALICE_error(USHORT number, const SafeArg& arg)
696696
{
697697
AliceGlobals* tdgbl = AliceGlobals::getSpecific();
698698
TEXT buffer[256];

src/alice/alice.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ struct tdr : public pool_alloc<alice_type_tdr>
120120
};
121121

122122
// CVC: This information should match Transaction Description Record constants in acl.h
123-
const int TDR_VERSION = 1;
123+
inline constexpr int TDR_VERSION = 1;
124124
enum tdr_vals {
125125
TDR_HOST_SITE = 1,
126126
TDR_DATABASE_PATH = 2,

src/alice/alice_proto.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ int alice(Firebird::UtilSvc*);
3333

3434
class AliceGlobals;
3535

36-
void ALICE_upper_case(const TEXT*, TEXT*, const size_t);
36+
void ALICE_upper_case(const TEXT*, TEXT*, const size_t) noexcept;
3737
void ALICE_print(USHORT, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg());
38-
void ALICE_error(USHORT, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg());
38+
[[noreturn]] void ALICE_error(USHORT, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg());
3939
void ALICE_print_status(bool error, const ISC_STATUS*);
40-
void ALICE_exit(int, AliceGlobals*);
40+
[[noreturn]] void ALICE_exit(int, AliceGlobals*);
4141

4242
#endif // ALICE_ALICE_PROTO_H

src/alice/aliceswi.h

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -27,49 +27,49 @@
2727

2828
// switch definitions
2929

30-
const SINT64 sw_list = 0x0000000000000001L; // Byte 0, Bit 0
31-
const SINT64 sw_prompt = 0x0000000000000002L;
32-
const SINT64 sw_commit = 0x0000000000000004L;
33-
const SINT64 sw_rollback = 0x0000000000000008L;
34-
const SINT64 sw_sweep = 0x0000000000000010L;
35-
const SINT64 sw_validate = 0x0000000000000020L;
36-
const SINT64 sw_no_update = 0x0000000000000040L;
37-
const SINT64 sw_full = 0x0000000000000080L;
38-
const SINT64 sw_mend = 0x0000000000000100L; // Byte 1, Bit 0
39-
const SINT64 sw_all = 0x0000000000000200L;
40-
const SINT64 sw_enable = 0x0000000000000400L;
41-
const SINT64 sw_disable = 0x0000000000000800L;
42-
const SINT64 sw_ignore = 0x0000000000001000L;
43-
const SINT64 sw_activate = 0x0000000000002000L;
44-
const SINT64 sw_two_phase = 0x0000000000004000L;
45-
const SINT64 sw_housekeeping = 0x0000000000008000L;
46-
const SINT64 sw_kill = 0x0000000000010000L; // Byte 2, Bit 0
47-
//const SINT64 sw_begin_log = 0x0000000000020000L;
48-
//const SINT64 sw_quit_log = 0x0000000000040000L;
49-
const SINT64 sw_write = 0x0000000000080000L;
50-
const SINT64 sw_no_reserve = 0x0000000000100000L;
51-
const SINT64 sw_user = 0x0000000000200000L;
52-
const SINT64 sw_password = 0x0000000000400000L;
53-
const SINT64 sw_shut = 0x0000000000800000L;
54-
const SINT64 sw_online = 0x0000000001000000L; // Byte 3, Bit 0
55-
//const SINT64 sw_cache = 0x0000000002000000L;
56-
const SINT64 sw_attach = 0x0000000004000000L;
57-
const SINT64 sw_force = 0x0000000008000000L;
58-
const SINT64 sw_tran = 0x0000000010000000L;
59-
const SINT64 sw_buffers = 0x0000000020000000L;
60-
const SINT64 sw_mode = 0x0000000040000000L;
61-
const SINT64 sw_set_db_dialect = 0x0000000080000000L;
62-
const SINT64 sw_trusted_auth = QUADCONST(0x0000000100000000); // Byte 4, Bit 0
63-
const SINT64 sw_parallel_workers= QUADCONST(0x0000000200000000);
64-
const SINT64 sw_fetch_password = QUADCONST(0x0000000800000000);
65-
const SINT64 sw_nolinger = QUADCONST(0x0000001000000000);
66-
const SINT64 sw_icu = QUADCONST(0x0000002000000000);
67-
const SINT64 sw_role = QUADCONST(0x0000004000000000);
68-
const SINT64 sw_replica = QUADCONST(0x0000008000000000);
69-
const SINT64 sw_upgrade = QUADCONST(0x0000010000000000);
30+
inline constexpr SINT64 sw_list = 0x0000000000000001L; // Byte 0, Bit 0
31+
inline constexpr SINT64 sw_prompt = 0x0000000000000002L;
32+
inline constexpr SINT64 sw_commit = 0x0000000000000004L;
33+
inline constexpr SINT64 sw_rollback = 0x0000000000000008L;
34+
inline constexpr SINT64 sw_sweep = 0x0000000000000010L;
35+
inline constexpr SINT64 sw_validate = 0x0000000000000020L;
36+
inline constexpr SINT64 sw_no_update = 0x0000000000000040L;
37+
inline constexpr SINT64 sw_full = 0x0000000000000080L;
38+
inline constexpr SINT64 sw_mend = 0x0000000000000100L; // Byte 1, Bit 0
39+
inline constexpr SINT64 sw_all = 0x0000000000000200L;
40+
inline constexpr SINT64 sw_enable = 0x0000000000000400L;
41+
inline constexpr SINT64 sw_disable = 0x0000000000000800L;
42+
inline constexpr SINT64 sw_ignore = 0x0000000000001000L;
43+
inline constexpr SINT64 sw_activate = 0x0000000000002000L;
44+
inline constexpr SINT64 sw_two_phase = 0x0000000000004000L;
45+
inline constexpr SINT64 sw_housekeeping = 0x0000000000008000L;
46+
inline constexpr SINT64 sw_kill = 0x0000000000010000L; // Byte 2, Bit 0
47+
//inline constexpr SINT64 sw_begin_log = 0x0000000000020000L;
48+
//inline constexpr SINT64 sw_quit_log = 0x0000000000040000L;
49+
inline constexpr SINT64 sw_write = 0x0000000000080000L;
50+
inline constexpr SINT64 sw_no_reserve = 0x0000000000100000L;
51+
inline constexpr SINT64 sw_user = 0x0000000000200000L;
52+
inline constexpr SINT64 sw_password = 0x0000000000400000L;
53+
inline constexpr SINT64 sw_shut = 0x0000000000800000L;
54+
inline constexpr SINT64 sw_online = 0x0000000001000000L; // Byte 3, Bit 0
55+
//inline constexpr SINT64 sw_cache = 0x0000000002000000L;
56+
inline constexpr SINT64 sw_attach = 0x0000000004000000L;
57+
inline constexpr SINT64 sw_force = 0x0000000008000000L;
58+
inline constexpr SINT64 sw_tran = 0x0000000010000000L;
59+
inline constexpr SINT64 sw_buffers = 0x0000000020000000L;
60+
inline constexpr SINT64 sw_mode = 0x0000000040000000L;
61+
inline constexpr SINT64 sw_set_db_dialect = 0x0000000080000000L;
62+
inline constexpr SINT64 sw_trusted_auth = QUADCONST(0x0000000100000000); // Byte 4, Bit 0
63+
inline constexpr SINT64 sw_parallel_workers = QUADCONST(0x0000000200000000);
64+
inline constexpr SINT64 sw_fetch_password = QUADCONST(0x0000000800000000);
65+
inline constexpr SINT64 sw_nolinger = QUADCONST(0x0000001000000000);
66+
inline constexpr SINT64 sw_icu = QUADCONST(0x0000002000000000);
67+
inline constexpr SINT64 sw_role = QUADCONST(0x0000004000000000);
68+
inline constexpr SINT64 sw_replica = QUADCONST(0x0000008000000000);
69+
inline constexpr SINT64 sw_upgrade = QUADCONST(0x0000010000000000);
7070

7171
// Popular combination of compatible switches
72-
const SINT64 sw_auth_set = sw_user | sw_password | sw_role | sw_fetch_password | sw_trusted_auth;
72+
inline constexpr SINT64 sw_auth_set = sw_user | sw_password | sw_role | sw_fetch_password | sw_trusted_auth;
7373

7474

7575
enum alice_switches
@@ -86,7 +86,7 @@ enum alice_switches
8686
IN_SW_ALICE_MEND = 9,
8787
IN_SW_ALICE_ALL = 10,
8888
IN_SW_ALICE_ENABLE = 11,
89-
//IN_SW_ALICE_DISABLE = 12,
89+
//IN_SW_ALICE_DISABLE = 12,
9090
IN_SW_ALICE_IGNORE = 13,
9191
IN_SW_ALICE_ACTIVATE = 14,
9292
IN_SW_ALICE_TWO_PHASE = 15,
@@ -131,20 +131,20 @@ enum alice_switches
131131
IN_SW_ALICE_UPGRADE = 52
132132
};
133133

134-
static const char* const ALICE_SW_ASYNC = "ASYNC";
135-
static const char* const ALICE_SW_SYNC = "SYNC";
134+
static inline constexpr const char* ALICE_SW_ASYNC = "ASYNC";
135+
static inline constexpr const char* ALICE_SW_SYNC = "SYNC";
136136

137-
static const char* const ALICE_SW_MODE_NONE = "NONE";
138-
static const char* const ALICE_SW_MODE_RO = "READ_ONLY";
139-
static const char* const ALICE_SW_MODE_RW = "READ_WRITE";
137+
static inline constexpr const char* ALICE_SW_MODE_NONE = "NONE";
138+
static inline constexpr const char* ALICE_SW_MODE_RO = "READ_ONLY";
139+
static inline constexpr const char* ALICE_SW_MODE_RW = "READ_WRITE";
140140

141-
static const char* const ALICE_SW_SHUT_NORMAL = "NORMAL";
142-
static const char* const ALICE_SW_SHUT_MULTI = "MULTI";
143-
static const char* const ALICE_SW_SHUT_SINGLE = "SINGLE";
144-
static const char* const ALICE_SW_SHUT_FULL = "FULL";
141+
static inline constexpr const char* ALICE_SW_SHUT_NORMAL = "NORMAL";
142+
static inline constexpr const char* ALICE_SW_SHUT_MULTI = "MULTI";
143+
static inline constexpr const char* ALICE_SW_SHUT_SINGLE = "SINGLE";
144+
static inline constexpr const char* ALICE_SW_SHUT_FULL = "FULL";
145145

146146
// Switch table
147-
static const Switches::in_sw_tab_t alice_in_sw_table[] =
147+
static inline constexpr Switches::in_sw_tab_t alice_in_sw_table[] =
148148
{
149149
{IN_SW_ALICE_ACTIVATE, isc_spb_prp_activate, "ACTIVATE_SHADOW", sw_activate,
150150
0, ~(sw_activate | sw_auth_set | sw_nolinger), false, true, 25, 2, NULL},
@@ -321,12 +321,12 @@ static const Switches::in_sw_tab_t alice_in_sw_table[] =
321321
0, 0, false, false, 0, 0, NULL}
322322
};
323323

324-
static const char* alice_shut_mode_sw_table[] =
324+
static inline constexpr const char* alice_shut_mode_sw_table[] =
325325
{
326326
ALICE_SW_SHUT_NORMAL, ALICE_SW_SHUT_MULTI, ALICE_SW_SHUT_SINGLE, ALICE_SW_SHUT_FULL
327327
};
328328

329-
static const char* alice_repl_mode_sw_table[] =
329+
static inline constexpr const char* alice_repl_mode_sw_table[] =
330330
{
331331
ALICE_SW_MODE_NONE, ALICE_SW_MODE_RO, ALICE_SW_MODE_RW
332332
};

src/alice/exe.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static void buildDpb(Firebird::ClumpletWriter&, const SINT64);
5252
static void extract_db_info(const UCHAR*, size_t);
5353

5454
// Keep always in sync with function extract_db_info()
55-
static const TEXT val_errors[] =
55+
static constexpr TEXT val_errors[] =
5656
{
5757
isc_info_page_errors, isc_info_record_errors, isc_info_bpage_errors,
5858
isc_info_dpage_errors, isc_info_ipage_errors, isc_info_ppage_errors,
@@ -338,7 +338,7 @@ static void buildDpb(Firebird::ClumpletWriter& dpb, const SINT64 switches)
338338
dpb.insertTag(isc_dpb_upgrade_db);
339339

340340
const unsigned char* authBlock;
341-
unsigned int authBlockSize = tdgbl->uSvc->getAuthBlock(&authBlock);
341+
const unsigned int authBlockSize = tdgbl->uSvc->getAuthBlock(&authBlock);
342342

343343
if (authBlockSize)
344344
{

src/alice/tdr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static void reattach_databases(tdr*);
5757
static bool reconnect(FB_API_HANDLE, TraNumber, const TEXT*, SINT64);
5858

5959

60-
static const UCHAR limbo_info[] = { isc_info_limbo, isc_info_end };
60+
static constexpr UCHAR limbo_info[] = { isc_info_limbo, isc_info_end };
6161

6262

6363
//
@@ -292,7 +292,7 @@ void TDR_list_limbo(FB_API_HANDLE handle, const TEXT* name, const SINT64 switche
292292
for (Firebird::ClumpletReader p(Firebird::ClumpletReader::InfoResponse, buffer, sizeof(buffer));
293293
!p.isEof(); p.moveNext())
294294
{
295-
UCHAR item = p.getClumpTag();
295+
const UCHAR item = p.getClumpTag();
296296
if (item == isc_info_end)
297297
break;
298298

0 commit comments

Comments
 (0)