diff --git a/logdoctor/modules/checks.cpp b/logdoctor/modules/checks.cpp index d22adcb3..401a2e10 100644 --- a/logdoctor/modules/checks.cpp +++ b/logdoctor/modules/checks.cpp @@ -81,7 +81,6 @@ bool CheckSec::newStatsDatabase( QSqlDatabase& db, const std::string& db_path, c } else { // succesfully creted database file, now create the tables QSqlQuery query; - int tries; for ( const QString& ws_name : ws_names ) { if ( successful == false ) { break; } // compose the statement with the table name for the access logs @@ -405,7 +404,6 @@ bool CheckSec::newHashesDatabase( QSqlDatabase& db, const std::string& db_path, } else { // succesfully creted database file, now create the tables QSqlQuery query; - int tries; for ( const QString& ws_name : ws_names ) { if ( successful == false ) { break; } // compose the statement with the table name for the access logs diff --git a/logdoctor/tools/craplog/modules/hash.cpp b/logdoctor/tools/craplog/modules/hash.cpp index c7fe19df..8191bea2 100644 --- a/logdoctor/tools/craplog/modules/hash.cpp +++ b/logdoctor/tools/craplog/modules/hash.cpp @@ -33,13 +33,6 @@ bool HashOps::loadUsedHashesLists( const std::string& db_path ) { bool successful = true; const QString db_name = QString::fromStdString( db_path.substr( db_path.find_last_of( '/' ) + 1 ) ); - const std::unordered_map ws_names = { - {11, "apache"}, - {12, "nginx"}, - {13, "iis"} }; - const std::unordered_map log_types = { - {1, "access"}, - {2, "error"} }; QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName( QString::fromStdString( db_path ) ); @@ -55,8 +48,8 @@ bool HashOps::loadUsedHashesLists( const std::string& db_path ) } else { QSqlQuery query = QSqlQuery( db ); - for ( const auto& [wid,name] : ws_names ) { - for ( const auto& [tid,type] : log_types ) { + for ( const auto& [wid,name] : this->ws_names ) { + for ( const auto& [tid,type] : this->log_types ) { if ( query.exec("SELECT hash FROM "+name+"_"+type+";") == false ) { // error querying database successful = false; diff --git a/logdoctor/tools/craplog/modules/logs.h b/logdoctor/tools/craplog/modules/logs.h index 764716ee..506499af 100644 --- a/logdoctor/tools/craplog/modules/logs.h +++ b/logdoctor/tools/craplog/modules/logs.h @@ -61,7 +61,7 @@ private: const FormatOps::LogsFormat& format ); // temporary vars - int size, lines; + int size=0, lines=0; }; diff --git a/logdoctor/tools/crapview/modules/query.cpp b/logdoctor/tools/crapview/modules/query.cpp index f0134786..d7f63ba8 100644 --- a/logdoctor/tools/crapview/modules/query.cpp +++ b/logdoctor/tools/crapview/modules/query.cpp @@ -263,7 +263,6 @@ void DbQuery::updateWarnings( const QString& web_server, const QString& log_type if ( db.open() == false ) { // error opening database - successful = false; QString err_msg = ""; if ( this->dialog_level == 2 ) { err_msg = db.lastError().text(); @@ -364,7 +363,7 @@ void DbQuery::getWarnCounts( std::tupleMSG_ERR_UNX_LT).arg( log_type ), true ); } } - int year, month, day, hour, minute; + int year, month, day, hour; if ( successful == true ) { // setup period limits try { @@ -620,16 +619,16 @@ void DbQuery::getSpeedData(std::tupleLogFields_to_DbFields.value( log_field_1_ ), log_field_2 = this->LogFields_to_DbFields.value( log_field_2_ ); - int hour, aux_hour, minute, aux_minute, count; - // 1 month, no need to loop stmt = QString("SELECT \"hour\", \"minute\" FROM \"%1\" WHERE \"year\"=%2 AND \"month\"=%3 AND \"day\"=%4") .arg( table.replace("'","''") ) @@ -1381,6 +1378,7 @@ void DbQuery::getRelationalCountsDay(std::tupleLogFields_to_DbFields.value( log_field_1_ ), log_field_2 = this->LogFields_to_DbFields.value( log_field_2_ ); - int n_days = 0, - n_months = this->getMonthsCount( from_year, from_month, to_year, to_month ); + int n_months = this->getMonthsCount( from_year, from_month, to_year, to_month ); QDateTime time; int year = from_year, diff --git a/logdoctor/utilities/io.cpp b/logdoctor/utilities/io.cpp index c303dc87..ba1849d5 100644 --- a/logdoctor/utilities/io.cpp +++ b/logdoctor/utilities/io.cpp @@ -108,7 +108,6 @@ bool IOutils::renameAsCopy( const std::string& path ) noexcept(true) const std::vector IOutils::readLines(const std::string& path, const int n_lines, const bool random, const bool strip_lines ) { // read rhe first N lines only - bool result = true; std::ifstream file; std::string line; std::vector lines, aux_lines; @@ -175,7 +174,6 @@ const std::vector IOutils::readLines(const std::string& path, const // failed reading lines.clear(); aux_lines.clear(); - result = false; if ( file.is_open() ) { file.close(); } @@ -183,7 +181,6 @@ const std::vector IOutils::readLines(const std::string& path, const } catch (...) { lines.clear(); aux_lines.clear(); - result = false; if ( file.is_open() ) { file.close(); } @@ -192,6 +189,7 @@ const std::vector IOutils::readLines(const std::string& path, const if ( file.is_open() ) { file.close(); } + aux_lines.clear(); return lines; } @@ -203,7 +201,7 @@ const std::string IOutils::readFile( const std::string& path ) std::string content = std::string(); try { constexpr std::size_t read_size = std::size_t(4096); - std::ifstream file(path); + file = std::ifstream(path); if ( file.is_open() == false ) { throw std::ios_base::failure( "file is not open" ); } @@ -219,13 +217,11 @@ const std::string IOutils::readFile( const std::string& path ) std::istreambuf_iterator() ); } catch (const std::ios_base::failure& err) { // failed reading - content = ""; if ( file.is_open() == true ) { file.close(); } throw err; } catch (...) { - content = ""; if ( file.is_open() == true ) { file.close(); } diff --git a/logdoctor/utilities/rtf.cpp b/logdoctor/utilities/rtf.cpp index 716df505..45d83b73 100644 --- a/logdoctor/utilities/rtf.cpp +++ b/logdoctor/utilities/rtf.cpp @@ -27,7 +27,7 @@ void RichText::enrichLogs( QString &rich_content, const std::string& content, co QString rich_line="", class_name=""; std::string sep, fld, fld_str, aux_sep1, aux_sep2, aux_fld_str; bool missing=false; - int start, stop=0, i, aux_start1, aux_start2, aux_stop, + int start, stop, i, aux_start1, aux_start2, aux_stop, line_size, sep_size, n_sep = logs_format.separators.size()-1; std::vector lines; diff --git a/logdoctor/utilities/strings.cpp b/logdoctor/utilities/strings.cpp index 634fd6e2..ab2eabf4 100644 --- a/logdoctor/utilities/strings.cpp +++ b/logdoctor/utilities/strings.cpp @@ -138,7 +138,7 @@ std::string StringOps::lstrip( const std::string& str, const std::string& chars std::string StringOps::rstrip( const std::string& str, const std::string& chars ) { - bool found = true; + bool found; int i = str.size() - 1; while ( i >= 0 ) { found = false; @@ -233,8 +233,8 @@ void StringOps::split( std::vector& list, const std::string& target void StringOps::splitrip( std::vector& list, const std::string& target_str, const std::string& separator, const std::string& strip ) { std::vector aux; - const std::string str = StringOps::strip( target_str, strip ); - StringOps::split( aux, str, separator ); + const std::string str_ = StringOps::strip( target_str, strip ); + StringOps::split( aux, str_, separator ); for ( const std::string& str : aux ) { if ( str.size() == 0 ) { continue;