Skip to content

Commit a3a5786

Browse files
committed
Fix conversion warnings in ini
+ use constexpr
1 parent 17fe9da commit a3a5786

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed

src/jrd/ini.epp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ namespace
9797
}
9898

9999
template <typename T>
100-
bool getCharsetByTextType(T& charSet, const USHORT subType)
100+
bool getCharsetByTextType(T& charSet, const SSHORT subType) noexcept
101101
{
102102
switch (subType)
103103
{
@@ -177,7 +177,7 @@ namespace
177177

178178
class SecurityHelper
179179
{
180-
static const unsigned FB_MAX_ACL_SIZE = 4096;
180+
static inline constexpr unsigned FB_MAX_ACL_SIZE = 4096;
181181

182182
public:
183183
SecurityHelper(const MetaName& ownerName, AutoRequest& handle)
@@ -207,7 +207,7 @@ namespace
207207
}
208208

209209
protected:
210-
UCHAR buffer[FB_MAX_ACL_SIZE];
210+
UCHAR buffer[FB_MAX_ACL_SIZE]{};
211211
ULONG length = 0;
212212

213213
protected:
@@ -661,7 +661,8 @@ void INI_format(thread_db* tdbb, const string& charset)
661661
// Store RELATIONS and RELATION_FIELDS
662662

663663
dsc schemaDesc;
664-
schemaDesc.makeText(strlen(SYSTEM_SCHEMA), CS_METADATA, (UCHAR*) SYSTEM_SCHEMA);
664+
schemaDesc.makeText(static_cast<USHORT>(strlen(SYSTEM_SCHEMA)), CS_METADATA,
665+
(UCHAR*) SYSTEM_SCHEMA);
665666

666667
AutoRequest handle2;
667668

@@ -936,7 +937,7 @@ void INI_init(thread_db* tdbb)
936937

937938
relation->rel_formats = vec<Format*>::newVector(*pool, 1);
938939

939-
const auto majorVersion = ODS_VERSION;
940+
constexpr auto majorVersion = ODS_VERSION;
940941
const auto dbMinorVersion = dbb->dbb_ods_version ? dbb->dbb_minor_version : ODS_CURRENT;
941942
// We need only the latest format for virtual tables
942943
auto minorVersion = isPersistent ? ODS_RELEASED : ODS_CURRENT;
@@ -1209,7 +1210,8 @@ void INI_upgrade(thread_db* tdbb)
12091210
const char* context = nullptr;
12101211

12111212
dsc schemaDesc;
1212-
schemaDesc.makeText(strlen(SYSTEM_SCHEMA), CS_METADATA, (UCHAR*) SYSTEM_SCHEMA);
1213+
schemaDesc.makeText(static_cast<USHORT>(strlen(SYSTEM_SCHEMA)), CS_METADATA,
1214+
(UCHAR*) SYSTEM_SCHEMA);
12131215

12141216
try {
12151217

src/jrd/ini.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ enum name_ids
5858

5959
#define NAME(name, id) name,
6060

61-
static const TEXT* const names[] =
61+
static inline constexpr const TEXT* names[] =
6262
{
6363
0,
6464
#include "../jrd/names.h"
@@ -68,9 +68,9 @@ static const TEXT* const names[] =
6868
//******************************
6969
// fields.h
7070
//******************************
71-
const USHORT BLOB_SIZE = 8;
72-
const USHORT TIMESTAMP_SIZE = 8;
73-
const USHORT TIMESTAMP_TZ_SIZE = 12;
71+
inline constexpr USHORT BLOB_SIZE = 8;
72+
inline constexpr USHORT TIMESTAMP_SIZE = 8;
73+
inline constexpr USHORT TIMESTAMP_TZ_SIZE = 12;
7474

7575
// Pick up global ids
7676

@@ -108,7 +108,7 @@ struct gfld
108108
USHORT gfld_ods_version;
109109
};
110110

111-
static const struct gfld gfields[] =
111+
static inline constexpr struct gfld gfields[] =
112112
{
113113
#include "../jrd/fields.h"
114114
{ 0, 0, dtype_unknown, 0, 0, NULL, 0, false, 0 }
@@ -142,19 +142,19 @@ typedef rids RIDS;
142142
(int) name, (int) id, update, (int) ods,
143143
#define END_RELATION 0,
144144

145-
const int RFLD_R_NAME = 0;
146-
const int RFLD_R_ID = 1;
147-
const int RFLD_R_ODS = 2;
148-
const int RFLD_R_TYPE = 3;
149-
const int RFLD_RPT = 4;
145+
inline constexpr int RFLD_R_NAME = 0;
146+
inline constexpr int RFLD_R_ID = 1;
147+
inline constexpr int RFLD_R_ODS = 2;
148+
inline constexpr int RFLD_R_TYPE = 3;
149+
inline constexpr int RFLD_RPT = 4;
150150

151-
const int RFLD_F_NAME = 0;
152-
const int RFLD_F_ID = 1;
153-
const int RFLD_F_UPDATE = 2;
154-
const int RFLD_F_ODS = 3;
155-
const int RFLD_F_LENGTH = 4;
151+
inline constexpr int RFLD_F_NAME = 0;
152+
inline constexpr int RFLD_F_ID = 1;
153+
inline constexpr int RFLD_F_UPDATE = 2;
154+
inline constexpr int RFLD_F_ODS = 3;
155+
inline constexpr int RFLD_F_LENGTH = 4;
156156

157-
static const int relfields[] =
157+
static inline constexpr int relfields[] =
158158
{
159159
#include "../jrd/relations.h"
160160
0
@@ -186,7 +186,7 @@ struct rtyp
186186

187187
#define TYPE(text, type, field) { text, type, field },
188188

189-
static const rtyp types[] =
189+
static inline constexpr rtyp types[] =
190190
{
191191
#include "../jrd/types.h"
192192
{NULL, 0, 0}

0 commit comments

Comments
 (0)