From f8007f407157e250e4cde6e38574121695ef3083 Mon Sep 17 00:00:00 2001 From: robocop Date: Sun, 24 Feb 2008 03:23:40 +0000 Subject: [PATCH] Misc. --- src/jrd/TempSpace.h | 4 +- src/jrd/TextType.cpp | 8 ++-- src/jrd/os/win32/winnt.cpp | 4 +- src/jrd/par.cpp | 32 ++++++++-------- src/jrd/perf.cpp | 15 ++++++-- src/jrd/rse.cpp | 76 ++++++++++++++++++++------------------ src/jrd/scl.epp | 9 +++-- src/jrd/tra.cpp | 31 ++++++++-------- src/jrd/why.cpp | 6 ++- 9 files changed, 99 insertions(+), 86 deletions(-) diff --git a/src/jrd/TempSpace.h b/src/jrd/TempSpace.h index 85a3861da7..c3386edea3 100644 --- a/src/jrd/TempSpace.h +++ b/src/jrd/TempSpace.h @@ -95,8 +95,8 @@ private: { if ((offset < this->size) && (offset + _size <= this->size)) return ptr + offset; - else - return NULL; + + return NULL; } bool sameFile(const TempFile* file) const diff --git a/src/jrd/TextType.cpp b/src/jrd/TextType.cpp index 43b3f9118e..94c78c678b 100644 --- a/src/jrd/TextType.cpp +++ b/src/jrd/TextType.cpp @@ -341,8 +341,8 @@ ULONG TextType::str_to_upper(ULONG srcLen, { if (tt->texttype_fn_str_to_upper) return (*tt->texttype_fn_str_to_upper)(tt, srcLen, src, dstLen, dst); - else - return Firebird::IntlUtil::toUpper(getCharSet(), srcLen, src, dstLen, dst, NULL); + + return Firebird::IntlUtil::toUpper(getCharSet(), srcLen, src, dstLen, dst, NULL); } @@ -353,8 +353,8 @@ ULONG TextType::str_to_lower(ULONG srcLen, { if (tt->texttype_fn_str_to_lower) return (*tt->texttype_fn_str_to_lower)(tt, srcLen, src, dstLen, dst); - else - return Firebird::IntlUtil::toLower(getCharSet(), srcLen, src, dstLen, dst, NULL); + + return Firebird::IntlUtil::toLower(getCharSet(), srcLen, src, dstLen, dst, NULL); } diff --git a/src/jrd/os/win32/winnt.cpp b/src/jrd/os/win32/winnt.cpp index 8c44fa63da..c95600ebda 100644 --- a/src/jrd/os/win32/winnt.cpp +++ b/src/jrd/os/win32/winnt.cpp @@ -540,14 +540,14 @@ namespace { class HugeStaticBuffer { public: - HugeStaticBuffer(MemoryPool& p) + explicit HugeStaticBuffer(MemoryPool& p) : zeroArray(p), zeroBuff(zeroArray.getBuffer(ZERO_BUF_SIZE)) { memset(zeroBuff, 0, ZERO_BUF_SIZE); } - const char* get() { return zeroBuff; } + const char* get() const { return zeroBuff; } private: Firebird::Array zeroArray; diff --git a/src/jrd/par.cpp b/src/jrd/par.cpp index a78420c834..80549d1e77 100644 --- a/src/jrd/par.cpp +++ b/src/jrd/par.cpp @@ -1106,9 +1106,8 @@ static SSHORT par_context(CompilerScratch* csb, SSHORT* context_ptr) if (csb->csb_g_flags & csb_reuse_context) { return tail->csb_stream; } - else { - error(csb, isc_ctxinuse, 0); - } + + error(csb, isc_ctxinuse, 0); } const SSHORT stream = csb->nextStream(false); @@ -1476,10 +1475,9 @@ static jrd_nod* par_function(thread_db* tdbb, CompilerScratch* csb) anode->nod_arg[e_fun_args] = par_args(tdbb, csb, VALUE); return anode; } - else { - csb->csb_running -= count; - error(csb, isc_funnotdef, isc_arg_string, ERR_cstring(name), 0); - } + + csb->csb_running -= count; + error(csb, isc_funnotdef, isc_arg_string, ERR_cstring(name), 0); } UserFunction* homonyms; @@ -2441,17 +2439,17 @@ static jrd_nod* par_rse(thread_db* tdbb, CompilerScratch* csb, SSHORT rse_op) if (!rse->rse_jointype || (rse->rse_count == 2 && rse->rse_boolean)) { - // Convert right outer joins to left joins to avoid - // RIGHT JOIN handling at lower engine levels - if (rse->rse_jointype == blr_right) { - // Swap sub-streams - jrd_nod* temp = rse->rse_relation[0]; - rse->rse_relation[0] = rse->rse_relation[1]; - rse->rse_relation[1] = temp; + // Convert right outer joins to left joins to avoid + // RIGHT JOIN handling at lower engine levels + if (rse->rse_jointype == blr_right) { + // Swap sub-streams + jrd_nod* temp = rse->rse_relation[0]; + rse->rse_relation[0] = rse->rse_relation[1]; + rse->rse_relation[1] = temp; - rse->rse_jointype = blr_left; - } - return (jrd_nod*) rse; + rse->rse_jointype = blr_left; + } + return (jrd_nod*) rse; } } syntax_error(csb, (TEXT*)((rse_op == blr_rs_stream) ? diff --git a/src/jrd/perf.cpp b/src/jrd/perf.cpp index bd858e8924..b0a9a6efdc 100644 --- a/src/jrd/perf.cpp +++ b/src/jrd/perf.cpp @@ -246,7 +246,8 @@ void API_ROUTINE perf_get_info(FB_API_HANDLE* handle, PERF* perf) const char* p = buffer; while (true) - switch (*p++) { + switch (*p++) + { case isc_info_reads: perf->perf_reads = get_parameter(&p); break; @@ -283,12 +284,18 @@ void API_ROUTINE perf_get_info(FB_API_HANDLE* handle, PERF* perf) return; case isc_info_error: - if (p[2] == isc_info_marks) + switch (p[2]) + { + case isc_info_marks: perf->perf_marks = 0; - else if (p[2] == isc_info_current_memory) + break; + case isc_info_current_memory: perf->perf_current_memory = 0; - else if (p[2] == isc_info_max_memory) + break; + case isc_info_max_memory: perf->perf_max_memory = 0; + break; + } { const SLONG temp = isc_vax_integer(p, 2); fb_assert(temp <= MAX_SSHORT); diff --git a/src/jrd/rse.cpp b/src/jrd/rse.cpp index 2d72499882..aa2d13310d 100644 --- a/src/jrd/rse.cpp +++ b/src/jrd/rse.cpp @@ -2241,47 +2241,51 @@ static bool get_record(thread_db* tdbb, break; case rsb_skip: - switch (mode) { -#ifdef SCROLLABLE_CURSORS - case RSE_get_backward: - if (((irsb_skip_n*) impure)->irsb_count > 0) + { + irsb_skip_n* skip = (irsb_skip_n*) impure; + switch (mode) { - invalidate_child_rpbs(tdbb, rsb); - return false; - } - if (((irsb_skip_n*) impure)->irsb_count == 0) - { - ((irsb_skip_n*) impure)->irsb_count++; - if (get_record(tdbb, rsb->rsb_next, NULL, mode)) + #ifdef SCROLLABLE_CURSORS + case RSE_get_backward: + if (skip->irsb_count > 0) + { invalidate_child_rpbs(tdbb, rsb); - return false; - } - ((irsb_skip_n*) impure)->irsb_count++; - if (!get_record(tdbb, rsb->rsb_next, NULL, mode)) - return false; - break; - - case RSE_get_current: - if (((irsb_skip_n*) impure)->irsb_count >= 1) - { - invalidate_child_rpbs(tdbb, rsb); - return false; - } - else if (!get_record(tdbb, rsb->rsb_next, NULL, mode)) - return false; - break; -#endif - - case RSE_get_forward: - while (((irsb_skip_n*) impure)->irsb_count > 1) { - ((irsb_skip_n*) impure)->irsb_count--; + return false; + } + if (skip->irsb_count == 0) + { + skip->irsb_count++; + if (get_record(tdbb, rsb->rsb_next, NULL, mode)) + invalidate_child_rpbs(tdbb, rsb); + return false; + } + skip->irsb_count++; if (!get_record(tdbb, rsb->rsb_next, NULL, mode)) return false; + break; + + case RSE_get_current: + if (skip->irsb_count >= 1) + { + invalidate_child_rpbs(tdbb, rsb); + return false; + } + if (!get_record(tdbb, rsb->rsb_next, NULL, mode)) + return false; + break; + #endif + + case RSE_get_forward: + while (skip->irsb_count > 1) { + skip->irsb_count--; + if (!get_record(tdbb, rsb->rsb_next, NULL, mode)) + return false; + } + skip->irsb_count--; + if (!get_record(tdbb, rsb->rsb_next, NULL, mode)) + return false; + break; } - ((irsb_skip_n*) impure)->irsb_count--; - if (!get_record(tdbb, rsb->rsb_next, NULL, mode)) - return false; - break; } break; diff --git a/src/jrd/scl.epp b/src/jrd/scl.epp index 8b7f311506..9860a0236a 100644 --- a/src/jrd/scl.epp +++ b/src/jrd/scl.epp @@ -144,26 +144,26 @@ void SCL_check_access(const SecurityClass* s_class, 0); } - const Attachment* const attachment = tdbb->getAttachment(); + const Attachment& attachment = *tdbb->getAttachment(); // Allow the database owner to back up a database even if he does not have // read access to all the tables in the database - if ((attachment->att_flags & ATT_gbak_attachment) && (mask & SCL_read)) + if ((attachment.att_flags & ATT_gbak_attachment) && (mask & SCL_read)) { return; } // Allow the locksmith any access to database - if (attachment->locksmith()) + if (attachment.locksmith()) { return; } bool denied_db = false; - const SecurityClass* const att_class = attachment->att_security_class; + const SecurityClass* const att_class = attachment.att_security_class; if (att_class && !(att_class->scl_flags & mask)) { denied_db = true; @@ -974,6 +974,7 @@ static bool check_user_group(const UCHAR* acl, else // processing group name { Firebird::UCharBuffer buffer; + fb_assert(l < length); // Not sure how we can guarantee this. UCHAR* user_group_name = buffer.getBuffer(length); do { const TEXT one_char = *acl++; diff --git a/src/jrd/tra.cpp b/src/jrd/tra.cpp index 8325a4200a..c0b2b5cbd9 100644 --- a/src/jrd/tra.cpp +++ b/src/jrd/tra.cpp @@ -646,8 +646,10 @@ int TRA_get_state(thread_db* tdbb, SLONG number) return TPC_snapshot_state(tdbb, number); if (number && dbb->dbb_pc_transactions) + { if (TRA_precommited(tdbb, number, number)) return tra_precommitted; + } return TRA_fetch_state(tdbb, number); } @@ -1069,7 +1071,7 @@ void TRA_release_transaction(thread_db* tdbb, jrd_tra* transaction) } } - { + { // scope vec& rels = *dbb->dbb_relations; for (size_t i = 0; i < rels.count(); i++) { @@ -1080,7 +1082,7 @@ void TRA_release_transaction(thread_db* tdbb, jrd_tra* transaction) } } - } + } // end scope // Release the locks associated with the transaction @@ -1275,10 +1277,8 @@ void TRA_rollback(thread_db* tdbb, jrd_tra* transaction, const bool retaining_fl retain_context(tdbb, transaction, false, state); return; } - else { - TRA_set_state(tdbb, transaction, transaction->tra_number, state); - } + TRA_set_state(tdbb, transaction, transaction->tra_number, state); TRA_release_transaction(tdbb, transaction); } @@ -1352,16 +1352,15 @@ void TRA_set_state(thread_db* tdbb, jrd_tra* transaction, SLONG number, SSHORT s if (transaction && !(transaction->tra_flags & TRA_write)) return; - else { - { //scope - Database::Checkout dcoHolder(dbb); - THREAD_YIELD(); - } - tip = reinterpret_cast(CCH_FETCH(tdbb, &window, LCK_write, pag_transactions)); - if (generation == tip->pag_generation) - CCH_MARK_MUST_WRITE(tdbb, &window); - CCH_RELEASE(tdbb, &window); + + { //scope + Database::Checkout dcoHolder(dbb); + THREAD_YIELD(); } + tip = reinterpret_cast(CCH_FETCH(tdbb, &window, LCK_write, pag_transactions)); + if (generation == tip->pag_generation) + CCH_MARK_MUST_WRITE(tdbb, &window); + CCH_RELEASE(tdbb, &window); #endif } @@ -1450,8 +1449,8 @@ int TRA_snapshot_state(thread_db* tdbb, const jrd_tra* trans, SLONG number) int state = TPC_snapshot_state(tdbb, number); if (state == tra_active) return tra_committed; - else - return state; + + return state; } // If the transaction is a commited sub-transction - do the easy lookup. diff --git a/src/jrd/why.cpp b/src/jrd/why.cpp index b3b2d75754..96f39473ee 100644 --- a/src/jrd/why.cpp +++ b/src/jrd/why.cpp @@ -4191,7 +4191,7 @@ ISC_STATUS API_ROUTINE GDS_RECONNECT(ISC_STATUS* user_status, &handle, length, id)) { - return status[1]; + return status[1]; } new Transaction(handle, tra_handle, dbb); @@ -5352,8 +5352,10 @@ static Transaction* find_transaction(Attachment* dbb, **************************************/ for (; transaction; transaction = transaction->next) + { if (transaction->parent == dbb) return transaction; + } return NULL; } @@ -5741,6 +5743,7 @@ static ISC_STATUS prepare(ISC_STATUS* user_status, length = p - description; for (sub = transaction->next; sub; sub = sub->next) + { if (CALL(PROC_PREPARE, sub->implementation) (status, &sub->handle, length, description)) @@ -5750,6 +5753,7 @@ static ISC_STATUS prepare(ISC_STATUS* user_status, } return status[1]; } + } if (description != tdr_buffer) free_block(description);