From cbbf267e88a2a8b1ef23f760899076248f89af46 Mon Sep 17 00:00:00 2001 From: Patrick LeBlanc Date: Mon, 19 Nov 2018 13:19:15 -0600 Subject: [PATCH 1/9] MCOL-537, cleanup compiler warnings. Checkpointing a bunch of fixes. Work in progress... --- dbcon/execplan/predicateoperator.cpp | 16 ---- dbcon/joblist/jlf_subquery.cpp | 5 +- dbcon/joblist/joblistfactory.cpp | 82 +------------------ dbcon/joblist/windowfunctionstep.cpp | 15 ---- oam/oamcpp/liboamcpp.cpp | 7 +- oamapps/alarmmanager/alarmmanager.cpp | 3 +- utils/compress/version1.cpp | 3 + utils/dataconvert/dataconvert.cpp | 40 +++++---- utils/funcexp/func_insert.cpp | 2 +- utils/funcexp/func_md5.cpp | 8 +- utils/funcexp/func_substring_index.cpp | 3 +- .../hdfs-shared/HdfsRdwrFileBuffer.cpp | 2 +- .../idbhdfs/hdfs-shared/HdfsRdwrFileBuffer.h | 2 +- utils/loggingcpp/messagelog.cpp | 10 +-- utils/messageqcpp/inetstreamsocket.cpp | 4 +- utils/querytele/queryteleprotoimpl.cpp | 6 ++ utils/rwlock/rwlock.cpp | 2 + utils/threadpool/prioritythreadpool.cpp | 4 +- utils/threadpool/threadpool.h | 4 +- utils/udfsdk/mcsv1_udaf.h | 4 + writeengine/wrapper/we_colop.cpp | 2 +- writeengine/xml/we_xmlgenproc.cpp | 10 ++- writeengine/xml/we_xmlgenproc.h | 2 +- writeengine/xml/we_xmljob.cpp | 8 +- 24 files changed, 85 insertions(+), 159 deletions(-) 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/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 b0c314364..32c7a0836 100644 --- a/dbcon/joblist/joblistfactory.cpp +++ b/dbcon/joblist/joblistfactory.cpp @@ -93,38 +93,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) { @@ -1446,54 +1414,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) @@ -1818,7 +1738,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/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/oam/oamcpp/liboamcpp.cpp b/oam/oamcpp/liboamcpp.cpp index 805c7d5d0..3ce191a6e 100644 --- a/oam/oamcpp/liboamcpp.cpp +++ b/oam/oamcpp/liboamcpp.cpp @@ -154,12 +154,12 @@ 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(); @@ -8601,7 +8601,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,7 +10470,6 @@ void Oam::sendStatusUpdate(ByteStream obs, ByteStream::byte returnRequestType) if (ibs.length() > 0) { ibs >> returnRequestType; - if ( returnRequestType == returnRequestType ) { processor.shutdown(); diff --git a/oamapps/alarmmanager/alarmmanager.cpp b/oamapps/alarmmanager/alarmmanager.cpp index 10ca418d1..c6f008859 100644 --- a/oamapps/alarmmanager/alarmmanager.cpp +++ b/oamapps/alarmmanager/alarmmanager.cpp @@ -484,7 +484,6 @@ void ALARMManager::sendAlarmReport (const char* componentID, int alarmID, int st else processName = repProcessName; - int returnStatus = API_SUCCESS; //default ByteStream msg1; // setup message @@ -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/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 9cd776130..343227430 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++) @@ -872,7 +859,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; @@ -2157,7 +2143,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); @@ -2422,11 +2409,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; @@ -2438,7 +2424,11 @@ 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. + #pragma GCC diagnostic ignored "-Wformat-truncation=" snprintf( buf, 15, "%llu", (long long unsigned int)data); + #pragma GCC diagnostic pop string year, month, day, hour, min, sec, msec; int64_t y = 0, m = 0, d = 0, h = 0, minute = 0, s = 0, ms = 0; @@ -2541,6 +2531,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; @@ -2563,7 +2555,12 @@ 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. + #pragma GCC diagnostic ignored "-Wformat-truncation=" snprintf( buf, 15, "%llu", (long long unsigned int)data); + #pragma GCC diagnostic pop + //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; @@ -2671,6 +2668,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}; @@ -2689,7 +2688,12 @@ 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. + #pragma GCC diagnostic ignored "-Wformat-truncation=" snprintf( buf, 15, "%llu", (long long unsigned int)data); + #pragma GCC diagnostic pop + //string date = buf; string hour, min, sec, msec; int64_t h = 0, minute = 0, s = 0, ms = 0; diff --git a/utils/funcexp/func_insert.cpp b/utils/funcexp/func_insert.cpp index 88d731eb4..5a54f0699 100644 --- a/utils/funcexp/func_insert.cpp +++ b/utils/funcexp/func_insert.cpp @@ -89,11 +89,11 @@ 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_md5.cpp b/utils/funcexp/func_md5.cpp index 4023ec4a0..8ab05b346 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 { @@ -263,7 +263,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 +297,7 @@ char* MD5File(char* szFilename) return NULL; // failed } - +#endif // md5::Init // Initializes a new context. diff --git a/utils/funcexp/func_substring_index.cpp b/utils/funcexp/func_substring_index.cpp index f68679992..4c85f4182 100644 --- a/utils/funcexp/func_substring_index.cpp +++ b/utils/funcexp/func_substring_index.cpp @@ -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/idbhdfs/hdfs-shared/HdfsRdwrFileBuffer.cpp b/utils/idbhdfs/hdfs-shared/HdfsRdwrFileBuffer.cpp index 7d934b3b9..a63f8e2e2 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 74fdf7020..a12a30850 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..8b4aa4b1e 100644 --- a/utils/messageqcpp/inetstreamsocket.cpp +++ b/utils/messageqcpp/inetstreamsocket.cpp @@ -966,7 +966,9 @@ void InetStreamSocket::connect(const sockaddr* serv_addr) #ifdef _MSC_VER (void)::recv(socketParms().sd(), &buf, 1, 0); #else - (void)::read(socketParms().sd(), &buf, 1); + #pragma GCC diagnostic ignored "-Wunused-result" + ::read(socketParms().sd(), &buf, 1); // we know 1 byte is in the recv buffer + #pragma GCC diagnostic pop #endif return; } diff --git a/utils/querytele/queryteleprotoimpl.cpp b/utils/querytele/queryteleprotoimpl.cpp index 2364d39ef..e1ad7025a 100644 --- a/utils/querytele/queryteleprotoimpl.cpp +++ b/utils/querytele/queryteleprotoimpl.cpp @@ -94,6 +94,7 @@ string get_trace_file() return oss.str(); } +#ifdef QUERY_TELE_DEBUG void log_query(const querytele::QueryTele& qtdata) { ofstream trace(get_trace_file().c_str(), ios::out | ios::app); @@ -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 92fd0ad98..51c080a18 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 84c9aff7a..e0129bb44 100644 --- a/utils/threadpool/threadpool.h +++ b/utils/threadpool/threadpool.h @@ -75,7 +75,9 @@ public: boost::thread* create_thread(F threadfunc) { boost::lock_guard guard(m); - std::auto_ptr new_thread(new boost::thread(threadfunc)); + std::unique_ptr new_thread(new boost::thread(threadfunc)); + // auto_ptr was deprecated + //std::auto_ptr new_thread(new boost::thread(threadfunc)); threads.push_back(new_thread.get()); return new_thread.release(); } diff --git a/utils/udfsdk/mcsv1_udaf.h b/utils/udfsdk/mcsv1_udaf.h index d6ba04483..edb0f3942 100644 --- a/utils/udfsdk/mcsv1_udaf.h +++ b/utils/udfsdk/mcsv1_udaf.h @@ -1029,6 +1029,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/writeengine/wrapper/we_colop.cpp b/writeengine/wrapper/we_colop.cpp index ffd01df2e..515e9f7b2 100644 --- a/writeengine/wrapper/we_colop.cpp +++ b/writeengine/wrapper/we_colop.cpp @@ -238,7 +238,7 @@ int ColumnOp::allocRowId(const TxnID& txnid, bool useStartingExtent, for (i = 0; i < dbRootExtentTrackers.size(); i++) { - if (i != column.colNo) + if (i != (int) column.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..d5a787769 100644 --- a/writeengine/xml/we_xmlgenproc.cpp +++ b/writeengine/xml/we_xmlgenproc.cpp @@ -442,6 +442,9 @@ void XMLGenProc::getColumnsForTable( //------------------------------------------------------------------------------ // Generate Job XML File Name //------------------------------------------------------------------------------ + +// This isn't used currently, commenting it out +#if 0 std::string XMLGenProc::genJobXMLFileName( ) const { std::string xmlFileName; @@ -465,7 +468,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 runtime_error("Failed to get the current working directory!"); boost::filesystem::path p2(cwdPath); p2 /= p; xmlFileName = p2.string(); @@ -479,6 +485,8 @@ std::string XMLGenProc::genJobXMLFileName( ) const return xmlFileName; } +#endif + //------------------------------------------------------------------------------ // writeXMLFile diff --git a/writeengine/xml/we_xmlgenproc.h b/writeengine/xml/we_xmlgenproc.h index 4b7ec4ed5..adce2d75f 100644 --- a/writeengine/xml/we_xmlgenproc.h +++ b/writeengine/xml/we_xmlgenproc.h @@ -90,7 +90,7 @@ public: /** @brief Generate Job XML file name */ - EXPORT std::string genJobXMLFileName( ) const; + //EXPORT std::string genJobXMLFileName( ) const; /** @brief Write xml file document to the destination Job XML file. * diff --git a/writeengine/xml/we_xmljob.cpp b/writeengine/xml/we_xmljob.cpp index 8d755b824..5f409daa0 100644 --- a/writeengine/xml/we_xmljob.cpp +++ b/writeengine/xml/we_xmljob.cpp @@ -1301,7 +1301,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; From 9dc33c4e8279628f424c8d5fef43f19ee4014610 Mon Sep 17 00:00:00 2001 From: Roman Nozdrin Date: Fri, 30 Nov 2018 13:24:58 +0300 Subject: [PATCH 2/9] Another try to cope with warnings under gcc 8.2. --- dbcon/dmlpackage/dml-scan.sh | 4 +-- dbcon/execplan/treenode.h | 6 +++-- dbcon/joblist/pdictionaryscan.cpp | 9 ++++--- dbcon/mysql/ha_calpont_execplan.cpp | 2 +- dbcon/mysql/ha_calpont_impl.cpp | 4 +-- dbcon/mysql/is_columnstore_files.cpp | 9 ++++--- oam/oamcpp/liboamcpp.cpp | 14 +++------- oamapps/alarmmanager/alarmmanager.cpp | 6 ++--- oamapps/mcsadmin/mcsadmin.cpp | 1 - oamapps/postConfigure/postConfigure.cpp | 20 +++++++------- oamapps/serverMonitor/cpuMonitor.cpp | 3 ++- oamapps/serverMonitor/msgProcessor.cpp | 4 +-- primitives/blockcache/filebuffer.cpp | 5 +++- primitives/linux-port/column.cpp | 3 ++- primitives/linux-port/dictionary.cpp | 16 +++++++++--- .../primproc/batchprimitiveprocessor.cpp | 18 ++++++++----- procmgr/processmanager.cpp | 26 ++++++++++--------- procmon/processmonitor.cpp | 4 +-- tools/configMgt/autoInstaller.cpp | 4 +-- utils/cacheutils/cacheutils.cpp | 6 +++-- utils/dataconvert/dataconvert.cpp | 9 ++++--- utils/funcexp/func_insert.cpp | 2 ++ utils/funcexp/func_lpad.cpp | 2 -- utils/funcexp/func_md5.cpp | 4 ++- utils/funcexp/func_repeat.cpp | 2 +- utils/funcexp/func_substring_index.cpp | 2 +- utils/idbdatafile/PosixFileSystem.cpp | 2 +- utils/threadpool/threadpool.h | 4 +-- versioning/BRM/extentmap.cpp | 6 +++-- versioning/BRM/mastersegmenttable.cpp | 3 ++- writeengine/dictionary/we_dctnry.cpp | 10 ++++--- writeengine/server/we_ddlcommandproc.cpp | 6 +++-- writeengine/shared/we_fileop.cpp | 20 +++++++++----- writeengine/shared/we_index.h | 2 +- writeengine/shared/we_type.h | 2 +- writeengine/splitter/we_filereadthread.cpp | 2 +- writeengine/wrapper/we_colop.cpp | 3 ++- 37 files changed, 145 insertions(+), 100 deletions(-) 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/treenode.h b/dbcon/execplan/treenode.h index 91ceb2a11..6a49fa16f 100644 --- a/dbcon/execplan/treenode.h +++ b/dbcon/execplan/treenode.h @@ -1139,7 +1139,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)) @@ -1169,7 +1171,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/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/mysql/ha_calpont_execplan.cpp b/dbcon/mysql/ha_calpont_execplan.cpp index 7b33f4318..65d0ac4a6 100644 --- a/dbcon/mysql/ha_calpont_execplan.cpp +++ b/dbcon/mysql/ha_calpont_execplan.cpp @@ -4684,7 +4684,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 7dffcd36f..1d8f5b385 100644 --- a/dbcon/mysql/ha_calpont_impl.cpp +++ b/dbcon/mysql/ha_calpont_impl.cpp @@ -2856,7 +2856,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) { @@ -5140,7 +5140,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/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/oam/oamcpp/liboamcpp.cpp b/oam/oamcpp/liboamcpp.cpp index 3ce191a6e..927250cfc 100644 --- a/oam/oamcpp/liboamcpp.cpp +++ b/oam/oamcpp/liboamcpp.cpp @@ -159,7 +159,9 @@ Oam::Oam() userDir = USER; if ( USER != "root") + { 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"; @@ -10470,11 +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/alarmmanager.cpp b/oamapps/alarmmanager/alarmmanager.cpp index c6f008859..2d057944c 100644 --- a/oamapps/alarmmanager/alarmmanager.cpp +++ b/oamapps/alarmmanager/alarmmanager.cpp @@ -484,10 +484,10 @@ void ALARMManager::sendAlarmReport (const char* componentID, int alarmID, int st else processName = repProcessName; - ByteStream msg1; +ByteStream msg1; - // setup message - msg1 << (ByteStream::byte) alarmID; +// setup message +msg1 << (ByteStream::byte) alarmID; msg1 << (std::string) componentID; msg1 << (ByteStream::byte) state; msg1 << (std::string) ModuleName; diff --git a/oamapps/mcsadmin/mcsadmin.cpp b/oamapps/mcsadmin/mcsadmin.cpp index d07c67ffb..02a77f56a 100644 --- a/oamapps/mcsadmin/mcsadmin.cpp +++ b/oamapps/mcsadmin/mcsadmin.cpp @@ -5904,7 +5904,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/postConfigure.cpp b/oamapps/postConfigure/postConfigure.cpp index fdfc1482c..0cacf4cd4 100644 --- a/oamapps/postConfigure/postConfigure.cpp +++ b/oamapps/postConfigure/postConfigure.cpp @@ -272,9 +272,7 @@ int main(int argc, char* argv[]) //check if root-user int user; - int usergroup; user = getuid(); - usergroup = getgid(); string SUDO = ""; if (user != 0) @@ -1412,7 +1410,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()); @@ -1973,7 +1971,7 @@ int main(int argc, char* argv[]) } } - unsigned int maxPMNicCount = 1; + int maxPMNicCount = 1; //configure module type bool parentOAMmoduleConfig = false; @@ -2110,7 +2108,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); @@ -2184,8 +2182,7 @@ int main(int argc, char* argv[]) } } } - - unsigned int nicID=1; + int nicID=1; for( ; nicID < MaxNicID +1 ; nicID++ ) { if ( !found ) @@ -3546,7 +3543,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(); @@ -4007,9 +4004,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; @@ -6417,7 +6416,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/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/linux-port/column.cpp b/primitives/linux-port/column.cpp index 2b4450d2c..5722aef5d 100644 --- a/primitives/linux-port/column.cpp +++ b/primitives/linux-port/column.cpp @@ -1421,7 +1421,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/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/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/autoInstaller.cpp b/tools/configMgt/autoInstaller.cpp index 15ac98c33..31623b73f 100644 --- a/tools/configMgt/autoInstaller.cpp +++ b/tools/configMgt/autoInstaller.cpp @@ -636,7 +636,7 @@ int main(int argc, char* argv[]) // Columnstore.xml found //try to parse it - Config* sysConfigOld; + //Config* sysConfigOld; ofstream file("/dev/null"); @@ -648,7 +648,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/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/dataconvert/dataconvert.cpp b/utils/dataconvert/dataconvert.cpp index 343227430..a2e3aaa47 100644 --- a/utils/dataconvert/dataconvert.cpp +++ b/utils/dataconvert/dataconvert.cpp @@ -1744,7 +1744,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)); } @@ -2046,7 +2047,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); @@ -2057,7 +2059,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); } diff --git a/utils/funcexp/func_insert.cpp b/utils/funcexp/func_insert.cpp index 5a54f0699..20109c27b 100644 --- a/utils/funcexp/func_insert.cpp +++ b/utils/funcexp/func_insert.cpp @@ -92,7 +92,9 @@ std::string Func_insert::getStrVal(rowgroup::Row& row, string tnewstr; stringValue(fp[0], row, isNull, tstr); if (isNull) + { return ""; + } stringValue(fp[3], row, isNull, tnewstr); if (isNull) 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 8ab05b346..9780c389d 100644 --- a/utils/funcexp/func_md5.cpp +++ b/utils/funcexp/func_md5.cpp @@ -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); 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 4c85f4182..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; 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/threadpool/threadpool.h b/utils/threadpool/threadpool.h index e0129bb44..e7ee9de82 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 @@ -76,8 +78,6 @@ public: { boost::lock_guard guard(m); std::unique_ptr new_thread(new boost::thread(threadfunc)); - // auto_ptr was deprecated - //std::auto_ptr new_thread(new boost::thread(threadfunc)); threads.push_back(new_thread.get()); return new_thread.release(); } 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/writeengine/dictionary/we_dctnry.cpp b/writeengine/dictionary/we_dctnry.cpp index d477349ad..6200cc248 100644 --- a/writeengine/dictionary/we_dctnry.cpp +++ b/writeengine/dictionary/we_dctnry.cpp @@ -803,7 +803,8 @@ int Dctnry::insertDctnry(const char* buf, while (startPos < totalRow) { found = false; - memset(&curSig, 0, sizeof(curSig)); + void *curSigPtr = static_cast(&curSig); + memset(curSigPtr, 0, sizeof(curSig)); curSig.size = pos[startPos][col].offset; // Strip trailing null bytes '\0' (by adjusting curSig.size) if import- @@ -1317,7 +1318,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)) @@ -1361,8 +1363,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/shared/we_fileop.cpp b/writeengine/shared/we_fileop.cpp index 7a2a2456b..b5970abbb 100644 --- a/writeengine/shared/we_fileop.cpp +++ b/writeengine/shared/we_fileop.cpp @@ -332,12 +332,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; @@ -365,6 +368,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++ ) { @@ -378,10 +382,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; @@ -412,6 +416,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++) { @@ -422,12 +427,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 06a367ecb..08df6f10e 100644 --- a/writeengine/shared/we_type.h +++ b/writeengine/shared/we_type.h @@ -487,7 +487,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/wrapper/we_colop.cpp b/writeengine/wrapper/we_colop.cpp index 515e9f7b2..4e08bd742 100644 --- a/writeengine/wrapper/we_colop.cpp +++ b/writeengine/wrapper/we_colop.cpp @@ -238,7 +238,8 @@ int ColumnOp::allocRowId(const TxnID& txnid, bool useStartingExtent, for (i = 0; i < dbRootExtentTrackers.size(); i++) { - if (i != (int) 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 From a8adef8820e5270b95e5d9af3124383d36173925 Mon Sep 17 00:00:00 2001 From: Roman Nozdrin Date: Wed, 1 May 2019 16:06:48 +0300 Subject: [PATCH 3/9] MCOL-1495 DML operations created two fCatalogMap entries per session. These entries were never deleted so WE leaks about 7MB per 100 DML sessions. I add purge operations in the very end of four functions involved in DML. --- writeengine/server/we_dmlcommandproc.cpp | 32 +++++++++++++----------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/writeengine/server/we_dmlcommandproc.cpp b/writeengine/server/we_dmlcommandproc.cpp index cbc84e26e..e5f552927 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; } @@ -3774,7 +3776,6 @@ uint8_t WE_DMLCommandProc::processUpdate(messageqcpp::ByteStream& bs, err = IDBErrorInfo::instance()->errorMsg(WARN_DATA_TRUNC, args); } - //cout << "finished update" << endl; return rc; } @@ -3957,6 +3958,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; } @@ -4132,7 +4137,6 @@ uint8_t WE_DMLCommandProc::processDelete(messageqcpp::ByteStream& bs, } } - //cout << "WES return rc " << (int)rc << " with msg " << err << endl; return rc; } From 9e7d852804d796b64e38d720ad2fef7b32c20945 Mon Sep 17 00:00:00 2001 From: Patrice Linel Date: Wed, 1 May 2019 10:29:57 -0500 Subject: [PATCH 4/9] unneeded k for loop --- writeengine/server/we_dmlcommandproc.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/writeengine/server/we_dmlcommandproc.cpp b/writeengine/server/we_dmlcommandproc.cpp index cbc84e26e..118363217 100644 --- a/writeengine/server/we_dmlcommandproc.cpp +++ b/writeengine/server/we_dmlcommandproc.cpp @@ -2847,16 +2847,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; From b2bf6dece586c735ee30cd078081b8e8c7729546 Mon Sep 17 00:00:00 2001 From: gscteam <49755341+gscteam@users.noreply.github.com> Date: Wed, 1 May 2019 13:38:02 -0500 Subject: [PATCH 5/9] missing semicol --- writeengine/server/we_dmlcommandproc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/writeengine/server/we_dmlcommandproc.cpp b/writeengine/server/we_dmlcommandproc.cpp index 118363217..1ca4d1d7c 100644 --- a/writeengine/server/we_dmlcommandproc.cpp +++ b/writeengine/server/we_dmlcommandproc.cpp @@ -2847,7 +2847,7 @@ 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); - int rrid = (int) relativeRID / (BYTE_PER_BLOCK / colWidth) + int rrid = (int) relativeRID / (BYTE_PER_BLOCK / colWidth); // populate stats.blocksChanged if (rrid > preBlkNums[j]) { From 7e2cb0562472a2d05316889b5cf175d735da93a4 Mon Sep 17 00:00:00 2001 From: Roman Nozdrin Date: Mon, 29 Apr 2019 12:26:12 +0300 Subject: [PATCH 6/9] MCOL-537 There are no CS-specific warnings building with gcc 8.2. --- dbcon/execplan/arithmeticoperator.cpp | 16 ---- dbcon/execplan/logicoperator.cpp | 16 ---- dbcon/joblist/joblistfactory.cpp | 30 -------- dbcon/mysql/ha_calpont_dml.cpp | 97 ------------------------- dbcon/mysql/ha_calpont_partition.cpp | 15 ---- ddlproc/ddlproc.cpp | 10 ++- exemgr/main.cpp | 16 ++-- primitives/blockcache/iomanager.cpp | 67 +---------------- primitives/primproc/columncommand.cpp | 11 --- primitives/primproc/primitiveserver.cpp | 27 ------- primitives/primproc/primproc.cpp | 18 +++-- tools/dbbuilder/dbbuilder.cpp | 40 +++++----- tools/dbloadxml/colxml.cpp | 3 + utils/dataconvert/dataconvert.h | 5 +- utils/querytele/queryteleprotoimpl.cpp | 2 +- versioning/BRM/slavecomm.cpp | 10 ++- writeengine/bulk/cpimport.cpp | 7 +- writeengine/bulk/we_tableinfo.cpp | 11 ++- writeengine/server/we_getfilesizes.cpp | 4 +- writeengine/shared/we_chunkmanager.cpp | 8 ++ writeengine/splitter/we_splitterapp.cpp | 3 + writeengine/xml/we_xmlgenproc.cpp | 10 +-- writeengine/xml/we_xmlgenproc.h | 2 +- 23 files changed, 94 insertions(+), 334 deletions(-) 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/joblist/joblistfactory.cpp b/dbcon/joblist/joblistfactory.cpp index 32c7a0836..21df156a7 100644 --- a/dbcon/joblist/joblistfactory.cpp +++ b/dbcon/joblist/joblistfactory.cpp @@ -94,36 +94,6 @@ namespace using namespace joblist; -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) { if (sc == NULL) diff --git a/dbcon/mysql/ha_calpont_dml.cpp b/dbcon/mysql/ha_calpont_dml.cpp index 0e2bce76c..f6393a09f 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_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/ddlproc/ddlproc.cpp b/ddlproc/ddlproc.cpp index 6f827f8fd..bb3020deb 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,10 @@ 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 ) + { + std::cerr << "Could not set working directory" << std::endl; + } WriteEngine::WriteEngineWrapper::init( WriteEngine::SUBSYSTEM_ID_DDLPROC ); #ifdef _MSC_VER diff --git a/exemgr/main.cpp b/exemgr/main.cpp index 259d1443e..252f8fbf5 100644 --- a/exemgr/main.cpp +++ b/exemgr/main.cpp @@ -1325,13 +1325,15 @@ void setupSignalHandlers() #endif } -void setupCwd(ResourceManager* rm) +int8_t setupCwd(ResourceManager* rm) { 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) @@ -1497,9 +1499,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; @@ -1523,9 +1528,6 @@ int main(int argc, char* argv[]) return 2; } - - setupCwd(rm); - cleanTempDir(); MsgMap msgMap; 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/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 2e88493a0..a8ceb1451 100644 --- a/primitives/primproc/primproc.cpp +++ b/primitives/primproc/primproc.cpp @@ -146,17 +146,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() @@ -342,11 +344,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; @@ -366,6 +368,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/tools/dbbuilder/dbbuilder.cpp b/tools/dbbuilder/dbbuilder.cpp index aec094b89..634a78ebd 100644 --- a/tools/dbbuilder/dbbuilder.cpp +++ b/tools/dbbuilder/dbbuilder.cpp @@ -58,11 +58,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) @@ -72,12 +72,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 @@ -130,6 +124,7 @@ int main(int argc, char* argv[]) std::string schema("tpch"); Oam oam; bool fFlg = false; + int rc = 0; opterr = 0; @@ -193,7 +188,10 @@ int main(int argc, char* argv[]) if ( buildOption == SYSCATALOG_ONLY ) { - setUp(); + if ( setUp() ) + { + cerr << "setUp() call error " << endl; + } bool canWrite = true; @@ -209,9 +207,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", @@ -243,7 +245,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; @@ -255,7 +257,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; @@ -274,7 +276,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; @@ -287,11 +289,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."; @@ -309,7 +309,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; @@ -320,7 +320,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 00171ffc0..9c28b232d 100644 --- a/tools/dbloadxml/colxml.cpp +++ b/tools/dbloadxml/colxml.cpp @@ -46,7 +46,10 @@ int main(int argc, char** argv) #ifdef _MSC_VER //FIXME #else +#pragma GCC diagnostic ignored "-Wunused-result" setuid( 0 ); // set effective ID to root; ignore return status + // Why should we raise privileges if we don't care? +#pragma GCC diagnostic pop #endif setlocale(LC_ALL, ""); WriteEngine::Config::initConfigCache(); // load Columnstore.xml config settings diff --git a/utils/dataconvert/dataconvert.h b/utils/dataconvert/dataconvert.h index a6ce20198..2e0d225fe 100644 --- a/utils/dataconvert/dataconvert.h +++ b/utils/dataconvert/dataconvert.h @@ -673,12 +673,15 @@ 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. +#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 } inline std::string DataConvert::decimalToString(int64_t value, uint8_t scale, execplan::CalpontSystemCatalog::ColDataType colDataType) diff --git a/utils/querytele/queryteleprotoimpl.cpp b/utils/querytele/queryteleprotoimpl.cpp index e1ad7025a..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; @@ -94,7 +95,6 @@ string get_trace_file() return oss.str(); } -#ifdef QUERY_TELE_DEBUG void log_query(const querytele::QueryTele& qtdata) { ofstream trace(get_trace_file().c_str(), ios::out | ios::app); 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..c23b3170d 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,9 @@ int main(int argc, char** argv) #ifdef _MSC_VER _setmaxstdio(2048); #else +#pragma GCC diagnostic ignored "-Wunused-result" setuid( 0 ); // set effective ID to root; ignore return status +#pragma GCC diagnostic pop #endif setupSignalHandlers(); diff --git a/writeengine/bulk/we_tableinfo.cpp b/writeengine/bulk/we_tableinfo.cpp index 2885d1462..593b68647 100644 --- a/writeengine/bulk/we_tableinfo.cpp +++ b/writeengine/bulk/we_tableinfo.cpp @@ -1462,9 +1462,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() ); @@ -1569,8 +1571,9 @@ void TableInfo::writeErrReason( const std::vector< std::pair(&tv.tv_sec), <m); char tmText[24]; + // this snprintf call causes a compiler warning b/c buffer size is less + // then maximum string size. +#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 string dbgFileName(rlcFileName + tmText); ostringstream oss; @@ -2106,10 +2110,14 @@ 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. +#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 string dbgFileName(rlcFileName + tmText); ostringstream oss; diff --git a/writeengine/splitter/we_splitterapp.cpp b/writeengine/splitter/we_splitterapp.cpp index dac0c7387..12e3f2389 100644 --- a/writeengine/splitter/we_splitterapp.cpp +++ b/writeengine/splitter/we_splitterapp.cpp @@ -604,7 +604,10 @@ void WESplitterApp::updateWithJobFile(int aIdx) int main(int argc, char** argv) { std::string err; +#pragma GCC diagnostic ignored "-Wunused-result" + // Why do we need this if we don't care about f()'s rc ? setuid(0); //@BUG 4343 set effective userid to root. +#pragma GCC diagnostic pop std::cin.sync_with_stdio(false); try diff --git a/writeengine/xml/we_xmlgenproc.cpp b/writeengine/xml/we_xmlgenproc.cpp index d5a787769..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,13 +438,11 @@ void XMLGenProc::getColumnsForTable( throw std::runtime_error( oss.str() ); } } - + //------------------------------------------------------------------------------ // Generate Job XML File Name //------------------------------------------------------------------------------ -// This isn't used currently, commenting it out -#if 0 std::string XMLGenProc::genJobXMLFileName( ) const { std::string xmlFileName; @@ -471,7 +469,7 @@ std::string XMLGenProc::genJobXMLFileName( ) const char *buf; buf = getcwd(cwdPath, sizeof(cwdPath)); if (buf == NULL) - throw runtime_error("Failed to get the current working directory!"); + throw std::runtime_error("Failed to get the current working directory!"); boost::filesystem::path p2(cwdPath); p2 /= p; xmlFileName = p2.string(); @@ -485,9 +483,7 @@ std::string XMLGenProc::genJobXMLFileName( ) const return xmlFileName; } -#endif - //------------------------------------------------------------------------------ // writeXMLFile //------------------------------------------------------------------------------ diff --git a/writeengine/xml/we_xmlgenproc.h b/writeengine/xml/we_xmlgenproc.h index adce2d75f..4b7ec4ed5 100644 --- a/writeengine/xml/we_xmlgenproc.h +++ b/writeengine/xml/we_xmlgenproc.h @@ -90,7 +90,7 @@ public: /** @brief Generate Job XML file name */ - //EXPORT std::string genJobXMLFileName( ) const; + EXPORT std::string genJobXMLFileName( ) const; /** @brief Write xml file document to the destination Job XML file. * From b2436502cbfd683990966e9c312894ac8ab39d25 Mon Sep 17 00:00:00 2001 From: Roman Nozdrin Date: Wed, 8 May 2019 11:41:26 +0300 Subject: [PATCH 7/9] MCOL-537 Enabled -Wno-unused-result for OAM code. Fixed pragmas that disables compilation checks. DDLProc now returns an error if it couldn't cwd. Use either auto_ptr or unique_ptr depending on GCC version. --- ddlproc/ddlproc.cpp | 10 +++++++++- oam/oamcpp/CMakeLists.txt | 2 ++ oamapps/alarmmanager/alarmmanager.cpp | 4 ++-- oamapps/columnstoreSupport/CMakeLists.txt | 2 ++ oamapps/mcsadmin/CMakeLists.txt | 2 ++ oamapps/postConfigure/CMakeLists.txt | 6 ++++++ oamapps/serverMonitor/CMakeLists.txt | 2 ++ procmgr/CMakeLists.txt | 2 ++ procmon/CMakeLists.txt | 2 ++ tools/configMgt/CMakeLists.txt | 14 ++------------ tools/dbloadxml/colxml.cpp | 13 +++++-------- utils/dataconvert/dataconvert.cpp | 21 +++++++++++++++------ utils/dataconvert/dataconvert.h | 3 +++ utils/messageqcpp/inetstreamsocket.cpp | 12 ++++++++---- utils/threadpool/threadpool.h | 4 ++++ writeengine/bulk/cpimport.cpp | 8 +++++--- writeengine/shared/we_chunkmanager.cpp | 7 +++++++ writeengine/splitter/we_splitterapp.cpp | 10 +++++++--- 18 files changed, 85 insertions(+), 39 deletions(-) diff --git a/ddlproc/ddlproc.cpp b/ddlproc/ddlproc.cpp index bb3020deb..5cc663fc2 100644 --- a/ddlproc/ddlproc.cpp +++ b/ddlproc/ddlproc.cpp @@ -106,9 +106,17 @@ int main(int argc, char* argv[]) if ( setupCwd() < 0 ) { - std::cerr << "Could not set working directory" << std::endl; + 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 // In windows, initializing the wrapper (A dll) does not set the static variables 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/oamapps/alarmmanager/alarmmanager.cpp b/oamapps/alarmmanager/alarmmanager.cpp index 2d057944c..f07130c7b 100644 --- a/oamapps/alarmmanager/alarmmanager.cpp +++ b/oamapps/alarmmanager/alarmmanager.cpp @@ -486,8 +486,8 @@ void ALARMManager::sendAlarmReport (const char* componentID, int alarmID, int st ByteStream msg1; -// setup message -msg1 << (ByteStream::byte) alarmID; + // setup message + msg1 << (ByteStream::byte) alarmID; msg1 << (std::string) componentID; msg1 << (ByteStream::byte) state; msg1 << (std::string) ModuleName; 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/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/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/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/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/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/dbloadxml/colxml.cpp b/tools/dbloadxml/colxml.cpp index 9c28b232d..2e2d192c9 100644 --- a/tools/dbloadxml/colxml.cpp +++ b/tools/dbloadxml/colxml.cpp @@ -43,14 +43,11 @@ using namespace bulkloadxml; int main(int argc, char** argv) { const int DEBUG_LVL_TO_DUMP_SYSCAT_RPT = 4; -#ifdef _MSC_VER - //FIXME -#else -#pragma GCC diagnostic ignored "-Wunused-result" - setuid( 0 ); // set effective ID to root; ignore return status - // Why should we raise privileges if we don't care? -#pragma GCC diagnostic pop -#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/dataconvert/dataconvert.cpp b/utils/dataconvert/dataconvert.cpp index a2e3aaa47..311d82e08 100644 --- a/utils/dataconvert/dataconvert.cpp +++ b/utils/dataconvert/dataconvert.cpp @@ -2429,9 +2429,12 @@ int64_t DataConvert::intToDate(int64_t data) // 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. - #pragma GCC diagnostic ignored "-Wformat-truncation=" +#if defined(__GNUC__) && __GNUC__ >= 5 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-truncation=" snprintf( buf, 15, "%llu", (long long unsigned int)data); - #pragma GCC diagnostic pop +#pragma GCC diagnostic pop +#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; @@ -2560,9 +2563,12 @@ int64_t DataConvert::intToDatetime(int64_t data, bool* date) // 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. - #pragma GCC diagnostic ignored "-Wformat-truncation=" +#if defined(__GNUC__) && __GNUC__ >= 5 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-truncation=" snprintf( buf, 15, "%llu", (long long unsigned int)data); - #pragma GCC diagnostic pop +#pragma GCC diagnostic pop +#endif //string date = buf; string year, month, day, hour, min, sec, msec; @@ -2693,9 +2699,12 @@ int64_t DataConvert::intToTime(int64_t data, bool fromString) // 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. - #pragma GCC diagnostic ignored "-Wformat-truncation=" +#if defined(__GNUC__) && __GNUC__ >= 5 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-truncation=" snprintf( buf, 15, "%llu", (long long unsigned int)data); - #pragma GCC diagnostic pop +#pragma GCC diagnostic pop +#endif //string date = buf; string hour, min, sec, msec; diff --git a/utils/dataconvert/dataconvert.h b/utils/dataconvert/dataconvert.h index 2e0d225fe..b81634639 100644 --- a/utils/dataconvert/dataconvert.h +++ b/utils/dataconvert/dataconvert.h @@ -675,6 +675,8 @@ inline void DataConvert::timeToString1( long long timevalue, char* buf, unsigned } // this snprintf call causes a compiler warning b/c buffer size is less // then maximum string size. +#if defined(__GNUC__) && __GNUC__ >= 5 +#pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wformat-truncation=" snprintf( buf, buflen, "%02d%02d%02d", hour, @@ -682,6 +684,7 @@ inline void DataConvert::timeToString1( long long timevalue, char* buf, unsigned (unsigned)((timevalue >> 14) & 0xff) ); #pragma GCC diagnostic pop +#endif } inline std::string DataConvert::decimalToString(int64_t value, uint8_t scale, execplan::CalpontSystemCatalog::ColDataType colDataType) diff --git a/utils/messageqcpp/inetstreamsocket.cpp b/utils/messageqcpp/inetstreamsocket.cpp index 8b4aa4b1e..1e09c38cf 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,11 +963,16 @@ void InetStreamSocket::connect(const sockaddr* serv_addr) if (ret == 1) { #ifdef _MSC_VER + char buf = '\0'; (void)::recv(socketParms().sd(), &buf, 1, 0); #else - #pragma GCC diagnostic ignored "-Wunused-result" - ::read(socketParms().sd(), &buf, 1); // we know 1 byte is in the recv buffer - #pragma GCC diagnostic pop +#if defined(__GNUC__) && __GNUC__ >= 5 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + char buf = '\0'; + ssize_t bytes = ::read(socketParms().sd(), &buf, 1); // we know 1 byte is in the recv buffer +#pragma GCC diagnostic pop +#endif // pragma #endif return; } diff --git a/utils/threadpool/threadpool.h b/utils/threadpool/threadpool.h index e7ee9de82..fa6921900 100644 --- a/utils/threadpool/threadpool.h +++ b/utils/threadpool/threadpool.h @@ -77,7 +77,11 @@ public: boost::thread* create_thread(F threadfunc) { boost::lock_guard guard(m); +#if defined(__GNUC__) && __GNUC__ >= 5 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(); } diff --git a/writeengine/bulk/cpimport.cpp b/writeengine/bulk/cpimport.cpp index c23b3170d..54b688d0b 100644 --- a/writeengine/bulk/cpimport.cpp +++ b/writeengine/bulk/cpimport.cpp @@ -1022,9 +1022,11 @@ int main(int argc, char** argv) #ifdef _MSC_VER _setmaxstdio(2048); #else -#pragma GCC diagnostic ignored "-Wunused-result" - setuid( 0 ); // set effective ID to root; ignore return status -#pragma GCC diagnostic pop + // set effective ID to root + if( setuid( 0 ) < 0 ) + { + std::cerr << " cpimport: setuid failed " << std::endl; + } #endif setupSignalHandlers(); diff --git a/writeengine/shared/we_chunkmanager.cpp b/writeengine/shared/we_chunkmanager.cpp index f701f94ee..e6fa43db1 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 @@ -1925,12 +1926,15 @@ int ChunkManager::reallocateChunks(CompFileData* fileData) char tmText[24]; // this snprintf call causes a compiler warning b/c buffer size is less // then maximum string size. +#if defined(__GNUC__) && __GNUC__ >= 5 +#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 +#endif string dbgFileName(rlcFileName + tmText); ostringstream oss; @@ -2112,12 +2116,15 @@ int ChunkManager::reallocateChunks(CompFileData* fileData) char tmText[24]; // this snprintf call causes a compiler warning b/c buffer size is less // then maximum string size. +#if defined(__GNUC__) && __GNUC__ >= 5 +#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 +#endif string dbgFileName(rlcFileName + tmText); ostringstream oss; diff --git a/writeengine/splitter/we_splitterapp.cpp b/writeengine/splitter/we_splitterapp.cpp index 12e3f2389..af4f6b294 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,10 +605,13 @@ void WESplitterApp::updateWithJobFile(int aIdx) int main(int argc, char** argv) { std::string err; -#pragma GCC diagnostic ignored "-Wunused-result" // Why do we need this if we don't care about f()'s rc ? - setuid(0); //@BUG 4343 set effective userid to root. -#pragma GCC diagnostic pop + // @BUG4343 + if( setuid( 0 ) < 0 ) + { + std::cerr << " we_splitterapp: setuid failed " << std::endl; + } + std::cin.sync_with_stdio(false); try From 99d172372d0e7d205fe2afb4748f0adbbde6a6f1 Mon Sep 17 00:00:00 2001 From: Ben Thompson Date: Wed, 8 May 2019 12:01:30 -0500 Subject: [PATCH 8/9] Fix for newer version of CMake/CPack --- cpackEngineRPM.cmake | 228 +------------------------------------------ 1 file changed, 3 insertions(+), 225 deletions(-) diff --git a/cpackEngineRPM.cmake b/cpackEngineRPM.cmake index 83a707dbd..2ae976911 100644 --- a/cpackEngineRPM.cmake +++ b/cpackEngineRPM.cmake @@ -119,233 +119,11 @@ SET(ignored #%define _prefix ${CMAKE_INSTALL_PREFIX} #") -SET(CPACK_RPM_platform_USER_FILELIST -"/usr/local/mariadb/columnstore/bin/DDLProc" -"/usr/local/mariadb/columnstore/bin/ExeMgr" -"/usr/local/mariadb/columnstore/bin/ProcMgr" -"/usr/local/mariadb/columnstore/bin/ProcMon" -"/usr/local/mariadb/columnstore/bin/DMLProc" -"/usr/local/mariadb/columnstore/bin/WriteEngineServer" -"/usr/local/mariadb/columnstore/bin/cpimport" -"/usr/local/mariadb/columnstore/bin/post-install" -"/usr/local/mariadb/columnstore/bin/post-mysql-install" -"/usr/local/mariadb/columnstore/bin/post-mysqld-install" -"/usr/local/mariadb/columnstore/bin/pre-uninstall" -"/usr/local/mariadb/columnstore/bin/PrimProc" -"/usr/local/mariadb/columnstore/bin/run.sh" -"/usr/local/mariadb/columnstore/bin/columnstore" -"/usr/local/mariadb/columnstore/bin/columnstoreSyslog" -"/usr/local/mariadb/columnstore/bin/columnstoreSyslog7" -"/usr/local/mariadb/columnstore/bin/columnstoreSyslog-ng" -"/usr/local/mariadb/columnstore/bin/syslogSetup.sh" -"/usr/local/mariadb/columnstore/bin/cplogger" -"/usr/local/mariadb/columnstore/bin/columnstore.def" -"/usr/local/mariadb/columnstore/bin/dbbuilder" -"/usr/local/mariadb/columnstore/bin/cpimport.bin" -"/usr/local/mariadb/columnstore/bin/load_brm" -"/usr/local/mariadb/columnstore/bin/save_brm" -"/usr/local/mariadb/columnstore/bin/dbrmctl" -"/usr/local/mariadb/columnstore/bin/controllernode" -"/usr/local/mariadb/columnstore/bin/reset_locks" -"/usr/local/mariadb/columnstore/bin/workernode" -"/usr/local/mariadb/columnstore/bin/colxml" -"/usr/local/mariadb/columnstore/bin/clearShm" -"/usr/local/mariadb/columnstore/bin/viewtablelock" -"/usr/local/mariadb/columnstore/bin/cleartablelock" -"/usr/local/mariadb/columnstore/bin/mcsadmin" -"/usr/local/mariadb/columnstore/bin/remote_command.sh" -"/usr/local/mariadb/columnstore/bin/postConfigure" -"/usr/local/mariadb/columnstore/bin/columnstoreLogRotate" -"/usr/local/mariadb/columnstore/bin/transactionLog" -"/usr/local/mariadb/columnstore/bin/columnstoreDBWrite" -"/usr/local/mariadb/columnstore/bin/transactionLogArchiver.sh" -"/usr/local/mariadb/columnstore/bin/installer" -"/usr/local/mariadb/columnstore/bin/module_installer.sh" -"/usr/local/mariadb/columnstore/bin/package_installer.sh" -"/usr/local/mariadb/columnstore/bin/startupTests.sh" -"/usr/local/mariadb/columnstore/bin/os_check.sh" -"/usr/local/mariadb/columnstore/bin/remote_scp_put.sh" -"/usr/local/mariadb/columnstore/bin/remotessh.exp" -"/usr/local/mariadb/columnstore/bin/ServerMonitor" -"/usr/local/mariadb/columnstore/bin/master-rep-columnstore.sh" -"/usr/local/mariadb/columnstore/bin/slave-rep-columnstore.sh" -"/usr/local/mariadb/columnstore/bin/rsync.sh" -"/usr/local/mariadb/columnstore/bin/columnstoreSupport" -"/usr/local/mariadb/columnstore/bin/hardwareReport.sh" -"/usr/local/mariadb/columnstore/bin/softwareReport.sh" -"/usr/local/mariadb/columnstore/bin/configReport.sh" -"/usr/local/mariadb/columnstore/bin/logReport.sh" -"/usr/local/mariadb/columnstore/bin/bulklogReport.sh" -"/usr/local/mariadb/columnstore/bin/resourceReport.sh" -"/usr/local/mariadb/columnstore/bin/hadoopReport.sh" -"/usr/local/mariadb/columnstore/bin/alarmReport.sh" -"/usr/local/mariadb/columnstore/bin/remote_command_verify.sh" -"/usr/local/mariadb/columnstore/bin/disable-rep-columnstore.sh" -"/usr/local/mariadb/columnstore/bin/columnstore.service" -"/usr/local/mariadb/columnstore/etc/MessageFile.txt" -"/usr/local/mariadb/columnstore/etc/ErrorMessage.txt" -"/usr/local/mariadb/columnstore/local/module" -"/usr/local/mariadb/columnstore/releasenum" -"/usr/local/mariadb/columnstore/bin/rollback" -"/usr/local/mariadb/columnstore/bin/editem" -"/usr/local/mariadb/columnstore/bin/getConfig" -"/usr/local/mariadb/columnstore/bin/setConfig" -"/usr/local/mariadb/columnstore/bin/setenv-hdfs-12" -"/usr/local/mariadb/columnstore/bin/setenv-hdfs-20" -"/usr/local/mariadb/columnstore/bin/configxml.sh" -"/usr/local/mariadb/columnstore/bin/remote_scp_get.sh" -"/usr/local/mariadb/columnstore/bin/columnstoreAlias" -"/usr/local/mariadb/columnstore/bin/autoConfigure" -"/usr/local/mariadb/columnstore/bin/ddlcleanup" -"/usr/local/mariadb/columnstore/bin/idbmeminfo" -"/usr/local/mariadb/columnstore/bin/MCSInstanceCmds.sh" -"/usr/local/mariadb/columnstore/bin/MCSVolumeCmds.sh" -"/usr/local/mariadb/columnstore/bin/binary_installer.sh" -"/usr/local/mariadb/columnstore/bin/myCnf-include-args.text" -"/usr/local/mariadb/columnstore/bin/myCnf-exclude-args.text" -"/usr/local/mariadb/columnstore/bin/mycnfUpgrade" -"/usr/local/mariadb/columnstore/bin/getMySQLpw" -"/usr/local/mariadb/columnstore/bin/columnstore.conf" -"/usr/local/mariadb/columnstore/post/functions" -"/usr/local/mariadb/columnstore/post/test-001.sh" -"/usr/local/mariadb/columnstore/post/test-002.sh" -"/usr/local/mariadb/columnstore/post/test-003.sh" -"/usr/local/mariadb/columnstore/post/test-004.sh" -"/usr/local/mariadb/columnstore/bin/os_detect.sh" -"/usr/local/mariadb/columnstore/bin/columnstoreClusterTester.sh" -"/usr/local/mariadb/columnstore/bin/mariadb-command-line.sh" -"/usr/local/mariadb/columnstore/bin/quick_installer_single_server.sh" -"/usr/local/mariadb/columnstore/bin/quick_installer_multi_server.sh" -"/usr/local/mariadb/columnstore/bin/quick_installer_amazon.sh" -${ignored}) +SET(CPACK_RPM_platform_USER_FILELIST ${ignored}) -SET(CPACK_RPM_libs_USER_FILELIST -"/usr/local/mariadb/columnstore/lib/libconfigcpp.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libconfigcpp.so.1" -"/usr/local/mariadb/columnstore/lib/libconfigcpp.so" -"/usr/local/mariadb/columnstore/lib/libddlpackageproc.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libddlpackageproc.so.1" -"/usr/local/mariadb/columnstore/lib/libddlpackageproc.so" -"/usr/local/mariadb/columnstore/lib/libddlpackage.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libddlpackage.so.1" -"/usr/local/mariadb/columnstore/lib/libddlpackage.so" -"/usr/local/mariadb/columnstore/lib/libdmlpackageproc.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libdmlpackageproc.so.1" -"/usr/local/mariadb/columnstore/lib/libdmlpackageproc.so" -"/usr/local/mariadb/columnstore/lib/libdmlpackage.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libdmlpackage.so.1" -"/usr/local/mariadb/columnstore/lib/libdmlpackage.so" -"/usr/local/mariadb/columnstore/lib/libexecplan.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libexecplan.so.1" -"/usr/local/mariadb/columnstore/lib/libexecplan.so" -"/usr/local/mariadb/columnstore/lib/libfuncexp.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libfuncexp.so.1" -"/usr/local/mariadb/columnstore/lib/libfuncexp.so" -"/usr/local/mariadb/columnstore/lib/libudfsdk.so.1.1.0" -"/usr/local/mariadb/columnstore/lib/libudfsdk.so.1" -"/usr/local/mariadb/columnstore/lib/libudfsdk.so" -"/usr/local/mariadb/columnstore/lib/libjoblist.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libjoblist.so.1" -"/usr/local/mariadb/columnstore/lib/libjoblist.so" -"/usr/local/mariadb/columnstore/lib/libjoiner.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libjoiner.so.1" -"/usr/local/mariadb/columnstore/lib/libjoiner.so" -"/usr/local/mariadb/columnstore/lib/libloggingcpp.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libloggingcpp.so.1" -"/usr/local/mariadb/columnstore/lib/libloggingcpp.so" -"/usr/local/mariadb/columnstore/lib/libmessageqcpp.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libmessageqcpp.so.1" -"/usr/local/mariadb/columnstore/lib/libmessageqcpp.so" -"/usr/local/mariadb/columnstore/lib/liboamcpp.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/liboamcpp.so.1" -"/usr/local/mariadb/columnstore/lib/liboamcpp.so" -"/usr/local/mariadb/columnstore/lib/libalarmmanager.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libalarmmanager.so.1" -"/usr/local/mariadb/columnstore/lib/libalarmmanager.so" -"/usr/local/mariadb/columnstore/lib/libthreadpool.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libthreadpool.so.1" -"/usr/local/mariadb/columnstore/lib/libthreadpool.so" -"/usr/local/mariadb/columnstore/lib/libwindowfunction.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libwindowfunction.so.1" -"/usr/local/mariadb/columnstore/lib/libwindowfunction.so" -"/usr/local/mariadb/columnstore/lib/libwriteengine.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libwriteengine.so.1" -"/usr/local/mariadb/columnstore/lib/libwriteengine.so" -"/usr/local/mariadb/columnstore/lib/libwriteengineclient.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libwriteengineclient.so.1" -"/usr/local/mariadb/columnstore/lib/libwriteengineclient.so" -"/usr/local/mariadb/columnstore/lib/libbrm.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libbrm.so.1" -"/usr/local/mariadb/columnstore/lib/libbrm.so" -"/usr/local/mariadb/columnstore/lib/librwlock.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/librwlock.so.1" -"/usr/local/mariadb/columnstore/lib/librwlock.so" -"/usr/local/mariadb/columnstore/lib/libdataconvert.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libdataconvert.so.1" -"/usr/local/mariadb/columnstore/lib/libdataconvert.so" -"/usr/local/mariadb/columnstore/lib/librowgroup.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/librowgroup.so.1" -"/usr/local/mariadb/columnstore/lib/librowgroup.so" -"/usr/local/mariadb/columnstore/lib/libcacheutils.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libcacheutils.so.1" -"/usr/local/mariadb/columnstore/lib/libcacheutils.so" -"/usr/local/mariadb/columnstore/lib/libcommon.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libcommon.so.1" -"/usr/local/mariadb/columnstore/lib/libcommon.so" -"/usr/local/mariadb/columnstore/lib/libcompress.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libcompress.so.1" -"/usr/local/mariadb/columnstore/lib/libcompress.so" -"/usr/local/mariadb/columnstore/lib/libddlcleanuputil.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libddlcleanuputil.so.1" -"/usr/local/mariadb/columnstore/lib/libddlcleanuputil.so" -"/usr/local/mariadb/columnstore/lib/libbatchloader.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libbatchloader.so.1" -"/usr/local/mariadb/columnstore/lib/libbatchloader.so" -"/usr/local/mariadb/columnstore/lib/libquerystats.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libquerystats.so.1" -"/usr/local/mariadb/columnstore/lib/libquerystats.so" -"/usr/local/mariadb/columnstore/lib/libwriteengineredistribute.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libwriteengineredistribute.so.1" -"/usr/local/mariadb/columnstore/lib/libwriteengineredistribute.so" -"/usr/local/mariadb/columnstore/lib/libidbdatafile.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libidbdatafile.so.1" -"/usr/local/mariadb/columnstore/lib/libidbdatafile.so" -"/usr/local/mariadb/columnstore/lib/libthrift.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libthrift.so.1" -"/usr/local/mariadb/columnstore/lib/libthrift.so" -"/usr/local/mariadb/columnstore/lib/libquerytele.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libquerytele.so.1" -"/usr/local/mariadb/columnstore/lib/libquerytele.so" -${ignored}) +SET(CPACK_RPM_libs_USER_FILELIST ${ignored}) -SET(CPACK_RPM_storage-engine_USER_FILELIST -"/usr/local/mariadb/columnstore/lib/libcalmysql.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libcalmysql.so.1" -"/usr/local/mariadb/columnstore/lib/libcalmysql.so" -"/usr/local/mariadb/columnstore/lib/libudf_mysql.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/libudf_mysql.so.1" -"/usr/local/mariadb/columnstore/lib/libudf_mysql.so" -"/usr/local/mariadb/columnstore/lib/is_columnstore_columns.so" -"/usr/local/mariadb/columnstore/lib/is_columnstore_columns.so.1" -"/usr/local/mariadb/columnstore/lib/is_columnstore_columns.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/is_columnstore_extents.so" -"/usr/local/mariadb/columnstore/lib/is_columnstore_extents.so.1" -"/usr/local/mariadb/columnstore/lib/is_columnstore_extents.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/is_columnstore_tables.so" -"/usr/local/mariadb/columnstore/lib/is_columnstore_tables.so.1" -"/usr/local/mariadb/columnstore/lib/is_columnstore_tables.so.1.0.0" -"/usr/local/mariadb/columnstore/lib/is_columnstore_files.so" -"/usr/local/mariadb/columnstore/lib/is_columnstore_files.so.1" -"/usr/local/mariadb/columnstore/lib/is_columnstore_files.so.1.0.0" -"/usr/local/mariadb/columnstore/mysql/mysql-Columnstore" -"/usr/local/mariadb/columnstore/mysql/install_calpont_mysql.sh" -"/usr/local/mariadb/columnstore/mysql/syscatalog_mysql.sql" -"/usr/local/mariadb/columnstore/mysql/dumpcat_mysql.sql" -"/usr/local/mariadb/columnstore/mysql/calsetuserpriority.sql" -"/usr/local/mariadb/columnstore/mysql/calremoveuserpriority.sql" -"/usr/local/mariadb/columnstore/mysql/calshowprocesslist.sql" -"/usr/local/mariadb/columnstore/mysql/columnstore_info.sql" -${ignored}) +SET(CPACK_RPM_storage-engine_USER_FILELIST ${ignored}) INCLUDE (CPack) From 3c89a4bba467cfb5494c1a2dbdf6594679bd909f Mon Sep 17 00:00:00 2001 From: Roman Nozdrin Date: Thu, 9 May 2019 20:25:21 +0300 Subject: [PATCH 9/9] MCOL-537 Preprocessor if blocks with pragmas now have else branch. DMLProc exits on setupCwd failure. --- dmlproc/dmlproc.cpp | 36 +++++++++++++++++++++----- oamapps/alarmmanager/CMakeLists.txt | 2 ++ oamapps/mcsadmin/mcsadmin.cpp | 15 +++++------ utils/dataconvert/dataconvert.cpp | 12 ++++++--- utils/dataconvert/dataconvert.h | 8 +++++- utils/messageqcpp/inetstreamsocket.cpp | 7 +++-- utils/threadpool/threadpool.h | 2 +- writeengine/shared/we_chunkmanager.cpp | 16 ++++++++++-- writeengine/shared/we_chunkmanager.h | 1 - 9 files changed, 75 insertions(+), 24 deletions(-) diff --git a/dmlproc/dmlproc.cpp b/dmlproc/dmlproc.cpp index deb936422..3845ef37a 100644 --- a/dmlproc/dmlproc.cpp +++ b/dmlproc/dmlproc.cpp @@ -492,17 +492,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 @@ -521,7 +523,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 @@ -610,9 +623,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/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/mcsadmin/mcsadmin.cpp b/oamapps/mcsadmin/mcsadmin.cpp index 02a77f56a..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; diff --git a/utils/dataconvert/dataconvert.cpp b/utils/dataconvert/dataconvert.cpp index 311d82e08..0121b57c4 100644 --- a/utils/dataconvert/dataconvert.cpp +++ b/utils/dataconvert/dataconvert.cpp @@ -2429,11 +2429,13 @@ int64_t DataConvert::intToDate(int64_t data) // 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__ >= 5 +#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; @@ -2563,11 +2565,13 @@ int64_t DataConvert::intToDatetime(int64_t data, bool* date) // 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__ >= 5 +#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; @@ -2699,11 +2703,13 @@ int64_t DataConvert::intToTime(int64_t data, bool fromString) // 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__ >= 5 +#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; diff --git a/utils/dataconvert/dataconvert.h b/utils/dataconvert/dataconvert.h index b81634639..d563f5fea 100644 --- a/utils/dataconvert/dataconvert.h +++ b/utils/dataconvert/dataconvert.h @@ -675,7 +675,7 @@ inline void DataConvert::timeToString1( long long timevalue, char* buf, unsigned } // this snprintf call causes a compiler warning b/c buffer size is less // then maximum string size. -#if defined(__GNUC__) && __GNUC__ >= 5 +#if defined(__GNUC__) && __GNUC__ >= 6 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wformat-truncation=" snprintf( buf, buflen, "%02d%02d%02d", @@ -684,6 +684,12 @@ inline void DataConvert::timeToString1( long long timevalue, char* buf, unsigned (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 } diff --git a/utils/messageqcpp/inetstreamsocket.cpp b/utils/messageqcpp/inetstreamsocket.cpp index 1e09c38cf..d94a3eb94 100644 --- a/utils/messageqcpp/inetstreamsocket.cpp +++ b/utils/messageqcpp/inetstreamsocket.cpp @@ -966,12 +966,15 @@ void InetStreamSocket::connect(const sockaddr* serv_addr) char buf = '\0'; (void)::recv(socketParms().sd(), &buf, 1, 0); #else -#if defined(__GNUC__) && __GNUC__ >= 5 +#if defined(__GNUC__) && __GNUC__ >= 6 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-result" char buf = '\0'; - ssize_t bytes = ::read(socketParms().sd(), &buf, 1); // we know 1 byte is in the recv buffer + ::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/threadpool/threadpool.h b/utils/threadpool/threadpool.h index fa6921900..27d87fd12 100644 --- a/utils/threadpool/threadpool.h +++ b/utils/threadpool/threadpool.h @@ -77,7 +77,7 @@ public: boost::thread* create_thread(F threadfunc) { boost::lock_guard guard(m); -#if defined(__GNUC__) && __GNUC__ >= 5 +#if defined(__GNUC__) && __GNUC__ >= 7 std::unique_ptr new_thread(new boost::thread(threadfunc)); #else std::auto_ptr new_thread(new boost::thread(threadfunc)); diff --git a/writeengine/shared/we_chunkmanager.cpp b/writeengine/shared/we_chunkmanager.cpp index e6fa43db1..abe61ab11 100644 --- a/writeengine/shared/we_chunkmanager.cpp +++ b/writeengine/shared/we_chunkmanager.cpp @@ -66,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. //------------------------------------------------------------------------------ @@ -1926,7 +1928,7 @@ int ChunkManager::reallocateChunks(CompFileData* fileData) char tmText[24]; // this snprintf call causes a compiler warning b/c buffer size is less // then maximum string size. -#if defined(__GNUC__) && __GNUC__ >= 5 +#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", @@ -1934,6 +1936,11 @@ int ChunkManager::reallocateChunks(CompFileData* fileData) 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); @@ -2116,7 +2123,7 @@ int ChunkManager::reallocateChunks(CompFileData* fileData) char tmText[24]; // this snprintf call causes a compiler warning b/c buffer size is less // then maximum string size. -#if defined(__GNUC__) && __GNUC__ >= 5 +#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", @@ -2124,6 +2131,11 @@ int ChunkManager::reallocateChunks(CompFileData* fileData) 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); 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;