diff --git a/dbcon/dmlpackage/dml-scan.sh b/dbcon/dmlpackage/dml-scan.sh index 33299e477..1daa312cf 100755 --- a/dbcon/dmlpackage/dml-scan.sh +++ b/dbcon/dmlpackage/dml-scan.sh @@ -5,10 +5,10 @@ set +e; \ if [ -f dml-scan.cpp ]; \ then diff -abBq dml-scan-temp.cpp dml-scan.cpp >/dev/null 2>&1; \ - if [ $$? -ne 0 ]; \ + if [ $? -ne 0 ]; \ then mv -f dml-scan-temp.cpp dml-scan.cpp; \ else touch dml-scan.cpp; \ fi; \ else mv -f dml-scan-temp.cpp dml-scan.cpp; \ fi - rm -f dml-scan-temp.cpp \ No newline at end of file + rm -f dml-scan-temp.cpp diff --git a/dbcon/execplan/arithmeticoperator.cpp b/dbcon/execplan/arithmeticoperator.cpp index 71857a8fa..57b77381a 100644 --- a/dbcon/execplan/arithmeticoperator.cpp +++ b/dbcon/execplan/arithmeticoperator.cpp @@ -40,22 +40,6 @@ struct to_lower } }; -//Trim any leading/trailing ws -const string lrtrim(const string& in) -{ - string::size_type p1; - p1 = in.find_first_not_of(" \t\n"); - - if (p1 == string::npos) p1 = 0; - - string::size_type p2; - p2 = in.find_last_not_of(" \t\n"); - - if (p2 == string::npos) p2 = in.size() - 1; - - return string(in, p1, (p2 - p1 + 1)); -} - } namespace execplan diff --git a/dbcon/execplan/logicoperator.cpp b/dbcon/execplan/logicoperator.cpp index a5353e472..a466017da 100644 --- a/dbcon/execplan/logicoperator.cpp +++ b/dbcon/execplan/logicoperator.cpp @@ -40,22 +40,6 @@ struct to_lower } }; -//Trim any leading/trailing ws -const string lrtrim(const string& in) -{ - string::size_type p1; - p1 = in.find_first_not_of(" \t\n"); - - if (p1 == string::npos) p1 = 0; - - string::size_type p2; - p2 = in.find_last_not_of(" \t\n"); - - if (p2 == string::npos) p2 = in.size() - 1; - - return string(in, p1, (p2 - p1 + 1)); -} - } namespace execplan diff --git a/dbcon/execplan/predicateoperator.cpp b/dbcon/execplan/predicateoperator.cpp index 704ab3a63..b32de94c2 100644 --- a/dbcon/execplan/predicateoperator.cpp +++ b/dbcon/execplan/predicateoperator.cpp @@ -46,22 +46,6 @@ struct to_lower } }; -//Trim any leading/trailing ws -const string lrtrim(const string& in) -{ - string::size_type p1; - p1 = in.find_first_not_of(" \t\n"); - - if (p1 == string::npos) p1 = 0; - - string::size_type p2; - p2 = in.find_last_not_of(" \t\n"); - - if (p2 == string::npos) p2 = in.size() - 1; - - return string(in, p1, (p2 - p1 + 1)); -} - } namespace execplan diff --git a/dbcon/execplan/treenode.h b/dbcon/execplan/treenode.h index 9fea74984..9c4283042 100644 --- a/dbcon/execplan/treenode.h +++ b/dbcon/execplan/treenode.h @@ -1136,7 +1136,9 @@ inline int64_t TreeNode::getDatetimeIntVal() dataconvert::Time tt; int day = 0; - memcpy(&tt, &fResult.intVal, 8); + void *ttp = static_cast(&tt); + + memcpy(ttp, &fResult.intVal, 8); // Note, this should probably be current date +/- time if ((tt.hour > 23) && (!tt.is_neg)) @@ -1166,7 +1168,7 @@ inline int64_t TreeNode::getTimeIntVal() { dataconvert::DateTime dt; - memcpy(&dt, &fResult.intVal, 8); + memcpy((int64_t*)(&dt), &fResult.intVal, 8); dataconvert::Time tt(0, dt.hour, dt.minute, dt.second, dt.msecond, false); memcpy(&fResult.intVal, &tt, 8); return fResult.intVal; diff --git a/dbcon/joblist/jlf_subquery.cpp b/dbcon/joblist/jlf_subquery.cpp index 7f2544be8..56dba64d7 100644 --- a/dbcon/joblist/jlf_subquery.cpp +++ b/dbcon/joblist/jlf_subquery.cpp @@ -336,7 +336,8 @@ bool isNotInSubquery(JobStepVector& jsv) return notIn; } - +// This fcn is currently unused. Will keep it in the code for now. +#if 0 void alterCsepInExistsFilter(CalpontSelectExecutionPlan* csep, JobInfo& jobInfo) { // This is for window function in IN/EXISTS sub-query. @@ -364,7 +365,7 @@ void alterCsepInExistsFilter(CalpontSelectExecutionPlan* csep, JobInfo& jobInfo) if (wcs.size() > 1) retCols.insert(retCols.end(), wcs.begin() + 1, wcs.end()); } - +#endif void doCorrelatedExists(const ExistsFilter* ef, JobInfo& jobInfo) { diff --git a/dbcon/joblist/joblistfactory.cpp b/dbcon/joblist/joblistfactory.cpp index 788cf5cc9..30e683988 100644 --- a/dbcon/joblist/joblistfactory.cpp +++ b/dbcon/joblist/joblistfactory.cpp @@ -94,68 +94,6 @@ namespace { using namespace joblist; -//Find the next step downstream from *in. Assumes only the first such step is needed. -const JobStepVector::iterator getNextStep(JobStepVector::iterator& in, JobStepVector& list) -{ - JobStepVector::iterator end = list.end(); - - for (unsigned i = 0; i < in->get()->outputAssociation().outSize(); ++i) - { - JobStepVector::iterator iter = list.begin(); - AnyDataListSPtr outAdl = in->get()->outputAssociation().outAt(i); - - while (iter != end) - { - if (iter != in) - { - AnyDataListSPtr inAdl; - - for (unsigned j = 0; j < iter->get()->inputAssociation().outSize(); j++) - { - inAdl = iter->get()->inputAssociation().outAt(j); - - if (inAdl.get() == outAdl.get()) - return iter; - } - } - - ++iter; - } - } - - return end; -} - - -bool checkCombinable(JobStep* jobStepPtr) -{ - if (typeid(*(jobStepPtr)) == typeid(pColScanStep)) - { - return true; - } - else if (typeid(*(jobStepPtr)) == typeid(PseudoColStep)) - { - return true; - } - else if (typeid(*(jobStepPtr)) == typeid(pColStep)) - { - return true; - } - else if (typeid(*(jobStepPtr)) == typeid(pDictionaryStep)) - { - return true; - } - else if (typeid(*(jobStepPtr)) == typeid(PassThruStep)) - { - return true; - } - else if (typeid(*(jobStepPtr)) == typeid(FilterStep)) - { - return true; - } - - return false; -} void projectSimpleColumn(const SimpleColumn* sc, JobStepVector& jsv, JobInfo& jobInfo) { @@ -1447,54 +1385,6 @@ void changePcolStepToPcolScan(JobStepVector::iterator& it, JobStepVector::iterat } } -uint32_t shouldSort(const JobStep* inJobStep, int colWidth) -{ - //only pColStep and pColScan have colType - const pColStep* inStep = dynamic_cast(inJobStep); - - if (inStep && colWidth > inStep->colType().colWidth) - { - return 1; - } - - const pColScanStep* inScan = dynamic_cast(inJobStep); - - if (inScan && colWidth > inScan->colType().colWidth) - { - return 1; - } - - return 0; -} - -void convertPColStepInProjectToPassThru(JobStepVector& psv, JobInfo& jobInfo) -{ - for (JobStepVector::iterator iter = psv.begin(); iter != psv.end(); ++iter) - { - pColStep* colStep = dynamic_cast(iter->get()); - - if (colStep != NULL) - { - JobStepAssociation ia = iter->get()->inputAssociation(); - DataList_t* fifoDlp = ia.outAt(0).get()->dataList(); - - if (fifoDlp) - { - if (iter->get()->oid() >= 3000 && iter->get()->oid() == fifoDlp->OID()) - { - PassThruStep* pts = 0; - pts = new PassThruStep(*colStep); - pts->alias(colStep->alias()); - pts->view(colStep->view()); - pts->name(colStep->name()); - pts->tupleId(iter->get()->tupleId()); - iter->reset(pts); - } - } - } - } -} - // optimize filter order // perform none string filters first because string filter joins the tokens. void optimizeFilterOrder(JobStepVector& qsv) @@ -1819,7 +1709,7 @@ void makeVtableModeSteps(CalpontSelectExecutionPlan* csep, JobInfo& jobInfo, jobInfo.limitCount = (uint64_t) - 1; } - // support order by and limit in sub-query/union or + // support order by and limit in sub-query/union or // GROUP BY handler processed outer query order else if (csep->orderByCols().size() > 0) { diff --git a/dbcon/joblist/pdictionaryscan.cpp b/dbcon/joblist/pdictionaryscan.cpp index 6c1b7cecd..b8545b728 100644 --- a/dbcon/joblist/pdictionaryscan.cpp +++ b/dbcon/joblist/pdictionaryscan.cpp @@ -483,7 +483,8 @@ void pDictionaryScan::sendAPrimitiveMessage( ) { DictTokenByScanRequestHeader hdr; - memset(&hdr, 0, sizeof(hdr)); + void *hdrp = static_cast(&hdr); + memset(hdrp, 0, sizeof(hdr)); hdr.ism.Interleave = pm; hdr.ism.Flags = planFlagsToPrimFlags(fTraceFlags); @@ -913,7 +914,8 @@ void pDictionaryScan::serializeEqualityFilter() uint32_t i; vector empty; - memset(&ism, 0, sizeof(ISMPacketHeader)); + void *ismp = static_cast(&ism); + memset(ismp, 0, sizeof(ISMPacketHeader)); ism.Command = DICT_CREATE_EQUALITY_FILTER; msg.load((uint8_t*) &ism, sizeof(ISMPacketHeader)); msg << uniqueID; @@ -954,7 +956,8 @@ void pDictionaryScan::destroyEqualityFilter() ByteStream msg; ISMPacketHeader ism; - memset(&ism, 0, sizeof(ISMPacketHeader)); + void *ismp = static_cast(&ism); + memset(ismp, 0, sizeof(ISMPacketHeader)); ism.Command = DICT_DESTROY_EQUALITY_FILTER; msg.load((uint8_t*) &ism, sizeof(ISMPacketHeader)); msg << uniqueID; diff --git a/dbcon/joblist/windowfunctionstep.cpp b/dbcon/joblist/windowfunctionstep.cpp index 823b2bd04..fe43faa77 100644 --- a/dbcon/joblist/windowfunctionstep.cpp +++ b/dbcon/joblist/windowfunctionstep.cpp @@ -81,21 +81,6 @@ using namespace joblist; namespace { -string keyName(uint64_t i, uint32_t key, const joblist::JobInfo& jobInfo) -{ - string name = jobInfo.projectionCols[i]->alias(); - - if (name.empty()) - { - name = jobInfo.keyInfo->tupleKeyToName[key]; - - if (jobInfo.keyInfo->tupleKeyVec[key].fId < 100) - name = "Expression/Function"; - } - - return name = "'" + name + "'"; -} - uint64_t getColumnIndex(const SRCP& c, const map& m, JobInfo& jobInfo) { diff --git a/dbcon/mysql/ha_calpont_dml.cpp b/dbcon/mysql/ha_calpont_dml.cpp index 66edb13fa..e5f82f62b 100644 --- a/dbcon/mysql/ha_calpont_dml.cpp +++ b/dbcon/mysql/ha_calpont_dml.cpp @@ -88,103 +88,6 @@ inline uint32_t tid2sid(const uint32_t tid) } //StopWatch timer; -int buildBuffer(uchar* buf, string& buffer, int& columns, TABLE* table) -{ - char attribute_buffer[1024]; - String attribute(attribute_buffer, sizeof(attribute_buffer), - &my_charset_bin); - - std::string cols = " ("; - std::string vals = " values ("; - columns = 0; - - for (Field** field = table->field; *field; field++) - { - const char* ptr; - const char* end_ptr; - - if ((*field)->is_null()) - ptr = end_ptr = 0; - else - { - bitmap_set_bit(table->read_set, (*field)->field_index); - (*field)->val_str(&attribute, &attribute); - ptr = attribute.ptr(); - end_ptr = attribute.length() + ptr; - } - - if (columns > 0) - { - cols.append(","); - vals.append(","); - } - - columns++; - - cols.append((*field)->field_name.str); - - if (ptr == end_ptr) - { - vals.append ("NULL"); - } - else - { - - if ( (*field)->type() == MYSQL_TYPE_VARCHAR || - /*FIXME: (*field)->type() == MYSQL_TYPE_VARBINARY || */ - (*field)->type() == MYSQL_TYPE_VAR_STRING || - (*field)->type() == MYSQL_TYPE_STRING || - (*field)->type() == MYSQL_TYPE_DATE || - (*field)->type() == MYSQL_TYPE_DATETIME || - (*field)->type() == MYSQL_TYPE_DATETIME2 || - (*field)->type() == MYSQL_TYPE_TIME ) - vals.append("'"); - - while (ptr < end_ptr) - { - - if (*ptr == '\r') - { - ptr++; - } - else if (*ptr == '\n') - { - ptr++; - } - else if (*ptr == '\'' ) - { - //@Bug 1820. Replace apostrophe with strange character to pass parser. - vals += '\252'; - ptr++; - } - else - vals += *ptr++; - } - - if ( (*field)->type() == MYSQL_TYPE_VARCHAR || - /*FIXME: (*field)->type() == MYSQL_TYPE_VARBINARY || */ - (*field)->type() == MYSQL_TYPE_VAR_STRING || - (*field)->type() == MYSQL_TYPE_STRING || - (*field)->type() == MYSQL_TYPE_DATE || - (*field)->type() == MYSQL_TYPE_DATETIME || - (*field)->type() == MYSQL_TYPE_DATETIME2 || - (*field)->type() == MYSQL_TYPE_TIME ) - vals.append("'"); - } - } - - if (columns) - { - cols.append(") "); - vals.append(") "); - buffer = "INSERT INTO "; - buffer.append(table->s->table_name.str); - buffer.append(cols); - buffer.append(vals); - } - - return columns; -} uint32_t buildValueList (TABLE* table, cal_connection_info& ci ) { diff --git a/dbcon/mysql/ha_calpont_execplan.cpp b/dbcon/mysql/ha_calpont_execplan.cpp index e6acfadb9..cb31cc75a 100644 --- a/dbcon/mysql/ha_calpont_execplan.cpp +++ b/dbcon/mysql/ha_calpont_execplan.cpp @@ -4686,7 +4686,7 @@ ReturnedColumn* buildAggregateColumn(Item* item, gp_walk_info& gwi) } } } - catch (std::logic_error e) + catch (std::logic_error &e) { gwi.fatalParseError = true; gwi.parseErrorText = "error building Aggregate Function: "; diff --git a/dbcon/mysql/ha_calpont_impl.cpp b/dbcon/mysql/ha_calpont_impl.cpp index a2f4cfbe7..cc80f9898 100644 --- a/dbcon/mysql/ha_calpont_impl.cpp +++ b/dbcon/mysql/ha_calpont_impl.cpp @@ -2114,7 +2114,7 @@ int ha_calpont_impl_rnd_init(TABLE* table) //check whether the system is ready to process statement. #ifndef _MSC_VER static DBRM dbrm(true); - bool bSystemQueryReady = dbrm.getSystemQueryReady(); + int bSystemQueryReady = dbrm.getSystemQueryReady(); if (bSystemQueryReady == 0) { @@ -4269,7 +4269,7 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE //check whether the system is ready to process statement. #ifndef _MSC_VER static DBRM dbrm(true); - bool bSystemQueryReady = dbrm.getSystemQueryReady(); + int bSystemQueryReady = dbrm.getSystemQueryReady(); if (bSystemQueryReady == 0) { diff --git a/dbcon/mysql/ha_calpont_partition.cpp b/dbcon/mysql/ha_calpont_partition.cpp index 61063f2f6..7d2317661 100644 --- a/dbcon/mysql/ha_calpont_partition.cpp +++ b/dbcon/mysql/ha_calpont_partition.cpp @@ -239,21 +239,6 @@ struct PartitionInfo typedef map PartitionMap; -const string charcolToString(int64_t v) -{ - ostringstream oss; - char c; - - for (int i = 0; i < 8; i++) - { - c = v & 0xff; - oss << c; - v >>= 8; - } - - return oss.str(); -} - const string format(int64_t v, CalpontSystemCatalog::ColType& ct) { ostringstream oss; diff --git a/dbcon/mysql/is_columnstore_files.cpp b/dbcon/mysql/is_columnstore_files.cpp index 2ce7b1996..9bca1de21 100644 --- a/dbcon/mysql/is_columnstore_files.cpp +++ b/dbcon/mysql/is_columnstore_files.cpp @@ -100,6 +100,7 @@ static int generate_result(BRM::OID_t oid, BRM::DBRM* emp, TABLE* table, THD* th messageqcpp::MessageQueueClient* msgQueueClient; oam::Oam oam_instance; int pmId = 0; + int rc; emp->getExtents(oid, entries, false, false, true); @@ -121,7 +122,7 @@ static int generate_result(BRM::OID_t oid, BRM::DBRM* emp, TABLE* table, THD* th { oam_instance.getDbrootPmConfig(iter->dbRoot, pmId); } - catch (std::runtime_error) + catch (std::runtime_error&) { // MCOL-1116: If we are here a DBRoot is offline/missing iter++; @@ -137,14 +138,16 @@ static int generate_result(BRM::OID_t oid, BRM::DBRM* emp, TABLE* table, THD* th DbRootName << "DBRoot" << iter->dbRoot; std::string DbRootPath = config->getConfig("SystemConfig", DbRootName.str()); fileSize = compressedFileSize = 0; - snprintf(fullFileName, WriteEngine::FILE_NAME_SIZE, "%s/%s", DbRootPath.c_str(), oidDirName); + rc = snprintf(fullFileName, WriteEngine::FILE_NAME_SIZE, "%s/%s", DbRootPath.c_str(), oidDirName); std::ostringstream oss; oss << "pm" << pmId << "_WriteEngineServer"; std::string client = oss.str(); msgQueueClient = messageqcpp::MessageQueueClientPool::getInstance(oss.str()); - if (!get_file_sizes(msgQueueClient, fullFileName, &fileSize, &compressedFileSize)) + // snprintf output truncation check + if (rc == WriteEngine::FILE_NAME_SIZE || + !get_file_sizes(msgQueueClient, fullFileName, &fileSize, &compressedFileSize)) { messageqcpp::MessageQueueClientPool::releaseInstance(msgQueueClient); delete emp; diff --git a/ddlproc/ddlproc.cpp b/ddlproc/ddlproc.cpp index 6f827f8fd..5cc663fc2 100644 --- a/ddlproc/ddlproc.cpp +++ b/ddlproc/ddlproc.cpp @@ -71,14 +71,15 @@ namespace { DistributedEngineComm* Dec; -void setupCwd() +int8_t setupCwd() { string workdir = startup::StartUp::tmpDir(); if (workdir.length() == 0) workdir = "."; - (void)chdir(workdir.c_str()); + int8_t rc = chdir(workdir.c_str()); + return rc; } void added_a_pm(int) @@ -103,7 +104,18 @@ int main(int argc, char* argv[]) // This is unset due to the way we start it program_invocation_short_name = const_cast("DDLProc"); - setupCwd(); + if ( setupCwd() < 0 ) + { + LoggingID logid(23, 0, 0); + logging::Message::Args args1; + logging::Message msg(9); + args1.add("DDLProc could not set working directory "); + msg.format( args1 ); + logging::Logger logger(logid.fSubsysID); + logger.logMessage(LOG_TYPE_CRITICAL, msg, logid); + return 1; + } + WriteEngine::WriteEngineWrapper::init( WriteEngine::SUBSYSTEM_ID_DDLPROC ); #ifdef _MSC_VER diff --git a/dmlproc/dmlproc.cpp b/dmlproc/dmlproc.cpp index f7fedbf18..a3e6fa713 100644 --- a/dmlproc/dmlproc.cpp +++ b/dmlproc/dmlproc.cpp @@ -491,17 +491,19 @@ void rollbackAll(DBRM* dbrm) dbrm->setSystemReady(true); } -void setupCwd() +int8_t setupCwd() { string workdir = startup::StartUp::tmpDir(); if (workdir.length() == 0) workdir = "."; - (void)chdir(workdir.c_str()); + int8_t rc = chdir(workdir.c_str()); - if (access(".", W_OK) != 0) - (void)chdir("/tmp"); + if (rc < 0 || access(".", W_OK) != 0) + rc = chdir("/tmp"); + + return rc; } } // Namewspace @@ -520,7 +522,18 @@ int main(int argc, char* argv[]) Config* cf = Config::makeConfig(); - setupCwd(); + if ( setupCwd() ) + { + LoggingID logid(21, 0, 0); + logging::Message::Args args1; + logging::Message msg(1); + args1.add("DMLProc couldn't cwd."); + msg.format( args1 ); + logging::Logger logger(logid.fSubsysID); + logger.logMessage(LOG_TYPE_CRITICAL, msg, logid); + return 1; + } + WriteEngine::WriteEngineWrapper::init( WriteEngine::SUBSYSTEM_ID_DMLPROC ); #ifdef _MSC_VER @@ -609,9 +622,20 @@ int main(int argc, char* argv[]) try { string port = cf->getConfig(DMLProc, "Port"); - string cmd = "fuser -k " + port + "/tcp >/dev/null 2>&1"; + string cmd = "fuser -k " + port + "/tcp >/dev/null 2>&1"; + // Couldn't check the return code b/c + // fuser returns 1 for unused port. +#if defined(__GNUC__) && __GNUC__ >= 5 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" (void)::system(cmd.c_str()); +#pragma GCC diagnostic pop +#else + (void)::system(cmd.c_str()); +#endif + + } catch (...) { diff --git a/exemgr/main.cpp b/exemgr/main.cpp index 8c6d8b475..e972c40ad 100644 --- a/exemgr/main.cpp +++ b/exemgr/main.cpp @@ -1301,10 +1301,12 @@ void setupSignalHandlers() void setupCwd(joblist::ResourceManager* rm) { std::string workdir = rm->getScWorkingDir(); - (void)chdir(workdir.c_str()); + int8_t rc = chdir(workdir.c_str()); - if (access(".", W_OK) != 0) - (void)chdir("/tmp"); + if (rc < 0 || access(".", W_OK) != 0) + rc = chdir("/tmp"); + + return (rc < 0) ? -5 : rc; } void startRssMon(size_t maxPct, int pauseSeconds) @@ -1470,9 +1472,12 @@ int main(int argc, char* argv[]) break; default: + errMsg = "Couldn't change working directory or unknown error"; break; } + err = setupCwd(rm); + if (err < 0) { oam::Oam oam; @@ -1496,9 +1501,6 @@ int main(int argc, char* argv[]) return 2; } - - setupCwd(rm); - cleanTempDir(); logging::MsgMap msgMap; diff --git a/oam/oamcpp/CMakeLists.txt b/oam/oamcpp/CMakeLists.txt index 10f98a7cc..72d6cdae2 100644 --- a/oam/oamcpp/CMakeLists.txt +++ b/oam/oamcpp/CMakeLists.txt @@ -10,6 +10,8 @@ add_library(oamcpp SHARED ${oamcpp_LIB_SRCS}) target_link_libraries(oamcpp ) +target_compile_options(oamcpp PRIVATE -Wno-unused-result) + set_target_properties(oamcpp PROPERTIES VERSION 1.0.0 SOVERSION 1) install(TARGETS oamcpp DESTINATION ${ENGINE_LIBDIR} COMPONENT libs) diff --git a/oam/oamcpp/liboamcpp.cpp b/oam/oamcpp/liboamcpp.cpp index 805c7d5d0..927250cfc 100644 --- a/oam/oamcpp/liboamcpp.cpp +++ b/oam/oamcpp/liboamcpp.cpp @@ -154,12 +154,14 @@ Oam::Oam() char* p = getenv("USER"); if (p && *p) - USER = p; + USER = p; userDir = USER; if ( USER != "root") - userDir = "home/" + USER; + { + userDir = "home/" + USER; + } tmpdir = startup::StartUp::tmpDir(); @@ -2901,8 +2903,6 @@ oamModuleInfo_t Oam::getModuleInfo() // Get Server Type Install ID serverTypeInstall = atoi(sysConfig->getConfig("Installation", "ServerTypeInstall").c_str()); - - sysConfig; } catch (...) {} @@ -8563,9 +8563,6 @@ std::string Oam::createEC2Volume(std::string size, std::string name) oldFile.close(); - if ( volumeName == "unknown" ) - return "failed"; - if ( volumeName == "unknown" ) return "failed"; @@ -8601,7 +8598,7 @@ bool Oam::attachEC2Volume(std::string volumeName, std::string deviceName, std::s writeLog("attachEC2Volume: Attach failed, call detach:" + volumeName + " " + instanceName + " " + deviceName, LOG_TYPE_ERROR ); detachEC2Volume(volumeName); - } + } else return true; } @@ -10470,12 +10467,8 @@ void Oam::sendStatusUpdate(ByteStream obs, ByteStream::byte returnRequestType) if (ibs.length() > 0) { ibs >> returnRequestType; - - if ( returnRequestType == returnRequestType ) - { - processor.shutdown(); - return; - } + processor.shutdown(); + return; } else { diff --git a/oamapps/alarmmanager/CMakeLists.txt b/oamapps/alarmmanager/CMakeLists.txt index 73c069153..a6b12ab75 100644 --- a/oamapps/alarmmanager/CMakeLists.txt +++ b/oamapps/alarmmanager/CMakeLists.txt @@ -8,6 +8,8 @@ set(alarmmanager_LIB_SRCS alarmmanager.cpp alarm.cpp) add_library(alarmmanager SHARED ${alarmmanager_LIB_SRCS}) +target_compile_options(alarmmanager PRIVATE -Wno-unused-result) + set_target_properties(alarmmanager PROPERTIES VERSION 1.0.0 SOVERSION 1) install(TARGETS alarmmanager DESTINATION ${ENGINE_LIBDIR} COMPONENT libs) diff --git a/oamapps/alarmmanager/alarmmanager.cpp b/oamapps/alarmmanager/alarmmanager.cpp index 10ca418d1..f07130c7b 100644 --- a/oamapps/alarmmanager/alarmmanager.cpp +++ b/oamapps/alarmmanager/alarmmanager.cpp @@ -484,8 +484,7 @@ void ALARMManager::sendAlarmReport (const char* componentID, int alarmID, int st else processName = repProcessName; - int returnStatus = API_SUCCESS; //default - ByteStream msg1; +ByteStream msg1; // setup message msg1 << (ByteStream::byte) alarmID; @@ -621,7 +620,7 @@ void ALARMManager::getActiveAlarm(AlarmList& alarmList) const *****************************************************************************************/ void ALARMManager::getAlarm(std::string date, AlarmList& alarmList) const { - + string alarmFile = startup::StartUp::tmpDir() + "/alarms"; //make 1 alarm log file made up of archive and current alarm.log diff --git a/oamapps/columnstoreSupport/CMakeLists.txt b/oamapps/columnstoreSupport/CMakeLists.txt index 6b612c8d3..9274b936c 100644 --- a/oamapps/columnstoreSupport/CMakeLists.txt +++ b/oamapps/columnstoreSupport/CMakeLists.txt @@ -8,6 +8,8 @@ set(columnstoreSupport_SRCS columnstoreSupport.cpp) add_executable(columnstoreSupport ${columnstoreSupport_SRCS}) +target_compile_options(columnstoreSupport PRIVATE -Wno-unused-result) + target_link_libraries(columnstoreSupport ${ENGINE_LDFLAGS} readline ncurses ${MARIADB_CLIENT_LIBS} ${ENGINE_EXEC_LIBS}) install(TARGETS columnstoreSupport DESTINATION ${ENGINE_BINDIR} COMPONENT platform) diff --git a/oamapps/mcsadmin/CMakeLists.txt b/oamapps/mcsadmin/CMakeLists.txt index 8181c2aec..1052d77f8 100644 --- a/oamapps/mcsadmin/CMakeLists.txt +++ b/oamapps/mcsadmin/CMakeLists.txt @@ -8,6 +8,8 @@ set(mcsadmin_SRCS mcsadmin.cpp) add_executable(mcsadmin ${mcsadmin_SRCS}) +target_compile_options(mcsadmin PRIVATE -Wno-unused-result) + target_link_libraries(mcsadmin ${ENGINE_LDFLAGS} readline ncurses ${MARIADB_CLIENT_LIBS} ${ENGINE_EXEC_LIBS} ${ENGINE_WRITE_LIBS}) install(TARGETS mcsadmin DESTINATION ${ENGINE_BINDIR} COMPONENT platform) diff --git a/oamapps/mcsadmin/mcsadmin.cpp b/oamapps/mcsadmin/mcsadmin.cpp index d07c67ffb..c0507aadd 100644 --- a/oamapps/mcsadmin/mcsadmin.cpp +++ b/oamapps/mcsadmin/mcsadmin.cpp @@ -3348,15 +3348,14 @@ int processCommand(string* arguments) for (i = alarmList.begin(); i != alarmList.end(); ++i) { - switch (i->second.getState()) + // SET = 1, CLEAR = 0 + if (i->second.getState() == true) { - case SET: - cout << "SET" << endl; - break; - - case CLEAR: - cout << "CLEAR" << endl; - break; + cout << "SET" << endl; + } + else + { + cout << "CLEAR" << endl; } cout << "AlarmID = " << i->second.getAlarmID() << endl; @@ -5904,7 +5903,6 @@ int processCommand(string* arguments) int moduleID = 1; inputNames::const_iterator listPT1 = inputnames.begin(); - umStorageNames::const_iterator listPT2 = umstoragenames.begin(); for ( int i = 0 ; i < moduleCount ; i++ ) { diff --git a/oamapps/postConfigure/CMakeLists.txt b/oamapps/postConfigure/CMakeLists.txt index 4bdbadd1a..fc6ded9b3 100644 --- a/oamapps/postConfigure/CMakeLists.txt +++ b/oamapps/postConfigure/CMakeLists.txt @@ -8,6 +8,8 @@ set(postConfigure_SRCS postConfigure.cpp helpers.cpp) add_executable(postConfigure ${postConfigure_SRCS}) +target_compile_options(postConfigure PRIVATE -Wno-unused-result) + target_link_libraries(postConfigure ${ENGINE_LDFLAGS} readline ncurses ${MARIADB_CLIENT_LIBS} ${ENGINE_EXEC_LIBS}) install(TARGETS postConfigure DESTINATION ${ENGINE_BINDIR} COMPONENT platform) @@ -19,6 +21,8 @@ set(installer_SRCS installer.cpp helpers.cpp) add_executable(installer ${installer_SRCS}) +target_compile_options(installer PRIVATE -Wno-unused-result) + target_link_libraries(installer ${ENGINE_LDFLAGS} readline ncurses ${MARIADB_CLIENT_LIBS} ${ENGINE_EXEC_LIBS}) install(TARGETS installer DESTINATION ${ENGINE_BINDIR} COMPONENT platform) @@ -52,6 +56,8 @@ set(mycnfUpgrade_SRCS mycnfUpgrade.cpp) add_executable(mycnfUpgrade ${mycnfUpgrade_SRCS}) +target_compile_options(mycnfUpgrade PRIVATE -Wno-unused-result) + target_link_libraries(mycnfUpgrade ${ENGINE_LDFLAGS} readline ncurses ${MARIADB_CLIENT_LIBS} ${ENGINE_EXEC_LIBS}) install(TARGETS mycnfUpgrade DESTINATION ${ENGINE_BINDIR} COMPONENT platform) diff --git a/oamapps/postConfigure/postConfigure.cpp b/oamapps/postConfigure/postConfigure.cpp index ad7d27d7a..eee8e0edf 100644 --- a/oamapps/postConfigure/postConfigure.cpp +++ b/oamapps/postConfigure/postConfigure.cpp @@ -273,9 +273,7 @@ int main(int argc, char* argv[]) //check if root-user int user; - int usergroup; user = getuid(); - usergroup = getgid(); string SUDO = ""; if (user != 0) @@ -1413,7 +1411,7 @@ int main(int argc, char* argv[]) { string amazonLog = tmpDir + "/amazon.log"; string cmd = "aws --version > " + amazonLog + " 2>&1"; - int rtnCode = system(cmd.c_str()); + system(cmd.c_str()); ifstream in(amazonLog.c_str()); @@ -1974,7 +1972,7 @@ int main(int argc, char* argv[]) } } - unsigned int maxPMNicCount = 1; + int maxPMNicCount = 1; //configure module type bool parentOAMmoduleConfig = false; @@ -2111,7 +2109,7 @@ int main(int argc, char* argv[]) //clear any Equipped Module IP addresses that aren't in current ID range for ( int j = 0 ; j < listSize ; j++ ) { - for ( unsigned int k = 1 ; k < MaxNicID+1 ; k++) + for ( int k = 1 ; k < MaxNicID+1 ; k++) { string ModuleIPAddr = "ModuleIPAddr" + oam.itoa(j + 1) + "-" + oam.itoa(k) + "-" + oam.itoa(i + 1); @@ -2185,8 +2183,7 @@ int main(int argc, char* argv[]) } } } - - unsigned int nicID=1; + int nicID=1; for( ; nicID < MaxNicID +1 ; nicID++ ) { if ( !found ) @@ -3547,7 +3544,7 @@ int main(int argc, char* argv[]) for ( int pmsID = 1; pmsID < pmPorts + 1 ; ) { - for (unsigned int j = 1 ; j < maxPMNicCount + 1 ; j++) + for (int j = 1 ; j < maxPMNicCount + 1 ; j++) { PerformanceModuleList::iterator list1 = performancemodulelist.begin(); @@ -4008,9 +4005,11 @@ int main(int argc, char* argv[]) break; } - if ( pass1 == "exit") + if ( strncmp(pass1, "exit", 4) ) + { exit(0); - + } + string p1 = pass1; pass2 = getpass("Confirm password > "); string p2 = pass2; @@ -6418,7 +6417,6 @@ bool glusterSetup(string password, bool doNotResolveHostNames) Oam oam; int dataRedundancyCopies = 0; int dataRedundancyNetwork = 0; - int dataRedundancyStorage = 0; int numberDBRootsPerPM = DBRootCount / pmNumber; int numberBricksPM = 0; std::vector dbrootPms[DBRootCount]; diff --git a/oamapps/serverMonitor/CMakeLists.txt b/oamapps/serverMonitor/CMakeLists.txt index 91d13bbd0..59fbad662 100644 --- a/oamapps/serverMonitor/CMakeLists.txt +++ b/oamapps/serverMonitor/CMakeLists.txt @@ -18,6 +18,8 @@ set(ServerMonitor_SRCS add_executable(ServerMonitor ${ServerMonitor_SRCS}) +target_compile_options(ServerMonitor PRIVATE -Wno-unused-result) + target_link_libraries(ServerMonitor ${ENGINE_LDFLAGS} ${MARIADB_CLIENT_LIBS} ${ENGINE_EXEC_LIBS}) install(TARGETS ServerMonitor DESTINATION ${ENGINE_BINDIR} COMPONENT platform) diff --git a/oamapps/serverMonitor/cpuMonitor.cpp b/oamapps/serverMonitor/cpuMonitor.cpp index c9d458a4f..1f1d6b3b3 100644 --- a/oamapps/serverMonitor/cpuMonitor.cpp +++ b/oamapps/serverMonitor/cpuMonitor.cpp @@ -569,7 +569,8 @@ void ServerMonitor::getCPUdata() while (oldFile.getline(line, 400)) { string buf = line; - string::size_type pos = buf.find ('id,', 0); + // Questionable replacement + string::size_type pos = buf.find("id,", 0); if (pos == string::npos) { systemIdle = systemIdle + atol(buf.substr(0, pos - 1).c_str()); diff --git a/oamapps/serverMonitor/msgProcessor.cpp b/oamapps/serverMonitor/msgProcessor.cpp index 48bfaa2f0..1c7b928ee 100644 --- a/oamapps/serverMonitor/msgProcessor.cpp +++ b/oamapps/serverMonitor/msgProcessor.cpp @@ -100,8 +100,8 @@ void msgProcessor() Config* sysConfig = Config::makeConfig(); string port = sysConfig->getConfig(msgPort, "Port"); string cmd = "fuser -k " + port + "/tcp >/dev/null 2>&1"; - int user; - user = getuid(); + //int user; + //user = getuid(); system(cmd.c_str()); } diff --git a/primitives/blockcache/filebuffer.cpp b/primitives/blockcache/filebuffer.cpp index 5ac6ee466..aa598c008 100644 --- a/primitives/blockcache/filebuffer.cpp +++ b/primitives/blockcache/filebuffer.cpp @@ -40,7 +40,10 @@ FileBuffer::FileBuffer() : fDataLen(0), fLbid(-1), fVerid(0) FileBuffer::FileBuffer(const FileBuffer& rhs) { - if (this == NULL || this == &rhs) + // Removed the check for gcc 8.2. The latest gcc version we + // use ATM is 4.8.2 for centos 6 and it also doesn't need + // the check + if (this == &rhs) return; fLbid = rhs.fLbid; diff --git a/primitives/blockcache/iomanager.cpp b/primitives/blockcache/iomanager.cpp index 8e5e063cd..2bf4526e5 100644 --- a/primitives/blockcache/iomanager.cpp +++ b/primitives/blockcache/iomanager.cpp @@ -283,71 +283,6 @@ FdCacheType_t fdcache; boost::mutex fdMapMutex; rwlock::RWLock_local localLock; -void pause_(unsigned secs) -{ - struct timespec req; - struct timespec rem; - - req.tv_sec = secs; - req.tv_nsec = 0; - - rem.tv_sec = 0; - rem.tv_nsec = 0; - -#ifdef _MSC_VER - Sleep(req.tv_sec * 1000); -#else -again: - - if (nanosleep(&req, &rem) != 0) - if (rem.tv_sec > 0 || rem.tv_nsec > 0) - { - req = rem; - goto again; - } - -#endif -} - -const vector > getDBRootList() -{ - vector > ret; - Config* config; - uint32_t dbrootCount, i; - string stmp, devname, mountpoint; - char devkey[80], mountkey[80]; - - config = Config::makeConfig(); - - stmp = config->getConfig("SystemConfig", "DBRootCount"); - - if (stmp.empty()) - { - Message::Args args; - args.add("getDBRootList: Configuration error. No DBRootCount"); - primitiveprocessor::mlp->logMessage(logging::M0006, args, true); - throw runtime_error("getDBRootList: Configuration error. No DBRootCount"); - } - - dbrootCount = config->uFromText(stmp); - - for (i = 1; i <= dbrootCount; i++) - { - snprintf(mountkey, 80, "DBRoot%d", i); - snprintf(devkey, 80, "DBRootStorageLoc%d", i); - mountpoint = config->getConfig("SystemConfig", string(mountkey)); - devname = config->getConfig("Installation", string(devkey)); - - if (mountpoint == "" || devname == "") - throw runtime_error("getDBRootList: Configuration error. Don't know where DBRoots are mounted"); - - ret.push_back(pair(devname, mountpoint)); -// cout << "I see " << devname << " should be mounted at " << mountpoint << endl; - } - - return ret; -} - char* alignTo(const char* in, int av) { ptrdiff_t inx = reinterpret_cast(in); @@ -769,7 +704,7 @@ void* thr_popper(ioManager* arg) int opts = primitiveprocessor::directIOFlag ? IDBDataFile::USE_ODIRECT : 0; fp = NULL; uint32_t openRetries = 0; - int saveErrno; + int saveErrno = 0; while (fp == NULL && openRetries++ < 5) { diff --git a/primitives/linux-port/column.cpp b/primitives/linux-port/column.cpp index 8832a6448..afa411f08 100644 --- a/primitives/linux-port/column.cpp +++ b/primitives/linux-port/column.cpp @@ -1425,7 +1425,8 @@ namespace primitives void PrimitiveProcessor::p_Col(NewColRequestHeader* in, NewColResultHeader* out, unsigned outSize, unsigned* written) { - memcpy(out, in, sizeof(ISMPacketHeader) + sizeof(PrimitiveHeader)); + void *outp = static_cast(out); + memcpy(outp, in, sizeof(ISMPacketHeader) + sizeof(PrimitiveHeader)); out->NVALS = 0; out->LBID = in->LBID; out->ism.Command = COL_RESULTS; diff --git a/primitives/linux-port/dictionary.cpp b/primitives/linux-port/dictionary.cpp index 2860ab571..e5a334436 100644 --- a/primitives/linux-port/dictionary.cpp +++ b/primitives/linux-port/dictionary.cpp @@ -127,7 +127,11 @@ void PrimitiveProcessor::p_TokenByScan(const TokenByScanRequestHeader* h, retTokens = reinterpret_cast(&niceRet[rdvOffset]); retDataValues = reinterpret_cast(&niceRet[rdvOffset]); - memcpy(ret, h, sizeof(PrimitiveHeader) + sizeof(ISMPacketHeader)); + + { + void *retp = static_cast(ret); + memcpy(retp, h, sizeof(PrimitiveHeader) + sizeof(ISMPacketHeader)); + } ret->NVALS = 0; ret->NBYTES = sizeof(TokenByScanResultHeader); ret->ism.Command = DICT_SCAN_COMPARE_RESULTS; @@ -575,7 +579,10 @@ void PrimitiveProcessor::p_AggregateSignature(const AggregateSignatureRequestHea DataValue* min; DataValue* max; - memcpy(out, in, sizeof(ISMPacketHeader) + sizeof(PrimitiveHeader)); + { + void *outp = static_cast(out); + memcpy(outp, in, sizeof(ISMPacketHeader) + sizeof(PrimitiveHeader)); + } out->ism.Command = DICT_AGGREGATE_RESULTS; niceOutput = reinterpret_cast(out); @@ -824,7 +831,10 @@ void PrimitiveProcessor::p_Dictionary(const DictInput* in, vector* out, in8 = reinterpret_cast(in); - memcpy(&header, in, sizeof(ISMPacketHeader) + sizeof(PrimitiveHeader)); + { + void *hp = static_cast(&header); + memcpy(hp, in, sizeof(ISMPacketHeader) + sizeof(PrimitiveHeader)); + } header.ism.Command = DICT_RESULTS; header.NVALS = 0; header.LBID = in->LBID; diff --git a/primitives/primproc/batchprimitiveprocessor.cpp b/primitives/primproc/batchprimitiveprocessor.cpp index 752c94d9e..bf34e9cb4 100644 --- a/primitives/primproc/batchprimitiveprocessor.cpp +++ b/primitives/primproc/batchprimitiveprocessor.cpp @@ -1774,8 +1774,10 @@ void BatchPrimitiveProcessor::writeErrorMsg(const string& error, uint16_t errCod // we don't need every field of these headers. Init'ing them anyway // makes memory checkers happy. - memset(&ism, 0, sizeof(ISMPacketHeader)); - memset(&ph, 0, sizeof(PrimitiveHeader)); + void *ismp = static_cast(&ism); + void *php = static_cast(&ph); + memset(ismp, 0, sizeof(ISMPacketHeader)); + memset(php, 0, sizeof(PrimitiveHeader)); ph.SessionID = sessionID; ph.StepID = stepID; ph.UniqueID = uniqueID; @@ -1800,8 +1802,10 @@ void BatchPrimitiveProcessor::writeProjectionPreamble() // we don't need every field of these headers. Init'ing them anyway // makes memory checkers happy. - memset(&ism, 0, sizeof(ISMPacketHeader)); - memset(&ph, 0, sizeof(PrimitiveHeader)); + void *ismp = static_cast(&ism); + void *php = static_cast(&ph); + memset(ismp, 0, sizeof(ISMPacketHeader)); + memset(php, 0, sizeof(PrimitiveHeader)); ph.SessionID = sessionID; ph.StepID = stepID; ph.UniqueID = uniqueID; @@ -1899,8 +1903,10 @@ void BatchPrimitiveProcessor::makeResponse() // we don't need every field of these headers. Init'ing them anyway // makes memory checkers happy. - memset(&ism, 0, sizeof(ISMPacketHeader)); - memset(&ph, 0, sizeof(PrimitiveHeader)); + void *ismp = static_cast(&ism); + void *php = static_cast(&ph); + memset(ismp, 0, sizeof(ISMPacketHeader)); + memset(php, 0, sizeof(PrimitiveHeader)); ph.SessionID = sessionID; ph.StepID = stepID; ph.UniqueID = uniqueID; diff --git a/primitives/primproc/columncommand.cpp b/primitives/primproc/columncommand.cpp index ed4b26a44..f5db52a2d 100644 --- a/primitives/primproc/columncommand.cpp +++ b/primitives/primproc/columncommand.cpp @@ -51,17 +51,6 @@ using namespace logging; #define llabs labs #endif -namespace -{ -using namespace primitiveprocessor; - -double cotangent(double in) -{ - return (1.0 / tan(in)); -} - -} - namespace primitiveprocessor { diff --git a/primitives/primproc/primitiveserver.cpp b/primitives/primproc/primitiveserver.cpp index 9359556e9..54f4b7fb6 100644 --- a/primitives/primproc/primitiveserver.cpp +++ b/primitives/primproc/primitiveserver.cpp @@ -1097,33 +1097,6 @@ namespace { using namespace primitiveprocessor; -void pause_(unsigned delay) -{ - struct timespec req; - struct timespec rem; - - req.tv_sec = delay; - req.tv_nsec = 0; - - rem.tv_sec = 0; - rem.tv_nsec = 0; -#ifdef _MSC_VER - Sleep(req.tv_sec * 1000); -#else -again: - - if (nanosleep(&req, &rem) != 0) - { - if (rem.tv_sec > 0 || rem.tv_nsec > 0) - { - req = rem; - goto again; - } - } - -#endif -} - /** @brief The job type to process a dictionary scan (pDictionaryScan class on the UM) * TODO: Move this & the impl into different files */ diff --git a/primitives/primproc/primproc.cpp b/primitives/primproc/primproc.cpp index 3fbd23d45..79222f216 100644 --- a/primitives/primproc/primproc.cpp +++ b/primitives/primproc/primproc.cpp @@ -148,17 +148,19 @@ void setupSignalHandlers() #endif } -void setupCwd(Config* cf) +int8_t setupCwd(Config* cf) { string workdir = startup::StartUp::tmpDir(); if (workdir.length() == 0) workdir = "."; - (void)chdir(workdir.c_str()); + int8_t rc = chdir(workdir.c_str()); - if (access(".", W_OK) != 0) - (void)chdir("/tmp"); + if (rc < 0 || access(".", W_OK) != 0) + rc = chdir("/tmp"); + + return rc; } int setupResources() @@ -344,11 +346,11 @@ int main(int argc, char* argv[]) setupSignalHandlers(); - setupCwd(cf); + int err = 0; + err = setupCwd(cf); mlp = new primitiveprocessor::Logger(); - int err = 0; if (!gDebug) err = setupResources(); string errMsg; @@ -368,6 +370,10 @@ int main(int argc, char* argv[]) errMsg = "Could not install file limits to required value, please see non-root install documentation"; break; + case -5: + errMsg = "Could not change into working directory"; + break; + default: break; } diff --git a/procmgr/CMakeLists.txt b/procmgr/CMakeLists.txt index 642890e13..99320901d 100644 --- a/procmgr/CMakeLists.txt +++ b/procmgr/CMakeLists.txt @@ -8,6 +8,8 @@ set(ProcMgr_SRCS main.cpp processmanager.cpp ../utils/common/crashtrace.cpp) add_executable(ProcMgr ${ProcMgr_SRCS}) +target_compile_options(ProcMgr PRIVATE -Wno-unused-result) + target_link_libraries(ProcMgr ${ENGINE_LDFLAGS} cacheutils ${NETSNMP_LIBRARIES} ${MARIADB_CLIENT_LIBS} ${ENGINE_EXEC_LIBS}) install(TARGETS ProcMgr DESTINATION ${ENGINE_BINDIR} COMPONENT platform) diff --git a/procmgr/processmanager.cpp b/procmgr/processmanager.cpp index 686243f87..f05a7dcbf 100644 --- a/procmgr/processmanager.cpp +++ b/procmgr/processmanager.cpp @@ -1377,7 +1377,7 @@ void processMSG(messageqcpp::IOSocket* cfIos) // all transactions to finish or rollback as commanded. This is only set if // there are, in fact, transactions active (or cpimport). - int retStatus = oam::API_SUCCESS; + //int retStatus = oam::API_SUCCESS; if (HDFS) { @@ -1458,7 +1458,7 @@ void processMSG(messageqcpp::IOSocket* cfIos) if (opState == oam::MAN_DISABLED || opState == oam::AUTO_DISABLED) continue; - retStatus = processManager.shutdownModule((*pt).DeviceName, graceful, manualFlag, 0); + processManager.shutdownModule((*pt).DeviceName, graceful, manualFlag, 0); } } } @@ -3735,8 +3735,9 @@ int ProcessManager::disableModule(string target, bool manualFlag) //Update DBRM section of Columnstore.xml if ( updateWorkerNodeconfig() != API_SUCCESS ) + { return API_FAILURE; - + } processManager.recycleProcess(target); //check for SIMPLEX Processes on mate might need to be started @@ -5144,7 +5145,7 @@ int ProcessManager::addModule(oam::DeviceNetworkList devicenetworklist, std::str string loginTmp = tmpLogDir + "/login_test.log"; string cmd = installDir + "/bin/remote_command.sh " + IPAddr + " " + password + " 'ls' 1 > " + loginTmp; - int rtnCode = system(cmd.c_str()); + system(cmd.c_str()); if (!oam.checkLogStatus(loginTmp, "README")) { //check for RSA KEY ISSUE and fix @@ -7728,7 +7729,8 @@ void startSystemThread(oam::DeviceNetworkList Devicenetworklist) sleep(2); } - if ( rtn = oam::ACTIVE ) + // This was logical error and possible source of many problems. + if ( rtn == oam::ACTIVE ) //set query system state not ready processManager.setQuerySystemState(true); @@ -7869,8 +7871,8 @@ void stopSystemThread(oam::DeviceNetworkList Devicenetworklist) SystemModuleTypeConfig systemmoduletypeconfig; ALARMManager aManager; int status = API_SUCCESS; - bool exitThread = false; - int exitThreadStatus = oam::API_SUCCESS; + //bool exitThread = false; + //int exitThreadStatus = oam::API_SUCCESS; pthread_t ThreadId; ThreadId = pthread_self(); @@ -7887,16 +7889,16 @@ void stopSystemThread(oam::DeviceNetworkList Devicenetworklist) log.writeLog(__LINE__, "EXCEPTION ERROR on getSystemConfig: " + error, LOG_TYPE_ERROR); stopsystemthreadStatus = oam::API_FAILURE; processManager.setSystemState(oam::FAILED); - exitThread = true; - exitThreadStatus = oam::API_FAILURE; + //exitThread = true; + //exitThreadStatus = oam::API_FAILURE; } catch (...) { log.writeLog(__LINE__, "EXCEPTION ERROR on getSystemConfig: Caught unknown exception!", LOG_TYPE_ERROR); stopsystemthreadStatus = oam::API_FAILURE; processManager.setSystemState(oam::FAILED); - exitThread = true; - exitThreadStatus = oam::API_FAILURE; + //exitThread = true; + //exitThreadStatus = oam::API_FAILURE; } if ( devicenetworklist.size() != 0 ) @@ -7920,7 +7922,7 @@ void stopSystemThread(oam::DeviceNetworkList Devicenetworklist) try { int opState; - bool degraded = oam::ACTIVE; + bool degraded; oam.getModuleStatus(moduleName, opState, degraded); if (opState == oam::MAN_DISABLED || opState == oam::AUTO_DISABLED) diff --git a/procmon/CMakeLists.txt b/procmon/CMakeLists.txt index 8bfff3c5a..bd6efcceb 100644 --- a/procmon/CMakeLists.txt +++ b/procmon/CMakeLists.txt @@ -8,6 +8,8 @@ set(ProcMon_SRCS main.cpp processmonitor.cpp ../utils/common/crashtrace.cpp) add_executable(ProcMon ${ProcMon_SRCS}) +target_compile_options(ProcMon PRIVATE -Wno-unused-result) + target_link_libraries(ProcMon ${ENGINE_LDFLAGS} cacheutils ${NETSNMP_LIBRARIES} ${MARIADB_CLIENT_LIBS} ${ENGINE_EXEC_LIBS}) install(TARGETS ProcMon DESTINATION ${ENGINE_BINDIR} COMPONENT platform) diff --git a/procmon/processmonitor.cpp b/procmon/processmonitor.cpp index 9a8f4b8cd..f22be1b87 100644 --- a/procmon/processmonitor.cpp +++ b/procmon/processmonitor.cpp @@ -1497,7 +1497,6 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO string configureModuleName; msg >> configureModuleName; - uint16_t rtnCode; int requestStatus = API_SUCCESS; configureModule(configureModuleName); @@ -2220,7 +2219,8 @@ pid_t ProcessMonitor::startProcess(string processModuleType, string processName, string RunType, string DepProcessName[MAXDEPENDANCY], string DepModuleName[MAXDEPENDANCY], string LogFile, uint16_t initType, uint16_t actIndicator) { - pid_t newProcessID; + // Compiler complains about non-initialiased variable here. + pid_t newProcessID = 0; char* argList[MAXARGUMENTS]; unsigned int i = 0; MonitorLog log; diff --git a/tools/configMgt/CMakeLists.txt b/tools/configMgt/CMakeLists.txt index 0a2f88808..88a9667bc 100644 --- a/tools/configMgt/CMakeLists.txt +++ b/tools/configMgt/CMakeLists.txt @@ -8,6 +8,8 @@ set(autoInstaller_SRCS autoInstaller.cpp) add_executable(autoInstaller ${autoInstaller_SRCS}) +target_compile_options(autoInstaller PRIVATE -Wno-unused-result) + target_link_libraries(autoInstaller ${ENGINE_LDFLAGS} ${NETSNMP_LIBRARIES} ${MARIADB_CLIENT_LIBS} ${ENGINE_EXEC_LIBS} readline ncurses) install(TARGETS autoInstaller DESTINATION ${ENGINE_BINDIR}) @@ -22,15 +24,3 @@ add_executable(autoConfigure ${autoConfigure_SRCS}) target_link_libraries(autoConfigure ${ENGINE_LDFLAGS} ${NETSNMP_LIBRARIES} ${MARIADB_CLIENT_LIBS} ${ENGINE_EXEC_LIBS}) install(TARGETS autoConfigure DESTINATION ${ENGINE_BINDIR} COMPONENT platform) - - -########### next target ############### - -set(svnQuery_SRCS svnQuery.cpp) - -add_executable(svnQuery ${svnQuery_SRCS}) - -target_link_libraries(svnQuery ${ENGINE_LDFLAGS} ${NETSNMP_LIBRARIES} ${MARIADB_CLIENT_LIBS} ${ENGINE_EXEC_LIBS}) - -install(TARGETS svnQuery DESTINATION ${ENGINE_BINDIR}) - diff --git a/tools/configMgt/autoInstaller.cpp b/tools/configMgt/autoInstaller.cpp index fa748056d..7dfb934e9 100644 --- a/tools/configMgt/autoInstaller.cpp +++ b/tools/configMgt/autoInstaller.cpp @@ -637,7 +637,7 @@ int main(int argc, char* argv[]) // Columnstore.xml found //try to parse it - Config* sysConfigOld; + //Config* sysConfigOld; ofstream file("/dev/null"); @@ -649,7 +649,7 @@ int main(int argc, char* argv[]) // redirect cout to /dev/null cerr.rdbuf(file.rdbuf()); - sysConfigOld = Config::makeConfig( systemDir + "/Columnstore.xml"); + //sysConfigOld = Config::makeConfig( systemDir + "/Columnstore.xml"); // restore cout stream buffer cerr.rdbuf (strm_buffer); diff --git a/tools/dbbuilder/dbbuilder.cpp b/tools/dbbuilder/dbbuilder.cpp index 31e33c7df..7fbecf4e7 100644 --- a/tools/dbbuilder/dbbuilder.cpp +++ b/tools/dbbuilder/dbbuilder.cpp @@ -59,11 +59,11 @@ int setUp() { #ifndef _MSC_VER string cmd = "/bin/rm -f " + logFile + " >/dev/null 2>&1"; - (void)system(cmd.c_str()); + int rc = system(cmd.c_str()); cmd = "/bin/touch -f " + logFile + " >/dev/null 2>&1"; - (void)system(cmd.c_str()); + rc = system(cmd.c_str()); #endif - return 0; + return rc; } int checkNotThere(WriteEngine::FID fid) @@ -73,12 +73,6 @@ int checkNotThere(WriteEngine::FID fid) return (fileOp.existsOIDDir(fid) ? -1 : 0); } -void tearDown() -{ - string file = tmpDir + "/oidbitmap"; - unlink(file.c_str()); -} - void usage() { cerr << "Usage: dbbuilder [-h|f] function" << endl @@ -131,6 +125,7 @@ int main(int argc, char* argv[]) std::string schema("tpch"); Oam oam; bool fFlg = false; + int rc = 0; opterr = 0; @@ -194,7 +189,10 @@ int main(int argc, char* argv[]) if ( buildOption == SYSCATALOG_ONLY ) { - setUp(); + if ( setUp() ) + { + cerr << "setUp() call error " << endl; + } bool canWrite = true; @@ -210,9 +208,13 @@ int main(int argc, char* argv[]) "' > " + logFile; if (canWrite) - (void)system(cmd.c_str()); + { + rc = system(cmd.c_str()); + } else + { cerr << cmd << endl; + } errorHandler(sysCatalogErr, "Build system catalog", @@ -244,7 +246,7 @@ int main(int argc, char* argv[]) string cmd(string("echo 'FAILED: ") + ex.what() + "' > " + logFile); if (canWrite) - (void)system(cmd.c_str()); + rc = system(cmd.c_str()); else cerr << cmd << endl; @@ -256,7 +258,7 @@ int main(int argc, char* argv[]) string cmd = "echo 'FAILED: HDFS checking.' > " + logFile; if (canWrite) - (void)system(cmd.c_str()); + rc = system(cmd.c_str()); else cerr << cmd << endl; @@ -275,7 +277,7 @@ int main(int argc, char* argv[]) std::string cmd = "echo 'OK: buildOption=" + oam.itoa(buildOption) + "' > " + logFile; if (canWrite) - (void)system(cmd.c_str()); + rc = system(cmd.c_str()); else #ifdef _MSC_VER (void)0; @@ -288,11 +290,9 @@ int main(int argc, char* argv[]) if (canWrite) { - int err; + rc = system(cmd.c_str()); - err = system(cmd.c_str()); - - if (err != 0) + if (rc != 0) { ostringstream os; os << "Warning: running " << cmd << " failed. This is usually non-fatal."; @@ -310,7 +310,7 @@ int main(int argc, char* argv[]) string cmd = "echo 'FAILED: buildOption=" + oam.itoa(buildOption) + "' > " + logFile; if (canWrite) - (void)system(cmd.c_str()); + rc = system(cmd.c_str()); else cerr << cmd << endl; @@ -321,7 +321,7 @@ int main(int argc, char* argv[]) string cmd = "echo 'FAILED: buildOption=" + oam.itoa(buildOption) + "' > " + logFile; if (canWrite) - (void)system(cmd.c_str()); + rc = system(cmd.c_str()); else cerr << cmd << endl; diff --git a/tools/dbloadxml/colxml.cpp b/tools/dbloadxml/colxml.cpp index 87ef4b1a8..69be8d61e 100644 --- a/tools/dbloadxml/colxml.cpp +++ b/tools/dbloadxml/colxml.cpp @@ -44,11 +44,11 @@ using namespace bulkloadxml; int main(int argc, char** argv) { const int DEBUG_LVL_TO_DUMP_SYSCAT_RPT = 4; -#ifdef _MSC_VER - //FIXME -#else - setuid( 0 ); // set effective ID to root; ignore return status -#endif + // set effective ID to root + if( setuid( 0 ) < 0 ) + { + std::cerr << " colxml: setuid failed " << std::endl; + } setlocale(LC_ALL, ""); WriteEngine::Config::initConfigCache(); // load Columnstore.xml config settings diff --git a/utils/cacheutils/cacheutils.cpp b/utils/cacheutils/cacheutils.cpp index 99944ec7f..ca56e2da0 100644 --- a/utils/cacheutils/cacheutils.cpp +++ b/utils/cacheutils/cacheutils.cpp @@ -258,7 +258,8 @@ int flushOIDsFromCache(const vector& oids) ISMPacketHeader ism; uint32_t i; - memset(&ism, 0, sizeof(ISMPacketHeader)); + void *ismp = static_cast(&ism); + memset(ismp, 0, sizeof(ISMPacketHeader)); ism.Command = CACHE_FLUSH_BY_OID; bs.load((uint8_t*) &ism, sizeof(ISMPacketHeader)); bs << (uint32_t) oids.size(); @@ -285,7 +286,8 @@ int flushPartition(const std::vector& oids, set(&ism); + memset(ismp, 0, sizeof(ISMPacketHeader)); ism.Command = CACHE_FLUSH_PARTITION; bs.load((uint8_t*) &ism, sizeof(ISMPacketHeader)); serializeSet(bs, partitionNums); diff --git a/utils/compress/version1.cpp b/utils/compress/version1.cpp index 945e2617a..ab93bd325 100644 --- a/utils/compress/version1.cpp +++ b/utils/compress/version1.cpp @@ -90,6 +90,8 @@ namespace { short DSPort = 9199; +// this isn't currently used but could be in the future. +#if 0 void log(const string& s) { logging::MessageLog logger((logging::LoggingID())); @@ -100,6 +102,7 @@ void log(const string& s) message.format(args); logger.logErrorMessage(message); } +#endif struct ScopedCleaner { diff --git a/utils/dataconvert/dataconvert.cpp b/utils/dataconvert/dataconvert.cpp index d028bae2f..15a200d3b 100644 --- a/utils/dataconvert/dataconvert.cpp +++ b/utils/dataconvert/dataconvert.cpp @@ -83,19 +83,6 @@ bool from_string(T& t, const std::string& s, std::ios_base & (*f)(std::ios_base& return !(iss >> f >> t).fail(); } -uint64_t pow10_(int32_t scale) -{ - if (scale <= 0) return 1; - - idbassert(scale < 20); - uint64_t res = 1; - - for (int32_t i = 0; i < scale; i++) - res *= 10; - - return res; -} - bool number_value ( const string& data ) { for (unsigned int i = 0; i < strlen(data.c_str()); i++) @@ -893,7 +880,6 @@ bool mysql_str_to_datetime( const string& input, DateTime& output, bool& isDate bool mysql_str_to_time( const string& input, Time& output, long decimals ) { -// int32_t datesepct = 0; uint32_t dtend = 0; bool isNeg = false; @@ -1779,7 +1765,8 @@ int32_t DataConvert::convertColumnDate( bool DataConvert::isColumnDateValid( int32_t date ) { Date d; - memcpy(&d, &date, sizeof(int32_t)); + void* dp = static_cast(&d); + memcpy(dp, &date, sizeof(int32_t)); return (isDateValid(d.day, d.month, d.year)); } @@ -2081,7 +2068,8 @@ int64_t DataConvert::convertColumnTime( bool DataConvert::isColumnDateTimeValid( int64_t dateTime ) { DateTime dt; - memcpy(&dt, &dateTime, sizeof(uint64_t)); + void* dtp = static_cast(&dt); + memcpy(dtp, &dateTime, sizeof(uint64_t)); if (isDateValid(dt.day, dt.month, dt.year)) return isDateTimeValid(dt.hour, dt.minute, dt.second, dt.msecond); @@ -2092,7 +2080,8 @@ bool DataConvert::isColumnDateTimeValid( int64_t dateTime ) bool DataConvert::isColumnTimeValid( int64_t time ) { Time dt; - memcpy(&dt, &time, sizeof(uint64_t)); + void* dtp = static_cast(&dt); + memcpy(dtp, &time, sizeof(uint64_t)); return isTimeValid(dt.hour, dt.minute, dt.second, dt.msecond); } @@ -2178,7 +2167,8 @@ std::string DataConvert::datetimeToString1( long long datetimevalue ) { // @bug 4703 abandon multiple ostringstream's for conversion DateTime dt(datetimevalue); - const int DATETIMETOSTRING1_LEN = 22; // YYYYMMDDHHMMSSmmmmmm\0 + // Interesting, gcc 7 says the sprintf below generates between 21 and 23 bytes of output. + const int DATETIMETOSTRING1_LEN = 23; // YYYYMMDDHHMMSSmmmmmm\0 char buf[DATETIMETOSTRING1_LEN]; sprintf(buf, "%04d%02d%02d%02d%02d%02d%06d", dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.msecond); @@ -2443,11 +2433,10 @@ int64_t DataConvert::stringToDatetime(const string& data, bool* date) return -1; } +/* This is really painful and expensive b/c it seems the input is not normalized or +sanitized. That should really be done on ingestion. */ int64_t DataConvert::intToDate(int64_t data) { - //char buf[10] = {0}; - //snprintf( buf, 10, "%llu", (long long unsigned int)data); - //string date = buf; char buf[21] = {0}; Date aday; @@ -2459,7 +2448,16 @@ int64_t DataConvert::intToDate(int64_t data) return *(reinterpret_cast(&aday)); } + // this snprintf call causes a compiler warning b/c we're potentially copying a 20-digit # + // into 15 bytes, however, that appears to be intentional. +#if defined(__GNUC__) && __GNUC__ >= 6 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-truncation=" snprintf( buf, 15, "%llu", (long long unsigned int)data); +#pragma GCC diagnostic pop +#else + snprintf( buf, 15, "%llu", (long long unsigned int)data); +#endif string year, month, day, hour, min, sec, msec; int64_t y = 0, m = 0, d = 0, h = 0, minute = 0, s = 0, ms = 0; @@ -2562,6 +2560,8 @@ int64_t DataConvert::intToDate(int64_t data) return *(reinterpret_cast(&aday)); } +/* This is really painful and expensive b/c it seems the input is not normalized or +sanitized. That should really be done on ingestion. */ int64_t DataConvert::intToDatetime(int64_t data, bool* date) { bool isDate = false; @@ -2584,7 +2584,17 @@ int64_t DataConvert::intToDatetime(int64_t data, bool* date) return *(reinterpret_cast(&adaytime)); } + // this snprintf call causes a compiler warning b/c we're potentially copying a 20-digit # + // into 15 bytes, however, that appears to be intentional. +#if defined(__GNUC__) && __GNUC__ >= 6 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-truncation=" snprintf( buf, 15, "%llu", (long long unsigned int)data); +#pragma GCC diagnostic pop +#else + snprintf( buf, 15, "%llu", (long long unsigned int)data); +#endif + //string date = buf; string year, month, day, hour, min, sec, msec; int64_t y = 0, m = 0, d = 0, h = 0, minute = 0, s = 0, ms = 0; @@ -2692,6 +2702,8 @@ int64_t DataConvert::intToDatetime(int64_t data, bool* date) return *(reinterpret_cast(&adaytime)); } +/* This is really painful and expensive b/c it seems the input is not normalized or +sanitized. That should really be done on ingestion. */ int64_t DataConvert::intToTime(int64_t data, bool fromString) { char buf[21] = {0}; @@ -2710,7 +2722,17 @@ int64_t DataConvert::intToTime(int64_t data, bool fromString) return *(reinterpret_cast(&atime)); } + // this snprintf call causes a compiler warning b/c we're potentially copying a 20-digit # + // into 15 bytes, however, that appears to be intentional. +#if defined(__GNUC__) && __GNUC__ >= 6 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-truncation=" snprintf( buf, 15, "%llu", (long long unsigned int)data); +#pragma GCC diagnostic pop +#else + snprintf( buf, 15, "%llu", (long long unsigned int)data); +#endif + //string date = buf; string hour, min, sec, msec; int64_t h = 0, minute = 0, s = 0, ms = 0; diff --git a/utils/dataconvert/dataconvert.h b/utils/dataconvert/dataconvert.h index a6ce20198..d563f5fea 100644 --- a/utils/dataconvert/dataconvert.h +++ b/utils/dataconvert/dataconvert.h @@ -673,12 +673,24 @@ inline void DataConvert::timeToString1( long long timevalue, char* buf, unsigned buf++; buflen--; } - + // this snprintf call causes a compiler warning b/c buffer size is less + // then maximum string size. +#if defined(__GNUC__) && __GNUC__ >= 6 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-truncation=" snprintf( buf, buflen, "%02d%02d%02d", hour, (unsigned)((timevalue >> 32) & 0xff), (unsigned)((timevalue >> 14) & 0xff) ); +#pragma GCC diagnostic pop +#else + snprintf( buf, buflen, "%02d%02d%02d", + hour, + (unsigned)((timevalue >> 32) & 0xff), + (unsigned)((timevalue >> 14) & 0xff) + ); +#endif } inline std::string DataConvert::decimalToString(int64_t value, uint8_t scale, execplan::CalpontSystemCatalog::ColDataType colDataType) diff --git a/utils/funcexp/func_insert.cpp b/utils/funcexp/func_insert.cpp index 88d731eb4..20109c27b 100644 --- a/utils/funcexp/func_insert.cpp +++ b/utils/funcexp/func_insert.cpp @@ -89,11 +89,13 @@ std::string Func_insert::getStrVal(rowgroup::Row& row, execplan::CalpontSystemCatalog::ColType&) { string tstr; + string tnewstr; stringValue(fp[0], row, isNull, tstr); if (isNull) + { return ""; + } - string tnewstr; stringValue(fp[3], row, isNull, tnewstr); if (isNull) return ""; diff --git a/utils/funcexp/func_lpad.cpp b/utils/funcexp/func_lpad.cpp index b5acfd362..fbb5ceca2 100644 --- a/utils/funcexp/func_lpad.cpp +++ b/utils/funcexp/func_lpad.cpp @@ -103,8 +103,6 @@ std::string Func_lpad::getStrVal(rowgroup::Row& row, value += 0.5; else if (value < 0) value -= 0.5; - else if (value < 0) - value -= 0.5; int64_t ret = (int64_t) value; diff --git a/utils/funcexp/func_md5.cpp b/utils/funcexp/func_md5.cpp index 4023ec4a0..9780c389d 100644 --- a/utils/funcexp/func_md5.cpp +++ b/utils/funcexp/func_md5.cpp @@ -82,7 +82,7 @@ typedef unsigned char uchar; char* PrintMD5(uchar md5Digest[16]); char* MD5String(const char* szString); -char* MD5File(char* szFilename); +//char* MD5File(char* szFilename); class md5 { @@ -236,6 +236,7 @@ char* PrintMD5(uchar md5Digest[16]) char chBuffer[256]; char chEach[10]; int nCount; + size_t chEachSize = 0; memset(chBuffer, 0, 256); memset(chEach, 0, 10); @@ -243,7 +244,8 @@ char* PrintMD5(uchar md5Digest[16]) for (nCount = 0; nCount < 16; nCount++) { sprintf(chEach, "%02x", md5Digest[nCount]); - strncat(chBuffer, chEach, sizeof(chEach)); + chEachSize = sizeof(chEach); + strncat(chBuffer, chEach, chEachSize); } return strdup(chBuffer); @@ -263,7 +265,9 @@ char* MD5String(const char* szString) } -// MD5File: Performs the MD5 algorithm on a file (binar or text), +// this fcn isn't used, so commenting it +#if 0 +// MD5File: Performs the MD5 algorithm on a file (binary or text), // returning the results as a char*. Returns NULL if it fails. char* MD5File(char* szFilename) { @@ -295,7 +299,7 @@ char* MD5File(char* szFilename) return NULL; // failed } - +#endif // md5::Init // Initializes a new context. diff --git a/utils/funcexp/func_repeat.cpp b/utils/funcexp/func_repeat.cpp index b99114c5a..d79d16de1 100644 --- a/utils/funcexp/func_repeat.cpp +++ b/utils/funcexp/func_repeat.cpp @@ -93,7 +93,7 @@ std::string Func_repeat::getStrVal(rowgroup::Row& row, for ( int i = 0 ; i < count ; i ++ ) { - if (strcat(result, str.c_str()) == NULL) + if (strcat(result, str.c_str()) == NULL) //questionable check return ""; } diff --git a/utils/funcexp/func_substring_index.cpp b/utils/funcexp/func_substring_index.cpp index f68679992..04d4d9b12 100644 --- a/utils/funcexp/func_substring_index.cpp +++ b/utils/funcexp/func_substring_index.cpp @@ -76,7 +76,7 @@ std::string Func_substring_index::getStrVal(rowgroup::Row& row, if ( count > end ) return str; - if (( count < 0 ) && ((count * -1) > end)) + if (( count < 0 ) && ((count * -1) > (int64_t) end)) return str; string value = str; @@ -99,8 +99,7 @@ std::string Func_substring_index::getStrVal(rowgroup::Row& row, } else { - count = count * -1; - size_t end = strlen(str.c_str()); + count = -count; int pointer = end; int start = 0; diff --git a/utils/idbdatafile/PosixFileSystem.cpp b/utils/idbdatafile/PosixFileSystem.cpp index 48413b62a..f52bdc56a 100644 --- a/utils/idbdatafile/PosixFileSystem.cpp +++ b/utils/idbdatafile/PosixFileSystem.cpp @@ -261,7 +261,7 @@ int PosixFileSystem::listDirectory(const char* pathname, std::list& contents.push_back( itr->path().filename().generic_string() ); } } - catch (std::exception) + catch (std::exception &) { ret = -1; } diff --git a/utils/idbhdfs/hdfs-shared/HdfsRdwrFileBuffer.cpp b/utils/idbhdfs/hdfs-shared/HdfsRdwrFileBuffer.cpp index cab6ba545..bd0ce32d6 100644 --- a/utils/idbhdfs/hdfs-shared/HdfsRdwrFileBuffer.cpp +++ b/utils/idbhdfs/hdfs-shared/HdfsRdwrFileBuffer.cpp @@ -151,7 +151,7 @@ HdfsRdwrFileBuffer::HdfsRdwrFileBuffer(const char* fname, const char* mode, unsi // This constructor is for use by HdfsRdwrMemBuffer to create a file buffer when we // run out of memory. -HdfsRdwrFileBuffer::HdfsRdwrFileBuffer(HdfsRdwrMemBuffer* pMemBuffer) throw (std::exception) : +HdfsRdwrFileBuffer::HdfsRdwrFileBuffer(HdfsRdwrMemBuffer* pMemBuffer) : IDBDataFile(pMemBuffer->name().c_str()), m_buffer(NULL), m_dirty(false) diff --git a/utils/idbhdfs/hdfs-shared/HdfsRdwrFileBuffer.h b/utils/idbhdfs/hdfs-shared/HdfsRdwrFileBuffer.h index 8b922f97a..cfe159e1d 100644 --- a/utils/idbhdfs/hdfs-shared/HdfsRdwrFileBuffer.h +++ b/utils/idbhdfs/hdfs-shared/HdfsRdwrFileBuffer.h @@ -50,7 +50,7 @@ class HdfsRdwrFileBuffer: public IDBDataFile, boost::noncopyable { public: HdfsRdwrFileBuffer(const char* fname, const char* mode, unsigned opts); - HdfsRdwrFileBuffer(HdfsRdwrMemBuffer* pMemBuffer) throw (std::exception); + HdfsRdwrFileBuffer(HdfsRdwrMemBuffer* pMemBuffer); /* virtual */ ~HdfsRdwrFileBuffer(); /* virtual */ ssize_t pread(void* ptr, off64_t offset, size_t count); diff --git a/utils/loggingcpp/messagelog.cpp b/utils/loggingcpp/messagelog.cpp index 603aec6a7..a1dd850e2 100644 --- a/utils/loggingcpp/messagelog.cpp +++ b/utils/loggingcpp/messagelog.cpp @@ -180,21 +180,21 @@ const string MessageLog::format(const Message& msg, const char prefix) void MessageLog::logDebugMessage(const Message& msg) { ::openlog(SubsystemID[fLogData.fSubsysID].c_str(), 0 | LOG_PID, fFacility); - ::syslog(LOG_DEBUG, format(msg, 'D').c_str()); + ::syslog(LOG_DEBUG, "%s", format(msg, 'D').c_str()); ::closelog(); } void MessageLog::logInfoMessage(const Message& msg) { ::openlog(SubsystemID[fLogData.fSubsysID].c_str(), 0 | LOG_PID, fFacility); - ::syslog(LOG_INFO, format(msg, 'I').c_str()); + ::syslog(LOG_INFO, "%s", format(msg, 'I').c_str()); ::closelog(); } void MessageLog::logWarningMessage(const Message& msg) { ::openlog(SubsystemID[fLogData.fSubsysID].c_str(), 0 | LOG_PID, fFacility); - ::syslog(LOG_WARNING, format(msg, 'W').c_str()); + ::syslog(LOG_WARNING, "%s", format(msg, 'W').c_str()); ::closelog(); } @@ -202,14 +202,14 @@ void MessageLog::logErrorMessage(const Message& msg) { // @bug 24 use 'E' instead of 'S' ::openlog(SubsystemID[fLogData.fSubsysID].c_str(), 0 | LOG_PID, fFacility); - ::syslog(LOG_ERR, format(msg, 'E').c_str()); + ::syslog(LOG_ERR, "%s", format(msg, 'E').c_str()); ::closelog(); } void MessageLog::logCriticalMessage(const Message& msg) { ::openlog(SubsystemID[fLogData.fSubsysID].c_str(), 0 | LOG_PID, fFacility); - ::syslog(LOG_CRIT, format(msg, 'C').c_str()); + ::syslog(LOG_CRIT, "%s", format(msg, 'C').c_str()); ::closelog(); } //Bug 5218. comment out the following functions to alleviate issue where dml messages show up in crit.log. This diff --git a/utils/messageqcpp/inetstreamsocket.cpp b/utils/messageqcpp/inetstreamsocket.cpp index 2f5f82bb7..d94a3eb94 100644 --- a/utils/messageqcpp/inetstreamsocket.cpp +++ b/utils/messageqcpp/inetstreamsocket.cpp @@ -945,7 +945,6 @@ void InetStreamSocket::connect(const sockaddr* serv_addr) /* read a byte to artificially synchronize with accept() on the remote */ int ret = -1; int e = EBADF; - char buf = '\0'; struct pollfd pfd; long msecs = fConnectionTimeout.tv_sec * 1000 + fConnectionTimeout.tv_nsec / 1000000; @@ -964,9 +963,19 @@ void InetStreamSocket::connect(const sockaddr* serv_addr) if (ret == 1) { #ifdef _MSC_VER + char buf = '\0'; (void)::recv(socketParms().sd(), &buf, 1, 0); #else - (void)::read(socketParms().sd(), &buf, 1); +#if defined(__GNUC__) && __GNUC__ >= 6 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + char buf = '\0'; + ::read(socketParms().sd(), &buf, 1); // we know 1 byte is in the recv buffer +#pragma GCC diagnostic pop +#else + char buf = '\0'; + ::read(socketParms().sd(), &buf, 1); // we know 1 byte is in the recv buffer +#endif // pragma #endif return; } diff --git a/utils/querytele/queryteleprotoimpl.cpp b/utils/querytele/queryteleprotoimpl.cpp index 2364d39ef..fa54a0adf 100644 --- a/utils/querytele/queryteleprotoimpl.cpp +++ b/utils/querytele/queryteleprotoimpl.cpp @@ -80,6 +80,7 @@ struct QStats QStats fQStats; +#ifdef QUERY_TELE_DEBUG string get_trace_file() { ostringstream oss; @@ -125,7 +126,9 @@ void log_query(const querytele::QueryTele& qtdata) trace << endl; trace.close(); } +#endif +#ifdef QUERY_TELE_DEBUG const string st2str(enum querytele::StepType::type t) { switch (t) @@ -172,7 +175,9 @@ const string st2str(enum querytele::StepType::type t) return "INV"; } +#endif +#ifdef QUERY_TELE_DEBUG void log_step(const querytele::StepTele& stdata) { ofstream trace(get_trace_file().c_str(), ios::out | ios::app); @@ -207,6 +212,7 @@ void log_step(const querytele::StepTele& stdata) trace << endl; trace.close(); } +#endif void TeleConsumer() { diff --git a/utils/rwlock/rwlock.cpp b/utils/rwlock/rwlock.cpp index d042b905e..64d413c52 100644 --- a/utils/rwlock/rwlock.cpp +++ b/utils/rwlock/rwlock.cpp @@ -32,7 +32,9 @@ #include #endif +#ifndef NDEBUG #define NDEBUG +#endif #include using namespace std; diff --git a/utils/threadpool/prioritythreadpool.cpp b/utils/threadpool/prioritythreadpool.cpp index e25cd7af8..37ce34ffc 100644 --- a/utils/threadpool/prioritythreadpool.cpp +++ b/utils/threadpool/prioritythreadpool.cpp @@ -139,8 +139,8 @@ PriorityThreadPool::Priority PriorityThreadPool::pickAQueue(Priority preference) void PriorityThreadPool::threadFcn(const Priority preferredQueue) throw() { - Priority queue; - uint32_t weight, i; + Priority queue = LOW; + uint32_t weight, i = 0; vector runList; vector reschedule; uint32_t rescheduleCount; diff --git a/utils/threadpool/threadpool.h b/utils/threadpool/threadpool.h index 16754385d..27d87fd12 100644 --- a/utils/threadpool/threadpool.h +++ b/utils/threadpool/threadpool.h @@ -44,6 +44,8 @@ #include #include +#include + #if defined(_MSC_VER) && defined(xxxTHREADPOOL_DLLEXPORT) #define EXPORT __declspec(dllexport) #else @@ -75,8 +77,13 @@ public: boost::thread* create_thread(F threadfunc) { boost::lock_guard guard(m); - threads.push_back(new boost::thread(threadfunc)); - return threads.back(); +#if defined(__GNUC__) && __GNUC__ >= 7 + std::unique_ptr new_thread(new boost::thread(threadfunc)); +#else + std::auto_ptr new_thread(new boost::thread(threadfunc)); +#endif + threads.push_back(new_thread.get()); + return new_thread.release(); } void add_thread(boost::thread* thrd) diff --git a/utils/udfsdk/mcsv1_udaf.h b/utils/udfsdk/mcsv1_udaf.h index 0fcd877c9..afcbb362f 100644 --- a/utils/udfsdk/mcsv1_udaf.h +++ b/utils/udfsdk/mcsv1_udaf.h @@ -1027,6 +1027,10 @@ inline T mcsv1_UDAF::convertAnyTo(static_any::any& valIn) { val = valIn.cast(); } + else + { + throw runtime_error("mcsv1_UDAF::convertAnyTo(): input param has unrecognized type"); + } return val; } diff --git a/versioning/BRM/extentmap.cpp b/versioning/BRM/extentmap.cpp index 6070ab1f2..2c0334030 100644 --- a/versioning/BRM/extentmap.cpp +++ b/versioning/BRM/extentmap.cpp @@ -1141,7 +1141,8 @@ void ExtentMap::loadVersion4(ifstream& in) in.read((char*) &flNumElements, sizeof(int)); idbassert(emNumElements > 0); - memset(fExtentMap, 0, fEMShminfo->allocdSize); + void *fExtentMapPtr = static_cast(fExtentMap); + memset(fExtentMapPtr, 0, fEMShminfo->allocdSize); fEMShminfo->currentSize = 0; // init the free list @@ -1226,7 +1227,8 @@ void ExtentMap::loadVersion4(IDBDataFile* in) throw runtime_error("ExtentMap::loadVersion4(): read failed. Check the error log."); } - memset(fExtentMap, 0, fEMShminfo->allocdSize); + void *fExtentMapPtr = static_cast(fExtentMap); + memset(fExtentMapPtr, 0, fEMShminfo->allocdSize); fEMShminfo->currentSize = 0; // init the free list diff --git a/versioning/BRM/mastersegmenttable.cpp b/versioning/BRM/mastersegmenttable.cpp index 047c647f8..54921b644 100644 --- a/versioning/BRM/mastersegmenttable.cpp +++ b/versioning/BRM/mastersegmenttable.cpp @@ -189,7 +189,8 @@ void MasterSegmentTable::makeMSTSegment() void MasterSegmentTable::initMSTData() { - memset(fShmDescriptors, 0, MSTshmsize); + void *dp = static_cast(&fShmDescriptors); + memset(dp, 0, MSTshmsize); } MSTEntry* MasterSegmentTable::getTable_read(int num, bool block) const diff --git a/versioning/BRM/slavecomm.cpp b/versioning/BRM/slavecomm.cpp index 55fe3a15b..d72138e49 100644 --- a/versioning/BRM/slavecomm.cpp +++ b/versioning/BRM/slavecomm.cpp @@ -51,12 +51,14 @@ using namespace idbdatafile; namespace { +#ifdef USE_VERY_COMPLEX_DROP_CACHES void timespec_sub(const struct timespec& tv1, const struct timespec& tv2, double& tm) { tm = (double)(tv2.tv_sec - tv1.tv_sec) + 1.e-9 * (tv2.tv_nsec - tv1.tv_nsec); } +#endif } namespace BRM @@ -2176,8 +2178,12 @@ void SlaveComm::do_flushInodeCache() if ((fd = open("/proc/sys/vm/drop_caches", O_WRONLY)) >= 0) { - write(fd, "3\n", 2); - close(fd); + ssize_t written = write(fd, "3\n", 2); + int rc = close(fd); + if ( !written || rc ) + { + std::cerr << "Could not write into or close /proc/sys/vm/drop_caches" << std::endl; + } } #endif diff --git a/writeengine/bulk/cpimport.cpp b/writeengine/bulk/cpimport.cpp index 94dc5ae1d..54b688d0b 100644 --- a/writeengine/bulk/cpimport.cpp +++ b/writeengine/bulk/cpimport.cpp @@ -830,10 +830,11 @@ void printInputSource( if (alternateImportDir == IMPORT_PATH_CWD) { char cwdBuf[4096]; - ::getcwd(cwdBuf, sizeof(cwdBuf)); + char *bufPtr = &cwdBuf[0]; + bufPtr = ::getcwd(cwdBuf, sizeof(cwdBuf)); if (!(BulkLoad::disableConsoleOutput())) - cout << "Input file(s) will be read from : " << cwdBuf << endl; + cout << "Input file(s) will be read from : " << bufPtr << endl; } else { @@ -1021,7 +1022,11 @@ int main(int argc, char** argv) #ifdef _MSC_VER _setmaxstdio(2048); #else - setuid( 0 ); // set effective ID to root; ignore return status + // set effective ID to root + if( setuid( 0 ) < 0 ) + { + std::cerr << " cpimport: setuid failed " << std::endl; + } #endif setupSignalHandlers(); diff --git a/writeengine/bulk/we_tableinfo.cpp b/writeengine/bulk/we_tableinfo.cpp index 92f8ac19f..e51c8e2c2 100644 --- a/writeengine/bulk/we_tableinfo.cpp +++ b/writeengine/bulk/we_tableinfo.cpp @@ -1460,9 +1460,11 @@ void TableInfo::writeBadRows( const std::vector* errorDatRows, if (!p.has_root_path()) { + // We could fail here having fixed size buffer char cwdPath[4096]; - getcwd(cwdPath, sizeof(cwdPath)); - boost::filesystem::path rejectFileName2( cwdPath ); + char* buffPtr = &cwdPath[0]; + buffPtr = getcwd(cwdPath, sizeof(cwdPath)); + boost::filesystem::path rejectFileName2( buffPtr ); rejectFileName2 /= fRejectDataFileName; fBadFiles.push_back( rejectFileName2.string() ); @@ -1567,8 +1569,9 @@ void TableInfo::writeErrReason( const std::vector< std::pair(&curSig); + memset(curSigPtr, 0, sizeof(curSig)); curSig.size = pos[startPos][col].offset; // Strip trailing null bytes '\0' (by adjusting curSig.size) if import- @@ -1321,7 +1322,8 @@ void Dctnry::preLoadStringCache( const DataBlock& fileBlock ) int op = 1; // ordinal position of the string within the block Signature aSig; - memset( &aSig, 0, sizeof(Signature)); + void *aSigPtr = static_cast(&aSig); + memset(aSigPtr, 0, sizeof(aSig)); while ((offBeg != DCTNRY_END_HEADER) && (op <= MAX_STRING_CACHE_SIZE)) @@ -1365,8 +1367,10 @@ void Dctnry::preLoadStringCache( const DataBlock& fileBlock ) ******************************************************************************/ void Dctnry::addToStringCache( const Signature& newSig ) { + // We better add constructors that sets everything to 0; Signature asig; - memset(&asig, 0, sizeof(Signature)); + void *aSigPtr = static_cast(&asig); + memset(aSigPtr, 0, sizeof(asig)); asig.signature = new unsigned char[newSig.size]; memcpy(asig.signature, newSig.signature, newSig.size ); asig.size = newSig.size; diff --git a/writeengine/server/we_ddlcommandproc.cpp b/writeengine/server/we_ddlcommandproc.cpp index 19475ccbe..f536c2430 100644 --- a/writeengine/server/we_ddlcommandproc.cpp +++ b/writeengine/server/we_ddlcommandproc.cpp @@ -2469,7 +2469,8 @@ uint8_t WE_DDLCommandProc::updateSyscolumnTablename(ByteStream& bs, std::string& //It's the same string for each column, so we just need one dictionary struct - memset(&dictTuple, 0, sizeof(dictTuple)); + void *dictTuplePtr = static_cast(&dictTuple); + memset(dictTuplePtr, 0, sizeof(dictTuple)); dictTuple.sigValue = (unsigned char*)newTablename.c_str(); dictTuple.sigSize = newTablename.length(); dictTuple.isNull = false; @@ -3292,7 +3293,8 @@ uint8_t WE_DDLCommandProc::updateSystablesTablename(ByteStream& bs, std::string& //It's the same string for each column, so we just need one dictionary struct - memset(&dictTuple, 0, sizeof(dictTuple)); + void *dictTuplePtr = static_cast(&dictTuple); + memset(dictTuplePtr, 0, sizeof(dictTuple)); dictTuple.sigValue = (unsigned char*)newTablename.c_str(); dictTuple.sigSize = newTablename.length(); dictTuple.isNull = false; diff --git a/writeengine/server/we_dmlcommandproc.cpp b/writeengine/server/we_dmlcommandproc.cpp index 5da10433e..2acdd1578 100644 --- a/writeengine/server/we_dmlcommandproc.cpp +++ b/writeengine/server/we_dmlcommandproc.cpp @@ -722,6 +722,10 @@ uint8_t WE_DMLCommandProc::processSingleInsert(messageqcpp::ByteStream& bs, std: } } + // MCOL-1495 Remove fCatalogMap entries CS won't use anymore. + CalpontSystemCatalog::removeCalpontSystemCatalog(sessionId); + CalpontSystemCatalog::removeCalpontSystemCatalog(sessionId | 0x80000000); + return rc; } @@ -1361,7 +1365,9 @@ uint8_t WE_DMLCommandProc::processBatchInsert(messageqcpp::ByteStream& bs, std:: } } - //cout << "Batch insert return code " << rc << endl; + // MCOL-1495 Remove fCatalogMap entries CS won't use anymore. + CalpontSystemCatalog::removeCalpontSystemCatalog(sessionId); + CalpontSystemCatalog::removeCalpontSystemCatalog(sessionId | 0x80000000); return rc; } @@ -2087,18 +2093,11 @@ uint8_t WE_DMLCommandProc::processBatchInsertBinary(messageqcpp::ByteStream& bs, args.add(cols); err = IDBErrorInfo::instance()->errorMsg(WARN_DATA_TRUNC, args); - // Strict mode enabled, so rollback on warning - // NOTE: This doesn't seem to be a possible code path yet - /*if (insertPkg.get_isWarnToError()) - { - string applName ("BatchInsert"); - fWEWrapper.bulkRollback(tblOid,txnid.id,tableName.toString(), - applName, false, err); - BulkRollbackMgr::deleteMetaFile( tblOid ); - }*/ - } + } - //cout << "Batch insert return code " << rc << endl; + // MCOL-1495 Remove fCatalogMap entries CS won't use anymore. + CalpontSystemCatalog::removeCalpontSystemCatalog(sessionId); + CalpontSystemCatalog::removeCalpontSystemCatalog(sessionId | 0x80000000); return rc; } @@ -2240,6 +2239,9 @@ uint8_t WE_DMLCommandProc::commitBatchAutoOn(messageqcpp::ByteStream& bs, std::s fWEWrapper.getDictMap().erase(txnID); } + // MCOL-1495 Remove fCatalogMap entries CS won't use anymore. + CalpontSystemCatalog::removeCalpontSystemCatalog(sessionId); + CalpontSystemCatalog::removeCalpontSystemCatalog(sessionId | 0x80000000); return rc; } @@ -2847,16 +2849,14 @@ uint8_t WE_DMLCommandProc::processUpdate(messageqcpp::ByteStream& bs, convertToRelativeRid (rid, extentNum, blockNum); rowIDLists.push_back(rid); uint32_t colWidth = (colTypes[j].colWidth > 8 ? 8 : colTypes[j].colWidth); - - // populate stats.blocksChanged - for (unsigned int k = 0; k < columnsUpdated.size(); k++) + int rrid = (int) relativeRID / (BYTE_PER_BLOCK / colWidth); + // populate stats.blocksChanged + if (rrid > preBlkNums[j]) { - if ((int)(relativeRID / (BYTE_PER_BLOCK / colWidth)) > preBlkNums[j]) - { + preBlkNums[j] = rrid ; blocksChanged++; - preBlkNums[j] = relativeRID / (BYTE_PER_BLOCK / colWidth); - } - } + } + } ridsFetched = true; @@ -3778,7 +3778,6 @@ uint8_t WE_DMLCommandProc::processUpdate(messageqcpp::ByteStream& bs, err = IDBErrorInfo::instance()->errorMsg(WARN_DATA_TRUNC, args); } - //cout << "finished update" << endl; return rc; } @@ -3961,6 +3960,10 @@ uint8_t WE_DMLCommandProc::processFlushFiles(messageqcpp::ByteStream& bs, std::s //if (idbdatafile::IDBPolicy::useHdfs()) // cacheutils::dropPrimProcFdCache(); TableMetaData::removeTableMetaData(tableOid); + + // MCOL-1495 Remove fCatalogMap entries CS won't use anymore. + CalpontSystemCatalog::removeCalpontSystemCatalog(txnId); + CalpontSystemCatalog::removeCalpontSystemCatalog(txnId | 0x80000000); return rc; } @@ -4136,7 +4139,6 @@ uint8_t WE_DMLCommandProc::processDelete(messageqcpp::ByteStream& bs, } } - //cout << "WES return rc " << (int)rc << " with msg " << err << endl; return rc; } diff --git a/writeengine/server/we_getfilesizes.cpp b/writeengine/server/we_getfilesizes.cpp index 4a76bd598..5e408d4e5 100644 --- a/writeengine/server/we_getfilesizes.cpp +++ b/writeengine/server/we_getfilesizes.cpp @@ -269,8 +269,8 @@ int WE_GetFileSizes::processFileName( std::string& errMsg, int key) { uint8_t rc = 0; - off_t fileSize; - off_t compressedFileSize; + off_t fileSize = 0; + off_t compressedFileSize = 0; errMsg.clear(); try diff --git a/writeengine/shared/we_chunkmanager.cpp b/writeengine/shared/we_chunkmanager.cpp index e2759d186..abe61ab11 100644 --- a/writeengine/shared/we_chunkmanager.cpp +++ b/writeengine/shared/we_chunkmanager.cpp @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (C) 2019 MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -65,6 +66,8 @@ namespace WriteEngine extern int NUM_BLOCKS_PER_INITIAL_EXTENT; // defined in we_dctnry.cpp extern WErrorCodes ec; // defined in we_log.cpp +const int COMPRESSED_CHUNK_SIZE = compress::IDBCompressInterface::maxCompressedSize(UNCOMPRESSED_CHUNK_SIZE) + 64 + 3 + 8 * 1024; + //------------------------------------------------------------------------------ // Search for the specified chunk in fChunkList. //------------------------------------------------------------------------------ @@ -1923,10 +1926,22 @@ int ChunkManager::reallocateChunks(CompFileData* fileData) struct tm ltm; localtime_r(reinterpret_cast(&tv.tv_sec), <m); char tmText[24]; + // this snprintf call causes a compiler warning b/c buffer size is less + // then maximum string size. +#if defined(__GNUC__) && __GNUC__ >= 6 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-truncation=" snprintf(tmText, sizeof(tmText), ".%04d%02d%02d%02d%02d%02d%06ld", ltm.tm_year + 1900, ltm.tm_mon + 1, ltm.tm_mday, ltm.tm_hour, ltm.tm_min, ltm.tm_sec, tv.tv_usec); +#pragma GCC diagnostic pop +#else + snprintf(tmText, sizeof(tmText), ".%04d%02d%02d%02d%02d%02d%06ld", + ltm.tm_year + 1900, ltm.tm_mon + 1, + ltm.tm_mday, ltm.tm_hour, ltm.tm_min, + ltm.tm_sec, tv.tv_usec); +#endif string dbgFileName(rlcFileName + tmText); ostringstream oss; @@ -2106,10 +2121,22 @@ int ChunkManager::reallocateChunks(CompFileData* fileData) struct tm ltm; localtime_r(reinterpret_cast(&tv.tv_sec), <m); char tmText[24]; + // this snprintf call causes a compiler warning b/c buffer size is less + // then maximum string size. +#if defined(__GNUC__) && __GNUC__ >= 6 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-truncation=" snprintf(tmText, sizeof(tmText), ".%04d%02d%02d%02d%02d%02d%06ld", ltm.tm_year + 1900, ltm.tm_mon + 1, ltm.tm_mday, ltm.tm_hour, ltm.tm_min, ltm.tm_sec, tv.tv_usec); +#pragma GCC diagnostic pop +#else + snprintf(tmText, sizeof(tmText), ".%04d%02d%02d%02d%02d%02d%06ld", + ltm.tm_year + 1900, ltm.tm_mon + 1, + ltm.tm_mday, ltm.tm_hour, ltm.tm_min, + ltm.tm_sec, tv.tv_usec); +#endif string dbgFileName(rlcFileName + tmText); ostringstream oss; diff --git a/writeengine/shared/we_chunkmanager.h b/writeengine/shared/we_chunkmanager.h index 0d4d013d8..edf9b232f 100644 --- a/writeengine/shared/we_chunkmanager.h +++ b/writeengine/shared/we_chunkmanager.h @@ -68,7 +68,6 @@ const int UNCOMPRESSED_CHUNK_SIZE = compress::IDBCompressInterface::UNCOMPRESSED const int COMPRESSED_FILE_HEADER_UNIT = compress::IDBCompressInterface::HDR_BUF_LEN; // assume UNCOMPRESSED_CHUNK_SIZE > 0xBFFF (49151), 8 * 1024 bytes padding -const int COMPRESSED_CHUNK_SIZE = compress::IDBCompressInterface::maxCompressedSize(UNCOMPRESSED_CHUNK_SIZE) + 64 + 3 + 8 * 1024; const int BLOCKS_IN_CHUNK = UNCOMPRESSED_CHUNK_SIZE / BYTE_PER_BLOCK; const int MAXOFFSET_PER_CHUNK = 511 * BYTE_PER_BLOCK; diff --git a/writeengine/shared/we_fileop.cpp b/writeengine/shared/we_fileop.cpp index 784f8b4d9..d25088f77 100644 --- a/writeengine/shared/we_fileop.cpp +++ b/writeengine/shared/we_fileop.cpp @@ -330,12 +330,15 @@ int FileOp::deleteFile( FID fid ) const std::vector dbRootPathList; Config::getDBRootPathList( dbRootPathList ); + int rc; + for (unsigned i = 0; i < dbRootPathList.size(); i++) { char rootOidDirName[FILE_NAME_SIZE]; - sprintf(rootOidDirName, "%s/%s", dbRootPathList[i].c_str(), oidDirName); + rc = snprintf(rootOidDirName, FILE_NAME_SIZE, "%s/%s", + dbRootPathList[i].c_str(), oidDirName); - if ( IDBPolicy::remove( rootOidDirName ) != 0 ) + if ( rc == FILE_NAME_SIZE || IDBPolicy::remove( rootOidDirName ) != 0 ) { ostringstream oss; oss << "Unable to remove " << rootOidDirName; @@ -363,6 +366,7 @@ int FileOp::deleteFiles( const std::vector& fids ) const char dbDir [MAX_DB_DIR_LEVEL][MAX_DB_DIR_NAME_SIZE]; std::vector dbRootPathList; Config::getDBRootPathList( dbRootPathList ); + int rc; for ( unsigned n = 0; n < fids.size(); n++ ) { @@ -376,10 +380,10 @@ int FileOp::deleteFiles( const std::vector& fids ) const for (unsigned i = 0; i < dbRootPathList.size(); i++) { char rootOidDirName[FILE_NAME_SIZE]; - sprintf(rootOidDirName, "%s/%s", dbRootPathList[i].c_str(), + rc = snprintf(rootOidDirName, FILE_NAME_SIZE, "%s/%s", dbRootPathList[i].c_str(), oidDirName); - if ( IDBPolicy::remove( rootOidDirName ) != 0 ) + if ( rc == FILE_NAME_SIZE || IDBPolicy::remove( rootOidDirName ) != 0 ) { ostringstream oss; oss << "Unable to remove " << rootOidDirName; @@ -410,6 +414,7 @@ int FileOp::deletePartitions( const std::vector& fids, char dbDir [MAX_DB_DIR_LEVEL][MAX_DB_DIR_NAME_SIZE]; char rootOidDirName[FILE_NAME_SIZE]; char partitionDirName[FILE_NAME_SIZE]; + int rcd, rcp; for (uint32_t i = 0; i < partitions.size(); i++) { @@ -420,12 +425,13 @@ int FileOp::deletePartitions( const std::vector& fids, dbDir[0], dbDir[1], dbDir[2], dbDir[3], dbDir[4]); // config expects dbroot starting from 0 std::string rt( Config::getDBRootByNum(partitions[i].lp.dbroot) ); - sprintf(rootOidDirName, "%s/%s", + rcd = snprintf(rootOidDirName, FILE_NAME_SIZE, "%s/%s", rt.c_str(), tempFileName); - sprintf(partitionDirName, "%s/%s", + rcp = snprintf(partitionDirName, FILE_NAME_SIZE, "%s/%s", rt.c_str(), oidDirName); - if ( IDBPolicy::remove( rootOidDirName ) != 0 ) + if ( rcd == FILE_NAME_SIZE || rcp == FILE_NAME_SIZE + || IDBPolicy::remove( rootOidDirName ) != 0 ) { ostringstream oss; oss << "Unable to remove " << rootOidDirName; diff --git a/writeengine/shared/we_index.h b/writeengine/shared/we_index.h index d5438453d..bcd88e5e9 100644 --- a/writeengine/shared/we_index.h +++ b/writeengine/shared/we_index.h @@ -393,7 +393,7 @@ struct IdxMultiColKey curMask.reset(); curLevel = maxLevel = 0; totalBit = 0; - memset( testbitArray, 0, IDX_MAX_MULTI_COL_IDX_LEVEL); + memset( testbitArray, 0, IDX_MAX_MULTI_COL_IDX_LEVEL * sizeof(testbitArray[0])); memset( keyBuf, 0, IDX_MAX_MULTI_COL_BIT / 8 ); curMask = 0x1F; curMask = curMask << (IDX_MAX_MULTI_COL_BIT - 5); diff --git a/writeengine/shared/we_type.h b/writeengine/shared/we_type.h index 8a8cae5a9..8604b2169 100644 --- a/writeengine/shared/we_type.h +++ b/writeengine/shared/we_type.h @@ -489,7 +489,7 @@ struct CacheControl /** @brief Cache control structure */ int checkInterval; /** @brief A check point interval in seconds */ CacheControl() { - totalBlock = pctFree = checkInterval; /** @brief constructor */ + totalBlock = pctFree = checkInterval = 0; /** @brief constructor */ } }; diff --git a/writeengine/splitter/we_filereadthread.cpp b/writeengine/splitter/we_filereadthread.cpp index 6840d377d..e455ff518 100644 --- a/writeengine/splitter/we_filereadthread.cpp +++ b/writeengine/splitter/we_filereadthread.cpp @@ -356,7 +356,7 @@ unsigned int WEFileReadThread::readDataFile(messageqcpp::SBS& Sbs) //char aBuff[1024*1024]; // TODO May have to change it later //char*pStart = aBuff; unsigned int aIdx = 0; - unsigned int aLen = 0; + int aLen = 0; *Sbs << (ByteStream::byte)(WE_CLT_SRV_DATA); while ((!fInFile.eof()) && (aIdx < getBatchQty())) diff --git a/writeengine/splitter/we_splitterapp.cpp b/writeengine/splitter/we_splitterapp.cpp index 1b62c6bcd..f96da7463 100644 --- a/writeengine/splitter/we_splitterapp.cpp +++ b/writeengine/splitter/we_splitterapp.cpp @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (C) 2019 MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -604,7 +605,13 @@ void WESplitterApp::updateWithJobFile(int aIdx) int main(int argc, char** argv) { std::string err; - setuid(0); //@BUG 4343 set effective userid to root. + // Why do we need this if we don't care about f()'s rc ? + // @BUG4343 + if( setuid( 0 ) < 0 ) + { + std::cerr << " we_splitterapp: setuid failed " << std::endl; + } + std::cin.sync_with_stdio(false); try diff --git a/writeengine/wrapper/we_colop.cpp b/writeengine/wrapper/we_colop.cpp index 1359570e5..00fc25cc8 100644 --- a/writeengine/wrapper/we_colop.cpp +++ b/writeengine/wrapper/we_colop.cpp @@ -239,7 +239,8 @@ int ColumnOp::allocRowId(const TxnID& txnid, bool useStartingExtent, for (i = 0; i < dbRootExtentTrackers.size(); i++) { - if (i != column.colNo) + uint32_t colNo = column.colNo; + if (i != colNo) dbRootExtentTrackers[i]->nextSegFile(dbRoot, partition, segment, newHwm, startLbid); // Round up HWM to the end of the current extent diff --git a/writeengine/xml/we_xmlgenproc.cpp b/writeengine/xml/we_xmlgenproc.cpp index e1763bdb1..5789dca15 100644 --- a/writeengine/xml/we_xmlgenproc.cpp +++ b/writeengine/xml/we_xmlgenproc.cpp @@ -38,9 +38,9 @@ namespace { const char* DICT_TYPE("D"); const char* ENCODING("UTF-8"); -const char* JOBNAME("Job_"); const char* LOGNAME("Jobxml_"); const std::string LOGDIR("/log/"); +const char* JOBNAME("Job_"); } namespace WriteEngine @@ -438,10 +438,11 @@ void XMLGenProc::getColumnsForTable( throw std::runtime_error( oss.str() ); } } - + //------------------------------------------------------------------------------ // Generate Job XML File Name //------------------------------------------------------------------------------ + std::string XMLGenProc::genJobXMLFileName( ) const { std::string xmlFileName; @@ -465,7 +466,10 @@ std::string XMLGenProc::genJobXMLFileName( ) const if (!p.has_root_path()) { char cwdPath[4096]; - getcwd(cwdPath, sizeof(cwdPath)); + char *buf; + buf = getcwd(cwdPath, sizeof(cwdPath)); + if (buf == NULL) + throw std::runtime_error("Failed to get the current working directory!"); boost::filesystem::path p2(cwdPath); p2 /= p; xmlFileName = p2.string(); @@ -479,7 +483,7 @@ std::string XMLGenProc::genJobXMLFileName( ) const return xmlFileName; } - + //------------------------------------------------------------------------------ // writeXMLFile //------------------------------------------------------------------------------ diff --git a/writeengine/xml/we_xmljob.cpp b/writeengine/xml/we_xmljob.cpp index 4dd923172..5afbe8774 100644 --- a/writeengine/xml/we_xmljob.cpp +++ b/writeengine/xml/we_xmljob.cpp @@ -1313,7 +1313,13 @@ int XMLJob::genJobXMLFileName( // nothing else to do #else char cwdPath[4096]; - getcwd(cwdPath, sizeof(cwdPath)); + char *err; + err = getcwd(cwdPath, sizeof(cwdPath)); + if (err == NULL) + { + errMsg = "Failed to get the current working directory."; + return -1; + } string trailingPath(xmlFilePath.string()); xmlFilePath = cwdPath; xmlFilePath /= trailingPath;