Skip to content

Commit 2c687ec

Browse files
author
Artyom Abakumov
committed
Fix windows warnings (C4554, C4018) and mark error message constants as constexpr (C26814)
1 parent cc8009c commit 2c687ec

File tree

12 files changed

+45
-45
lines changed

12 files changed

+45
-45
lines changed

src/burp/BurpTasks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ void RestoreRelationTask::verbRecs(FB_UINT64& records, bool total)
822822

823823
void RestoreRelationTask::verbRecsFinal()
824824
{
825-
if (m_verbRecs < m_records)
825+
if (m_verbRecs < static_cast<FB_UINT64>(m_records))
826826
{
827827
m_verbRecs = m_records;
828828
BURP_verbose(107, SafeArg() << m_verbRecs);

src/common/CvtFormat.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ namespace
7575
const TrieNode* currentNode = m_root;
7676
FB_SIZE_T valueLength = fb_strlen(value);
7777

78-
for (outParsedTimezoneLength = 0; outParsedTimezoneLength < valueLength; outParsedTimezoneLength++)
78+
for (outParsedTimezoneLength = 0; static_cast<FB_SIZE_T>(outParsedTimezoneLength) < valueLength; outParsedTimezoneLength++)
7979
{
8080
int index = calculateIndex(value[outParsedTimezoneLength]);
8181

@@ -97,7 +97,7 @@ namespace
9797
TrieNode* currentNode = m_root;
9898
FB_SIZE_T valueLength = fb_strlen(value);
9999

100-
for (int i = 0; i < valueLength; i++)
100+
for (FB_SIZE_T i = 0; i < valueLength; i++)
101101
{
102102
int index = calculateIndex(value[i]);
103103

@@ -141,9 +141,9 @@ namespace
141141
InitInstance<TimeZoneTrie> timeZoneTrie;
142142

143143

144-
#define CVT_FORMAT(id, format) constexpr Patterns format = 1llu << id - 1;
145-
#define CVT_FORMAT2(id, format1, format2) constexpr Patterns format2 = 1llu << id - 1;
146-
#define CVT_FORMAT_FLAG(id, format) constexpr Patterns format = 1llu << id - 1;
144+
#define CVT_FORMAT(id, format) constexpr Patterns format = 1llu << (id - 1);
145+
#define CVT_FORMAT2(id, format1, format2) constexpr Patterns format2 = 1llu << (id - 1);
146+
#define CVT_FORMAT_FLAG(id, format) constexpr Patterns format = 1llu << (id - 1);
147147
namespace Format
148148
{
149149
typedef FB_UINT64 Patterns;
@@ -343,7 +343,7 @@ namespace
343343
if (number < 1 || number > 9)
344344
return Format::NONE;
345345

346-
return Format::FF1 << number - 1;
346+
return Format::FF1 << (number - 1);
347347
}
348348
break;
349349

@@ -1668,7 +1668,7 @@ ISC_TIMESTAMP_TZ CVT_format_string_to_datetime(const dsc* desc, const Firebird::
16681668
stringUpper[i] = toupper(sourceString[i]);
16691669

16701670
string formatUpper(format.length(), '\0');
1671-
for (int i = 0; i < format.length(); i++)
1671+
for (auto i = 0; i < format.length(); i++)
16721672
formatUpper[i] = toupper(format[i]);
16731673

16741674
StringToDateTimeData cvtData;

src/common/unicode_util.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,7 +1615,7 @@ UnicodeUtil::Utf16Collation* UnicodeUtil::Utf16Collation::create(
16151615

16161616
if (len >= 2)
16171617
{
1618-
obj->maxContractionsPrefixLength = len - 1 > obj->maxContractionsPrefixLength ?
1618+
obj->maxContractionsPrefixLength = static_cast<ULONG>(len - 1) > obj->maxContractionsPrefixLength ?
16191619
len - 1 : obj->maxContractionsPrefixLength;
16201620

16211621
UCHAR key[100];
@@ -1865,7 +1865,7 @@ USHORT UnicodeUtil::Utf16Collation::stringToKey(USHORT srcLen, const USHORT* src
18651865
lastCharKeyLen = icu->ucolGetSortKey(coll,
18661866
reinterpret_cast<const UChar*>(src + srcLenLong), i, lastCharKey, sizeof(lastCharKey));
18671867

1868-
if (prefixLen == 0 || prefixLen > dstLen - 2 || prefixLen > MAX_USHORT ||
1868+
if (prefixLen == 0 || prefixLen > dstLen - 2u || prefixLen > MAX_USHORT ||
18691869
lastCharKeyLen == 0)
18701870
{
18711871
return INTL_BAD_KEY_LENGTH;
@@ -1895,7 +1895,7 @@ USHORT UnicodeUtil::Utf16Collation::stringToKey(USHORT srcLen, const USHORT* src
18951895

18961896
const ULONG keyLen = prefixLen + keyIt.getCount() - advance;
18971897

1898-
if (keyLen > dstLen - 2 || keyLen > MAX_USHORT)
1898+
if (keyLen > dstLen - 2u || keyLen > MAX_USHORT)
18991899
return INTL_BAD_KEY_LENGTH;
19001900

19011901
dst[0] = UCHAR(keyLen & 0xFF);
@@ -1920,7 +1920,7 @@ USHORT UnicodeUtil::Utf16Collation::stringToKey(USHORT srcLen, const USHORT* src
19201920
ULONG keyLen = icu->ucolGetSortKey(coll,
19211921
reinterpret_cast<const UChar*>(src), srcLenLong, originalDst + 2, originalDstLen - 3);
19221922

1923-
if (keyLen == 0 || keyLen > originalDstLen - 3 || keyLen > MAX_USHORT)
1923+
if (keyLen == 0 || keyLen > originalDstLen - 3u || keyLen > MAX_USHORT)
19241924
return INTL_BAD_KEY_LENGTH;
19251925

19261926
fb_assert(originalDst[2 + keyLen - 1] == '\0');

src/dsql/BoolNodes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ bool ComparativeBoolNode::stringBoolean(thread_db* tdbb, Request* request, dsc*
10581058
cache->matcher->reset();
10591059
else
10601060
{
1061-
if (cache && cache->keySize < patternLen + escapeLen)
1061+
if (cache && cache->keySize < static_cast<ULONG>(patternLen) + escapeLen)
10621062
{
10631063
delete cache;
10641064
cache = nullptr;

src/dsql/ExprNodes.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12182,11 +12182,11 @@ dsc* SubstringSimilarNode::execute(thread_db* tdbb, Request* request) const
1218212182

1218312183
MoveBuffer patternBuffer;
1218412184
UCHAR* patternStr;
12185-
int patternLen = MOV_make_string2(tdbb, patternDesc, textType, &patternStr, patternBuffer);
12185+
ULONG patternLen = MOV_make_string2(tdbb, patternDesc, textType, &patternStr, patternBuffer);
1218612186

1218712187
MoveBuffer escapeBuffer;
1218812188
UCHAR* escapeStr;
12189-
int escapeLen = MOV_make_string2(tdbb, escapeDesc, textType, &escapeStr, escapeBuffer);
12189+
ULONG escapeLen = MOV_make_string2(tdbb, escapeDesc, textType, &escapeStr, escapeBuffer);
1219012190

1219112191
// Verify the correctness of the escape character.
1219212192
if (escapeLen == 0 || charSet->length(escapeLen, escapeStr, true) != 1)

src/dsql/StmtNodes.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3428,7 +3428,7 @@ ExecProcedureNode* ExecProcedureNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
34283428
const auto positionalArgCount = inputSources->items.getCount() -
34293429
(dsqlInputArgNames ? dsqlInputArgNames->getCount() : 0);
34303430

3431-
if (positionalArgCount > procedure->prc_in_count || dsqlInputArgNames)
3431+
if (static_cast<SSHORT>(positionalArgCount) > procedure->prc_in_count || dsqlInputArgNames)
34323432
{
34333433
const auto newInputs = FB_NEW_POOL(pool) ValueListNode(pool);
34343434
const auto newOutputs = FB_NEW_POOL(pool) ValueListNode(pool);
@@ -3443,7 +3443,7 @@ ExecProcedureNode* ExecProcedureNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
34433443

34443444
for (auto source : inputSources->items)
34453445
{
3446-
const bool isInput = (pos < positionalArgCount && pos < procedure->prc_in_count) ||
3446+
const bool isInput = (pos < positionalArgCount && pos < static_cast<unsigned>(procedure->prc_in_count)) ||
34473447
(pos >= positionalArgCount &&
34483448
!outFields.exist((*dsqlInputArgNames)[pos - positionalArgCount]));
34493449

src/include/firebird/iberror.h

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,32 @@
1717

1818
#ifdef __cplusplus /* c++ definitions */
1919

20-
const ISC_STATUS isc_facility = 20;
21-
const ISC_STATUS isc_base = isc_facility << 24;
22-
const ISC_STATUS isc_factor = 1;
23-
24-
const ISC_STATUS isc_arg_end = 0; // end of argument list
25-
const ISC_STATUS isc_arg_gds = 1; // generic DSRI status value
26-
const ISC_STATUS isc_arg_string = 2; // string argument
27-
const ISC_STATUS isc_arg_cstring = 3; // count & string argument
28-
const ISC_STATUS isc_arg_number = 4; // numeric argument (long)
29-
const ISC_STATUS isc_arg_interpreted = 5; // interpreted status code (string)
30-
const ISC_STATUS isc_arg_vms = 6; // VAX/VMS status code (long)
31-
const ISC_STATUS isc_arg_unix = 7; // UNIX error code
32-
const ISC_STATUS isc_arg_domain = 8; // Apollo/Domain error code
33-
const ISC_STATUS isc_arg_dos = 9; // MSDOS/OS2 error code
34-
const ISC_STATUS isc_arg_mpexl = 10; // HP MPE/XL error code
35-
const ISC_STATUS isc_arg_mpexl_ipc = 11; // HP MPE/XL IPC error code
36-
const ISC_STATUS isc_arg_next_mach = 15; // NeXT/Mach error code
37-
const ISC_STATUS isc_arg_netware = 16; // NetWare error code
38-
const ISC_STATUS isc_arg_win32 = 17; // Win32 error code
39-
const ISC_STATUS isc_arg_warning = 18; // warning argument
40-
const ISC_STATUS isc_arg_sql_state = 19; // SQLSTATE
20+
inline constexpr ISC_STATUS isc_facility = 20;
21+
inline constexpr ISC_STATUS isc_base = isc_facility << 24;
22+
inline constexpr ISC_STATUS isc_factor = 1;
23+
24+
inline constexpr ISC_STATUS isc_arg_end = 0; // end of argument list
25+
inline constexpr ISC_STATUS isc_arg_gds = 1; // generic DSRI status value
26+
inline constexpr ISC_STATUS isc_arg_string = 2; // string argument
27+
inline constexpr ISC_STATUS isc_arg_cstring = 3; // count & string argument
28+
inline constexpr ISC_STATUS isc_arg_number = 4; // numeric argument (long)
29+
inline constexpr ISC_STATUS isc_arg_interpreted = 5; // interpreted status code (string)
30+
inline constexpr ISC_STATUS isc_arg_vms = 6; // VAX/VMS status code (long)
31+
inline constexpr ISC_STATUS isc_arg_unix = 7; // UNIX error code
32+
inline constexpr ISC_STATUS isc_arg_domain = 8; // Apollo/Domain error code
33+
inline constexpr ISC_STATUS isc_arg_dos = 9; // MSDOS/OS2 error code
34+
inline constexpr ISC_STATUS isc_arg_mpexl = 10; // HP MPE/XL error code
35+
inline constexpr ISC_STATUS isc_arg_mpexl_ipc = 11; // HP MPE/XL IPC error code
36+
inline constexpr ISC_STATUS isc_arg_next_mach = 15; // NeXT/Mach error code
37+
inline constexpr ISC_STATUS isc_arg_netware = 16; // NetWare error code
38+
inline constexpr ISC_STATUS isc_arg_win32 = 17; // Win32 error code
39+
inline constexpr ISC_STATUS isc_arg_warning = 18; // warning argument
40+
inline constexpr ISC_STATUS isc_arg_sql_state = 19; // SQLSTATE
4141

4242
#define FB_IMPL_MSG_NO_SYMBOL(facility, number, text)
4343

4444
#define FB_IMPL_MSG_SYMBOL(facility, number, symbol, text) \
45-
const ISC_STATUS isc_##symbol = FB_IMPL_MSG_ENCODE(number, FB_IMPL_MSG_FACILITY_##facility);
45+
inline constexpr ISC_STATUS isc_##symbol = FB_IMPL_MSG_ENCODE(number, FB_IMPL_MSG_FACILITY_##facility);
4646

4747
#define FB_IMPL_MSG(facility, number, symbol, sqlCode, sqlClass, sqlSubClass, text) \
4848
FB_IMPL_MSG_SYMBOL(facility, number, symbol, text)
@@ -53,7 +53,7 @@ const ISC_STATUS isc_arg_sql_state = 19; // SQLSTATE
5353
#undef FB_IMPL_MSG_SYMBOL
5454
#undef FB_IMPL_MSG
5555

56-
const ISC_STATUS isc_err_max = 0
56+
inline constexpr ISC_STATUS isc_err_max = 0
5757
#define FB_IMPL_MSG_NO_SYMBOL(facility, number, text)
5858
#define FB_IMPL_MSG_SYMBOL(facility, number, symbol, text)
5959
#define FB_IMPL_MSG(facility, number, symbol, sqlCode, sqlClass, sqlSubClass, text) + 1

src/isql/FrontendLexer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ std::variant<FrontendLexer::SingleStatement, FrontendLexer::IncompleteTokenError
142142

143143
while (pos < end)
144144
{
145-
if (end - pos >= term.length() && std::equal(term.begin(), term.end(), pos))
145+
if (static_cast<decltype(term.length())>(end - pos) >= term.length() && std::equal(term.begin(), term.end(), pos))
146146
{
147147
const auto initialStatement = std::string(buffer.cbegin(), pos);
148148
pos += term.length();

src/isql/isql.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ const int ISQL_MSG_FAC = FB_IMPL_MSG_FACILITY_ISQL;
111111
#define FB_IMPL_MSG_NO_SYMBOL(facility, number, text)
112112

113113
#define FB_IMPL_MSG_SYMBOL(facility, number, symbol, text) \
114-
const int symbol = number;
114+
inline constexpr int symbol = number;
115115

116116
#define FB_IMPL_MSG(facility, number, symbol, sqlCode, sqlClass, sqlSubClass, text) \
117117
FB_IMPL_MSG_SYMBOL(facility, number, symbol, text)

src/jrd/ExtEngineManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ namespace
318318
checkMessageEof(aCheckMessageEof)
319319
{
320320
// Iterate over the format items, except the EOF item.
321-
for (unsigned i = 0; i < (fromMessage->format->fmt_count / 2) * 2; i += 2)
321+
for (unsigned i = 0; i < (fromMessage->format->fmt_count / 2u) * 2u; i += 2)
322322
{
323323
auto flag = FB_NEW_POOL(pool) ParameterNode(pool);
324324
flag->messageNumber = fromMessage->messageNumber;

0 commit comments

Comments
 (0)