From 66bfb4fe157d17a1ba5bd49c03e5064be009b541 Mon Sep 17 00:00:00 2001 From: Zakk0n Date: Wed, 27 Aug 2025 20:50:39 +0300 Subject: [PATCH 01/79] Null pointers done --- src/common/DynamicStrings.cpp | 4 ++++ src/gpre/obj_cxx.cpp | 3 ++- src/jrd/lck.cpp | 6 ++++++ src/jrd/replication/Applier.cpp | 2 +- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/common/DynamicStrings.cpp b/src/common/DynamicStrings.cpp index 72be2e07ae6..1e02df3e874 100644 --- a/src/common/DynamicStrings.cpp +++ b/src/common/DynamicStrings.cpp @@ -87,6 +87,8 @@ unsigned makeDynamicStrings(unsigned length, ISC_STATUS* const dst, const ISC_ST case isc_arg_cstring: fb_assert(string); *to++ = (ISC_STATUS)(IPTR) string; + if (!string) + break; memcpy(string, reinterpret_cast(from[1]), from[0]); string += *from++; *string++ = '\0'; @@ -97,6 +99,8 @@ unsigned makeDynamicStrings(unsigned length, ISC_STATUS* const dst, const ISC_ST case isc_arg_sql_state: fb_assert(string); *to++ = (ISC_STATUS)(IPTR) string; + if (!string) + break; strcpy(string, reinterpret_cast(*from)); string += strlen(string); string++; diff --git a/src/gpre/obj_cxx.cpp b/src/gpre/obj_cxx.cpp index b863f2cf3e6..aae53bdc94f 100644 --- a/src/gpre/obj_cxx.cpp +++ b/src/gpre/obj_cxx.cpp @@ -3368,7 +3368,8 @@ static void gen_t_start( const act* action, int column) if (trans->tra_db_count == 1) { - printa(column, "%s = %s->startTransaction(%s, %d, fb_tpb_%d);", + if (trans->tra_tpb) + printa(column, "%s = %s->startTransaction(%s, %d, fb_tpb_%d);", trans->tra_handle ? trans->tra_handle : gpreGlob.transaction_name, trans->tra_tpb->tpb_database->dbb_name->sym_string, vector, trans->tra_tpb->tpb_length, trans->tra_tpb->tpb_ident); diff --git a/src/jrd/lck.cpp b/src/jrd/lck.cpp index 8a3baf6bf8d..89f30736a78 100644 --- a/src/jrd/lck.cpp +++ b/src/jrd/lck.cpp @@ -1049,6 +1049,9 @@ static Lock* hash_get_lock(Lock* lock, USHORT* hash_slot, Lock*** prior) // if no collisions found, we're done + if (!att->att_compatibility_table) + return NULL; + Lock* match = (*att->att_compatibility_table)[hash_value]; if (!match) return NULL; @@ -1333,6 +1336,9 @@ static USHORT internal_downgrade(thread_db* tdbb, CheckStatusWrapper* statusVect // if we can convert to that level, set all identical locks as having that level + if (!first || !first->lck_physical) + return NULL; + if (level < first->lck_physical) { if (dbb->lockManager()->convert(tdbb, statusVector, first->lck_id, level, LCK_NO_WAIT, diff --git a/src/jrd/replication/Applier.cpp b/src/jrd/replication/Applier.cpp index c9e9f39419a..88a3a1d09e1 100644 --- a/src/jrd/replication/Applier.cpp +++ b/src/jrd/replication/Applier.cpp @@ -998,7 +998,7 @@ void Applier::storeBlob(thread_db* tdbb, TraNumber traNum, bid* blobId, fb_assert(blob->blb_flags & BLB_temporary); fb_assert(!(blob->blb_flags & BLB_closed)); - if (length) + if (blob && length) blob->BLB_put_segment(tdbb, data, length); else blob->BLB_close(tdbb); From 3ec8851ba8df3726a92397807519015d7ff00c8a Mon Sep 17 00:00:00 2001 From: Ilya Date: Fri, 29 Aug 2025 15:22:36 +0300 Subject: [PATCH 02/79] Fixed pointer that should not be dereferenced --- src/common/isc_sync.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/isc_sync.cpp b/src/common/isc_sync.cpp index abd5e881291..109464d477b 100644 --- a/src/common/isc_sync.cpp +++ b/src/common/isc_sync.cpp @@ -1438,7 +1438,7 @@ SharedMemoryBase::SharedMemoryBase(const TEXT* filename, ULONG length, IpcObject #endif #endif - memset(sh_mem_mutex->mtx_mutex, 0, sizeof(*(sh_mem_mutex->mtx_mutex))); + memset(sh_mem_mutex->mtx_mutex, 0, sizeof(sh_mem_mutex->mtx_mutex)); //int state = LOG_PTHREAD_ERROR(pthread_mutex_init(sh_mem_mutex->mtx_mutex, &mattr)); state = pthread_mutex_init(sh_mem_mutex->mtx_mutex, &mattr); From 4608d5b633d47c87e1956564807c3b6ca19eb50d Mon Sep 17 00:00:00 2001 From: Andrey Date: Tue, 2 Sep 2025 14:16:41 +0300 Subject: [PATCH 03/79] fix: ensure null termination when converting string_view to string --- src/common/CvtFormat.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/CvtFormat.cpp b/src/common/CvtFormat.cpp index 21e834cece5..c68abe3a6e4 100644 --- a/src/common/CvtFormat.cpp +++ b/src/common/CvtFormat.cpp @@ -1347,7 +1347,7 @@ namespace break; } if (strOffset >= strLength) - cb->err(Arg::Gds(isc_data_for_format_is_exhausted) << string(it->patternStr.data())); + cb->err(Arg::Gds(isc_data_for_format_is_exhausted) << string(it->patternStr.data(), it->patternStr.length())); std::string_view patternStr = it->patternStr; From 49b01df0cef2b9a2acd5dcb48ea183fa24d9f790 Mon Sep 17 00:00:00 2001 From: Andrey Date: Tue, 2 Sep 2025 14:19:36 +0300 Subject: [PATCH 04/79] fix: correcting the passing of arguments to a function and loop --- src/jrd/btr.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/jrd/btr.cpp b/src/jrd/btr.cpp index bf010642fa1..6f0376f8367 100644 --- a/src/jrd/btr.cpp +++ b/src/jrd/btr.cpp @@ -5806,8 +5806,8 @@ static ULONG insert_node(thread_db* tdbb, // For checking on duplicate nodes we should find the first matching key. UCHAR* pointer = find_node_start_point(bucket, key, 0, &prefix, - idx->idx_flags & idx_descending, - false, true, validateDuplicates ? NO_VALUE : newRecordNumber); + (idx->idx_flags & idx_descending) != 0, + false ? 1 : 0, true, validateDuplicates ? NO_VALUE : newRecordNumber); if (!pointer) return NO_VALUE_PAGE; @@ -6620,8 +6620,8 @@ static contents remove_leaf_node(thread_db* tdbb, index_insertion* insertion, WI UCHAR* pointer; USHORT prefix; while (!(pointer = find_node_start_point(page, key, 0, &prefix, - (idx->idx_flags & idx_descending), - false, false, + (idx->idx_flags & idx_descending) != 0, + false ? 1 : 0, false, (validateDuplicates ? NO_VALUE : insertion->iib_number)))) { page = (btree_page*) CCH_HANDOFF(tdbb, window, page->btr_sibling, LCK_write, pag_index); From fd6857cf8782d9daaa511a48c9fe9ccd705f4582 Mon Sep 17 00:00:00 2001 From: Andrey Date: Fri, 29 Aug 2025 11:58:46 +0300 Subject: [PATCH 05/79] fix: initializing a variable of type FB_UINT64 with a null value --- src/remote/client/interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/remote/client/interface.cpp b/src/remote/client/interface.cpp index 6c2d7b6067b..eb58847501d 100644 --- a/src/remote/client/interface.cpp +++ b/src/remote/client/interface.cpp @@ -2011,7 +2011,7 @@ unsigned char* Attachment::getLocalInfo(UCharBuffer& info, unsigned int buffer_l break; } - FB_UINT64 value; + FB_UINT64 value = 0; bool skip = false; switch (*item) From a6988a48d63e1c94571787f37905ed6de6f927ba Mon Sep 17 00:00:00 2001 From: Andrey Date: Fri, 29 Aug 2025 12:39:36 +0300 Subject: [PATCH 06/79] initializing a variable of type SINT64 with a null value --- src/jrd/os/posix/unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jrd/os/posix/unix.cpp b/src/jrd/os/posix/unix.cpp index f92600461e5..1f096aeae7a 100644 --- a/src/jrd/os/posix/unix.cpp +++ b/src/jrd/os/posix/unix.cpp @@ -522,7 +522,7 @@ bool PIO_header(thread_db* tdbb, UCHAR* address, unsigned length) const auto dbb = tdbb->getDatabase(); unsigned i; - SINT64 bytes; + SINT64 bytes = 0; PageSpace* const pageSpace = dbb->dbb_page_manager.findPageSpace(DB_PAGE_SPACE); jrd_file* const file = pageSpace->file; From 4e97b5c562c89a6383ebd35d1bab101fce9c9bd4 Mon Sep 17 00:00:00 2001 From: Andrey Date: Mon, 1 Sep 2025 08:06:55 +0300 Subject: [PATCH 07/79] changed the .ebb file, but the warning didn't go away --- src/burp/restore.epp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/burp/restore.epp b/src/burp/restore.epp index 1aecf4f1cb0..12dfcd14fe1 100644 --- a/src/burp/restore.epp +++ b/src/burp/restore.epp @@ -1596,7 +1596,7 @@ bool get_acl(BurpGlobals* tdgbl, const TEXT* owner_nm, ISC_QUAD* blob_id, ISC_QU ULONG length = 0; UCHAR item; - USHORT max_segment; + USHORT max_segment = 0; ULONG num_segments; const UCHAR* p = blob_info; @@ -1837,7 +1837,7 @@ void get_array(BurpGlobals* tdgbl, burp_rel* relation, UCHAR* record_buffer) SLONG last_element_dim[MAX_DIMENSION]; if (return_length != slice_length) { - int upper, lower; + int upper = 0, lower = 0; // // Ugh! The full array wasn't returned and versions of gbak prior to // V3.2I don't explicitly signal this. We must recompute the top From 7ec3f4b5dd4da1bbd647fe297ab863c407fec641 Mon Sep 17 00:00:00 2001 From: Andrey Date: Mon, 1 Sep 2025 08:51:22 +0300 Subject: [PATCH 08/79] initializing a variable of type USHORT with a null value --- skipfile.txt | 14 ++++++++++++++ src/jrd/cvt2.cpp | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 skipfile.txt diff --git a/skipfile.txt b/skipfile.txt new file mode 100644 index 00000000000..a8c92e6a5e0 --- /dev/null +++ b/skipfile.txt @@ -0,0 +1,14 @@ +- /*android*/ +- /*builds*/ +- /*doc*/ +- /*examples*/ +- /*extern*/ +- /*gen*/ +- /*m4*/ +- /*report_html*/ +- /*reports*/ ++ /*src*/ +- /*temp*/ +- /*vcpkg*/ +- /*vcpkg-custom*/ +- /*src/remote/client/interface.cpp*/ diff --git a/src/jrd/cvt2.cpp b/src/jrd/cvt2.cpp index 60be2939844..6a70b1f446c 100644 --- a/src/jrd/cvt2.cpp +++ b/src/jrd/cvt2.cpp @@ -974,7 +974,7 @@ USHORT CVT2_make_string2(const dsc* desc, USHORT to_interp, UCHAR** address, Mov **************************************/ UCHAR* from_buf; USHORT from_len; - USHORT from_interp; + USHORT from_interp = 0; fb_assert(desc != NULL); fb_assert(address != NULL); From a6db65e82c9da047f800f62657d2b0231a5742d1 Mon Sep 17 00:00:00 2001 From: Andrey Date: Mon, 1 Sep 2025 09:16:20 +0300 Subject: [PATCH 09/79] initializing a pointer of type SLONG* nullptr --- src/burp/restore.epp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/burp/restore.epp b/src/burp/restore.epp index 12dfcd14fe1..bc421315970 100644 --- a/src/burp/restore.epp +++ b/src/burp/restore.epp @@ -1771,7 +1771,7 @@ void get_array(BurpGlobals* tdgbl, burp_rel* relation, UCHAR* record_buffer) SLONG fld_ranges[2 * MAX_DIMENSION]; SLONG slice_length = 0; SLONG *range; - const SLONG* end_ranges; + const SLONG* end_ranges = nullptr; scan_attr_t scan_next_attr; skip_init(&scan_next_attr); att_type attribute; From 0fe320316cfaa63b0b9684fc9aa32d5fbe8c3e0e Mon Sep 17 00:00:00 2001 From: Andrey Date: Mon, 1 Sep 2025 09:21:31 +0300 Subject: [PATCH 10/79] initializing a pointer of type UCHAR* nullptr --- src/burp/restore.epp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/burp/restore.epp b/src/burp/restore.epp index bc421315970..1f1ddda5640 100644 --- a/src/burp/restore.epp +++ b/src/burp/restore.epp @@ -3369,7 +3369,7 @@ void get_data(BurpGlobals* tdgbl, burp_rel* relation, WriteRelationReq* req) } } - UCHAR* p; + UCHAR* p = nullptr; if (tdgbl->gbl_sw_transportable) { if (get(tdgbl) != att_xdr_length) From 533aab55b627fb713c080aa0a8c9141635c066c8 Mon Sep 17 00:00:00 2001 From: Andrey Date: Mon, 1 Sep 2025 09:39:27 +0300 Subject: [PATCH 11/79] initializing variables with zero and default value --- src/burp/restore.epp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/burp/restore.epp b/src/burp/restore.epp index 1f1ddda5640..4a02a4a4bf1 100644 --- a/src/burp/restore.epp +++ b/src/burp/restore.epp @@ -9066,7 +9066,7 @@ bool get_db_creator(BurpGlobals* tdgbl) att_type attribute; scan_attr_t scan_next_attr; TEXT usr[GDS_NAME_LEN]; - SSHORT uType; + SSHORT uType = 0; bool userSet, typeSet; userSet = typeSet = false; @@ -9389,7 +9389,7 @@ bool get_trigger_old (BurpGlobals* tdgbl, burp_rel* relation) * Get a trigger definition for a relation. * **************************************/ - enum trig_t type; + enum trig_t type = trig_pre_store; att_type attribute; TEXT name[GDS_NAME_LEN]; scan_attr_t scan_next_attr; From bf4e792523b9da678b0c91ca610a08874d498550 Mon Sep 17 00:00:00 2001 From: Filimonova Anna Date: Wed, 3 Sep 2025 21:23:52 +0300 Subject: [PATCH 12/79] Fix snprintf return value --- src/common/StatusArg.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/common/StatusArg.cpp b/src/common/StatusArg.cpp index a4fb738e530..c5f1774e613 100644 --- a/src/common/StatusArg.cpp +++ b/src/common/StatusArg.cpp @@ -407,19 +407,22 @@ Num::Num(ISC_STATUS s) noexcept : Int64::Int64(SINT64 val) noexcept : Str(text) { - snprintf(text, sizeof(text), "%" SQUADFORMAT, val); + (void)snprintf(text, sizeof(text), "%" SQUADFORMAT, val); } Int64::Int64(FB_UINT64 val) noexcept : Str(text) { - snprintf(text, sizeof(text), "%" UQUADFORMAT, val); + (void)snprintf(text, sizeof(text), "%" UQUADFORMAT, val); } Quad::Quad(const ISC_QUAD* quad) noexcept : Str(text) { - snprintf(text, sizeof(text), "%x:%x", quad->gds_quad_high, quad->gds_quad_low); + (void)snprintf(text, sizeof(text), "%x:%x", + (unsigned int)quad->gds_quad_high, + (unsigned int)quad->gds_quad_low + ); } Interpreted::Interpreted(const char* text) noexcept : From 96f1dc0e5c13c212792cf8ac444ba03fb2272755 Mon Sep 17 00:00:00 2001 From: Filimonova Anna Date: Wed, 3 Sep 2025 21:32:05 +0300 Subject: [PATCH 13/79] Fix unused parameters --- src/common/StatusArg.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/StatusArg.h b/src/common/StatusArg.h index 449734b6cca..8641d4a2d31 100644 --- a/src/common/StatusArg.h +++ b/src/common/StatusArg.h @@ -70,8 +70,8 @@ class Base virtual void clear() noexcept { } virtual void append(const StatusVector&) noexcept { } virtual void prepend(const StatusVector&) noexcept { } - virtual void assign(const StatusVector& ex) noexcept { } - virtual void assign(const Exception& ex) noexcept { } + virtual void assign(const StatusVector&) noexcept { } + virtual void assign(const Exception&) noexcept { } virtual ISC_STATUS copyTo(ISC_STATUS*) const noexcept { return 0; } virtual void copyTo(IStatus*) const noexcept { } virtual void appendTo(IStatus*) const noexcept { } From 64ef6a74576981b9c60f48e9a464cabce541588c Mon Sep 17 00:00:00 2001 From: Filimonova Anna Date: Wed, 3 Sep 2025 21:22:36 +0300 Subject: [PATCH 14/79] Fix calling virtual methods in constructor --- src/common/StatusArg.cpp | 14 +++++++------- src/common/StatusArg.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/common/StatusArg.cpp b/src/common/StatusArg.cpp index a4fb738e530..42a3e4dfac4 100644 --- a/src/common/StatusArg.cpp +++ b/src/common/StatusArg.cpp @@ -64,7 +64,7 @@ StatusVector::ImplStatusVector::ImplStatusVector(const ISC_STATUS* s) noexcept { fb_assert(s); - clear(); + ImplStatusVector::clear(); // special case - empty initialized status vector, no warnings if (s[0] != isc_arg_gds || s[1] != 0 || s[2] != 0) @@ -78,7 +78,7 @@ StatusVector::ImplStatusVector::ImplStatusVector(const IStatus* s) noexcept { fb_assert(s); - clear(); + ImplStatusVector::clear(); if (s->getState() & IStatus::STATE_ERRORS) append(s->getErrors()); @@ -91,9 +91,9 @@ StatusVector::ImplStatusVector::ImplStatusVector(const Exception& ex) noexcept m_status_vector(*getDefaultMemoryPool()), m_strings(*getDefaultMemoryPool()) { - clear(); + ImplStatusVector::clear(); - assign(ex); + ImplStatusVector::assign(ex); } StatusVector::StatusVector(ISC_STATUS k, ISC_STATUS c) : @@ -143,7 +143,7 @@ void StatusVector::ImplStatusVector::assign(const StatusVector& v) noexcept void StatusVector::ImplStatusVector::assign(const Exception& ex) noexcept { - clear(); + ImplStatusVector::clear(); ex.stuffException(m_status_vector); putStrArg(0); } @@ -263,7 +263,7 @@ bool StatusVector::ImplStatusVector::append(const ISC_STATUS* const from, const if (!count) return true; // not sure it's the best option here - unsigned lenBefore = length(); + unsigned lenBefore = ImplStatusVector::length(); ISC_STATUS* s = m_status_vector.getBuffer(lenBefore + count + 1); unsigned int copied = fb_utils::copyStatus(&s[lenBefore], count + 1, from, count); @@ -273,7 +273,7 @@ bool StatusVector::ImplStatusVector::append(const ISC_STATUS* const from, const if (!m_warning) { - for (unsigned n = 0; n < length(); ) + for (unsigned n = 0; n < ImplStatusVector::length(); ) { if (m_status_vector[n] == isc_arg_warning) { diff --git a/src/common/StatusArg.h b/src/common/StatusArg.h index 449734b6cca..4027f41ff6f 100644 --- a/src/common/StatusArg.h +++ b/src/common/StatusArg.h @@ -145,7 +145,7 @@ class StatusVector : public Base m_status_vector(*getDefaultMemoryPool()), m_strings(*getDefaultMemoryPool()) { - clear(); + ImplStatusVector::clear(); } explicit ImplStatusVector(const ISC_STATUS* s) noexcept; From e6dd217b5acc27b4ce859df713f97f5fd4b3b333 Mon Sep 17 00:00:00 2001 From: bobbert Date: Wed, 3 Sep 2025 22:06:54 +0300 Subject: [PATCH 15/79] fix: Initialize can_use_more to prevent compiler warning The 'can_use_more' variable is now initialized with a default value at declaration. This resolves the "variable may be uninitialized" compiler warning that occurred when the initial 'length' was zero. --- src/jrd/filters.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jrd/filters.cpp b/src/jrd/filters.cpp index 0d2e06e8504..3e82043ec08 100644 --- a/src/jrd/filters.cpp +++ b/src/jrd/filters.cpp @@ -1044,7 +1044,7 @@ ISC_STATUS filter_transliterate_text(USHORT action, BlobControl* control) // Do we already have enough bytes in temp buffer to fill output buffer? - bool can_use_more; + bool can_use_more = true; USHORT length = aux->ctlaux_buffer1_unused; if (length) { From 0e585d9ec1541bbc8c82d708d9d9c0f145454d29 Mon Sep 17 00:00:00 2001 From: bobbert Date: Wed, 3 Sep 2025 22:46:15 +0300 Subject: [PATCH 16/79] fix: Initialize long_value to prevent potential errors The 'long_value' variable was declared at the start of a loop without a default value. This created a risk of being used with a garbage value, triggering compiler warnings. --- src/gpre/pat.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gpre/pat.cpp b/src/gpre/pat.cpp index 817ae409765..523e1961142 100644 --- a/src/gpre/pat.cpp +++ b/src/gpre/pat.cpp @@ -181,7 +181,7 @@ void PATTERN_expand( USHORT column, const TEXT* pattern, PAT* args) SSHORT value; // value needs to be signed since some of the // values printed out are signed. - SLONG long_value; + SLONG long_value = 0; TEXT c; while ((c = *pattern++)) { From 2bebfda43747465ad68a6658d9d62253c0aff9f3 Mon Sep 17 00:00:00 2001 From: bobbert Date: Wed, 3 Sep 2025 22:51:01 +0300 Subject: [PATCH 17/79] fix: Initialize value variable to improve code robustness This prevents potential use of an uninitialized variable, silences static analysis warnings, and makes the code safer and more predictable, even if the problematic code path was not reachable under the current logic. --- src/gpre/pat.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gpre/pat.cpp b/src/gpre/pat.cpp index 523e1961142..9f09075add6 100644 --- a/src/gpre/pat.cpp +++ b/src/gpre/pat.cpp @@ -179,7 +179,7 @@ void PATTERN_expand( USHORT column, const TEXT* pattern, PAT* args) bool sw_gen = true; p += align(p, column); - SSHORT value; // value needs to be signed since some of the + SSHORT value = 0; // value needs to be signed since some of the // values printed out are signed. SLONG long_value = 0; TEXT c; From c1ed5c593393fc1b889229f8564e2629402119d9 Mon Sep 17 00:00:00 2001 From: bobbert Date: Wed, 3 Sep 2025 22:58:39 +0300 Subject: [PATCH 18/79] fix: Initialize 'length' variable in blr_print_dtype The 'length' variable was declared without a default value in a function with complex control flow (two separate switch statements). --- src/yvalve/gds.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/yvalve/gds.cpp b/src/yvalve/gds.cpp index ce575729601..d777802a203 100644 --- a/src/yvalve/gds.cpp +++ b/src/yvalve/gds.cpp @@ -3173,7 +3173,7 @@ static int blr_print_dtype(gds_ctl* control) * data described. * **************************************/ - SSHORT length; + SSHORT length = 0; const USHORT dtype = control->ctl_blr_reader.getByte(); From 80189d00de2dcf624439589e2b11952fed1b0ce2 Mon Sep 17 00:00:00 2001 From: bobbert Date: Wed, 3 Sep 2025 23:02:45 +0300 Subject: [PATCH 19/79] fix: Fixed warning about uninitialized variable n Initialized variable 'n' in blr_print_verb to 0 to avoid undefined behavior and remove compiler warning. --- src/yvalve/gds.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/yvalve/gds.cpp b/src/yvalve/gds.cpp index d777802a203..96b8a470081 100644 --- a/src/yvalve/gds.cpp +++ b/src/yvalve/gds.cpp @@ -3537,7 +3537,7 @@ static void blr_print_verb(gds_ctl* control, SSHORT level) blr_print_blr(control, blr_operator); level++; const UCHAR* ops = blr_print_table[blr_operator].blr_operators; - SSHORT n; + SSHORT n = 0; while (*ops) { From 85d238a637ff687957faac39795e5d9f4c7d6176 Mon Sep 17 00:00:00 2001 From: bobbert Date: Wed, 3 Sep 2025 23:08:26 +0300 Subject: [PATCH 20/79] fix: Initialize savNumber variable in BlockNode::execute The 'savNumber' variable was not initialized when declared. This resulted in a compiler warning and risk of using a garbage value in 'case Request::req_unwind' if the transaction was a system one (TRA_system). Added default initialization ({}) to ensure predictable behavior and fix a bug. --- src/dsql/StmtNodes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dsql/StmtNodes.cpp b/src/dsql/StmtNodes.cpp index 57026cc41d5..66b52aaf254 100644 --- a/src/dsql/StmtNodes.cpp +++ b/src/dsql/StmtNodes.cpp @@ -521,7 +521,7 @@ BlockNode* BlockNode::pass2(thread_db* tdbb, CompilerScratch* csb) const StmtNode* BlockNode::execute(thread_db* tdbb, Request* request, ExeState* exeState) const { jrd_tra* transaction = request->req_transaction; - SavNumber savNumber; + SavNumber savNumber{}; switch (request->req_operation) { From dae2d52f14c636a9477c3717b6ec7f1083a590b4 Mon Sep 17 00:00:00 2001 From: bobbert Date: Wed, 3 Sep 2025 23:12:46 +0300 Subject: [PATCH 21/79] fix: Initialize parentStream in EraseNode::pass1Erase The 'parentStream' variable was not initialized when declared. This could lead to a random value being used on the second and subsequent loop iterations in the pass1Erase function. Added default initialization ({}) to ensure safe behavior. --- src/dsql/StmtNodes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dsql/StmtNodes.cpp b/src/dsql/StmtNodes.cpp index 66b52aaf254..889d2aeae64 100644 --- a/src/dsql/StmtNodes.cpp +++ b/src/dsql/StmtNodes.cpp @@ -2475,7 +2475,7 @@ void EraseNode::pass1Erase(thread_db* tdbb, CompilerScratch* csb, EraseNode* nod jrd_rel* parent = NULL; jrd_rel* view = NULL; - StreamType parentStream; + StreamType parentStream{}; for (;;) { From 9744edb3077fffe09b9ebb3d889536453777040c Mon Sep 17 00:00:00 2001 From: bobbert Date: Wed, 3 Sep 2025 23:34:53 +0300 Subject: [PATCH 22/79] fix: Initialize returnsPos in ExecBlockNode::genBlr The 'returnsPos' variable was being set in two separate but logically mutually exclusive 'if' blocks. This was causing a false compiler warning about the possible use of an uninitialized variable. Added initialization of 'returnsPos = 0' on declaration to eliminate the warning. --- src/dsql/StmtNodes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dsql/StmtNodes.cpp b/src/dsql/StmtNodes.cpp index 889d2aeae64..585a0a7dcc0 100644 --- a/src/dsql/StmtNodes.cpp +++ b/src/dsql/StmtNodes.cpp @@ -5067,7 +5067,7 @@ void ExecBlockNode::genBlr(DsqlCompilerScratch* dsqlScratch) // Sub routine doesn't need ports and should generate BLR as declared in its metadata. const bool subRoutine = dsqlScratch->flags & DsqlCompilerScratch::FLAG_SUB_ROUTINE; - unsigned returnsPos; + unsigned returnsPos = 0; if (!subRoutine) { From 95d4f4eb3ae28387808b827de00fef35dce819e3 Mon Sep 17 00:00:00 2001 From: bobbert Date: Wed, 3 Sep 2025 23:39:47 +0300 Subject: [PATCH 23/79] fix: Initialize stream variables in ModifyNode::pass1Modify The 'parentStream' and 'parentNewStream' variables were not initialized when declared. This caused the compiler to warn about possible use of their values before assignment on the second and subsequent iterations of the loop. Added default initialization ({}) to both variables to ensure safe behavior. --- src/dsql/StmtNodes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dsql/StmtNodes.cpp b/src/dsql/StmtNodes.cpp index 585a0a7dcc0..528a9eb4e62 100644 --- a/src/dsql/StmtNodes.cpp +++ b/src/dsql/StmtNodes.cpp @@ -7994,7 +7994,7 @@ void ModifyNode::pass1Modify(thread_db* tdbb, CompilerScratch* csb, ModifyNode* jrd_rel* parent = NULL; jrd_rel* view = NULL; - StreamType parentStream, parentNewStream; + StreamType parentStream{}, parentNewStream{}; // To support nested views, loop until we hit a table or a view with user-defined triggers // (which means no update). From f151bfe0d25f03db15ede69516bcd6c7033fd474 Mon Sep 17 00:00:00 2001 From: bobbert Date: Wed, 3 Sep 2025 23:43:04 +0300 Subject: [PATCH 24/79] fix: Initialize parentStream variable in StoreNode::pass1Store The 'parentStream' variable was not initialized when declared. This was causing a compiler warning. Added default initialization ({}) to the variable to ensure safe behavior. --- src/dsql/StmtNodes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dsql/StmtNodes.cpp b/src/dsql/StmtNodes.cpp index 528a9eb4e62..7b5a310504e 100644 --- a/src/dsql/StmtNodes.cpp +++ b/src/dsql/StmtNodes.cpp @@ -9044,7 +9044,7 @@ bool StoreNode::pass1Store(thread_db* tdbb, CompilerScratch* csb, StoreNode* nod jrd_rel* parent = NULL; jrd_rel* view = NULL; - StreamType parentStream; + StreamType parentStream{}; // To support nested views, loop until we hit a table or a view with user-defined triggers // (which means no update). From d507bd2af93e71c699656d1c6d25678a05521e49 Mon Sep 17 00:00:00 2001 From: bobbert Date: Wed, 3 Sep 2025 23:46:41 +0300 Subject: [PATCH 25/79] fix: Initialize 'value' pointer in validateExpressions The 'value' pointer was not initialized, which created a risk of dereferencing it with a random value in one of the branches of the conditional logic. This resulted in a compiler warning and potential undefined behavior. Added initialization of the pointer to 'nullptr' to ensure a safe state. --- src/dsql/StmtNodes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dsql/StmtNodes.cpp b/src/dsql/StmtNodes.cpp index 7b5a310504e..0783241045d 100644 --- a/src/dsql/StmtNodes.cpp +++ b/src/dsql/StmtNodes.cpp @@ -12195,7 +12195,7 @@ static void validateExpressions(thread_db* tdbb, const Array& vali if (!i->boolean->execute(tdbb, request) && !(request->req_flags & req_null)) { // Validation error -- report result - const char* value; + const char* value = nullptr; VaryStr temp; const dsc* desc = EVL_expr(tdbb, request, i->value); From 362b2c1e1b464c4d0e069951e515663d69fc7232 Mon Sep 17 00:00:00 2001 From: bobbert Date: Wed, 3 Sep 2025 23:52:38 +0300 Subject: [PATCH 26/79] fix: Fix using uninitialized variable in stringToKey In UnicodeUtil::Utf16Collation::stringToKey function, 'lastCharKeyLen' variable was left uninitialized if 'srcLenLong' was zero. This resulted in reading random value from memory and undefined behavior. Added zero initialization for 'prefixLen' and 'lastCharKeyLen' when they are declared to fix the bug and eliminate compiler warning. --- src/common/unicode_util.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/unicode_util.cpp b/src/common/unicode_util.cpp index 05ffe216b40..54134157848 100644 --- a/src/common/unicode_util.cpp +++ b/src/common/unicode_util.cpp @@ -1853,7 +1853,7 @@ USHORT UnicodeUtil::Utf16Collation::stringToKey(USHORT srcLen, const USHORT* src if (keys) { UCHAR lastCharKey[BUFFER_TINY]; // sort key for a single character - ULONG prefixLen, lastCharKeyLen; + ULONG prefixLen = 0, lastCharKeyLen = 0; srcLenLong -= i; From b4bced0360411e51b4d0d267b44ae23754994a4c Mon Sep 17 00:00:00 2001 From: bobbert Date: Wed, 3 Sep 2025 23:55:35 +0300 Subject: [PATCH 27/79] fix: Initialize merge_pool pointer in Sort::sort method The 'merge_pool' pointer was initialized only under the condition 'count > 1'. Although its reading was protected by the same condition, the static analyzer issued a warning about the possible use of an uninitialized variable. Added initialization of the pointer to the value 'nullptr' when declaring. --- src/jrd/sort.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jrd/sort.cpp b/src/jrd/sort.cpp index 306937fb64c..b4a9c24c597 100644 --- a/src/jrd/sort.cpp +++ b/src/jrd/sort.cpp @@ -417,7 +417,7 @@ void Sort::sort(thread_db* tdbb) **************************************/ run_control* run; merge_control* merge; - merge_control* merge_pool; + merge_control* merge_pool = nullptr; try { From 50d02ae8939222f633910c185f93b1387172d91c Mon Sep 17 00:00:00 2001 From: bobbert Date: Wed, 3 Sep 2025 23:59:13 +0300 Subject: [PATCH 28/79] fix: Initialize 'value' variable in CVT_get_double In CVT_get_double, the 'value' variable was left uninitialized if the 'default' block was executed in the switch statement. This caused the compiler to warn about the possible use of the variable before it was initialized. Added 'value = 0.0' initialization on declaration to ensure safe behavior in all code paths. --- src/common/cvt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/cvt.cpp b/src/common/cvt.cpp index f0c7f86e972..878538a69a4 100644 --- a/src/common/cvt.cpp +++ b/src/common/cvt.cpp @@ -1406,7 +1406,7 @@ double CVT_get_double(const dsc* desc, DecimalStatus decSt, ErrorFunction err, b * Convert something arbitrary to a double precision number * **************************************/ - double value; + double value = 0.0; switch (desc->dsc_dtype) { From 59c6b115a122e89ad42925862ffd2e501cf94d33 Mon Sep 17 00:00:00 2001 From: bobbert Date: Thu, 4 Sep 2025 00:02:00 +0300 Subject: [PATCH 29/79] fix: Initialize ret_code variable in main loop The 'ret_code' variable was not initialized when declared in the do-while loop. Added initialization 'ret_code = 0' to make the code more robust. --- src/utilities/guard/guard.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utilities/guard/guard.cpp b/src/utilities/guard/guard.cpp index fbd96db318f..513d8581bc6 100644 --- a/src/utilities/guard/guard.cpp +++ b/src/utilities/guard/guard.cpp @@ -183,7 +183,7 @@ int CLIB_ROUTINE main( int argc, char **argv) time_t timer = 0; do { - int ret_code; + int ret_code = 0; if (shutting_down) { From 389068b12034cf2422a0bf98f131d3e8b40d423b Mon Sep 17 00:00:00 2001 From: bobbert Date: Thu, 4 Sep 2025 00:04:24 +0300 Subject: [PATCH 30/79] fix: Initialize minlen variable in EXE_assignment The 'minlen' variable was left uninitialized if the data type in 'to_desc' was not handled by any of the 'case' in the switch block. This resulted in reading a random value and undefined behavior. Added initialization 'minlen = 0' on declaration to fix the bug. --- src/jrd/exe.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jrd/exe.cpp b/src/jrd/exe.cpp index 3fbe78dc67c..4e972cc400c 100644 --- a/src/jrd/exe.cpp +++ b/src/jrd/exe.cpp @@ -555,7 +555,7 @@ void EXE_assignment(thread_db* tdbb, const ValueExprNode* to, dsc* from_desc, bo if (null && to_desc->dsc_dtype <= dtype_varying) { - USHORT minlen; + USHORT minlen = 0; switch (to_desc->dsc_dtype) { From 70dc2e3bb7f185c66b40a011294f7f68176b5f9f Mon Sep 17 00:00:00 2001 From: bobbert Date: Thu, 4 Sep 2025 00:07:25 +0300 Subject: [PATCH 31/79] fix: Initialize select_node pointer in FilteredStream::evaluateBoolean The 'select_node' pointer was not initialized on all code paths, leading to the risk of reading it before assigning a value. This could cause undefined behavior. Added initialization of the pointer to 'nullptr' when it is declared to fix the bug. --- src/jrd/recsrc/FilteredStream.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jrd/recsrc/FilteredStream.cpp b/src/jrd/recsrc/FilteredStream.cpp index 744ebf484dd..b47ff9c1c0e 100644 --- a/src/jrd/recsrc/FilteredStream.cpp +++ b/src/jrd/recsrc/FilteredStream.cpp @@ -187,7 +187,7 @@ bool FilteredStream::evaluateBoolean(thread_db* tdbb) const // on the right. // ANY/ALL select node pointer - const BoolExprNode* select_node; + const BoolExprNode* select_node = nullptr; // ANY/ALL column node pointer const BoolExprNode* column_node = m_anyBoolean; From 94c1f5f1626eb922006690c6e4db07375ac4d6b7 Mon Sep 17 00:00:00 2001 From: bobbert Date: Thu, 4 Sep 2025 00:10:29 +0300 Subject: [PATCH 32/79] fix Initialize variables in convertGregorianDateToWeekDate The variables 'yearNumber' and 'weekNumber' were not initialized when declared. Due to complex conditional logic, the compiler issued a warning about the possible use of an uninitialized variable 'weekNumber'. Added zero initialization to eliminate the warning. --- src/common/classes/NoThrowTimeStamp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/classes/NoThrowTimeStamp.cpp b/src/common/classes/NoThrowTimeStamp.cpp index 17404032865..8b850fb7882 100644 --- a/src/common/classes/NoThrowTimeStamp.cpp +++ b/src/common/classes/NoThrowTimeStamp.cpp @@ -356,7 +356,7 @@ int NoThrowTimeStamp::convertGregorianDateToWeekDate(const struct tm& times) noe const int weekday = 1 + ((h - 1) % 7); // Find if y m d falls in yearNumber y-1, weekNumber 52 or 53 - int yearNumber, weekNumber; + int yearNumber = 0, weekNumber = 0; if ((dayOfYearNumber <= (8 - jan1Weekday)) && (jan1Weekday > 4)) { From b72726043b0281e3b4881f703af5527c3617efb7 Mon Sep 17 00:00:00 2001 From: bobbert Date: Thu, 4 Sep 2025 00:13:02 +0300 Subject: [PATCH 33/79] fix: Initialize variables in BTR_reserve_slot The 'len' and 'space' variables were not initialized when declared, causing a compiler warning. Added zero initialization to eliminate the warning and improve code reliability. --- src/jrd/btr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jrd/btr.cpp b/src/jrd/btr.cpp index bf010642fa1..636e29fd895 100644 --- a/src/jrd/btr.cpp +++ b/src/jrd/btr.cpp @@ -2315,7 +2315,7 @@ void BTR_reserve_slot(thread_db* tdbb, IndexCreation& creation) } UCHAR* desc = 0; - USHORT len, space; + USHORT len = 0, space = 0; index_root_page::irt_repeat* slot = NULL; index_root_page::irt_repeat* end = NULL; From 74446773490f9d357681f4d6e25ed21310c5571e Mon Sep 17 00:00:00 2001 From: bobbert Date: Thu, 4 Sep 2025 00:17:13 +0300 Subject: [PATCH 34/79] fix: Initialize multiKeyLength in compress function The 'multiKeyLength' variable was only initialized when handling international string types, but was read for all types. This led to reading uninitialized memory and undefined behavior. Added initialization 'multiKeyLength = 0' on declaration to ensure correct logic for all index types. --- src/jrd/btr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jrd/btr.cpp b/src/jrd/btr.cpp index 636e29fd895..29f474b885c 100644 --- a/src/jrd/btr.cpp +++ b/src/jrd/btr.cpp @@ -2816,7 +2816,7 @@ static void compress(thread_db* tdbb, const Database* dbb = tdbb->getDatabase(); bool first_key = true; VaryStr buffer; - size_t multiKeyLength; + size_t multiKeyLength = 0; UCHAR* ptr; UCHAR* p = key->key_data; SSHORT scale = matchScale ? matchScale : desc->dsc_scale; From 0667b626a8fa6cc305275e2c8b879ab14921a1e3 Mon Sep 17 00:00:00 2001 From: bobbert Date: Thu, 4 Sep 2025 00:19:50 +0300 Subject: [PATCH 35/79] fix: Fix use of uninitialized ptr and length in compress The 'ptr' pointer and the 'length' variable were not initialized on all code paths inside the do-while loop, leading to reading from uninitialized memory and undefined behavior on the second and subsequent iterations. Added initialization ('ptr = nullptr' and 'length = 0') to fix these bugs and eliminate compiler warnings. --- src/jrd/btr.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jrd/btr.cpp b/src/jrd/btr.cpp index 29f474b885c..92a0657e0cf 100644 --- a/src/jrd/btr.cpp +++ b/src/jrd/btr.cpp @@ -2817,7 +2817,7 @@ static void compress(thread_db* tdbb, bool first_key = true; VaryStr buffer; size_t multiKeyLength = 0; - UCHAR* ptr; + UCHAR* ptr = nullptr; UCHAR* p = key->key_data; SSHORT scale = matchScale ? matchScale : desc->dsc_scale; @@ -2829,7 +2829,7 @@ static void compress(thread_db* tdbb, do { - size_t length; + size_t length = 0; has_next = false; From 64963c8be6a87da87db272de0d51f0762bdb0cae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=9D=D0=B8=D0=BA?= =?UTF-8?q?=D0=BE=D0=BB=D0=B0=D0=B5=D0=B2?= <117023363+3qupo@users.noreply.github.com> Date: Thu, 4 Sep 2025 14:22:59 +0300 Subject: [PATCH 36/79] Delete skipfile.txt --- skipfile.txt | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 skipfile.txt diff --git a/skipfile.txt b/skipfile.txt deleted file mode 100644 index a8c92e6a5e0..00000000000 --- a/skipfile.txt +++ /dev/null @@ -1,14 +0,0 @@ -- /*android*/ -- /*builds*/ -- /*doc*/ -- /*examples*/ -- /*extern*/ -- /*gen*/ -- /*m4*/ -- /*report_html*/ -- /*reports*/ -+ /*src*/ -- /*temp*/ -- /*vcpkg*/ -- /*vcpkg-custom*/ -- /*src/remote/client/interface.cpp*/ From ee3227151909d88585f73d7d215d50cc86f7fc51 Mon Sep 17 00:00:00 2001 From: Andrey Date: Fri, 5 Sep 2025 00:28:52 +1200 Subject: [PATCH 37/79] fix implicit conversion --- src/isql/isql.epp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/isql/isql.epp b/src/isql/isql.epp index 9b9fb7e7d2e..92bf61e87a6 100644 --- a/src/isql/isql.epp +++ b/src/isql/isql.epp @@ -5532,10 +5532,10 @@ void ISQL_get_version(bool call_by_create_db) switch (item) { case isc_info_ods_version: - isqlGlob.major_ods = p.getInt(); + isqlGlob.major_ods = static_cast(p.getInt()); break; case isc_info_ods_minor_version: - isqlGlob.minor_ods = p.getInt(); + isqlGlob.minor_ods = static_cast(p.getInt()); break; case isc_info_db_sql_dialect: global_dialect_spoken = p.getInt(); @@ -5641,7 +5641,7 @@ void ISQL_get_version(bool call_by_create_db) break; case frb_info_att_charset: - isqlGlob.att_charset = p.getInt(); + isqlGlob.att_charset = static_cast(p.getInt()); break; default: @@ -6965,7 +6965,7 @@ static processing_state parse_arg(int argc, SCHAR** argv, QualifiedMetaString& t break; case IN_SW_ISQL_SQLDIALECT: - requested_SQL_dialect = swarg_int; + requested_SQL_dialect = static_cast(swarg_int); if (requested_SQL_dialect < SQL_DIALECT_V5 || requested_SQL_dialect > SQL_DIALECT_CURRENT) { From fa01cd916c1f74f98959a78af8250783813d1f9a Mon Sep 17 00:00:00 2001 From: Zakk0n Date: Thu, 4 Sep 2025 23:59:21 +0300 Subject: [PATCH 38/79] Unserialized and uninitialized done --- src/dsql/DdlNodes.epp | 2 +- src/gpre/c_cxx.cpp | 2 ++ src/gpre/pat.cpp | 6 ++++-- src/jrd/IntlManager.cpp | 4 ++-- src/jrd/cvt2.cpp | 2 +- src/jrd/replication/Applier.cpp | 10 ++++++---- src/remote/server/server.cpp | 4 ++-- 7 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/dsql/DdlNodes.epp b/src/dsql/DdlNodes.epp index 3af5163719b..584ab90fca2 100644 --- a/src/dsql/DdlNodes.epp +++ b/src/dsql/DdlNodes.epp @@ -345,7 +345,7 @@ void defineComputed(DsqlCompilerScratch* dsqlScratch, RelationSourceNode* relati // Save the size of the field if it is specified. dsc saveDesc; saveDesc.dsc_dtype = 0; - bool saveCharSetIdSpecified; + bool saveCharSetIdSpecified = false; if (field && field->dtype) { diff --git a/src/gpre/c_cxx.cpp b/src/gpre/c_cxx.cpp index e5a5025dddc..c3b10bf1e32 100644 --- a/src/gpre/c_cxx.cpp +++ b/src/gpre/c_cxx.cpp @@ -2668,6 +2668,8 @@ static void gen_put_segment( const act* action, int column) args.pat_ident1 = blob->blb_len_ident; args.pat_ident2 = blob->blb_buff_ident; args.pat_string1 = global_status_name; + args.pat_long1 = NULL; + args.pat_long2 = NULL; PATTERN_expand((USHORT) column, pattern1, &args); set_sqlcode(action, column); diff --git a/src/gpre/pat.cpp b/src/gpre/pat.cpp index 817ae409765..e8b43e99adb 100644 --- a/src/gpre/pat.cpp +++ b/src/gpre/pat.cpp @@ -364,12 +364,14 @@ void PATTERN_expand( USHORT column, const TEXT* pattern, PAT* args) break; case L1: - long_value = args->pat_long1; + if (args && args->pat_long1) + long_value = args->pat_long1; long_flag = true; break; case L2: - long_value = args->pat_long2; + if (args && args->pat_long2) + long_value = args->pat_long2; long_flag = true; break; diff --git a/src/jrd/IntlManager.cpp b/src/jrd/IntlManager.cpp index 0c5a29048c6..716ec37941d 100644 --- a/src/jrd/IntlManager.cpp +++ b/src/jrd/IntlManager.cpp @@ -458,11 +458,11 @@ bool IntlManager::initialize() string configInfo; const ConfigFile::Parameter* module = ch->sub->findParameter("intl_module"); - const ConfigFile::Parameter* objModule; + const ConfigFile::Parameter* objModule = NULL; if (module && (objModule = configFile.findParameter("intl_module", module->value.c_str()))) { - if (!objModule->sub) + if (!objModule || !objModule->sub) fatal_exception::raiseFmt("Missing parameters for intl_module %s\n", module->value.c_str()); const ConfigFile::Parameter* fname = objModule->sub->findParameter("filename"); diff --git a/src/jrd/cvt2.cpp b/src/jrd/cvt2.cpp index 60be2939844..e61c5d8d07a 100644 --- a/src/jrd/cvt2.cpp +++ b/src/jrd/cvt2.cpp @@ -767,7 +767,7 @@ int CVT2_blob_compare(const dsc* arg1, const dsc* arg2, DecimalStatus decSt) * **************************************/ - SLONG l1, l2; + SLONG l1 = NULL, l2 = NULL; USHORT ttype2; int ret_val = 0; diff --git a/src/jrd/replication/Applier.cpp b/src/jrd/replication/Applier.cpp index 88a3a1d09e1..6a47bba47bd 100644 --- a/src/jrd/replication/Applier.cpp +++ b/src/jrd/replication/Applier.cpp @@ -998,10 +998,12 @@ void Applier::storeBlob(thread_db* tdbb, TraNumber traNum, bid* blobId, fb_assert(blob->blb_flags & BLB_temporary); fb_assert(!(blob->blb_flags & BLB_closed)); - if (blob && length) - blob->BLB_put_segment(tdbb, data, length); - else - blob->BLB_close(tdbb); + if (blob){ + if (length) + blob->BLB_put_segment(tdbb, data, length); + else + blob->BLB_close(tdbb); + } } void Applier::executeSql(thread_db* tdbb, diff --git a/src/remote/server/server.cpp b/src/remote/server/server.cpp index 6cea42401fa..c107d23b3c5 100644 --- a/src/remote/server/server.cpp +++ b/src/remote/server/server.cpp @@ -6129,10 +6129,10 @@ bool rem_port::sendInlineBlob(PACKET* sendL, Rtr* rtr, SQUAD blobId, ULONG maxSi if (status.getState() & IStatus::STATE_ERRORS) return false; - bool segmented; + bool segmented = false; ULONG num_segments; ULONG max_segment; - FB_UINT64 total_length; + FB_UINT64 total_length = 0u; ClumpletReader p(ClumpletReader::InfoResponse, info, sizeof(info)); for (; !p.isEof(); p.moveNext()) From 81edec99bccdaec7f6b1bcb33278b597850e421c Mon Sep 17 00:00:00 2001 From: Ilya Date: Fri, 5 Sep 2025 16:59:06 +0300 Subject: [PATCH 39/79] changed else if condition to else --- src/jrd/vio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jrd/vio.cpp b/src/jrd/vio.cpp index 6c595ab9105..9cef4e998ec 100644 --- a/src/jrd/vio.cpp +++ b/src/jrd/vio.cpp @@ -7296,7 +7296,7 @@ void VIO_update_in_place(thread_db* tdbb, { stack = &new_rpb->rpb_record->getPrecedence(); } - else if (org_rpb->rpb_record) // we apply update to delete stub + else // we apply update to delete stub { stack = &org_rpb->rpb_record->getPrecedence(); } From b14decb7bf6b1164f5453863dcee58376baac935 Mon Sep 17 00:00:00 2001 From: Andrey Date: Sat, 6 Sep 2025 18:27:03 +1200 Subject: [PATCH 40/79] fix format type --- src/isql/isql.epp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/isql/isql.epp b/src/isql/isql.epp index 92bf61e87a6..1c1bf95cc35 100644 --- a/src/isql/isql.epp +++ b/src/isql/isql.epp @@ -7151,7 +7151,7 @@ static unsigned print_item(TEXT** s, const IsqlVar* var, const unsigned length) blobid = var->value.blobid; snprintf(blobbuf, sizeof(blobbuf), "%" xLONGFORMAT":%" xLONGFORMAT, - blobid->gds_quad_high, blobid->gds_quad_low); + (ISC_ULONG) blobid->gds_quad_high, blobid->gds_quad_low); snprintf(p, bufSize, "%*s ", MAX(17, length), blobbuf); break; @@ -7161,7 +7161,7 @@ static unsigned print_item(TEXT** s, const IsqlVar* var, const unsigned length) blobid = var->value.blobid; snprintf(blobbuf, sizeof(blobbuf), "%" xLONGFORMAT":%" xLONGFORMAT, - blobid->gds_quad_high, blobid->gds_quad_low); + (ISC_ULONG) blobid->gds_quad_high, blobid->gds_quad_low); snprintf(p, bufSize, "%*s ", MAX(17, length), blobbuf); if (setValues.List) { From 7025b0804e62e0675e1ccecece488ba11402cfad Mon Sep 17 00:00:00 2001 From: Andrey Date: Sat, 6 Sep 2025 22:54:19 +1200 Subject: [PATCH 41/79] fix missing label --- src/isql/isql.epp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/isql/isql.epp b/src/isql/isql.epp index 9b9fb7e7d2e..0d2aeef4c60 100644 --- a/src/isql/isql.epp +++ b/src/isql/isql.epp @@ -6142,7 +6142,7 @@ static bool printUser(const char* dbName) continue; string txt; - switch(v.type & ~1) + switch (v.type & ~1) { case SQL_TEXT: txt.assign(v.value.asChar, v.length); @@ -6150,6 +6150,8 @@ static bool printUser(const char* dbName) case SQL_VARYING: txt.assign(v.value.asVary->vary_string, v.value.asVary->vary_length); break; + default: + break; } txt.trim(); @@ -7188,6 +7190,8 @@ static unsigned print_item(TEXT** s, const IsqlVar* var, const unsigned length) case SQL_INT64: value = *var->value.asBigint; break; + default: + break; } string str_buf; From e18f6817fa75721cbb3cff1dca59483c78b44344 Mon Sep 17 00:00:00 2001 From: Andrey Date: Sat, 6 Sep 2025 23:03:49 +1200 Subject: [PATCH 42/79] fix unused parameter --- src/isql/isql.epp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/isql/isql.epp b/src/isql/isql.epp index 0d2aeef4c60..102fd2ef7b6 100644 --- a/src/isql/isql.epp +++ b/src/isql/isql.epp @@ -6655,6 +6655,10 @@ static processing_state parse_arg(int argc, SCHAR** argv, QualifiedMetaString& t TEXT errbuf[MSG_LENGTH]; +#ifndef DEV_BUILD + (void) tabname; +#endif + // Initialize database name isqlGlob.global_Db_name[0] = '\0'; From 46b1515148ef00f82b05ea485119ed6d1a8eabaa Mon Sep 17 00:00:00 2001 From: Andrey Date: Sat, 6 Sep 2025 23:23:29 +1200 Subject: [PATCH 43/79] fix enumeration value in switch --- src/isql/isql.epp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/isql/isql.epp b/src/isql/isql.epp index 102fd2ef7b6..90c0122879d 100644 --- a/src/isql/isql.epp +++ b/src/isql/isql.epp @@ -6898,6 +6898,8 @@ static processing_state parse_arg(int argc, SCHAR** argv, QualifiedMetaString& t IUTILS_msg_get(EMPTY_PASS, errbuf, SafeArg() << swarg_str); // empty password file @1 break; + case fb_utils::FETCH_PASS_OK: + break; default: break; } From 242501cbdd6b6617e161040c4ad8a6ebbc884966 Mon Sep 17 00:00:00 2001 From: Andrey Date: Mon, 8 Sep 2025 13:22:15 +1200 Subject: [PATCH 44/79] fix disregarded value --- src/isql/isql.epp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/isql/isql.epp b/src/isql/isql.epp index 9b9fb7e7d2e..c20a7504858 100644 --- a/src/isql/isql.epp +++ b/src/isql/isql.epp @@ -5544,7 +5544,7 @@ void ISQL_get_version(bool call_by_create_db) if (isqlGlob.SQL_dialect > SQL_DIALECT_V5 && setValues.Warnings) { isqlGlob.printf(NEWLINE); - snprintf(bad_dialect_buf, sizeof(bad_dialect_buf), + (void) snprintf(bad_dialect_buf, sizeof(bad_dialect_buf), "WARNING: Pre IB V6 database only speaks SQL dialect 1 and does not accept " "Client SQL dialect %d . Client SQL dialect is reset to 1.\n", isqlGlob.SQL_dialect); @@ -5573,7 +5573,7 @@ void ISQL_get_version(bool call_by_create_db) { print_warning = false; isqlGlob.printf(NEWLINE); - snprintf(bad_dialect_buf, sizeof(bad_dialect_buf), + (void) snprintf(bad_dialect_buf, sizeof(bad_dialect_buf), "WARNING: This database speaks SQL dialect %d but Client SQL dialect was " "set to %d .\n", global_dialect_spoken, isqlGlob.SQL_dialect); isqlGlob.prints(bad_dialect_buf); @@ -5592,14 +5592,14 @@ void ISQL_get_version(bool call_by_create_db) { isqlGlob.printf(NEWLINE); if (call_by_create_db) - snprintf(bad_dialect_buf, sizeof(bad_dialect_buf), + (void) snprintf(bad_dialect_buf, sizeof(bad_dialect_buf), "WARNING: Pre IB V6 server only speaks SQL dialect 1 and does not accept " "Client SQL dialect %d . Client SQL dialect is reset to 1.\n", isqlGlob.SQL_dialect); else { //connecting_to_pre_v6_server = true; Not used anywhere. - snprintf(bad_dialect_buf, sizeof(bad_dialect_buf), + (void) snprintf(bad_dialect_buf, sizeof(bad_dialect_buf), "ERROR: Pre IB V6 server only speaks SQL dialect 1 and does not accept " "Client SQL dialect %d . Client SQL dialect is reset to 1.\n", isqlGlob.SQL_dialect); @@ -5611,7 +5611,7 @@ void ISQL_get_version(bool call_by_create_db) if (isqlGlob.SQL_dialect == 0) { //connecting_to_pre_v6_server = true; Not used anywhere. - snprintf(bad_dialect_buf, sizeof(bad_dialect_buf), + (void) snprintf(bad_dialect_buf, sizeof(bad_dialect_buf), "ERROR: Pre IB V6 server only speaks SQL dialect 1 and does not accept " "Client SQL dialect %d . Client SQL dialect is reset to 1.\n", isqlGlob.SQL_dialect); @@ -6475,7 +6475,7 @@ static processing_state newoutput(const TEXT* outfile) if (fp) { if (isqlGlob.Out && isqlGlob.Out != stdout) - fclose(isqlGlob.Out); + (void) fclose(isqlGlob.Out); isqlGlob.Out = fp; if (Merge_stderr) isqlGlob.Errfp = isqlGlob.Out; @@ -6495,7 +6495,7 @@ static processing_state newoutput(const TEXT* outfile) // Revert to stdout if (isqlGlob.Out != stdout) { - fclose(isqlGlob.Out); + (void) fclose(isqlGlob.Out); isqlGlob.Out = stdout; if (Merge_stderr) isqlGlob.Errfp = isqlGlob.Out; @@ -7067,7 +7067,7 @@ static bool checkSpecial(TEXT* const p, const int length, const double value) // produce of the value, and that the available buffer is at least 2 bytes longer for // a space (column separator) and nul-termination. const size_t bufSize = static_cast(length) + 2; - snprintf(p, bufSize, "%*.*s ", length, length, t); + (void) snprintf(p, bufSize, "%*.*s ", length, length, t); return true; } @@ -7110,9 +7110,9 @@ static unsigned print_item(TEXT** s, const IsqlVar* var, const unsigned length) } if (dtype == SQL_TEXT || dtype == SQL_VARYING || dtype == SQL_BOOLEAN) - snprintf(p, bufSize, "%-*.*s ", length, length, ""); + (void) snprintf(p, bufSize, "%-*.*s ", length, length, ""); else - snprintf(p, bufSize, "%*.*s ", length, length, ""); + (void) snprintf(p, bufSize, "%*.*s ", length, length, ""); } else if (!strncmp(var->field, "DB_KEY", 6)) { @@ -7127,7 +7127,7 @@ static unsigned print_item(TEXT** s, const IsqlVar* var, const unsigned length) } else { - snprintf(d, sizeof(d), "%02X", (unsigned int)(UCHAR)*t); + (void) snprintf(d, sizeof(d), "%02X", (unsigned int)(UCHAR)*t); strcat(p, d); } } @@ -7150,9 +7150,9 @@ static unsigned print_item(TEXT** s, const IsqlVar* var, const unsigned length) // Print blob-ids only here blobid = var->value.blobid; - snprintf(blobbuf, sizeof(blobbuf), "%" xLONGFORMAT":%" xLONGFORMAT, + (void) snprintf(blobbuf, sizeof(blobbuf), "%" xLONGFORMAT":%" xLONGFORMAT, blobid->gds_quad_high, blobid->gds_quad_low); - snprintf(p, bufSize, "%*s ", MAX(17, length), blobbuf); + (void) snprintf(p, bufSize, "%*s ", MAX(17, length), blobbuf); break; case SQL_BLOB: @@ -7160,9 +7160,9 @@ static unsigned print_item(TEXT** s, const IsqlVar* var, const unsigned length) // Print blob-ids only here blobid = var->value.blobid; - snprintf(blobbuf, sizeof(blobbuf), "%" xLONGFORMAT":%" xLONGFORMAT, + (void) snprintf(blobbuf, sizeof(blobbuf), "%" xLONGFORMAT":%" xLONGFORMAT, blobid->gds_quad_high, blobid->gds_quad_low); - snprintf(p, bufSize, "%*s ", MAX(17, length), blobbuf); + (void) snprintf(p, bufSize, "%*s ", MAX(17, length), blobbuf); if (setValues.List) { isqlGlob.printf("%s%s", blobbuf, NEWLINE); @@ -7192,7 +7192,7 @@ static unsigned print_item(TEXT** s, const IsqlVar* var, const unsigned length) string str_buf; print_item_numeric(value, length, dscale, str_buf.getBuffer(length)); - snprintf(p, bufSize, "%s ", str_buf.c_str()); + (void) snprintf(p, bufSize, "%s ", str_buf.c_str()); if (setValues.List) { str_buf.ltrim(); // Added 1999-03-23 to left-justify in LIST ON mode From daf766b70f6e9a853ebf876f3dbd5603499d35fa Mon Sep 17 00:00:00 2001 From: Ilya Date: Thu, 18 Sep 2025 16:29:26 +0300 Subject: [PATCH 45/79] Fixed disregarded return --- src/isql/isql.epp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/isql/isql.epp b/src/isql/isql.epp index 9b9fb7e7d2e..c9a6a829632 100644 --- a/src/isql/isql.epp +++ b/src/isql/isql.epp @@ -7219,20 +7219,20 @@ static unsigned print_item(TEXT** s, const IsqlVar* var, const unsigned length) #if defined(MINGW) if (value == 0) { - snprintf(p, bufSize, "% #*.*g ", length, (int) MIN(8, (length - 6)) - 1, value); + [[maybe_unused]] auto res = snprintf(p, bufSize, "% #*.*g ", length, (int) MIN(8, (length - 6)) - 1, value); if (setValues.List) { isqlGlob.printf("%.*g%s", FLOAT_LEN - 6 -1, value, NEWLINE); } } else { - snprintf(p, bufSize, "% #*.*g ", length, (int) MIN(8, (length - 6)), value); + [[maybe_unused]] auto res = snprintf(p, bufSize, "% #*.*g ", length, (int) MIN(8, (length - 6)), value); if (setValues.List) { isqlGlob.printf("%.*g%s", FLOAT_LEN - 6, value, NEWLINE); } } #else - snprintf(p, bufSize, "% #*.*g ", length, (int) MIN(8, (length - 6)), value); + [[maybe_unused]] auto res = snprintf(p, bufSize, "% #*.*g ", length, (int) MIN(8, (length - 6)), value); if (setValues.List) { isqlGlob.printf("%.*g%s", FLOAT_LEN - 6, value, NEWLINE); } From 5c87edb623471d4fc2355b9c8b9d77af323eb393 Mon Sep 17 00:00:00 2001 From: Andrey Date: Wed, 24 Sep 2025 01:18:49 +1200 Subject: [PATCH 46/79] fix format type --- src/isql/isql.epp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/isql/isql.epp b/src/isql/isql.epp index 1c1bf95cc35..fdc472e570d 100644 --- a/src/isql/isql.epp +++ b/src/isql/isql.epp @@ -7151,7 +7151,7 @@ static unsigned print_item(TEXT** s, const IsqlVar* var, const unsigned length) blobid = var->value.blobid; snprintf(blobbuf, sizeof(blobbuf), "%" xLONGFORMAT":%" xLONGFORMAT, - (ISC_ULONG) blobid->gds_quad_high, blobid->gds_quad_low); + static_cast(blobid->gds_quad_high), blobid->gds_quad_low); snprintf(p, bufSize, "%*s ", MAX(17, length), blobbuf); break; @@ -7161,7 +7161,7 @@ static unsigned print_item(TEXT** s, const IsqlVar* var, const unsigned length) blobid = var->value.blobid; snprintf(blobbuf, sizeof(blobbuf), "%" xLONGFORMAT":%" xLONGFORMAT, - (ISC_ULONG) blobid->gds_quad_high, blobid->gds_quad_low); + static_cast(blobid->gds_quad_high), blobid->gds_quad_low); snprintf(p, bufSize, "%*s ", MAX(17, length), blobbuf); if (setValues.List) { From 722d47d9ce10c36b0ada3412ac9ebcb3f184c99e Mon Sep 17 00:00:00 2001 From: Bobbert Date: Wed, 1 Oct 2025 01:26:06 +0300 Subject: [PATCH 47/79] fix: Refactor filters.cpp logic for 'can_use_more' and remove redundant checks --- src/jrd/filters.cpp | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/jrd/filters.cpp b/src/jrd/filters.cpp index 3e82043ec08..25cb43e6484 100644 --- a/src/jrd/filters.cpp +++ b/src/jrd/filters.cpp @@ -1046,20 +1046,10 @@ ISC_STATUS filter_transliterate_text(USHORT action, BlobControl* control) bool can_use_more = true; USHORT length = aux->ctlaux_buffer1_unused; - if (length) + if (length >= 4 && control->ctl_buffer_length < (length * aux->ctlaux_expansion_factor / EXP_SCALE)) { - if (control->ctl_buffer_length < (length * aux->ctlaux_expansion_factor / EXP_SCALE)) - { - // No need to fetch more bytes, we have enough pending - can_use_more = false; - } - else - can_use_more = true; - - // Always keep a minimal count of bytes in the input buffer, - // to prevent the case of truncated characters. - if (length < 4) - can_use_more = true; + // No need to fetch more bytes, we have enough pending + can_use_more = false; } /* Load data into the temporary buffer if, @@ -1072,7 +1062,7 @@ ISC_STATUS filter_transliterate_text(USHORT action, BlobControl* control) USHORT bytes_read_from_source = 0; ///if (!length || (can_use_more && (aux->ctlaux_source_blob_status == isc_segment))) - if (!length || can_use_more) + if (can_use_more) { // Get a segment, or partial segment, from the source // into the temporary buffer From ec9541b931a200faab65b6b16f40fe2a8141d5cc Mon Sep 17 00:00:00 2001 From: Bobbert Date: Wed, 1 Oct 2025 01:34:22 +0300 Subject: [PATCH 48/79] fix: Initialize value in PATTERN_expand and align comment (gpre/pat.cpp) --- src/gpre/pat.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gpre/pat.cpp b/src/gpre/pat.cpp index 9f09075add6..0a57f0ea2fc 100644 --- a/src/gpre/pat.cpp +++ b/src/gpre/pat.cpp @@ -180,8 +180,8 @@ void PATTERN_expand( USHORT column, const TEXT* pattern, PAT* args) p += align(p, column); SSHORT value = 0; // value needs to be signed since some of the - // values printed out are signed. - SLONG long_value = 0; + SLONG long_value = 0; // values printed out are signed. + TEXT c; while ((c = *pattern++)) { From 3cc0fb295ec3f57249dacbce3099125c5079dcbb Mon Sep 17 00:00:00 2001 From: Bobbert Date: Wed, 1 Oct 2025 01:47:15 +0300 Subject: [PATCH 49/79] fix: add assert 'value' --- src/dsql/StmtNodes.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dsql/StmtNodes.cpp b/src/dsql/StmtNodes.cpp index 0783241045d..ec65cea0d08 100644 --- a/src/dsql/StmtNodes.cpp +++ b/src/dsql/StmtNodes.cpp @@ -12207,6 +12207,7 @@ static void validateExpressions(thread_db* tdbb, const Array& vali else if (!length) value = ""; else + fb_assert(value); const_cast(value)[length] = 0; // safe cast - data is actually on the stack string name; From 1f3be44e5323e94f922546671b84395e3dbbebc8 Mon Sep 17 00:00:00 2001 From: Bobbert Date: Wed, 1 Oct 2025 22:34:42 +0300 Subject: [PATCH 50/79] fix: Narrow scope of merge_pool pointer in Sort::sort method --- src/jrd/sort.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jrd/sort.cpp b/src/jrd/sort.cpp index b4a9c24c597..306937fb64c 100644 --- a/src/jrd/sort.cpp +++ b/src/jrd/sort.cpp @@ -417,7 +417,7 @@ void Sort::sort(thread_db* tdbb) **************************************/ run_control* run; merge_control* merge; - merge_control* merge_pool = nullptr; + merge_control* merge_pool; try { From 0284e5a6c1863b6fbb9e0884a368dff3e6d92c41 Mon Sep 17 00:00:00 2001 From: Bobbert Date: Wed, 1 Oct 2025 22:41:12 +0300 Subject: [PATCH 51/79] fix: Scope ret_code outside of loop and initialize with NORMAL_EXIT in main --- src/utilities/guard/guard.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utilities/guard/guard.cpp b/src/utilities/guard/guard.cpp index 513d8581bc6..50c0ab94905 100644 --- a/src/utilities/guard/guard.cpp +++ b/src/utilities/guard/guard.cpp @@ -181,9 +181,9 @@ int CLIB_ROUTINE main( int argc, char **argv) divorce_terminal(mask); time_t timer = 0; + int ret_code = NORMAL_EXIT; do { - int ret_code = 0; if (shutting_down) { From 7abf37204ea5f59d2ff9cbc5f792378b99e04d47 Mon Sep 17 00:00:00 2001 From: Bobbert Date: Wed, 1 Oct 2025 22:45:38 +0300 Subject: [PATCH 52/79] fix: Initialize select_node in FilteredStream::evaluateBoolean and remove redundant else block --- src/jrd/recsrc/FilteredStream.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/jrd/recsrc/FilteredStream.cpp b/src/jrd/recsrc/FilteredStream.cpp index b47ff9c1c0e..be7ce534793 100644 --- a/src/jrd/recsrc/FilteredStream.cpp +++ b/src/jrd/recsrc/FilteredStream.cpp @@ -203,8 +203,6 @@ bool FilteredStream::evaluateBoolean(thread_db* tdbb) const select_node = booleanNode->arg1; column_node = booleanNode->arg2; } - else - select_node = NULL; } if (column_node && m_ansiAny) From 8f70f84fa9ffac947432dc4199d6ebfd3b01086b Mon Sep 17 00:00:00 2001 From: Bobbert Date: Wed, 1 Oct 2025 22:55:32 +0300 Subject: [PATCH 53/79] fix: Refactor weekDate logic to remove unnecessary initialization and false positive on weekNumber --- src/common/classes/NoThrowTimeStamp.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/common/classes/NoThrowTimeStamp.cpp b/src/common/classes/NoThrowTimeStamp.cpp index 8b850fb7882..80f2134c6f2 100644 --- a/src/common/classes/NoThrowTimeStamp.cpp +++ b/src/common/classes/NoThrowTimeStamp.cpp @@ -356,13 +356,12 @@ int NoThrowTimeStamp::convertGregorianDateToWeekDate(const struct tm& times) noe const int weekday = 1 + ((h - 1) % 7); // Find if y m d falls in yearNumber y-1, weekNumber 52 or 53 - int yearNumber = 0, weekNumber = 0; + int yearNumber, weekNumber; if ((dayOfYearNumber <= (8 - jan1Weekday)) && (jan1Weekday > 4)) { yearNumber = y - 1; - weekNumber = ((jan1Weekday == 5) || ((jan1Weekday == 6) && - isLeapYear(yearNumber))) ? 53 : 52; + weekNumber = ((jan1Weekday == 5) || ((jan1Weekday == 6) && isLeapYear(yearNumber))) ? 53 : 52; } else { @@ -376,15 +375,15 @@ int NoThrowTimeStamp::convertGregorianDateToWeekDate(const struct tm& times) noe yearNumber = y + 1; weekNumber = 1; } - } - // Find if y m d falls in yearNumber y, weekNumber 1 through 53 - if (yearNumber == y) - { - const int j = dayOfYearNumber + (7 - weekday) + (jan1Weekday - 1); - weekNumber = j / 7; - if (jan1Weekday > 4) - weekNumber--; + // Find if y m d falls in yearNumber y, weekNumber 1 through 53 + if (yearNumber == y) + { + const int j = dayOfYearNumber + (7 - weekday) + (jan1Weekday - 1); + weekNumber = j / 7; + if (jan1Weekday > 4) + weekNumber--; + } } return weekNumber; From 687c238b507bdfd190183b05c44960e27a6742d9 Mon Sep 17 00:00:00 2001 From: Bobbert Date: Wed, 1 Oct 2025 23:06:19 +0300 Subject: [PATCH 54/79] refactor: Narrow scope of 'len' and 'space' in BTR_reserve_slot to eliminate redundant initialization --- src/jrd/btr.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/jrd/btr.cpp b/src/jrd/btr.cpp index 92a0657e0cf..487c63f029d 100644 --- a/src/jrd/btr.cpp +++ b/src/jrd/btr.cpp @@ -2315,15 +2315,14 @@ void BTR_reserve_slot(thread_db* tdbb, IndexCreation& creation) } UCHAR* desc = 0; - USHORT len = 0, space = 0; index_root_page::irt_repeat* slot = NULL; index_root_page::irt_repeat* end = NULL; for (int retry = 0; retry < 2; ++retry) { - len = idx->idx_count * sizeof(irtd); + USHORT len = idx->idx_count * sizeof(irtd); - space = dbb->dbb_page_size; + USHORT space = dbb->dbb_page_size; slot = NULL; end = root->irt_rpt + root->irt_count; From e7fc91be19589fe47a1e257ce8f4ee422ad7a5b4 Mon Sep 17 00:00:00 2001 From: Bobbert Date: Thu, 2 Oct 2025 01:03:53 +0300 Subject: [PATCH 55/79] refactoring: remove unnecessary else --- src/common/unicode_util.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/common/unicode_util.cpp b/src/common/unicode_util.cpp index 54134157848..2101ecddc4a 100644 --- a/src/common/unicode_util.cpp +++ b/src/common/unicode_util.cpp @@ -1877,8 +1877,6 @@ USHORT UnicodeUtil::Utf16Collation::stringToKey(USHORT srcLen, const USHORT* src fb_assert(lastCharKey[lastCharKeyLen - 1] == '\0'); --lastCharKeyLen; } - else - prefixLen = 0; bool fallbackToPrefixKey = false; From d0d88ab400b85d4caabf90044940c5554e329c20 Mon Sep 17 00:00:00 2001 From: Bobbert Date: Thu, 2 Oct 2025 01:10:03 +0300 Subject: [PATCH 56/79] refactoring: while and if blocks using merge_pool --- src/jrd/sort.cpp | 77 ++++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 39 deletions(-) diff --git a/src/jrd/sort.cpp b/src/jrd/sort.cpp index 306937fb64c..54a0cd5b5d7 100644 --- a/src/jrd/sort.cpp +++ b/src/jrd/sort.cpp @@ -417,7 +417,6 @@ void Sort::sort(thread_db* tdbb) **************************************/ run_control* run; merge_control* merge; - merge_control* merge_pool; try { @@ -488,56 +487,56 @@ void Sort::sort(thread_db* tdbb) { fb_assert(!m_merge_pool); // shouldn't have a pool m_merge_pool = FB_NEW_POOL(m_owner->getPool()) merge_control[count - 1]; - merge_pool = m_merge_pool; + merge_control* merge_pool = m_merge_pool; memset(merge_pool, 0, (count - 1) * sizeof(merge_control)); - } - else - { - // Merge of 1 or 0 runs doesn't make sense - fb_assert(false); // We really shouldn't get here - merge = (merge_control*) *streams; // But if we do... - } - // Each pass through the vector builds a level of the merge tree - // by condensing two runs into one. - // We will continue to make passes until there is a single item. - // - // See also kissing cousin of this loop in mergeRuns() + // Each pass through the vector builds a level of the merge tree + // by condensing two runs into one. + // We will continue to make passes until there is a single item. + // + // See also kissing cousin of this loop in mergeRuns() - while (count > 1) - { - run_merge_hdr** m2 = m1 = streams; + while (count > 1) + { + run_merge_hdr** m2 = m1 = streams; - // "m1" is used to sequence through the runs being merged, - // while "m2" points at the new merged run + // "m1" is used to sequence through the runs being merged, + // while "m2" points at the new merged run - while (count >= 2) - { - merge = merge_pool++; - merge->mrg_header.rmh_type = RMH_TYPE_MRG; + while (count >= 2) + { + merge = merge_pool++; + merge->mrg_header.rmh_type = RMH_TYPE_MRG; - // garbage watch - fb_assert(((*m1)->rmh_type == RMH_TYPE_MRG) || ((*m1)->rmh_type == RMH_TYPE_RUN)); + // garbage watch + fb_assert(((*m1)->rmh_type == RMH_TYPE_MRG) || ((*m1)->rmh_type == RMH_TYPE_RUN)); - (*m1)->rmh_parent = merge; - merge->mrg_stream_a = *m1++; + (*m1)->rmh_parent = merge; + merge->mrg_stream_a = *m1++; - // garbage watch - fb_assert(((*m1)->rmh_type == RMH_TYPE_MRG) || ((*m1)->rmh_type == RMH_TYPE_RUN)); + // garbage watch + fb_assert(((*m1)->rmh_type == RMH_TYPE_MRG) || ((*m1)->rmh_type == RMH_TYPE_RUN)); - (*m1)->rmh_parent = merge; - merge->mrg_stream_b = *m1++; + (*m1)->rmh_parent = merge; + merge->mrg_stream_b = *m1++; - merge->mrg_record_a = NULL; - merge->mrg_record_b = NULL; + merge->mrg_record_a = NULL; + merge->mrg_record_b = NULL; - *m2++ = (run_merge_hdr*) merge; - count -= 2; - } + *m2++ = (run_merge_hdr*) merge; + count -= 2; + } - if (count) - *m2++ = *m1++; - count = m2 - streams; + if (count) + *m2++ = *m1++; + count = m2 - streams; + } + } + else + { + // Merge of 1 or 0 runs doesn't make sense + fb_assert(false); // We really shouldn't get here + merge = (merge_control*) *streams; // But if we do... } streams.reset(); From 7b65a8e09a1680b8081dae3283b9279b3b245e6d Mon Sep 17 00:00:00 2001 From: Filimonova Anna Date: Thu, 2 Oct 2025 20:07:48 +0300 Subject: [PATCH 57/79] fix_snprintf_retval: use static_cast --- src/common/StatusArg.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/StatusArg.cpp b/src/common/StatusArg.cpp index c5f1774e613..39abf70643b 100644 --- a/src/common/StatusArg.cpp +++ b/src/common/StatusArg.cpp @@ -420,8 +420,8 @@ Quad::Quad(const ISC_QUAD* quad) noexcept : Str(text) { (void)snprintf(text, sizeof(text), "%x:%x", - (unsigned int)quad->gds_quad_high, - (unsigned int)quad->gds_quad_low + static_cast(quad->gds_quad_high), + quad->gds_quad_low ); } From c6185abf331eb0fe564e9aa53120dce9413d677c Mon Sep 17 00:00:00 2001 From: Bobbert Date: Fri, 3 Oct 2025 12:36:51 +0300 Subject: [PATCH 58/79] fix: initialization custom types in 'StmtNodes.cpp'. --- src/dsql/StmtNodes.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dsql/StmtNodes.cpp b/src/dsql/StmtNodes.cpp index ec65cea0d08..1956f351de3 100644 --- a/src/dsql/StmtNodes.cpp +++ b/src/dsql/StmtNodes.cpp @@ -521,7 +521,7 @@ BlockNode* BlockNode::pass2(thread_db* tdbb, CompilerScratch* csb) const StmtNode* BlockNode::execute(thread_db* tdbb, Request* request, ExeState* exeState) const { jrd_tra* transaction = request->req_transaction; - SavNumber savNumber{}; + SavNumber savNumber = 0; switch (request->req_operation) { @@ -2475,7 +2475,7 @@ void EraseNode::pass1Erase(thread_db* tdbb, CompilerScratch* csb, EraseNode* nod jrd_rel* parent = NULL; jrd_rel* view = NULL; - StreamType parentStream{}; + StreamType parentStream = 0; for (;;) { @@ -7994,7 +7994,7 @@ void ModifyNode::pass1Modify(thread_db* tdbb, CompilerScratch* csb, ModifyNode* jrd_rel* parent = NULL; jrd_rel* view = NULL; - StreamType parentStream{}, parentNewStream{}; + StreamType parentStream = 0, parentNewStream = 0; // To support nested views, loop until we hit a table or a view with user-defined triggers // (which means no update). @@ -9044,7 +9044,7 @@ bool StoreNode::pass1Store(thread_db* tdbb, CompilerScratch* csb, StoreNode* nod jrd_rel* parent = NULL; jrd_rel* view = NULL; - StreamType parentStream{}; + StreamType parentStream = 0; // To support nested views, loop until we hit a table or a view with user-defined triggers // (which means no update). From 4a7916a16414ab522d5d8d1576a65877913dad27 Mon Sep 17 00:00:00 2001 From: Bobbert Date: Sun, 5 Oct 2025 22:19:06 +0300 Subject: [PATCH 59/79] fix: moving the preassignment of 'len', 'space' to the end of the for iterations and initializing them from the beginning with the correct values --- src/jrd/btr.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/jrd/btr.cpp b/src/jrd/btr.cpp index 487c63f029d..23cfe9a0445 100644 --- a/src/jrd/btr.cpp +++ b/src/jrd/btr.cpp @@ -2315,14 +2315,13 @@ void BTR_reserve_slot(thread_db* tdbb, IndexCreation& creation) } UCHAR* desc = 0; + USHORT len = idx->idx_count * sizeof(irtd); + USHORT space = dbb->dbb_page_size; index_root_page::irt_repeat* slot = NULL; index_root_page::irt_repeat* end = NULL; for (int retry = 0; retry < 2; ++retry) { - USHORT len = idx->idx_count * sizeof(irtd); - - USHORT space = dbb->dbb_page_size; slot = NULL; end = root->irt_rpt + root->irt_count; @@ -2357,6 +2356,9 @@ void BTR_reserve_slot(thread_db* tdbb, IndexCreation& creation) } else break; + + len = idx->idx_count * sizeof(irtd); + space = dbb->dbb_page_size; } // If we didn't pick up an empty slot, allocate a new one From 2cc6b6fd1cd044baf30befd376fc98f46db04d23 Mon Sep 17 00:00:00 2001 From: Bobbert Date: Sun, 5 Oct 2025 22:50:05 +0300 Subject: [PATCH 60/79] fix: Initializing yearNumber with y and weekNumber with computed value instead of declaring them uninitialized. Move the condition (yearNumber == y) inside the else block since it can only be true in that case. Remove intermediate variable j. --- src/common/classes/NoThrowTimeStamp.cpp | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/common/classes/NoThrowTimeStamp.cpp b/src/common/classes/NoThrowTimeStamp.cpp index 80f2134c6f2..47927fd9531 100644 --- a/src/common/classes/NoThrowTimeStamp.cpp +++ b/src/common/classes/NoThrowTimeStamp.cpp @@ -355,18 +355,21 @@ int NoThrowTimeStamp::convertGregorianDateToWeekDate(const struct tm& times) noe const int h = dayOfYearNumber + (jan1Weekday - 1); const int weekday = 1 + ((h - 1) % 7); + int weekNumber = (dayOfYearNumber + (7 - weekday) + (jan1Weekday - 1)) / 7; + if (jan1Weekday > 4) + weekNumber--; + // Find if y m d falls in yearNumber y-1, weekNumber 52 or 53 - int yearNumber, weekNumber; + int yearNumber = y; if ((dayOfYearNumber <= (8 - jan1Weekday)) && (jan1Weekday > 4)) { yearNumber = y - 1; - weekNumber = ((jan1Weekday == 5) || ((jan1Weekday == 6) && isLeapYear(yearNumber))) ? 53 : 52; + weekNumber = ((jan1Weekday == 5) || ((jan1Weekday == 6) && + isLeapYear(yearNumber))) ? 53 : 52; } else { - yearNumber = y; - // Find if y m d falls in yearNumber y+1, weekNumber 1 const int i = isLeapYear(y) ? 366 : 365; @@ -375,15 +378,6 @@ int NoThrowTimeStamp::convertGregorianDateToWeekDate(const struct tm& times) noe yearNumber = y + 1; weekNumber = 1; } - - // Find if y m d falls in yearNumber y, weekNumber 1 through 53 - if (yearNumber == y) - { - const int j = dayOfYearNumber + (7 - weekday) + (jan1Weekday - 1); - weekNumber = j / 7; - if (jan1Weekday > 4) - weekNumber--; - } } return weekNumber; From 108d0fa144f6b6e1eeff68ed1eabb05a5ab95d9b Mon Sep 17 00:00:00 2001 From: Bobbert Date: Sun, 5 Oct 2025 23:09:00 +0300 Subject: [PATCH 61/79] refactor: move ret_code declaration into loop scope --- src/utilities/guard/guard.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utilities/guard/guard.cpp b/src/utilities/guard/guard.cpp index 50c0ab94905..324b952f951 100644 --- a/src/utilities/guard/guard.cpp +++ b/src/utilities/guard/guard.cpp @@ -181,7 +181,6 @@ int CLIB_ROUTINE main( int argc, char **argv) divorce_terminal(mask); time_t timer = 0; - int ret_code = NORMAL_EXIT; do { @@ -226,6 +225,7 @@ int CLIB_ROUTINE main( int argc, char **argv) } // wait for child to die, and evaluate exit status + int ret_code = NORMAL_EXIT; bool shutdown_child = true; if (!shutting_down) { From 8f23b0a13d571d6e3c3ca272d86aedb2dfd2692d Mon Sep 17 00:00:00 2001 From: Bobbert Date: Sun, 5 Oct 2025 23:20:54 +0300 Subject: [PATCH 62/79] refactor: remove old comment and add new --- src/jrd/filters.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/jrd/filters.cpp b/src/jrd/filters.cpp index 25cb43e6484..fe0a1ae7f99 100644 --- a/src/jrd/filters.cpp +++ b/src/jrd/filters.cpp @@ -1046,6 +1046,8 @@ ISC_STATUS filter_transliterate_text(USHORT action, BlobControl* control) bool can_use_more = true; USHORT length = aux->ctlaux_buffer1_unused; + // Always keep a minimal count of bytes in the input buffer + // to prevent the case of truncated characters. if (length >= 4 && control->ctl_buffer_length < (length * aux->ctlaux_expansion_factor / EXP_SCALE)) { // No need to fetch more bytes, we have enough pending @@ -1061,7 +1063,6 @@ ISC_STATUS filter_transliterate_text(USHORT action, BlobControl* control) USHORT bytes_read_from_source = 0; - ///if (!length || (can_use_more && (aux->ctlaux_source_blob_status == isc_segment))) if (can_use_more) { // Get a segment, or partial segment, from the source From 1519ed205094dd17990c7fdefb52d732d4b30217 Mon Sep 17 00:00:00 2001 From: Bobbert Date: Mon, 6 Oct 2025 00:06:16 +0300 Subject: [PATCH 63/79] refactor: move returnsPos declaration to its actual usage point inside the subRoutine validation block. --- src/dsql/StmtNodes.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/dsql/StmtNodes.cpp b/src/dsql/StmtNodes.cpp index 1956f351de3..f4673bbc777 100644 --- a/src/dsql/StmtNodes.cpp +++ b/src/dsql/StmtNodes.cpp @@ -5067,8 +5067,6 @@ void ExecBlockNode::genBlr(DsqlCompilerScratch* dsqlScratch) // Sub routine doesn't need ports and should generate BLR as declared in its metadata. const bool subRoutine = dsqlScratch->flags & DsqlCompilerScratch::FLAG_SUB_ROUTINE; - unsigned returnsPos = 0; - if (!subRoutine) { // Now do the input parameters. @@ -5080,8 +5078,6 @@ void ExecBlockNode::genBlr(DsqlCompilerScratch* dsqlScratch) dsql_var::TYPE_INPUT, 0, (USHORT) (2 * i), i); } - returnsPos = dsqlScratch->variables.getCount(); - // Now do the output parameters. for (FB_SIZE_T i = 0; i < returns.getCount(); ++i) { @@ -5130,7 +5126,6 @@ void ExecBlockNode::genBlr(DsqlCompilerScratch* dsqlScratch) if (subRoutine) { dsqlScratch->genParameters(parameters, returns); - returnsPos = dsqlScratch->variables.getCount() - dsqlScratch->outputVariables.getCount(); } if (parameters.hasData()) @@ -5145,6 +5140,8 @@ void ExecBlockNode::genBlr(DsqlCompilerScratch* dsqlScratch) { // This validation is needed only for subroutines. Standard EXECUTE BLOCK moves input // parameters to variables and are then validated. + // Number of input parameters to validate (total variables minus output variables) + const unsigned returnsPos = dsqlScratch->variables.getCount() - dsqlScratch->outputVariables.getCount(); for (unsigned i = 0; i < returnsPos; ++i) { From 91d3a109616525f4be50b88404d0b70ebf4c8d8d Mon Sep 17 00:00:00 2001 From: Andrey Date: Mon, 6 Oct 2025 22:07:04 +1200 Subject: [PATCH 64/79] fix disregarded value --- src/isql/isql.epp | 82 +++++++++++++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 27 deletions(-) diff --git a/src/isql/isql.epp b/src/isql/isql.epp index c20a7504858..2c62cde1706 100644 --- a/src/isql/isql.epp +++ b/src/isql/isql.epp @@ -5544,10 +5544,11 @@ void ISQL_get_version(bool call_by_create_db) if (isqlGlob.SQL_dialect > SQL_DIALECT_V5 && setValues.Warnings) { isqlGlob.printf(NEWLINE); - (void) snprintf(bad_dialect_buf, sizeof(bad_dialect_buf), + [[maybe_unused]] auto result = snprintf(bad_dialect_buf, sizeof(bad_dialect_buf), "WARNING: Pre IB V6 database only speaks SQL dialect 1 and does not accept " "Client SQL dialect %d . Client SQL dialect is reset to 1.\n", isqlGlob.SQL_dialect); + fb_assert(result >= 0); isqlGlob.prints(bad_dialect_buf); } } @@ -5573,9 +5574,10 @@ void ISQL_get_version(bool call_by_create_db) { print_warning = false; isqlGlob.printf(NEWLINE); - (void) snprintf(bad_dialect_buf, sizeof(bad_dialect_buf), + [[maybe_unused]] auto result = snprintf(bad_dialect_buf, sizeof(bad_dialect_buf), "WARNING: This database speaks SQL dialect %d but Client SQL dialect was " "set to %d .\n", global_dialect_spoken, isqlGlob.SQL_dialect); + fb_assert(result >= 0); isqlGlob.prints(bad_dialect_buf); } } @@ -5592,17 +5594,21 @@ void ISQL_get_version(bool call_by_create_db) { isqlGlob.printf(NEWLINE); if (call_by_create_db) - (void) snprintf(bad_dialect_buf, sizeof(bad_dialect_buf), + { + [[maybe_unused]] auto result = snprintf(bad_dialect_buf, sizeof(bad_dialect_buf), "WARNING: Pre IB V6 server only speaks SQL dialect 1 and does not accept " "Client SQL dialect %d . Client SQL dialect is reset to 1.\n", isqlGlob.SQL_dialect); + fb_assert(result >= 0); + } else { //connecting_to_pre_v6_server = true; Not used anywhere. - (void) snprintf(bad_dialect_buf, sizeof(bad_dialect_buf), + [[maybe_unused]] auto result = snprintf(bad_dialect_buf, sizeof(bad_dialect_buf), "ERROR: Pre IB V6 server only speaks SQL dialect 1 and does not accept " "Client SQL dialect %d . Client SQL dialect is reset to 1.\n", isqlGlob.SQL_dialect); + fb_assert(result >= 0); } isqlGlob.prints(bad_dialect_buf); } @@ -5611,10 +5617,11 @@ void ISQL_get_version(bool call_by_create_db) if (isqlGlob.SQL_dialect == 0) { //connecting_to_pre_v6_server = true; Not used anywhere. - (void) snprintf(bad_dialect_buf, sizeof(bad_dialect_buf), + [[maybe_unused]] auto result = snprintf(bad_dialect_buf, sizeof(bad_dialect_buf), "ERROR: Pre IB V6 server only speaks SQL dialect 1 and does not accept " "Client SQL dialect %d . Client SQL dialect is reset to 1.\n", isqlGlob.SQL_dialect); + fb_assert(result >= 0); isqlGlob.prints(bad_dialect_buf); } } @@ -6475,7 +6482,10 @@ static processing_state newoutput(const TEXT* outfile) if (fp) { if (isqlGlob.Out && isqlGlob.Out != stdout) - (void) fclose(isqlGlob.Out); + { + [[maybe_unused]] auto result = fclose(isqlGlob.Out); + fb_assert(result == 0); + } isqlGlob.Out = fp; if (Merge_stderr) isqlGlob.Errfp = isqlGlob.Out; @@ -6495,7 +6505,8 @@ static processing_state newoutput(const TEXT* outfile) // Revert to stdout if (isqlGlob.Out != stdout) { - (void) fclose(isqlGlob.Out); + [[maybe_unused]] auto result = fclose(isqlGlob.Out); + fb_assert(result == 0); isqlGlob.Out = stdout; if (Merge_stderr) isqlGlob.Errfp = isqlGlob.Out; @@ -7067,7 +7078,8 @@ static bool checkSpecial(TEXT* const p, const int length, const double value) // produce of the value, and that the available buffer is at least 2 bytes longer for // a space (column separator) and nul-termination. const size_t bufSize = static_cast(length) + 2; - (void) snprintf(p, bufSize, "%*.*s ", length, length, t); + [[maybe_unused]] auto result = snprintf(p, bufSize, "%*.*s ", length, length, t); + fb_assert(result >= 0); return true; } @@ -7110,9 +7122,15 @@ static unsigned print_item(TEXT** s, const IsqlVar* var, const unsigned length) } if (dtype == SQL_TEXT || dtype == SQL_VARYING || dtype == SQL_BOOLEAN) - (void) snprintf(p, bufSize, "%-*.*s ", length, length, ""); + { + [[maybe_unused]] auto result = snprintf(p, bufSize, "%-*.*s ", length, length, ""); + fb_assert(result >= 0); + } else - (void) snprintf(p, bufSize, "%*.*s ", length, length, ""); + { + [[maybe_unused]] auto result = snprintf(p, bufSize, "%*.*s ", length, length, ""); + fb_assert(result >= 0); + } } else if (!strncmp(var->field, "DB_KEY", 6)) { @@ -7127,7 +7145,8 @@ static unsigned print_item(TEXT** s, const IsqlVar* var, const unsigned length) } else { - (void) snprintf(d, sizeof(d), "%02X", (unsigned int)(UCHAR)*t); + [[maybe_unused]] auto result = snprintf(d, sizeof(d), "%02X", (unsigned int)(UCHAR)*t); + fb_assert(result >= 0); strcat(p, d); } } @@ -7146,28 +7165,36 @@ static unsigned print_item(TEXT** s, const IsqlVar* var, const unsigned length) switch (dtype) { case SQL_ARRAY: + { - // Print blob-ids only here + // Print blob-ids only here - blobid = var->value.blobid; - (void) snprintf(blobbuf, sizeof(blobbuf), "%" xLONGFORMAT":%" xLONGFORMAT, - blobid->gds_quad_high, blobid->gds_quad_low); - (void) snprintf(p, bufSize, "%*s ", MAX(17, length), blobbuf); + blobid = var->value.blobid; + [[maybe_unused]] auto result = snprintf(blobbuf, sizeof(blobbuf), "%" xLONGFORMAT":%" xLONGFORMAT, + blobid->gds_quad_high, blobid->gds_quad_low); + fb_assert(result >= 0); + result = snprintf(p, bufSize, "%*s ", MAX(17, length), blobbuf); + fb_assert(result >= 0); + } break; case SQL_BLOB: + { - // Print blob-ids only here + // Print blob-ids only here - blobid = var->value.blobid; - (void) snprintf(blobbuf, sizeof(blobbuf), "%" xLONGFORMAT":%" xLONGFORMAT, - blobid->gds_quad_high, blobid->gds_quad_low); - (void) snprintf(p, bufSize, "%*s ", MAX(17, length), blobbuf); - if (setValues.List) - { - isqlGlob.printf("%s%s", blobbuf, NEWLINE); - dtype = ISQL_print_item_blob(isqlGlob.Out, var, M__trans, setValues.Doblob); - isqlGlob.printf(NEWLINE); + blobid = var->value.blobid; + [[maybe_unused]] auto result = snprintf(blobbuf, sizeof(blobbuf), "%" xLONGFORMAT":%" xLONGFORMAT, + blobid->gds_quad_high, blobid->gds_quad_low); + fb_assert(result >= 0); + result = snprintf(p, bufSize, "%*s ", MAX(17, length), blobbuf); + fb_assert(result >= 0); + if (setValues.List) + { + isqlGlob.printf("%s%s", blobbuf, NEWLINE); + dtype = ISQL_print_item_blob(isqlGlob.Out, var, M__trans, setValues.Doblob); + isqlGlob.printf(NEWLINE); + } } break; @@ -7192,7 +7219,8 @@ static unsigned print_item(TEXT** s, const IsqlVar* var, const unsigned length) string str_buf; print_item_numeric(value, length, dscale, str_buf.getBuffer(length)); - (void) snprintf(p, bufSize, "%s ", str_buf.c_str()); + [[maybe_unused]] auto result = snprintf(p, bufSize, "%s ", str_buf.c_str()); + fb_assert(result >= 0); if (setValues.List) { str_buf.ltrim(); // Added 1999-03-23 to left-justify in LIST ON mode From 2d89042b512545aa06a0b1c9140e642a31755b28 Mon Sep 17 00:00:00 2001 From: Ilya Date: Tue, 7 Oct 2025 13:09:53 +0300 Subject: [PATCH 65/79] Added default init --- src/jrd/inf.cpp | 8 ++++---- src/jrd/intl.cpp | 2 +- src/remote/server/server.cpp | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/jrd/inf.cpp b/src/jrd/inf.cpp index b65ba73ef54..c1bdc07d730 100644 --- a/src/jrd/inf.cpp +++ b/src/jrd/inf.cpp @@ -177,7 +177,7 @@ void INF_blob_info(const blb* blob, CHECK_INPUT("INF_blob_info"); UCHAR buffer[BUFFER_TINY]; - USHORT length; + USHORT length = 0; const UCHAR* const end_items = items + item_length; const UCHAR* const end = info + output_length; @@ -289,7 +289,7 @@ void INF_database_info(thread_db* tdbb, CountsBuffer counts_buffer; UCHAR* buffer = counts_buffer.getBuffer(BUFFER_SMALL, false); - ULONG length, err_val; + ULONG length = 0, err_val = 0; bool header_refreshed = false; Database* const dbb = tdbb->getDatabase(); @@ -778,7 +778,7 @@ void INF_database_info(thread_db* tdbb, case fb_info_page_contents: { bool validArgs = false; - ULONG pageNum; + ULONG pageNum = 0; if (end_items - items >= 2) { @@ -1196,7 +1196,7 @@ void INF_transaction_info(const jrd_tra* transaction, CHECK_INPUT("INF_transaction_info"); UCHAR buffer[MAXPATHLEN]; - ULONG length; + ULONG length = 0; const UCHAR* const end_items = items + item_length; const UCHAR* const end = info + output_length; diff --git a/src/jrd/intl.cpp b/src/jrd/intl.cpp index bea8bf03f69..34f592d4818 100644 --- a/src/jrd/intl.cpp +++ b/src/jrd/intl.cpp @@ -818,7 +818,7 @@ void INTL_convert_string(dsc* to, const dsc* from, Firebird::Callbacks* cb) reinterpret_cast(((vary*) p)->vary_string) : p; - ULONG to_fill; + ULONG to_fill = 0; if (from_cs != to_cs && to_cs != CS_BINARY && to_cs != CS_NONE && from_cs != CS_NONE) { diff --git a/src/remote/server/server.cpp b/src/remote/server/server.cpp index 6cea42401fa..096da8126f6 100644 --- a/src/remote/server/server.cpp +++ b/src/remote/server/server.cpp @@ -4652,7 +4652,7 @@ void rem_port::info(P_OP op, P_INFO* stuff, PACKET* sendL) HalfStaticArray info; UCHAR* info_buffer = NULL; - ULONG info_len; + ULONG info_len = 0; HalfStaticArray temp; UCHAR* temp_buffer = NULL; @@ -6130,8 +6130,8 @@ bool rem_port::sendInlineBlob(PACKET* sendL, Rtr* rtr, SQUAD blobId, ULONG maxSi return false; bool segmented; - ULONG num_segments; - ULONG max_segment; + ULONG num_segments = 0; + ULONG max_segment = 0; FB_UINT64 total_length; ClumpletReader p(ClumpletReader::InfoResponse, info, sizeof(info)); From 3d40fb5b031a5d44cf430f9cecc4572f7e96d678 Mon Sep 17 00:00:00 2001 From: Ilya Date: Tue, 7 Oct 2025 13:24:21 +0300 Subject: [PATCH 66/79] Added fb_assert --- src/isql/isql.epp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/isql/isql.epp b/src/isql/isql.epp index c9a6a829632..8d1597332fb 100644 --- a/src/isql/isql.epp +++ b/src/isql/isql.epp @@ -7220,6 +7220,8 @@ static unsigned print_item(TEXT** s, const IsqlVar* var, const unsigned length) if (value == 0) { [[maybe_unused]] auto res = snprintf(p, bufSize, "% #*.*g ", length, (int) MIN(8, (length - 6)) - 1, value); + fb_assert(res >= 0); + if (setValues.List) { isqlGlob.printf("%.*g%s", FLOAT_LEN - 6 -1, value, NEWLINE); } @@ -7227,12 +7229,16 @@ static unsigned print_item(TEXT** s, const IsqlVar* var, const unsigned length) else { [[maybe_unused]] auto res = snprintf(p, bufSize, "% #*.*g ", length, (int) MIN(8, (length - 6)), value); + fb_assert(res >= 0); + if (setValues.List) { isqlGlob.printf("%.*g%s", FLOAT_LEN - 6, value, NEWLINE); } } #else [[maybe_unused]] auto res = snprintf(p, bufSize, "% #*.*g ", length, (int) MIN(8, (length - 6)), value); + fb_assert(res >= 0); + if (setValues.List) { isqlGlob.printf("%.*g%s", FLOAT_LEN - 6, value, NEWLINE); } From 1e7eedc8c4427873ba7fc752bec63e5d107bb27a Mon Sep 17 00:00:00 2001 From: Ilya Date: Tue, 7 Oct 2025 13:43:20 +0300 Subject: [PATCH 67/79] fixed implicit conversion --- src/isql/isql.epp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/isql/isql.epp b/src/isql/isql.epp index 9b9fb7e7d2e..fd9129d4c0d 100644 --- a/src/isql/isql.epp +++ b/src/isql/isql.epp @@ -7209,7 +7209,7 @@ static unsigned print_item(TEXT** s, const IsqlVar* var, const unsigned length) // one digit more than the specified precision when the value is 0 // The bug appears in TCS DSQL_DOMAIN_12 and 13 // - const double value = *var->value.asFloat; + const double value = static_cast(*var->value.asFloat); if (checkSpecial(p, length, value)) { @@ -7252,7 +7252,7 @@ static unsigned print_item(TEXT** s, const IsqlVar* var, const unsigned length) // Don't let numeric/decimal doubles overflow print length // Special handling for 0 -- don't test log for length unsigned rounded = 0; - if (dscale && (!value || + if (dscale && (value == 0 || (rounded = static_cast(ceil(fabs(log10(fabs(value)))))) < length - 10)) { unsigned precision = 0; From 930f693d6f0f7843470426751e398c26ef6de821 Mon Sep 17 00:00:00 2001 From: Ilya Date: Tue, 7 Oct 2025 13:56:16 +0300 Subject: [PATCH 68/79] Added default init --- src/jrd/btr.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/jrd/btr.h b/src/jrd/btr.h index de47709ae13..2a6c4f8056d 100644 --- a/src/jrd/btr.h +++ b/src/jrd/btr.h @@ -152,10 +152,10 @@ inline constexpr int key_empty = 1; // Key contains empty data / empty string struct temporary_key { - USHORT key_length; + USHORT key_length = 0; UCHAR key_data[MAX_KEY + 1]; - UCHAR key_flags; - USHORT key_nulls; // bitmap of encountered null segments, + UCHAR key_flags = 0; + USHORT key_nulls = 0; // bitmap of encountered null segments, // USHORT is enough to store MAX_INDEX_SEGMENTS bits Firebird::AutoPtr key_next; // next key (INTL_KEY_MULTI_STARTING) }; From e175d7bf0be394f34a64b31dd87037601c7df39b Mon Sep 17 00:00:00 2001 From: Ilya Date: Tue, 7 Oct 2025 14:01:00 +0300 Subject: [PATCH 69/79] Added fb_assert --- src/jrd/vio.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/jrd/vio.cpp b/src/jrd/vio.cpp index 9cef4e998ec..f01c5a0873e 100644 --- a/src/jrd/vio.cpp +++ b/src/jrd/vio.cpp @@ -7298,6 +7298,7 @@ void VIO_update_in_place(thread_db* tdbb, } else // we apply update to delete stub { + fb_assert(org_rpb->rpb_record); stack = &org_rpb->rpb_record->getPrecedence(); } // According to DS on firebird-devel: it is not possible update non-existing record so stack is From 9a73c13d581947f1621d4525e614d71c44dfb688 Mon Sep 17 00:00:00 2001 From: Filimonova Anna Date: Sat, 11 Oct 2025 16:32:27 +0300 Subject: [PATCH 70/79] assert snprintf return value in StatusArg.cpp --- src/common/StatusArg.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/common/StatusArg.cpp b/src/common/StatusArg.cpp index 39abf70643b..cf6554434b9 100644 --- a/src/common/StatusArg.cpp +++ b/src/common/StatusArg.cpp @@ -407,22 +407,25 @@ Num::Num(ISC_STATUS s) noexcept : Int64::Int64(SINT64 val) noexcept : Str(text) { - (void)snprintf(text, sizeof(text), "%" SQUADFORMAT, val); + [[maybe_unused]] auto result = snprintf(text, sizeof(text), "%" SQUADFORMAT, val); + fb_assert(result >= 0); } Int64::Int64(FB_UINT64 val) noexcept : Str(text) { - (void)snprintf(text, sizeof(text), "%" UQUADFORMAT, val); + [[maybe_unused]] auto result = snprintf(text, sizeof(text), "%" UQUADFORMAT, val); + fb_assert(result >= 0); } Quad::Quad(const ISC_QUAD* quad) noexcept : Str(text) { - (void)snprintf(text, sizeof(text), "%x:%x", + [[maybe_unused]] auto result = snprintf(text, sizeof(text), "%x:%x", static_cast(quad->gds_quad_high), quad->gds_quad_low ); + fb_assert(result >= 0); } Interpreted::Interpreted(const char* text) noexcept : From 163d58092ac7019a03f5109c517e66848d9fe4d3 Mon Sep 17 00:00:00 2001 From: Andrey Date: Mon, 20 Oct 2025 19:18:11 +1200 Subject: [PATCH 71/79] fix unused parameter --- src/isql/isql.epp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/isql/isql.epp b/src/isql/isql.epp index 90c0122879d..ef848fd23f3 100644 --- a/src/isql/isql.epp +++ b/src/isql/isql.epp @@ -6636,7 +6636,7 @@ static processing_state newtrans(const TEXT* statement) } -static processing_state parse_arg(int argc, SCHAR** argv, QualifiedMetaString& tabname) +static processing_state parse_arg(int argc, SCHAR** argv, [[maybe_unused]] QualifiedMetaString& tabname) // , FILE** sess) Last param was for wisql { /************************************** @@ -6655,10 +6655,6 @@ static processing_state parse_arg(int argc, SCHAR** argv, QualifiedMetaString& t TEXT errbuf[MSG_LENGTH]; -#ifndef DEV_BUILD - (void) tabname; -#endif - // Initialize database name isqlGlob.global_Db_name[0] = '\0'; From c3f70f8dfe0ccee04cacb2a2b8eca575a9041b66 Mon Sep 17 00:00:00 2001 From: Andrey Date: Mon, 20 Oct 2025 19:26:29 +1200 Subject: [PATCH 72/79] fix enumeration value in switch --- src/isql/isql.epp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/isql/isql.epp b/src/isql/isql.epp index ef848fd23f3..3005c57430c 100644 --- a/src/isql/isql.epp +++ b/src/isql/isql.epp @@ -6894,8 +6894,6 @@ static processing_state parse_arg(int argc, SCHAR** argv, [[maybe_unused]] Quali IUTILS_msg_get(EMPTY_PASS, errbuf, SafeArg() << swarg_str); // empty password file @1 break; - case fb_utils::FETCH_PASS_OK: - break; default: break; } From c26523987df014f35514a668cc113bce3963df97 Mon Sep 17 00:00:00 2001 From: Andrey Date: Mon, 20 Oct 2025 19:38:28 +1200 Subject: [PATCH 73/79] fix missing label --- src/isql/isql.epp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/isql/isql.epp b/src/isql/isql.epp index 3005c57430c..8a0f168b48c 100644 --- a/src/isql/isql.epp +++ b/src/isql/isql.epp @@ -6151,6 +6151,7 @@ static bool printUser(const char* dbName) txt.assign(v.value.asVary->vary_string, v.value.asVary->vary_length); break; default: + fb_assert(false); break; } @@ -7191,6 +7192,7 @@ static unsigned print_item(TEXT** s, const IsqlVar* var, const unsigned length) value = *var->value.asBigint; break; default: + fb_assert(false); break; } From 94649713b6efd9633a3ee782eb8a64438f24891e Mon Sep 17 00:00:00 2001 From: Bobbert Date: Wed, 29 Oct 2025 01:20:03 +0300 Subject: [PATCH 74/79] refactor: indentation fixed --- src/utilities/guard/guard.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utilities/guard/guard.cpp b/src/utilities/guard/guard.cpp index 324b952f951..e32bebd1963 100644 --- a/src/utilities/guard/guard.cpp +++ b/src/utilities/guard/guard.cpp @@ -225,7 +225,7 @@ int CLIB_ROUTINE main( int argc, char **argv) } // wait for child to die, and evaluate exit status - int ret_code = NORMAL_EXIT; + int ret_code = NORMAL_EXIT; bool shutdown_child = true; if (!shutting_down) { From 5a1075493fcdfd890ec4e98ae4b16109868dc17f Mon Sep 17 00:00:00 2001 From: Bobbert Date: Wed, 29 Oct 2025 01:32:12 +0300 Subject: [PATCH 75/79] refactor: optimize week date conversion with bitwise operations 1) Use bit shifts instead of division by 4 2) Replace % 4 with bitwise AND 3) Use bitwise &/| instead of logical &&/|| for branchless code --- src/common/classes/NoThrowTimeStamp.cpp | 48 +++++++++++-------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/src/common/classes/NoThrowTimeStamp.cpp b/src/common/classes/NoThrowTimeStamp.cpp index 47927fd9531..f61a1cea0b3 100644 --- a/src/common/classes/NoThrowTimeStamp.cpp +++ b/src/common/classes/NoThrowTimeStamp.cpp @@ -341,45 +341,37 @@ int NoThrowTimeStamp::convertGregorianDateToWeekDate(const struct tm& times) noe { // Algorithm for Converting Gregorian Dates to ISO 8601 Week Date by Rick McCarty, 1999 // http://personal.ecu.edu/mccartyr/ISOwdALG.txt - const int y = times.tm_year + 1900; - const int dayOfYearNumber = times.tm_yday + 1; + const int dayOfYear = times.tm_yday + 1; // Find the jan1Weekday for y (Monday=1, Sunday=7) - const int yy = (y - 1) % 100; - const int c = (y - 1) - yy; - const int g = yy + yy / 4; - const int jan1Weekday = 1 + (((((c / 100) % 4) * 5) + g) % 7); - - // Find the weekday for y m d - const int h = dayOfYearNumber + (jan1Weekday - 1); - const int weekday = 1 + ((h - 1) % 7); + const int y_1 = y - 1; + const int yy = y_1 % 100; + const int c = y_1 - yy; + const int g = yy + (yy >> 2); + const int jan1Weekday = 1 + (((((c / 100) & 3) * 5) + g) % 7); - int weekNumber = (dayOfYearNumber + (7 - weekday) + (jan1Weekday - 1)) / 7; - if (jan1Weekday > 4) - weekNumber--; + const int weekday = 1 + ((dayOfYear + jan1Weekday - 2) % 7); // Find if y m d falls in yearNumber y-1, weekNumber 52 or 53 - int yearNumber = y; - - if ((dayOfYearNumber <= (8 - jan1Weekday)) && (jan1Weekday > 4)) + if ((dayOfYear <= (8 - jan1Weekday)) & (jan1Weekday > 4)) { - yearNumber = y - 1; - weekNumber = ((jan1Weekday == 5) || ((jan1Weekday == 6) && - isLeapYear(yearNumber))) ? 53 : 52; + const int prevYearLeap = (!(y_1 & 3) && ((y_1 % 100) || !(y_1 % 400))); + const int is53 = (jan1Weekday == 5) | ((jan1Weekday == 6) & prevYearLeap); + return 52 + is53; } - else + + // Find if y m d falls in yearNumber y+1, weekNumber 1 + const int daysInYear = 365 + (!(y & 3) && ((y % 100) || !(y % 400))); + if ((daysInYear - dayOfYear) < (4 - weekday)) { - // Find if y m d falls in yearNumber y+1, weekNumber 1 - const int i = isLeapYear(y) ? 366 : 365; - - if ((i - dayOfYearNumber) < (4 - weekday)) - { - yearNumber = y + 1; - weekNumber = 1; - } + return 1; } + // Find if y m d falls in yearNumber y, weekNumber 1 through 53 + const int j = dayOfYear + (7 - weekday) + (jan1Weekday - 1); + const int weekNumber = (j / 7) - (jan1Weekday > 4); // Subtract 1 if jan1Weekday > 4 + return weekNumber; } From b122e4ded6dd47851b68b707cf5606000fded503 Mon Sep 17 00:00:00 2001 From: Bobbert Date: Wed, 29 Oct 2025 23:51:22 +0300 Subject: [PATCH 76/79] refactor: the type of the variable `len` has been changed to const USHORT, and the constant initialization with the same value has been removed. --- src/jrd/btr.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/jrd/btr.cpp b/src/jrd/btr.cpp index 23cfe9a0445..f7cf9067b91 100644 --- a/src/jrd/btr.cpp +++ b/src/jrd/btr.cpp @@ -2315,7 +2315,7 @@ void BTR_reserve_slot(thread_db* tdbb, IndexCreation& creation) } UCHAR* desc = 0; - USHORT len = idx->idx_count * sizeof(irtd); + const USHORT len = idx->idx_count * sizeof(irtd); USHORT space = dbb->dbb_page_size; index_root_page::irt_repeat* slot = NULL; index_root_page::irt_repeat* end = NULL; @@ -2357,7 +2357,6 @@ void BTR_reserve_slot(thread_db* tdbb, IndexCreation& creation) else break; - len = idx->idx_count * sizeof(irtd); space = dbb->dbb_page_size; } From f43dd1a90a2e28f46fc789d6b4ce6444b81867cf Mon Sep 17 00:00:00 2001 From: Andrey Date: Sat, 13 Dec 2025 13:40:31 +0300 Subject: [PATCH 77/79] fixed implicit type conversion errors --- src/jrd/btr.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/jrd/btr.cpp b/src/jrd/btr.cpp index 6f0376f8367..9c17b5af151 100644 --- a/src/jrd/btr.cpp +++ b/src/jrd/btr.cpp @@ -5806,8 +5806,8 @@ static ULONG insert_node(thread_db* tdbb, // For checking on duplicate nodes we should find the first matching key. UCHAR* pointer = find_node_start_point(bucket, key, 0, &prefix, - (idx->idx_flags & idx_descending) != 0, - false ? 1 : 0, true, validateDuplicates ? NO_VALUE : newRecordNumber); + idx->idx_flags & idx_descending, + 0, true, validateDuplicates ? NO_VALUE : newRecordNumber); if (!pointer) return NO_VALUE_PAGE; @@ -6620,8 +6620,8 @@ static contents remove_leaf_node(thread_db* tdbb, index_insertion* insertion, WI UCHAR* pointer; USHORT prefix; while (!(pointer = find_node_start_point(page, key, 0, &prefix, - (idx->idx_flags & idx_descending) != 0, - false ? 1 : 0, false, + idx->idx_flags & idx_descending, + 0, false, (validateDuplicates ? NO_VALUE : insertion->iib_number)))) { page = (btree_page*) CCH_HANDOFF(tdbb, window, page->btr_sibling, LCK_write, pag_index); From bfa093b37911d2e9939df78e3f754da5098a4928 Mon Sep 17 00:00:00 2001 From: Andrey Date: Sat, 13 Dec 2025 14:01:47 +0300 Subject: [PATCH 78/79] the default value for trig_t has been added and initialized --- src/burp/burp.h | 1 + src/burp/restore.epp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/burp/burp.h b/src/burp/burp.h index d21317e0b18..3929ef325cc 100644 --- a/src/burp/burp.h +++ b/src/burp/burp.h @@ -707,6 +707,7 @@ enum att_type { // Trigger types enum trig_t { + trig_none = 0, trig_pre_store = 1, // default trig_pre_modify, // default trig_post_erase // default diff --git a/src/burp/restore.epp b/src/burp/restore.epp index 4a02a4a4bf1..bfa3c941ba6 100644 --- a/src/burp/restore.epp +++ b/src/burp/restore.epp @@ -9389,7 +9389,7 @@ bool get_trigger_old (BurpGlobals* tdgbl, burp_rel* relation) * Get a trigger definition for a relation. * **************************************/ - enum trig_t type = trig_pre_store; + enum trig_t type = trig_none; att_type attribute; TEXT name[GDS_NAME_LEN]; scan_attr_t scan_next_attr; From f335f7c0a35cdd003ae041da7f201b494526c321 Mon Sep 17 00:00:00 2001 From: Andrey Date: Sat, 13 Dec 2025 17:04:57 +0300 Subject: [PATCH 79/79] the default value is 0 as there will be a recalculation --- src/dsql/DdlNodes.epp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dsql/DdlNodes.epp b/src/dsql/DdlNodes.epp index 3af5163719b..355e558e2bf 100644 --- a/src/dsql/DdlNodes.epp +++ b/src/dsql/DdlNodes.epp @@ -184,7 +184,8 @@ static void checkForeignKeyTempScope(thread_db* tdbb, jrd_tra* transaction, { AutoCacheRequest request(tdbb, drq_l_rel_info, DYN_REQUESTS); QualifiedName masterRelName; - rel_t masterType, childType; + rel_t masterType = rel_persistent; + rel_t childType = rel_persistent; FOR(REQUEST_HANDLE request TRANSACTION_HANDLE transaction) RLC_M IN RDB$RELATION_CONSTRAINTS CROSS