diff --git a/src/burp/burp.h b/src/burp/burp.h index 3fb58a76b9e..d9fa2ae4eae 100644 --- a/src/burp/burp.h +++ b/src/burp/burp.h @@ -708,6 +708,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 1108459d14d..5c66f74cc99 100644 --- a/src/burp/restore.epp +++ b/src/burp/restore.epp @@ -1602,7 +1602,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; @@ -1777,7 +1777,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; @@ -1843,7 +1843,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 @@ -3375,7 +3375,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) @@ -9078,7 +9078,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; @@ -9401,7 +9401,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_none; att_type attribute; TEXT name[GDS_NAME_LEN]; scan_attr_t scan_next_attr; diff --git a/src/common/CvtFormat.cpp b/src/common/CvtFormat.cpp index 6476f39da57..bddc8ce4f45 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; 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/common/StatusArg.cpp b/src/common/StatusArg.cpp index a4fb738e530..235d37ab023 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) { @@ -407,19 +407,25 @@ Num::Num(ISC_STATUS s) noexcept : Int64::Int64(SINT64 val) noexcept : Str(text) { - 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) { - 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) { - snprintf(text, sizeof(text), "%x:%x", quad->gds_quad_high, quad->gds_quad_low); + [[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 : diff --git a/src/common/StatusArg.h b/src/common/StatusArg.h index 449734b6cca..47362c6e810 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 { } @@ -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; diff --git a/src/common/classes/NoThrowTimeStamp.cpp b/src/common/classes/NoThrowTimeStamp.cpp index 17404032865..f61a1cea0b3 100644 --- a/src/common/classes/NoThrowTimeStamp.cpp +++ b/src/common/classes/NoThrowTimeStamp.cpp @@ -341,51 +341,36 @@ 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); + 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); - // Find the weekday for y m d - const int h = dayOfYearNumber + (jan1Weekday - 1); - const int weekday = 1 + ((h - 1) % 7); + const int weekday = 1 + ((dayOfYear + jan1Weekday - 2) % 7); // Find if y m d falls in yearNumber y-1, weekNumber 52 or 53 - int yearNumber, weekNumber; - - 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 - { - yearNumber = y; - // 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; - } + // 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)) + { + return 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--; - } + const int j = dayOfYear + (7 - weekday) + (jan1Weekday - 1); + const int weekNumber = (j / 7) - (jan1Weekday > 4); // Subtract 1 if jan1Weekday > 4 return weekNumber; } diff --git a/src/common/cvt.cpp b/src/common/cvt.cpp index da9b6c40d6a..f3213ca9997 100644 --- a/src/common/cvt.cpp +++ b/src/common/cvt.cpp @@ -1433,7 +1433,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) { diff --git a/src/common/isc_sync.cpp b/src/common/isc_sync.cpp index 9998406e93f..885c89edd27 100644 --- a/src/common/isc_sync.cpp +++ b/src/common/isc_sync.cpp @@ -1473,7 +1473,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); diff --git a/src/common/unicode_util.cpp b/src/common/unicode_util.cpp index 05ffe216b40..2101ecddc4a 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; @@ -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; diff --git a/src/dsql/DdlNodes.epp b/src/dsql/DdlNodes.epp index 02e4550a85c..fd8878e868b 100644 --- a/src/dsql/DdlNodes.epp +++ b/src/dsql/DdlNodes.epp @@ -216,7 +216,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 @@ -402,7 +403,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/dsql/StmtNodes.cpp b/src/dsql/StmtNodes.cpp index 208e7db07a3..51b90632a35 100644 --- a/src/dsql/StmtNodes.cpp +++ b/src/dsql/StmtNodes.cpp @@ -523,7 +523,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) { @@ -2494,7 +2494,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 (;;) { @@ -5173,7 +5173,6 @@ void ExecBlockNode::genBlr(DsqlCompilerScratch* dsqlScratch) { inputStart = dsqlScratch->variables.getCount(); dsqlScratch->genParameters(parameters, returns); - returnsPos = dsqlScratch->variables.getCount() - dsqlScratch->outputVariables.getCount(); } if (parameters.hasData()) @@ -5188,6 +5187,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 = inputStart; i < returnsPos; ++i) { @@ -8035,7 +8036,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). @@ -9090,7 +9091,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). @@ -12437,7 +12438,7 @@ static void validateExpressions(thread_db* tdbb, const Array& vali if (i->boolean->execute(tdbb, request) == TriState(false)) { // Validation error -- report result - const char* value; + const char* value = nullptr; VaryStr temp; const dsc* desc = EVL_expr(tdbb, request, i->value); @@ -12449,6 +12450,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; 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/obj_cxx.cpp b/src/gpre/obj_cxx.cpp index dcc2735d45b..52bad0e4630 100644 --- a/src/gpre/obj_cxx.cpp +++ b/src/gpre/obj_cxx.cpp @@ -3367,7 +3367,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/gpre/pat.cpp b/src/gpre/pat.cpp index e0ac289d753..96810a7521f 100644 --- a/src/gpre/pat.cpp +++ b/src/gpre/pat.cpp @@ -170,9 +170,9 @@ 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 - // values printed out are signed. - SLONG long_value; + SSHORT value = 0; // value needs to be signed since some of the + SLONG long_value = 0; // values printed out are signed. + TEXT c; while ((c = *pattern++)) { @@ -355,12 +355,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/isql/isql.epp b/src/isql/isql.epp index 999bfcab4ed..d3b03a1c245 100644 --- a/src/isql/isql.epp +++ b/src/isql/isql.epp @@ -5543,10 +5543,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(); @@ -5555,10 +5555,11 @@ 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), + [[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); } } @@ -5584,9 +5585,10 @@ void ISQL_get_version(bool call_by_create_db) { print_warning = false; isqlGlob.printf(NEWLINE); - 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); } } @@ -5603,17 +5605,21 @@ 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), + { + [[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. - 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); } @@ -5622,10 +5628,11 @@ 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), + [[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); } } @@ -6153,7 +6160,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); @@ -6161,6 +6168,9 @@ static bool printUser(const char* dbName) case SQL_VARYING: txt.assign(v.value.asVary->vary_string, v.value.asVary->vary_length); break; + default: + fb_assert(false); + break; } txt.trim(); @@ -6486,7 +6496,10 @@ static processing_state newoutput(const TEXT* outfile) if (fp) { if (isqlGlob.Out && isqlGlob.Out != stdout) - fclose(isqlGlob.Out); + { + [[maybe_unused]] auto result = fclose(isqlGlob.Out); + fb_assert(result == 0); + } isqlGlob.Out = fp; if (Merge_stderr) isqlGlob.Errfp = isqlGlob.Out; @@ -6506,7 +6519,8 @@ static processing_state newoutput(const TEXT* outfile) // Revert to stdout if (isqlGlob.Out != stdout) { - fclose(isqlGlob.Out); + [[maybe_unused]] auto result = fclose(isqlGlob.Out); + fb_assert(result == 0); isqlGlob.Out = stdout; if (Merge_stderr) isqlGlob.Errfp = isqlGlob.Out; @@ -6645,7 +6659,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 { /************************************** @@ -6976,7 +6990,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) { @@ -7077,7 +7091,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; - snprintf(p, bufSize, "%*.*s ", length, length, t); + [[maybe_unused]] auto result = snprintf(p, bufSize, "%*.*s ", length, length, t); + fb_assert(result >= 0); return true; } @@ -7120,9 +7135,15 @@ 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, ""); + { + [[maybe_unused]] auto result = snprintf(p, bufSize, "%-*.*s ", length, length, ""); + fb_assert(result >= 0); + } else - 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)) { @@ -7137,7 +7158,8 @@ static unsigned print_item(TEXT** s, const IsqlVar* var, const unsigned length) } else { - 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); } } @@ -7156,28 +7178,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; - snprintf(blobbuf, sizeof(blobbuf), "%" xLONGFORMAT":%" xLONGFORMAT, - blobid->gds_quad_high, blobid->gds_quad_low); - snprintf(p, bufSize, "%*s ", MAX(17, length), blobbuf); + blobid = var->value.blobid; + [[maybe_unused]] auto result = snprintf(blobbuf, sizeof(blobbuf), "%" xLONGFORMAT":%" xLONGFORMAT, + static_cast(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; - snprintf(blobbuf, sizeof(blobbuf), "%" xLONGFORMAT":%" xLONGFORMAT, - blobid->gds_quad_high, blobid->gds_quad_low); - 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, + static_cast(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; @@ -7198,11 +7228,15 @@ static unsigned print_item(TEXT** s, const IsqlVar* var, const unsigned length) case SQL_INT64: value = *var->value.asBigint; break; + default: + fb_assert(false); + break; } string str_buf; print_item_numeric(value, length, dscale, str_buf.getBuffer(length)); - 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 @@ -7219,7 +7253,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)) { @@ -7229,20 +7263,26 @@ 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); + fb_assert(res >= 0); + 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); + fb_assert(res >= 0); + 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); + fb_assert(res >= 0); + if (setValues.List) { isqlGlob.printf("%.*g%s", FLOAT_LEN - 6, value, NEWLINE); } @@ -7262,7 +7302,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; diff --git a/src/jrd/IntlManager.cpp b/src/jrd/IntlManager.cpp index 3c4c74c1547..d750c558343 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/btr.cpp b/src/jrd/btr.cpp index 1767eda9b83..4e1cf0be455 100644 --- a/src/jrd/btr.cpp +++ b/src/jrd/btr.cpp @@ -2907,15 +2907,13 @@ void BTR_reserve_slot(thread_db* tdbb, IndexCreation& creation, IndexCreateLock& } UCHAR* desc = 0; - USHORT len, space; + 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; for (int retry = 0; retry < 2; ++retry) { - len = idx->idx_count * sizeof(irtd); - - space = dbb->dbb_page_size; slot = NULL; end = root->irt_rpt + root->irt_count; @@ -2950,6 +2948,8 @@ void BTR_reserve_slot(thread_db* tdbb, IndexCreation& creation, IndexCreateLock& } else break; + + space = dbb->dbb_page_size; } // If we didn't pick up an empty slot, allocate a new one @@ -3410,8 +3410,8 @@ static void compress(thread_db* tdbb, bool first_key = true; VaryStr buffer; - size_t multiKeyLength; - UCHAR* ptr; + size_t multiKeyLength = 0; + UCHAR* ptr = nullptr; UCHAR* p = key->key_data; SSHORT scale = matchScale ? matchScale : desc->dsc_scale; @@ -3423,7 +3423,7 @@ static void compress(thread_db* tdbb, do { - size_t length; + size_t length = 0; has_next = false; @@ -6400,7 +6400,7 @@ 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); + 0, true, validateDuplicates ? NO_VALUE : newRecordNumber); if (!pointer) return NO_VALUE_PAGE; @@ -7207,8 +7207,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, (validateDuplicates ? NO_VALUE : insertion->iib_number)))) { page = (btree_page*) CCH_HANDOFF(tdbb, window, page->btr_sibling, LCK_write, pag_index); diff --git a/src/jrd/btr.h b/src/jrd/btr.h index 8edc0e34364..24d02878837 100644 --- a/src/jrd/btr.h +++ b/src/jrd/btr.h @@ -180,10 +180,10 @@ inline constexpr int key_empty = 1; // Key contains empty data / empty string struct temporary_mini_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 }; diff --git a/src/jrd/cvt2.cpp b/src/jrd/cvt2.cpp index 81ca4658ce8..328419ad5d8 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; int ret_val = 0; thread_db* tdbb = NULL; @@ -973,6 +973,7 @@ USHORT CVT2_make_string2(const dsc* desc, TTypeId to_interp, UCHAR** address, Mo **************************************/ UCHAR* from_buf; USHORT from_len; + TTypeId from_interp; fb_assert(desc != NULL); diff --git a/src/jrd/exe.cpp b/src/jrd/exe.cpp index 0ec9deafabd..a0f7f597e7f 100644 --- a/src/jrd/exe.cpp +++ b/src/jrd/exe.cpp @@ -551,7 +551,7 @@ void EXE_assignment(thread_db* tdbb, const ValueExprNode* to, dsc* from_desc, if (null && to_desc->dsc_dtype <= dtype_varying) { - USHORT minlen; + USHORT minlen = 0; switch (to_desc->dsc_dtype) { diff --git a/src/jrd/filters.cpp b/src/jrd/filters.cpp index 41acb8dcc07..c7ebce81fe3 100644 --- a/src/jrd/filters.cpp +++ b/src/jrd/filters.cpp @@ -1044,22 +1044,14 @@ 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) + // 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)) { - 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, @@ -1071,8 +1063,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 diff --git a/src/jrd/inf.cpp b/src/jrd/inf.cpp index 270b3bee1c1..d2a4bd4cf0f 100644 --- a/src/jrd/inf.cpp +++ b/src/jrd/inf.cpp @@ -144,7 +144,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; @@ -256,6 +256,7 @@ void INF_database_info(thread_db* tdbb, HalfStaticArray resultBuffer; + const auto dbb = tdbb->getDatabase(); CHECK_DBB(dbb); const auto attachment = tdbb->getAttachment(); @@ -294,7 +295,7 @@ void INF_database_info(thread_db* tdbb, }; UCHAR* buffer = resultBuffer.getBuffer(BUFFER_SMALL, false); - ULONG length, err_val; + ULONG length = 0, err_val = 0; bool headerRefreshed = false; auto refreshHeader = [&]() @@ -755,7 +756,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) { @@ -1185,7 +1186,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 45bb706547d..ae8fc43936c 100644 --- a/src/jrd/intl.cpp +++ b/src/jrd/intl.cpp @@ -579,7 +579,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/jrd/lck.cpp b/src/jrd/lck.cpp index a1868ed441e..dda42af5d60 100644 --- a/src/jrd/lck.cpp +++ b/src/jrd/lck.cpp @@ -1069,6 +1069,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; @@ -1353,6 +1356,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(LockManagerEngineCallbacks(tdbb), statusVector, diff --git a/src/jrd/os/posix/unix.cpp b/src/jrd/os/posix/unix.cpp index 780eeb90500..3b276f4cdfc 100644 --- a/src/jrd/os/posix/unix.cpp +++ b/src/jrd/os/posix/unix.cpp @@ -533,7 +533,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; diff --git a/src/jrd/recsrc/FilteredStream.cpp b/src/jrd/recsrc/FilteredStream.cpp index bfbfd03aa64..5fc5699c332 100644 --- a/src/jrd/recsrc/FilteredStream.cpp +++ b/src/jrd/recsrc/FilteredStream.cpp @@ -190,7 +190,7 @@ Firebird::TriState 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; @@ -206,8 +206,6 @@ Firebird::TriState FilteredStream::evaluateBoolean(thread_db* tdbb) const select_node = booleanNode->arg1; column_node = booleanNode->arg2; } - else - select_node = NULL; } if (column_node && m_ansiAny) diff --git a/src/jrd/replication/Applier.cpp b/src/jrd/replication/Applier.cpp index e28e2a52d4f..1d2510a4ee9 100644 --- a/src/jrd/replication/Applier.cpp +++ b/src/jrd/replication/Applier.cpp @@ -990,10 +990,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 (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/jrd/sort.cpp b/src/jrd/sort.cpp index b1a0a7fe19c..473e698f9a7 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(); diff --git a/src/jrd/vio.cpp b/src/jrd/vio.cpp index 4a20d727a11..66a6f07bd70 100644 --- a/src/jrd/vio.cpp +++ b/src/jrd/vio.cpp @@ -7264,8 +7264,9 @@ 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 { + 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 diff --git a/src/remote/client/interface.cpp b/src/remote/client/interface.cpp index 731b68266ec..c9f65bf9e19 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) diff --git a/src/remote/server/server.cpp b/src/remote/server/server.cpp index c9143b39c63..a1f4fc4e22d 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; @@ -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; - ULONG num_segments; - ULONG max_segment; - FB_UINT64 total_length; + bool segmented = false; + ULONG num_segments = 0; + ULONG max_segment = 0; + FB_UINT64 total_length = 0u; ClumpletReader p(ClumpletReader::InfoResponse, info, sizeof(info)); for (; !p.isEof(); p.moveNext()) diff --git a/src/utilities/guard/guard.cpp b/src/utilities/guard/guard.cpp index fbd96db318f..e32bebd1963 100644 --- a/src/utilities/guard/guard.cpp +++ b/src/utilities/guard/guard.cpp @@ -183,7 +183,6 @@ int CLIB_ROUTINE main( int argc, char **argv) time_t timer = 0; do { - int ret_code; if (shutting_down) { @@ -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) { diff --git a/src/yvalve/gds.cpp b/src/yvalve/gds.cpp index 162fa9d8d65..d3960a592f7 100644 --- a/src/yvalve/gds.cpp +++ b/src/yvalve/gds.cpp @@ -3180,7 +3180,7 @@ static int blr_print_dtype(gds_ctl* control) * data described. * **************************************/ - SSHORT length; + SSHORT length = 0; const USHORT dtype = control->ctl_blr_reader.getByte(); @@ -3544,7 +3544,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) {