Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/burp/BurpTasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<FB_UINT64>(m_records))
{
m_verbRecs = m_records;
BURP_verbose(107, SafeArg() << m_verbRecs);
Expand Down
14 changes: 7 additions & 7 deletions src/common/CvtFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<FB_SIZE_T>(outParsedTimezoneLength) < valueLength; outParsedTimezoneLength++)
{
int index = calculateIndex(value[outParsedTimezoneLength]);

Expand All @@ -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]);

Expand Down Expand Up @@ -141,9 +141,9 @@ namespace
InitInstance<TimeZoneTrie> 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;
Expand Down Expand Up @@ -343,7 +343,7 @@ namespace
if (number < 1 || number > 9)
return Format::NONE;

return Format::FF1 << number - 1;
return Format::FF1 << (number - 1);
}
break;

Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/common/unicode_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1615,7 +1615,7 @@ UnicodeUtil::Utf16Collation* UnicodeUtil::Utf16Collation::create(

if (len >= 2)
{
obj->maxContractionsPrefixLength = len - 1 > obj->maxContractionsPrefixLength ?
obj->maxContractionsPrefixLength = static_cast<ULONG>(len - 1) > obj->maxContractionsPrefixLength ?
len - 1 : obj->maxContractionsPrefixLength;

UCHAR key[100];
Expand Down Expand Up @@ -1865,7 +1865,7 @@ USHORT UnicodeUtil::Utf16Collation::stringToKey(USHORT srcLen, const USHORT* src
lastCharKeyLen = icu->ucolGetSortKey(coll,
reinterpret_cast<const UChar*>(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;
Expand Down Expand Up @@ -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);
Expand All @@ -1920,7 +1920,7 @@ USHORT UnicodeUtil::Utf16Collation::stringToKey(USHORT srcLen, const USHORT* src
ULONG keyLen = icu->ucolGetSortKey(coll,
reinterpret_cast<const UChar*>(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');
Expand Down
2 changes: 1 addition & 1 deletion src/dsql/BoolNodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ULONG>(patternLen) + escapeLen)
{
delete cache;
cache = nullptr;
Expand Down
4 changes: 2 additions & 2 deletions src/dsql/ExprNodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/dsql/StmtNodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<SSHORT>(positionalArgCount) > procedure->prc_in_count || dsqlInputArgNames)
{
const auto newInputs = FB_NEW_POOL(pool) ValueListNode(pool);
const auto newOutputs = FB_NEW_POOL(pool) ValueListNode(pool);
Expand All @@ -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<unsigned>(procedure->prc_in_count)) ||
(pos >= positionalArgCount &&
!outFields.exist((*dsqlInputArgNames)[pos - positionalArgCount]));

Expand Down
52 changes: 29 additions & 23 deletions src/include/firebird/iberror.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,38 @@

#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
#if __cplusplus >= 201703L // C++17 or later
#define STATUS_EXPR inline constexpr ISC_STATUS
#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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe name it STATUS_CONST instead?


#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);
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)
Expand All @@ -53,7 +59,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
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
Expand Down
2 changes: 1 addition & 1 deletion src/isql/FrontendLexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ std::variant<FrontendLexer::SingleStatement, FrontendLexer::IncompleteTokenError

while (pos < end)
{
if (end - pos >= term.length() && std::equal(term.begin(), term.end(), pos))
if (static_cast<decltype(term.length())>(end - pos) >= term.length() && std::equal(term.begin(), term.end(), pos))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a fixed type, please.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it to FB_SIZE_T

{
const auto initialStatement = std::string(buffer.cbegin(), pos);
pos += term.length();
Expand Down
2 changes: 1 addition & 1 deletion src/isql/isql.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/jrd/ExtEngineManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/jrd/idx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/jrd/sqz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<unsigned>(MAX_NONCOMP_RUN - m_runs.back()), length);
length -= max;
m_runs.back() += max;
}
Expand Down
Loading