Skip to content

Commit 50849da

Browse files
committed
Fix compiler warning in filters
+ constexpr and misc other changes
1 parent e7764dc commit 50849da

File tree

2 files changed

+51
-52
lines changed

2 files changed

+51
-52
lines changed

src/jrd/acl.h

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -28,54 +28,54 @@
2828
// of int, based on usage, but they aren't coherent either with scl.epp's
2929
// P_NAMES.p_names_acl that's USHORT.
3030

31-
const int ACL_version = 2;
31+
inline constexpr int ACL_version = 2;
3232

33-
const int ACL_end = 0;
34-
const int ACL_id_list = 1;
35-
const int ACL_priv_list = 2;
33+
inline constexpr int ACL_end = 0;
34+
inline constexpr int ACL_id_list = 1;
35+
inline constexpr int ACL_priv_list = 2;
3636

3737
// Privileges to be granted
3838

39-
const int priv_end = 0;
40-
const int priv_control = 1; // Control over ACL
41-
const int priv_grant = 2; // Unused
42-
const int priv_drop = 3; // Drop object
43-
const int priv_select = 4; // SELECT
44-
const int priv_write = 5; // Unused
45-
const int priv_alter = 6; // Alter object
46-
const int priv_insert = 7; // INSERT
47-
const int priv_delete = 8; // DELETE
48-
const int priv_update = 9; // UPDATE
49-
const int priv_references = 10; // REFERENCES for foreign key
50-
const int priv_execute = 11; // EXECUTE (procedure, function, package)
39+
inline constexpr int priv_end = 0;
40+
inline constexpr int priv_control = 1; // Control over ACL
41+
inline constexpr int priv_grant = 2; // Unused
42+
inline constexpr int priv_drop = 3; // Drop object
43+
inline constexpr int priv_select = 4; // SELECT
44+
inline constexpr int priv_write = 5; // Unused
45+
inline constexpr int priv_alter = 6; // Alter object
46+
inline constexpr int priv_insert = 7; // INSERT
47+
inline constexpr int priv_delete = 8; // DELETE
48+
inline constexpr int priv_update = 9; // UPDATE
49+
inline constexpr int priv_references = 10; // REFERENCES for foreign key
50+
inline constexpr int priv_execute = 11; // EXECUTE (procedure, function, package)
5151
// New in FB3
52-
const int priv_usage = 12; // USAGE (domain, exception, sequence, collation)
53-
const int priv_create = 13; // Create object
54-
const int priv_alter_any = 14; // Alter any object
55-
const int priv_drop_any = 15; // Drop any object
56-
const int priv_max = 16;
52+
inline constexpr int priv_usage = 12; // USAGE (domain, exception, sequence, collation)
53+
inline constexpr int priv_create = 13; // Create object
54+
inline constexpr int priv_alter_any = 14; // Alter any object
55+
inline constexpr int priv_drop_any = 15; // Drop any object
56+
inline constexpr int priv_max = 16;
5757

5858
// Identification criterias
5959

60-
const int id_end = 0;
61-
const int id_group = 1; // UNIX group id
62-
const int id_user = 2; // UNIX user
63-
const int id_person = 3; // User name
64-
const int id_project = 4; // Project name
65-
const int id_organization = 5; // Organization name
66-
const int id_node = 6; // Node id
67-
const int id_view = 7; // View name
68-
const int id_views = 8; // All views
69-
const int id_trigger = 9; // Trigger name
70-
const int id_procedure = 10; // Procedure name
71-
const int id_sql_role = 11; // SQL role
60+
inline constexpr int id_end = 0;
61+
inline constexpr int id_group = 1; // UNIX group id
62+
inline constexpr int id_user = 2; // UNIX user
63+
inline constexpr int id_person = 3; // User name
64+
inline constexpr int id_project = 4; // Project name
65+
inline constexpr int id_organization = 5; // Organization name
66+
inline constexpr int id_node = 6; // Node id
67+
inline constexpr int id_view = 7; // View name
68+
inline constexpr int id_views = 8; // All views
69+
inline constexpr int id_trigger = 9; // Trigger name
70+
inline constexpr int id_procedure = 10; // Procedure name
71+
inline constexpr int id_sql_role = 11; // SQL role
7272
// New in FB3
73-
const int id_package = 12; // Package name
74-
const int id_function = 13; // Function name
75-
const int id_filter = 14; // Filter name
73+
inline constexpr int id_package = 12; // Package name
74+
inline constexpr int id_function = 13; // Function name
75+
inline constexpr int id_filter = 14; // Filter name
7676
// New in FB4
77-
const int id_privilege = 15; // System privilege
78-
const int id_max = 16;
77+
inline constexpr int id_privilege = 15; // System privilege
78+
inline constexpr int id_max = 16;
7979

8080
/* Format of access control list:
8181
@@ -91,10 +91,10 @@ const int id_max = 16;
9191
// Transaction Description Record
9292
// CVC: This information should match enum tdr_vals in alice.h
9393

94-
const int TDR_VERSION = 1;
95-
const int TDR_HOST_SITE = 1;
96-
const int TDR_DATABASE_PATH = 2;
97-
const int TDR_TRANSACTION_ID = 3;
98-
const int TDR_REMOTE_SITE = 4;
94+
inline constexpr int TDR_VERSION = 1;
95+
inline constexpr int TDR_HOST_SITE = 1;
96+
inline constexpr int TDR_DATABASE_PATH = 2;
97+
inline constexpr int TDR_TRANSACTION_ID = 3;
98+
inline constexpr int TDR_REMOTE_SITE = 4;
9999

100100
#endif // JRD_ACL_H

src/jrd/filters.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static void string_put(BlobControl*, const char*);
5555
* For V3 historical reasons, only ASCII byte values are passed
5656
* through. All other byte values are mapped to ascii '.'
5757
*/
58-
static const UCHAR char_tab[128] =
58+
static inline constexpr UCHAR char_tab[128] =
5959
{
6060
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0,
6161
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -77,10 +77,10 @@ struct filter_tmp
7777
TEXT tmp_string[1];
7878
};
7979

80-
const char* const WILD_CARD_UIC = "(*.*)";
80+
inline constexpr const char* WILD_CARD_UIC = "(*.*)";
8181

8282
// TXNN: Used on filter of internal data structure to text
83-
static const TEXT* acl_privs[priv_max] =
83+
static inline constexpr const TEXT* acl_privs[priv_max] =
8484
{
8585
"?",
8686
"control",
@@ -100,7 +100,7 @@ static const TEXT* acl_privs[priv_max] =
100100
"drop_any"
101101
};
102102

103-
static const TEXT* acl_ids[id_max] =
103+
static inline constexpr const TEXT* acl_ids[id_max] =
104104
{
105105
"?: ",
106106
"group: ",
@@ -119,7 +119,7 @@ static const TEXT* acl_ids[id_max] =
119119
};
120120

121121
// TXNN: Used on filter of internal data structure to text
122-
static const TEXT dtypes[DTYPE_TYPE_MAX][36] =
122+
static inline constexpr TEXT dtypes[DTYPE_TYPE_MAX][36] =
123123
{
124124
"none",
125125
"CHAR",
@@ -474,11 +474,10 @@ ISC_STATUS filter_runtime(USHORT action, BlobControl* control)
474474
// Loop thru descriptors looking for one with a data type
475475
UCHAR temp[BUFFER_SMALL];
476476
UCHAR* buff = temp;
477-
const USHORT buff_len = sizeof(temp);
478477
control->ctl_data[3] = 8;
479478

480479
USHORT length;
481-
const ISC_STATUS status = caller(isc_blob_filter_get_segment, control, buff_len, buff, &length);
480+
const ISC_STATUS status = caller(isc_blob_filter_get_segment, control, sizeof(temp), buff, &length);
482481

483482
if (status == isc_segment)
484483
return isc_segstr_eof;
@@ -814,7 +813,7 @@ ISC_STATUS filter_transliterate_text(USHORT action, BlobControl* control)
814813
thread_db* tdbb = NULL;
815814
// Note: Cannot pass tdbb without API change to user filters
816815

817-
const USHORT EXP_SCALE = 128; // to keep expansion non-floating
816+
constexpr USHORT EXP_SCALE = 128; // to keep expansion non-floating
818817

819818
ctlaux* aux = (ctlaux*) control->ctl_data[0];
820819

@@ -1305,7 +1304,7 @@ static void dump_blr(void* arg, SSHORT /*offset*/, const char* line)
13051304
}
13061305

13071306
// Pad out to indent length with spaces
1308-
snprintf(temp, l + 1, "%-*s%s", data_len, "", line);
1307+
snprintf(temp, l + 1, "%-*s%s", static_cast<int>(data_len), "", line);
13091308
string_put(control, temp);
13101309

13111310
if (temp != buffer)

0 commit comments

Comments
 (0)