From 2c687eceaac185079975866302f01abf07df7212 Mon Sep 17 00:00:00 2001 From: Artyom Abakumov Date: Tue, 24 Dec 2024 12:19:09 +0300 Subject: [PATCH 1/6] Fix windows warnings (C4554, C4018) and mark error message constants as constexpr (C26814) --- src/burp/BurpTasks.cpp | 2 +- src/common/CvtFormat.cpp | 14 +++++------ src/common/unicode_util.cpp | 8 +++--- src/dsql/BoolNodes.cpp | 2 +- src/dsql/ExprNodes.cpp | 4 +-- src/dsql/StmtNodes.cpp | 4 +-- src/include/firebird/iberror.h | 46 +++++++++++++++++----------------- src/isql/FrontendLexer.cpp | 2 +- src/isql/isql.h | 2 +- src/jrd/ExtEngineManager.cpp | 2 +- src/jrd/idx.cpp | 2 +- src/jrd/sqz.cpp | 2 +- 12 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/burp/BurpTasks.cpp b/src/burp/BurpTasks.cpp index 396e1d7ea53..96376ab5aef 100644 --- a/src/burp/BurpTasks.cpp +++ b/src/burp/BurpTasks.cpp @@ -822,7 +822,7 @@ void RestoreRelationTask::verbRecs(FB_UINT64& records, bool total) void RestoreRelationTask::verbRecsFinal() { - if (m_verbRecs < m_records) + if (m_verbRecs < static_cast(m_records)) { m_verbRecs = m_records; BURP_verbose(107, SafeArg() << m_verbRecs); diff --git a/src/common/CvtFormat.cpp b/src/common/CvtFormat.cpp index 3ceb1c256e4..fa0c4b84c69 100644 --- a/src/common/CvtFormat.cpp +++ b/src/common/CvtFormat.cpp @@ -75,7 +75,7 @@ namespace const TrieNode* currentNode = m_root; FB_SIZE_T valueLength = fb_strlen(value); - for (outParsedTimezoneLength = 0; outParsedTimezoneLength < valueLength; outParsedTimezoneLength++) + for (outParsedTimezoneLength = 0; static_cast(outParsedTimezoneLength) < valueLength; outParsedTimezoneLength++) { int index = calculateIndex(value[outParsedTimezoneLength]); @@ -97,7 +97,7 @@ namespace TrieNode* currentNode = m_root; FB_SIZE_T valueLength = fb_strlen(value); - for (int i = 0; i < valueLength; i++) + for (FB_SIZE_T i = 0; i < valueLength; i++) { int index = calculateIndex(value[i]); @@ -141,9 +141,9 @@ namespace InitInstance timeZoneTrie; - #define CVT_FORMAT(id, format) constexpr Patterns format = 1llu << id - 1; - #define CVT_FORMAT2(id, format1, format2) constexpr Patterns format2 = 1llu << id - 1; - #define CVT_FORMAT_FLAG(id, format) constexpr Patterns format = 1llu << id - 1; + #define CVT_FORMAT(id, format) constexpr Patterns format = 1llu << (id - 1); + #define CVT_FORMAT2(id, format1, format2) constexpr Patterns format2 = 1llu << (id - 1); + #define CVT_FORMAT_FLAG(id, format) constexpr Patterns format = 1llu << (id - 1); namespace Format { typedef FB_UINT64 Patterns; @@ -343,7 +343,7 @@ namespace if (number < 1 || number > 9) return Format::NONE; - return Format::FF1 << number - 1; + return Format::FF1 << (number - 1); } break; @@ -1668,7 +1668,7 @@ ISC_TIMESTAMP_TZ CVT_format_string_to_datetime(const dsc* desc, const Firebird:: stringUpper[i] = toupper(sourceString[i]); string formatUpper(format.length(), '\0'); - for (int i = 0; i < format.length(); i++) + for (auto i = 0; i < format.length(); i++) formatUpper[i] = toupper(format[i]); StringToDateTimeData cvtData; diff --git a/src/common/unicode_util.cpp b/src/common/unicode_util.cpp index ce9ffd31cf6..fb55773d367 100644 --- a/src/common/unicode_util.cpp +++ b/src/common/unicode_util.cpp @@ -1615,7 +1615,7 @@ UnicodeUtil::Utf16Collation* UnicodeUtil::Utf16Collation::create( if (len >= 2) { - obj->maxContractionsPrefixLength = len - 1 > obj->maxContractionsPrefixLength ? + obj->maxContractionsPrefixLength = static_cast(len - 1) > obj->maxContractionsPrefixLength ? len - 1 : obj->maxContractionsPrefixLength; UCHAR key[100]; @@ -1865,7 +1865,7 @@ USHORT UnicodeUtil::Utf16Collation::stringToKey(USHORT srcLen, const USHORT* src lastCharKeyLen = icu->ucolGetSortKey(coll, reinterpret_cast(src + srcLenLong), i, lastCharKey, sizeof(lastCharKey)); - if (prefixLen == 0 || prefixLen > dstLen - 2 || prefixLen > MAX_USHORT || + if (prefixLen == 0 || prefixLen > dstLen - 2u || prefixLen > MAX_USHORT || lastCharKeyLen == 0) { return INTL_BAD_KEY_LENGTH; @@ -1895,7 +1895,7 @@ USHORT UnicodeUtil::Utf16Collation::stringToKey(USHORT srcLen, const USHORT* src const ULONG keyLen = prefixLen + keyIt.getCount() - advance; - if (keyLen > dstLen - 2 || keyLen > MAX_USHORT) + if (keyLen > dstLen - 2u || keyLen > MAX_USHORT) return INTL_BAD_KEY_LENGTH; dst[0] = UCHAR(keyLen & 0xFF); @@ -1920,7 +1920,7 @@ USHORT UnicodeUtil::Utf16Collation::stringToKey(USHORT srcLen, const USHORT* src ULONG keyLen = icu->ucolGetSortKey(coll, reinterpret_cast(src), srcLenLong, originalDst + 2, originalDstLen - 3); - if (keyLen == 0 || keyLen > originalDstLen - 3 || keyLen > MAX_USHORT) + if (keyLen == 0 || keyLen > originalDstLen - 3u || keyLen > MAX_USHORT) return INTL_BAD_KEY_LENGTH; fb_assert(originalDst[2 + keyLen - 1] == '\0'); diff --git a/src/dsql/BoolNodes.cpp b/src/dsql/BoolNodes.cpp index 38975713c5a..b75c55b2c3b 100644 --- a/src/dsql/BoolNodes.cpp +++ b/src/dsql/BoolNodes.cpp @@ -1058,7 +1058,7 @@ bool ComparativeBoolNode::stringBoolean(thread_db* tdbb, Request* request, dsc* cache->matcher->reset(); else { - if (cache && cache->keySize < patternLen + escapeLen) + if (cache && cache->keySize < static_cast(patternLen) + escapeLen) { delete cache; cache = nullptr; diff --git a/src/dsql/ExprNodes.cpp b/src/dsql/ExprNodes.cpp index 8320ab355be..0e8ffea89b3 100644 --- a/src/dsql/ExprNodes.cpp +++ b/src/dsql/ExprNodes.cpp @@ -12182,11 +12182,11 @@ dsc* SubstringSimilarNode::execute(thread_db* tdbb, Request* request) const MoveBuffer patternBuffer; UCHAR* patternStr; - int patternLen = MOV_make_string2(tdbb, patternDesc, textType, &patternStr, patternBuffer); + ULONG patternLen = MOV_make_string2(tdbb, patternDesc, textType, &patternStr, patternBuffer); MoveBuffer escapeBuffer; UCHAR* escapeStr; - int escapeLen = MOV_make_string2(tdbb, escapeDesc, textType, &escapeStr, escapeBuffer); + ULONG escapeLen = MOV_make_string2(tdbb, escapeDesc, textType, &escapeStr, escapeBuffer); // Verify the correctness of the escape character. if (escapeLen == 0 || charSet->length(escapeLen, escapeStr, true) != 1) diff --git a/src/dsql/StmtNodes.cpp b/src/dsql/StmtNodes.cpp index 3252da179b1..e54886aa179 100644 --- a/src/dsql/StmtNodes.cpp +++ b/src/dsql/StmtNodes.cpp @@ -3428,7 +3428,7 @@ ExecProcedureNode* ExecProcedureNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) const auto positionalArgCount = inputSources->items.getCount() - (dsqlInputArgNames ? dsqlInputArgNames->getCount() : 0); - if (positionalArgCount > procedure->prc_in_count || dsqlInputArgNames) + if (static_cast(positionalArgCount) > procedure->prc_in_count || dsqlInputArgNames) { const auto newInputs = FB_NEW_POOL(pool) ValueListNode(pool); const auto newOutputs = FB_NEW_POOL(pool) ValueListNode(pool); @@ -3443,7 +3443,7 @@ ExecProcedureNode* ExecProcedureNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) for (auto source : inputSources->items) { - const bool isInput = (pos < positionalArgCount && pos < procedure->prc_in_count) || + const bool isInput = (pos < positionalArgCount && pos < static_cast(procedure->prc_in_count)) || (pos >= positionalArgCount && !outFields.exist((*dsqlInputArgNames)[pos - positionalArgCount])); diff --git a/src/include/firebird/iberror.h b/src/include/firebird/iberror.h index 5e6446f1365..0aba71f7de1 100644 --- a/src/include/firebird/iberror.h +++ b/src/include/firebird/iberror.h @@ -17,32 +17,32 @@ #ifdef __cplusplus /* c++ definitions */ -const ISC_STATUS isc_facility = 20; -const ISC_STATUS isc_base = isc_facility << 24; -const ISC_STATUS isc_factor = 1; - -const ISC_STATUS isc_arg_end = 0; // end of argument list -const ISC_STATUS isc_arg_gds = 1; // generic DSRI status value -const ISC_STATUS isc_arg_string = 2; // string argument -const ISC_STATUS isc_arg_cstring = 3; // count & string argument -const ISC_STATUS isc_arg_number = 4; // numeric argument (long) -const ISC_STATUS isc_arg_interpreted = 5; // interpreted status code (string) -const ISC_STATUS isc_arg_vms = 6; // VAX/VMS status code (long) -const ISC_STATUS isc_arg_unix = 7; // UNIX error code -const ISC_STATUS isc_arg_domain = 8; // Apollo/Domain error code -const ISC_STATUS isc_arg_dos = 9; // MSDOS/OS2 error code -const ISC_STATUS isc_arg_mpexl = 10; // HP MPE/XL error code -const ISC_STATUS isc_arg_mpexl_ipc = 11; // HP MPE/XL IPC error code -const ISC_STATUS isc_arg_next_mach = 15; // NeXT/Mach error code -const ISC_STATUS isc_arg_netware = 16; // NetWare error code -const ISC_STATUS isc_arg_win32 = 17; // Win32 error code -const ISC_STATUS isc_arg_warning = 18; // warning argument -const ISC_STATUS isc_arg_sql_state = 19; // SQLSTATE +inline constexpr ISC_STATUS isc_facility = 20; +inline constexpr ISC_STATUS isc_base = isc_facility << 24; +inline constexpr ISC_STATUS isc_factor = 1; + +inline constexpr ISC_STATUS isc_arg_end = 0; // end of argument list +inline constexpr ISC_STATUS isc_arg_gds = 1; // generic DSRI status value +inline constexpr ISC_STATUS isc_arg_string = 2; // string argument +inline constexpr ISC_STATUS isc_arg_cstring = 3; // count & string argument +inline constexpr ISC_STATUS isc_arg_number = 4; // numeric argument (long) +inline constexpr ISC_STATUS isc_arg_interpreted = 5; // interpreted status code (string) +inline constexpr ISC_STATUS isc_arg_vms = 6; // VAX/VMS status code (long) +inline constexpr ISC_STATUS isc_arg_unix = 7; // UNIX error code +inline constexpr ISC_STATUS isc_arg_domain = 8; // Apollo/Domain error code +inline constexpr ISC_STATUS isc_arg_dos = 9; // MSDOS/OS2 error code +inline constexpr ISC_STATUS isc_arg_mpexl = 10; // HP MPE/XL error code +inline constexpr ISC_STATUS isc_arg_mpexl_ipc = 11; // HP MPE/XL IPC error code +inline constexpr ISC_STATUS isc_arg_next_mach = 15; // NeXT/Mach error code +inline constexpr ISC_STATUS isc_arg_netware = 16; // NetWare error code +inline constexpr ISC_STATUS isc_arg_win32 = 17; // Win32 error code +inline constexpr ISC_STATUS isc_arg_warning = 18; // warning argument +inline constexpr ISC_STATUS isc_arg_sql_state = 19; // SQLSTATE #define FB_IMPL_MSG_NO_SYMBOL(facility, number, text) #define FB_IMPL_MSG_SYMBOL(facility, number, symbol, text) \ - const ISC_STATUS isc_##symbol = FB_IMPL_MSG_ENCODE(number, FB_IMPL_MSG_FACILITY_##facility); + inline constexpr ISC_STATUS isc_##symbol = FB_IMPL_MSG_ENCODE(number, FB_IMPL_MSG_FACILITY_##facility); #define FB_IMPL_MSG(facility, number, symbol, sqlCode, sqlClass, sqlSubClass, text) \ FB_IMPL_MSG_SYMBOL(facility, number, symbol, text) @@ -53,7 +53,7 @@ const ISC_STATUS isc_arg_sql_state = 19; // SQLSTATE #undef FB_IMPL_MSG_SYMBOL #undef FB_IMPL_MSG -const ISC_STATUS isc_err_max = 0 +inline constexpr ISC_STATUS isc_err_max = 0 #define FB_IMPL_MSG_NO_SYMBOL(facility, number, text) #define FB_IMPL_MSG_SYMBOL(facility, number, symbol, text) #define FB_IMPL_MSG(facility, number, symbol, sqlCode, sqlClass, sqlSubClass, text) + 1 diff --git a/src/isql/FrontendLexer.cpp b/src/isql/FrontendLexer.cpp index 5c5a63d911d..4ad0ec200d0 100644 --- a/src/isql/FrontendLexer.cpp +++ b/src/isql/FrontendLexer.cpp @@ -142,7 +142,7 @@ std::variant= term.length() && std::equal(term.begin(), term.end(), pos)) + if (static_cast(end - pos) >= term.length() && std::equal(term.begin(), term.end(), pos)) { const auto initialStatement = std::string(buffer.cbegin(), pos); pos += term.length(); diff --git a/src/isql/isql.h b/src/isql/isql.h index 8c97ec42a8e..6a63bb0794c 100644 --- a/src/isql/isql.h +++ b/src/isql/isql.h @@ -111,7 +111,7 @@ const int ISQL_MSG_FAC = FB_IMPL_MSG_FACILITY_ISQL; #define FB_IMPL_MSG_NO_SYMBOL(facility, number, text) #define FB_IMPL_MSG_SYMBOL(facility, number, symbol, text) \ - const int symbol = number; + inline constexpr int symbol = number; #define FB_IMPL_MSG(facility, number, symbol, sqlCode, sqlClass, sqlSubClass, text) \ FB_IMPL_MSG_SYMBOL(facility, number, symbol, text) diff --git a/src/jrd/ExtEngineManager.cpp b/src/jrd/ExtEngineManager.cpp index 8f28a59fcc3..862662845bb 100644 --- a/src/jrd/ExtEngineManager.cpp +++ b/src/jrd/ExtEngineManager.cpp @@ -318,7 +318,7 @@ namespace checkMessageEof(aCheckMessageEof) { // Iterate over the format items, except the EOF item. - for (unsigned i = 0; i < (fromMessage->format->fmt_count / 2) * 2; i += 2) + for (unsigned i = 0; i < (fromMessage->format->fmt_count / 2u) * 2u; i += 2) { auto flag = FB_NEW_POOL(pool) ParameterNode(pool); flag->messageNumber = fromMessage->messageNumber; diff --git a/src/jrd/idx.cpp b/src/jrd/idx.cpp index 5c22b9b1862..ce7003ad9e4 100644 --- a/src/jrd/idx.cpp +++ b/src/jrd/idx.cpp @@ -808,7 +808,7 @@ bool IndexCreateTask::getResult(IStatus* status) int IndexCreateTask::getMaxWorkers() { - const int parWorkers = m_items.getCount(); + const FB_SIZE_T parWorkers = m_items.getCount(); if (parWorkers == 1 || m_countPP == 0) return 1; diff --git a/src/jrd/sqz.cpp b/src/jrd/sqz.cpp index c366b7ebe74..3b51e2071fb 100644 --- a/src/jrd/sqz.cpp +++ b/src/jrd/sqz.cpp @@ -76,7 +76,7 @@ unsigned Compressor::nonCompressableRun(unsigned length) if (m_runs.hasData() && m_runs.back() > 0 && m_runs.back() < MAX_NONCOMP_RUN) { - const auto max = MIN(MAX_NONCOMP_RUN - m_runs.back(), length); + const auto max = MIN(static_cast(MAX_NONCOMP_RUN - m_runs.back()), length); length -= max; m_runs.back() += max; } From f872d554bc74a4077a237e28bd792ecdff2e426e Mon Sep 17 00:00:00 2001 From: Artyom Abakumov Date: Tue, 24 Dec 2024 19:32:27 +0300 Subject: [PATCH 2/6] Use inline constexpr only when C++17 or newer is used --- src/include/firebird/iberror.h | 52 +++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/src/include/firebird/iberror.h b/src/include/firebird/iberror.h index 0aba71f7de1..cf44341726f 100644 --- a/src/include/firebird/iberror.h +++ b/src/include/firebird/iberror.h @@ -17,32 +17,38 @@ #ifdef __cplusplus /* c++ definitions */ -inline constexpr ISC_STATUS isc_facility = 20; -inline constexpr ISC_STATUS isc_base = isc_facility << 24; -inline constexpr ISC_STATUS isc_factor = 1; - -inline constexpr ISC_STATUS isc_arg_end = 0; // end of argument list -inline constexpr ISC_STATUS isc_arg_gds = 1; // generic DSRI status value -inline constexpr ISC_STATUS isc_arg_string = 2; // string argument -inline constexpr ISC_STATUS isc_arg_cstring = 3; // count & string argument -inline constexpr ISC_STATUS isc_arg_number = 4; // numeric argument (long) -inline constexpr ISC_STATUS isc_arg_interpreted = 5; // interpreted status code (string) -inline constexpr ISC_STATUS isc_arg_vms = 6; // VAX/VMS status code (long) -inline constexpr ISC_STATUS isc_arg_unix = 7; // UNIX error code -inline constexpr ISC_STATUS isc_arg_domain = 8; // Apollo/Domain error code -inline constexpr ISC_STATUS isc_arg_dos = 9; // MSDOS/OS2 error code -inline constexpr ISC_STATUS isc_arg_mpexl = 10; // HP MPE/XL error code -inline constexpr ISC_STATUS isc_arg_mpexl_ipc = 11; // HP MPE/XL IPC error code -inline constexpr ISC_STATUS isc_arg_next_mach = 15; // NeXT/Mach error code -inline constexpr ISC_STATUS isc_arg_netware = 16; // NetWare error code -inline constexpr ISC_STATUS isc_arg_win32 = 17; // Win32 error code -inline constexpr ISC_STATUS isc_arg_warning = 18; // warning argument -inline constexpr ISC_STATUS isc_arg_sql_state = 19; // SQLSTATE +#if __cplusplus >= 201703L // C++17 or later +#define STATUS_EXPR STATUS_EXPR +#else +#define STATUS_EXPR const ISC_STATUS +#endif + +STATUS_EXPR isc_facility = 20; +STATUS_EXPR isc_base = isc_facility << 24; +STATUS_EXPR isc_factor = 1; + +STATUS_EXPR isc_arg_end = 0; // end of argument list +STATUS_EXPR isc_arg_gds = 1; // generic DSRI status value +STATUS_EXPR isc_arg_string = 2; // string argument +STATUS_EXPR isc_arg_cstring = 3; // count & string argument +STATUS_EXPR isc_arg_number = 4; // numeric argument (long) +STATUS_EXPR isc_arg_interpreted = 5; // interpreted status code (string) +STATUS_EXPR isc_arg_vms = 6; // VAX/VMS status code (long) +STATUS_EXPR isc_arg_unix = 7; // UNIX error code +STATUS_EXPR isc_arg_domain = 8; // Apollo/Domain error code +STATUS_EXPR isc_arg_dos = 9; // MSDOS/OS2 error code +STATUS_EXPR isc_arg_mpexl = 10; // HP MPE/XL error code +STATUS_EXPR isc_arg_mpexl_ipc = 11; // HP MPE/XL IPC error code +STATUS_EXPR isc_arg_next_mach = 15; // NeXT/Mach error code +STATUS_EXPR isc_arg_netware = 16; // NetWare error code +STATUS_EXPR isc_arg_win32 = 17; // Win32 error code +STATUS_EXPR isc_arg_warning = 18; // warning argument +STATUS_EXPR isc_arg_sql_state = 19; // SQLSTATE #define FB_IMPL_MSG_NO_SYMBOL(facility, number, text) #define FB_IMPL_MSG_SYMBOL(facility, number, symbol, text) \ - inline constexpr ISC_STATUS isc_##symbol = FB_IMPL_MSG_ENCODE(number, FB_IMPL_MSG_FACILITY_##facility); + STATUS_EXPR isc_##symbol = FB_IMPL_MSG_ENCODE(number, FB_IMPL_MSG_FACILITY_##facility); #define FB_IMPL_MSG(facility, number, symbol, sqlCode, sqlClass, sqlSubClass, text) \ FB_IMPL_MSG_SYMBOL(facility, number, symbol, text) @@ -53,7 +59,7 @@ inline constexpr ISC_STATUS isc_arg_sql_state = 19; // SQLSTATE #undef FB_IMPL_MSG_SYMBOL #undef FB_IMPL_MSG -inline constexpr ISC_STATUS isc_err_max = 0 +STATUS_EXPR isc_err_max = 0 #define FB_IMPL_MSG_NO_SYMBOL(facility, number, text) #define FB_IMPL_MSG_SYMBOL(facility, number, symbol, text) #define FB_IMPL_MSG(facility, number, symbol, sqlCode, sqlClass, sqlSubClass, text) + 1 From 65d1c7a29ccd6ca67108088a032a56e9c8aac1c2 Mon Sep 17 00:00:00 2001 From: Artyom Abakumov Date: Tue, 24 Dec 2024 19:35:30 +0300 Subject: [PATCH 3/6] Fix wrong copy-paste --- src/include/firebird/iberror.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/firebird/iberror.h b/src/include/firebird/iberror.h index cf44341726f..da72cb48afe 100644 --- a/src/include/firebird/iberror.h +++ b/src/include/firebird/iberror.h @@ -18,7 +18,7 @@ #ifdef __cplusplus /* c++ definitions */ #if __cplusplus >= 201703L // C++17 or later -#define STATUS_EXPR STATUS_EXPR +#define STATUS_EXPR inline constexpr ISC_STATUS #else #define STATUS_EXPR const ISC_STATUS #endif From 2d2ec71c7bde7cf7f4c9d8fa1dbe1dac6c8b34c9 Mon Sep 17 00:00:00 2001 From: Artyom Abakumov Date: Wed, 25 Dec 2024 15:16:16 +0300 Subject: [PATCH 4/6] Change input type from int to uint if possible --- src/common/CvtFormat.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/CvtFormat.cpp b/src/common/CvtFormat.cpp index fa0c4b84c69..0c893fe29e8 100644 --- a/src/common/CvtFormat.cpp +++ b/src/common/CvtFormat.cpp @@ -70,12 +70,12 @@ namespace } } - bool contains(const char* value, USHORT& outTimezoneId, int& outParsedTimezoneLength) + bool contains(const char* value, USHORT& outTimezoneId, FB_SIZE_T& outParsedTimezoneLength) { const TrieNode* currentNode = m_root; FB_SIZE_T valueLength = fb_strlen(value); - for (outParsedTimezoneLength = 0; static_cast(outParsedTimezoneLength) < valueLength; outParsedTimezoneLength++) + for (outParsedTimezoneLength = 0; outParsedTimezoneLength < valueLength; outParsedTimezoneLength++) { int index = calculateIndex(value[outParsedTimezoneLength]); @@ -1541,7 +1541,7 @@ namespace } case Format::TZR: { - int parsedTimezoneNameLength = 0; + FB_SIZE_T parsedTimezoneNameLength = 0; const bool timezoneNameIsCorrect = timeZoneTrie().contains(str + strOffset, outTimezoneId, parsedTimezoneNameLength); if (!timezoneNameIsCorrect) status_exception::raise(Arg::Gds(isc_invalid_timezone_region) << string(str + strOffset, parsedTimezoneNameLength)); From 5b1fbddfeb0c797953ef29e266dde4ff0b8a338a Mon Sep 17 00:00:00 2001 From: Artyom Abakumov Date: Wed, 25 Dec 2024 16:26:06 +0300 Subject: [PATCH 5/6] Use static type instead of decltype --- src/isql/FrontendLexer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/isql/FrontendLexer.cpp b/src/isql/FrontendLexer.cpp index 4ad0ec200d0..3a6adab5e96 100644 --- a/src/isql/FrontendLexer.cpp +++ b/src/isql/FrontendLexer.cpp @@ -142,7 +142,7 @@ std::variant(end - pos) >= term.length() && std::equal(term.begin(), term.end(), pos)) + if (static_cast(end - pos) >= term.length() && std::equal(term.begin(), term.end(), pos)) { const auto initialStatement = std::string(buffer.cbegin(), pos); pos += term.length(); From ad675c4b1d5a63b0bd10ec8e5580ec92556683d1 Mon Sep 17 00:00:00 2001 From: Artyom Abakumov Date: Fri, 27 Dec 2024 15:10:12 +0300 Subject: [PATCH 6/6] Fix rest c4018 warnings --- src/burp/restore.epp | 2 +- src/jrd/inf.cpp | 2 +- src/jrd/sqz.cpp | 2 +- src/yvalve/why.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/burp/restore.epp b/src/burp/restore.epp index f992afd2b2e..c157be66114 100644 --- a/src/burp/restore.epp +++ b/src/burp/restore.epp @@ -12365,7 +12365,7 @@ bool RestoreRelationTask::fileReader(Item& item) const FB_SSIZE_T attLen = 1 + (tdgbl->gbl_sw_transportable ? 12 : 6); const FB_SSIZE_T overhead = tdgbl->gbl_sw_compress ? (len / 127 + 1) : 0; - if (len + attLen + overhead > space) + if (static_cast(len) + attLen + overhead > space) { if (ioBuf) { diff --git a/src/jrd/inf.cpp b/src/jrd/inf.cpp index cdac0eeb5a8..370fa35ceff 100644 --- a/src/jrd/inf.cpp +++ b/src/jrd/inf.cpp @@ -785,7 +785,7 @@ void INF_database_info(thread_db* tdbb, length = gds__vax_integer(items, 2); items += 2; - if (end_items - items >= length) + if (static_cast(end_items - items) >= length) { pageNum = gds__vax_integer(items, length); items += length; diff --git a/src/jrd/sqz.cpp b/src/jrd/sqz.cpp index 3b51e2071fb..d1d6e5f6e07 100644 --- a/src/jrd/sqz.cpp +++ b/src/jrd/sqz.cpp @@ -558,7 +558,7 @@ ULONG Difference::apply(ULONG diffLength, ULONG outLength, UCHAR* const output) BUGCHECK(177); // msg 177 applied differences will not fit in record } - const auto length = p - output; + const FB_UINT64 length = p - output; if (length > outLength) BUGCHECK(177); // msg 177 applied differences will not fit in record diff --git a/src/yvalve/why.cpp b/src/yvalve/why.cpp index cc722930c2b..f4777497b30 100644 --- a/src/yvalve/why.cpp +++ b/src/yvalve/why.cpp @@ -1424,7 +1424,7 @@ static void setTextType(XSQLVAR* var, unsigned charSet) static int sqldaTruncateString(char* buffer, FB_SIZE_T size, const char* s) { int ret = fb_utils::snprintf(buffer, size, "%s", s); - return MIN(ret, size - 1); + return MIN(ret, static_cast(size - 1)); } // Describe parameters metadata in an sqlda.