@@ -152,7 +152,7 @@ static SINT64 ISQL_vax_integer(const UCHAR* bytes, USHORT length)
152
152
// Initialize types
153
153
154
154
// Keep this array in sync with obj.h in jrd.
155
- static const SCHAR* Object_types[] =
155
+ static constexpr const SCHAR* Object_types[] =
156
156
{
157
157
"Table",
158
158
"View",
@@ -178,21 +178,21 @@ static const SCHAR* Object_types[] =
178
178
179
179
180
180
181
- const SCHAR* Trigger_prefix_types[] =
181
+ constexpr const SCHAR* Trigger_prefix_types[] =
182
182
{
183
183
"BEFORE", // keyword
184
184
"AFTER" // keyword
185
185
};
186
186
187
- const SCHAR* Trigger_suffix_types[] =
187
+ constexpr const SCHAR* Trigger_suffix_types[] =
188
188
{
189
189
"",
190
190
"INSERT", // keyword
191
191
"UPDATE", // keyword
192
192
"DELETE" // keyword
193
193
};
194
194
195
- const SCHAR* Db_trigger_types[] =
195
+ constexpr const SCHAR* Db_trigger_types[] =
196
196
{
197
197
"CONNECT", // keyword
198
198
"DISCONNECT", // keyword
@@ -216,7 +216,7 @@ enum priv_flag {
216
216
};
217
217
218
218
219
- static const struct
219
+ static constexpr struct
220
220
{
221
221
USHORT priv_flag;
222
222
const char* priv_string;
@@ -236,12 +236,12 @@ static const struct
236
236
237
237
// strlen of each element above, + strlen(", ") for separators
238
238
239
- const int MAX_PRIV_LIST = (6 + 2 + 7 + 2 + 6 + 2 + 6 + 2 + 6 + 2 + 10 + 2 + 6 + 2 + 5 + 2 + 4 + 1);
239
+ constexpr int MAX_PRIV_LIST = (6 + 2 + 7 + 2 + 6 + 2 + 6 + 2 + 6 + 2 + 10 + 2 + 6 + 2 + 5 + 2 + 4 + 1);
240
240
241
- const int PRIV_UPDATE_POS = 4;
242
- const int PRIV_REFERENCES_POS = 5;
241
+ constexpr int PRIV_UPDATE_POS = 4;
242
+ constexpr int PRIV_REFERENCES_POS = 5;
243
243
244
- const int RELATION_PRIV_ALL = priv_SELECT | priv_INSERT | priv_UPDATE | priv_DELETE | priv_REFERENCES;
244
+ constexpr int RELATION_PRIV_ALL = priv_SELECT | priv_INSERT | priv_UPDATE | priv_DELETE | priv_REFERENCES;
245
245
246
246
struct PrivilegeFields
247
247
{
@@ -252,7 +252,7 @@ struct PrivilegeFields
252
252
// Added support to display FORCED WRITES status. - PR 27-NOV-2001
253
253
// Added support to display transaction info when next_transaction id is fixed.
254
254
// Added support to display ODS version. CVC 26-Aug-2004.
255
- static const UCHAR db_items[] =
255
+ static constexpr UCHAR db_items[] =
256
256
{
257
257
isc_info_page_size,
258
258
isc_info_db_size_in_pages,
@@ -286,7 +286,7 @@ static const UCHAR db_items[] =
286
286
* This same BPB is safe to use for both V3 & V4 db's - as
287
287
* a V3 db will ignore the source_ & target_interp values.
288
288
*/
289
- static const UCHAR metadata_text_bpb[] =
289
+ static constexpr UCHAR metadata_text_bpb[] =
290
290
{
291
291
isc_bpb_version1,
292
292
isc_bpb_source_type, 1, isc_blob_text,
@@ -297,12 +297,12 @@ static const UCHAR metadata_text_bpb[] =
297
297
298
298
// trigger action helpers
299
299
300
- inline int TRIGGER_ACTION_PREFIX(int value)
300
+ inline int TRIGGER_ACTION_PREFIX(int value) noexcept
301
301
{
302
302
return (value + 1) & 1;
303
303
}
304
304
305
- inline int TRIGGER_ACTION_SUFFIX(int value, int slot)
305
+ inline int TRIGGER_ACTION_SUFFIX(int value, int slot) noexcept
306
306
{
307
307
return ((value + 1) >> (slot * 2 - 1)) & 3;
308
308
}
@@ -314,7 +314,7 @@ const string SHOW_trigger_action(SINT64 type)
314
314
case TRIGGER_TYPE_DML:
315
315
{
316
316
char buffer[256];
317
- int prefix = TRIGGER_ACTION_PREFIX(type);
317
+ const int prefix = TRIGGER_ACTION_PREFIX(type);
318
318
strcpy(buffer, Trigger_prefix_types[prefix]);
319
319
int suffix = TRIGGER_ACTION_SUFFIX(type, 1);
320
320
strcat(buffer, " ");
@@ -386,7 +386,7 @@ void SHOW_comments(bool force)
386
386
if (isqlGlob.major_ods >= ODS_VERSION11 || force)
387
387
{
388
388
char banner[BUFFER_LENGTH128];
389
- fb_utils:: snprintf(banner, sizeof(banner), "%s/* Comments for database objects. */%s", NEWLINE, NEWLINE);
389
+ snprintf(banner, sizeof(banner), "%s/* Comments for database objects. */%s", NEWLINE, NEWLINE);
390
390
show_comments(cmmExtract, banner);
391
391
}
392
392
}
@@ -426,7 +426,7 @@ void SHOW_dbb_parameters(Firebird::IAttachment* db_handle,
426
426
427
427
for (Firebird::ClumpletReader p(Firebird::ClumpletReader::InfoResponse, buffer, sizeof(buffer)); !p.isEof(); p.moveNext())
428
428
{
429
- UCHAR item = p.getClumpTag();
429
+ const UCHAR item = p.getClumpTag();
430
430
SINT64 value_out = 0;
431
431
432
432
/*
@@ -676,7 +676,7 @@ void SHOW_dbb_parameters(Firebird::IAttachment* db_handle,
676
676
}
677
677
678
678
679
- void SHOW_read_owner()
679
+ void SHOW_read_owner() noexcept
680
680
{
681
681
/**************************************
682
682
*
@@ -786,7 +786,7 @@ static void set_grantee(int user_type, const QualifiedMetaString& name, string&
786
786
}
787
787
788
788
789
- static USHORT convert_privilege_to_code(char privilege)
789
+ static USHORT convert_privilege_to_code(char privilege) noexcept
790
790
{
791
791
switch (privilege)
792
792
{
@@ -804,9 +804,9 @@ static USHORT convert_privilege_to_code(char privilege)
804
804
case 'G':
805
805
// Execute should not be here
806
806
return 0;
807
+ default:
808
+ return priv_UNKNOWN;
807
809
}
808
-
809
- return priv_UNKNOWN;
810
810
}
811
811
812
812
@@ -1304,7 +1304,7 @@ processing_state SHOW_grants(const std::optional<QualifiedMetaString>& name,
1304
1304
PRV.RDB$PRIVILEGE EQ 'M'
1305
1305
SORTED BY PRV.RDB$USER_SCHEMA_NAME, PRV.RDB$USER
1306
1306
{
1307
- MetaString role_name(PRV.RDB$RELATION_NAME);
1307
+ const MetaString role_name(PRV.RDB$RELATION_NAME);
1308
1308
1309
1309
user_string = IUTILS_name_to_string(PRV.RDB$USER);
1310
1310
@@ -1317,7 +1317,7 @@ processing_state SHOW_grants(const std::optional<QualifiedMetaString>& name,
1317
1317
if (!PRV.RDB$FIELD_NAME.NULL && PRV.RDB$FIELD_NAME[0] == 'D')
1318
1318
default_option = " DEFAULT";
1319
1319
1320
- fb_utils:: snprintf(Print_buffer, sizeof(Print_buffer), "GRANT%s %s TO %s%s%s%s%s",
1320
+ snprintf(Print_buffer, sizeof(Print_buffer), "GRANT%s %s TO %s%s%s%s%s",
1321
1321
default_option,
1322
1322
IUTILS_name_to_string(role_name).c_str(),
1323
1323
user_string.c_str(), with_option, granted_by(PRV.RDB$GRANTOR, PRV.RDB$GRANTOR.NULL).c_str(),
@@ -1733,15 +1733,15 @@ void SHOW_print_metadata_text_blob(FILE* fp, ISC_QUAD* blobid, bool escape_squot
1733
1733
while (true)
1734
1734
{
1735
1735
unsigned int length;
1736
- int cc = blob->getSegment(fbStatus, sizeof(buffer) - 1, buffer, &length);
1736
+ const int cc = blob->getSegment(fbStatus, sizeof(buffer) - 1, buffer, &length);
1737
1737
if (cc == Firebird::IStatus::RESULT_NO_DATA || cc == Firebird::IStatus::RESULT_ERROR)
1738
1738
break;
1739
1739
1740
1740
// ASF: In Windows, \n characters are printed as \r\n in text mode.
1741
1741
// If the original string has \r\n, they're printed as \r\r\n, resulting
1742
1742
// in mixed/wrong line endings. So here, we filter any \r present just
1743
1743
// before \n.
1744
- bool prevEndedWithCr = endedWithCr;
1744
+ const bool prevEndedWithCr = endedWithCr;
1745
1745
1746
1746
if ((endedWithCr = length != 0 && buffer[length - 1] == '\r'))
1747
1747
--length;
@@ -3463,9 +3463,7 @@ static void show_db()
3463
3463
3464
3464
// First general database parameters
3465
3465
3466
- bool translate = true;
3467
-
3468
- SHOW_dbb_parameters(DB, db_items, sizeof(db_items), translate, NEWLINE);
3466
+ SHOW_dbb_parameters(DB, db_items, sizeof(db_items), true, NEWLINE);
3469
3467
3470
3468
FOR DBB IN RDB$DATABASE
3471
3469
CROSS CS IN RDB$CHARACTER_SETS
@@ -4141,7 +4139,7 @@ static processing_state show_functions(const std::optional<QualifiedMetaString>&
4141
4139
*
4142
4140
**************************************/
4143
4141
4144
- int systemFlag = system ? 1 : 0;
4142
+ const int systemFlag = system ? 1 : 0;
4145
4143
4146
4144
// If no function name was given, just list the functions
4147
4145
if (!name)
@@ -4616,7 +4614,7 @@ static processing_state show_generators(const std::optional<QualifiedMetaString>
4616
4614
4617
4615
Firebird::AlignedBuffer<20> outBuffer;
4618
4616
fb_assert(outMetadata->getMessageLength(fbStatus) <= outBuffer.size());
4619
- unsigned off = outMetadata->getOffset(fbStatus, 0);
4617
+ const unsigned off = outMetadata->getOffset(fbStatus, 0);
4620
4618
if (ISQL_errmsg (fbStatus))
4621
4619
return ps_ERR;
4622
4620
@@ -4644,7 +4642,7 @@ static processing_state show_generators(const std::optional<QualifiedMetaString>
4644
4642
continue;
4645
4643
4646
4644
found = true;
4647
- ISC_INT64 val = use64 ? *((ISC_INT64*) &outBuffer[off]) : *((SLONG*) &outBuffer[off]);
4645
+ const ISC_INT64 val = use64 ? *((ISC_INT64*) &outBuffer[off]) : *((SLONG*) &outBuffer[off]);
4648
4646
4649
4647
isqlGlob.printf("Generator %s, current value: %" SQUADFORMAT,
4650
4648
IUTILS_name_to_string(genName).c_str(), val);
@@ -4655,7 +4653,7 @@ static processing_state show_generators(const std::optional<QualifiedMetaString>
4655
4653
WITH G2.RDB$SCHEMA_NAME EQUIV NULLIF(genName.schema.c_str(), '') AND
4656
4654
G2.RDB$GENERATOR_NAME = genName.object.c_str()
4657
4655
{
4658
- ISC_INT64 initval = !G2.RDB$INITIAL_VALUE.NULL ? G2.RDB$INITIAL_VALUE : 0;
4656
+ const ISC_INT64 initval = !G2.RDB$INITIAL_VALUE.NULL ? G2.RDB$INITIAL_VALUE : 0;
4659
4657
isqlGlob.printf(", initial value: %" SQUADFORMAT ", increment: %" SLONGFORMAT,
4660
4658
initval, G2.RDB$GENERATOR_INCREMENT);
4661
4659
}
@@ -4853,7 +4851,7 @@ static processing_state show_packages(const std::optional<QualifiedMetaString>&
4853
4851
SORTED BY PACK.RDB$SCHEMA_NAME, PACK.RDB$PACKAGE_NAME
4854
4852
{
4855
4853
const QualifiedMetaString packageName(PACK.RDB$PACKAGE_NAME, PACK.RDB$SCHEMA_NAME);
4856
- bool system_flag = !PACK.RDB$SYSTEM_FLAG.NULL && PACK.RDB$SYSTEM_FLAG > 0;
4854
+ const bool system_flag = !PACK.RDB$SYSTEM_FLAG.NULL && PACK.RDB$SYSTEM_FLAG > 0;
4857
4855
4858
4856
if (system_flag == sys)
4859
4857
{
@@ -4932,7 +4930,7 @@ static processing_state show_packages(const std::optional<QualifiedMetaString>&
4932
4930
}
4933
4931
4934
4932
4935
- static void printMap(bool extract, bool global, const MetaString& name, char* usng, const MetaString& plugin,
4933
+ static void printMap(bool extract, bool global, const MetaString& name, const char* usng, const MetaString& plugin,
4936
4934
const MetaString& db, const MetaString& fromType, const MetaString& from, short toType, const MetaString& to)
4937
4935
{
4938
4936
if (extract)
@@ -4969,7 +4967,7 @@ static void printMap(bool extract, bool global, const MetaString& name, char* us
4969
4967
if (db.hasData())
4970
4968
isqlGlob.printf("IN %s ", IUTILS_name_to_string(db).c_str());
4971
4969
4972
- bool anyObj = from == "*";
4970
+ const bool anyObj = from == "*";
4973
4971
isqlGlob.printf("FROM %s", anyObj ? "ANY " : "");
4974
4972
isqlGlob.printf("%s ", IUTILS_name_to_string(fromType).c_str());
4975
4973
if (!anyObj)
@@ -5089,7 +5087,7 @@ static processing_state show_proc(const std::optional<QualifiedMetaString>& name
5089
5087
FOR PRC IN RDB$PROCEDURES
5090
5088
SORTED BY PRC.RDB$SCHEMA_NAME, PRC.RDB$PACKAGE_NAME, PRC.RDB$PROCEDURE_NAME
5091
5089
{
5092
- bool system_flag = !PRC.RDB$SYSTEM_FLAG.NULL && PRC.RDB$SYSTEM_FLAG > 0;
5090
+ const bool system_flag = !PRC.RDB$SYSTEM_FLAG.NULL && PRC.RDB$SYSTEM_FLAG > 0;
5093
5091
5094
5092
if (system_flag == sys)
5095
5093
{
@@ -5499,7 +5497,7 @@ bool SHOW_system_privileges(const MetaString& name, const char* prefix, bool lf)
5499
5497
{
5500
5498
for (unsigned byte = 0; byte < sizeof(X.RDB$SYSTEM_PRIVILEGES); ++byte)
5501
5499
{
5502
- char b = X.RDB$SYSTEM_PRIVILEGES[byte];
5500
+ const char b = X.RDB$SYSTEM_PRIVILEGES[byte];
5503
5501
for (int bit = 0; bit < 8; ++bit)
5504
5502
{
5505
5503
if (b & (1 << bit))
@@ -5557,7 +5555,7 @@ static processing_state show_role(const std::optional<MetaString>& name, bool sy
5557
5555
SORTED BY X.RDB$ROLE_NAME
5558
5556
{
5559
5557
const MetaString roleName(X.RDB$ROLE_NAME);
5560
- bool system_flag = !X.RDB$SYSTEM_FLAG.NULL && X.RDB$SYSTEM_FLAG > 0;
5558
+ const bool system_flag = !X.RDB$SYSTEM_FLAG.NULL && X.RDB$SYSTEM_FLAG > 0;
5561
5559
5562
5560
if (system_flag == system)
5563
5561
{
@@ -5659,7 +5657,7 @@ static processing_state show_schemas(const std::optional<MetaString>& name, bool
5659
5657
SORTED BY SCH.RDB$SCHEMA_NAME
5660
5658
{
5661
5659
const MetaString schemaName(SCH.RDB$SCHEMA_NAME);
5662
- bool systemFlag = !SCH.RDB$SYSTEM_FLAG.NULL && SCH.RDB$SYSTEM_FLAG > 0;
5660
+ const bool systemFlag = !SCH.RDB$SYSTEM_FLAG.NULL && SCH.RDB$SYSTEM_FLAG > 0;
5663
5661
5664
5662
if ((name && name != schemaName) || (!name && systemFlag != system))
5665
5663
continue;
@@ -6585,13 +6583,13 @@ static processing_state show_users12()
6585
6583
Firebird::AlignedBuffer<MAX_SQL_IDENTIFIER_SIZE + 32> outBuffer;
6586
6584
fb_assert(outMetadata->getMessageLength(fbStatus) <= outBuffer.size());
6587
6585
6588
- char* mark = ( char*) &outBuffer[outMetadata->getOffset(fbStatus, 0)];
6586
+ const char* mark = reinterpret_cast< char*>( &outBuffer[outMetadata->getOffset(fbStatus, 0)]) ;
6589
6587
if (ISQL_errmsg (fbStatus))
6590
6588
return ps_ERR;
6591
6589
vary* username = (vary*) &outBuffer[outMetadata->getOffset(fbStatus, 1)];
6592
6590
if (ISQL_errmsg (fbStatus))
6593
6591
return ps_ERR;
6594
- int* cnt = ( int*) &outBuffer[outMetadata->getOffset(fbStatus, 2)];
6592
+ const int* cnt = reinterpret_cast< int*>( &outBuffer[outMetadata->getOffset(fbStatus, 2)]) ;
6595
6593
if (ISQL_errmsg (fbStatus))
6596
6594
return ps_ERR;
6597
6595
@@ -6702,11 +6700,11 @@ static processing_state show_users()
6702
6700
rc = SKIP; // We found at least one user.
6703
6701
}
6704
6702
6705
- unsigned len = p.getBytes()[0];
6703
+ const unsigned len = p.getBytes()[0];
6706
6704
fb_assert(len == p.getClumpLength() - 1);
6707
6705
const UCHAR* uname = p.getBytes() + 1;
6708
6706
// Let's mark all attachments with our same user with a # prefix.
6709
- bool same(len == my_user->vary_length && !memcmp(my_user->vary_string, uname, len));
6707
+ const bool same = (len == my_user->vary_length && !memcmp(my_user->vary_string, uname, len));
6710
6708
isqlGlob.printf("%c %.*s", same ? '#' : ' ', len, uname);
6711
6709
isqlGlob.printf("\n");
6712
6710
}
0 commit comments