build: Treat warnings as errors (#923)

* squash and rebase andronov-alexey:treat_warnings_as_errors from pull request #850
* fix remaining warnings in java lib
This commit is contained in:
Malte Langkabel
2020-02-14 16:34:04 +01:00
committed by GitHub
parent e5c1a118d7
commit a30f47e27f
112 changed files with 634 additions and 430 deletions
+6
View File
@@ -32,7 +32,10 @@ public:
static CharT* CopyFn(CharT* destination, const CharT* source, size_t num)
{
#pragma warning(push)
#pragma warning(disable : 4996)
return strncpy(destination, source, num);
#pragma warning(pop)
}
};
@@ -50,7 +53,10 @@ public:
static CharT* CopyFn(CharT* destination, const CharT* source, size_t num)
{
#pragma warning(push)
#pragma warning(disable : 4996)
return wcsncpy(destination, source, num);
#pragma warning(pop)
}
};
+4 -4
View File
@@ -23,7 +23,7 @@ std::string TimeStamp::secondsToString(double secs)
int seconds = int(secs);
secs -= seconds;
int milliSeconds = secs * 1000;
const int milliSeconds = static_cast<int>(secs * 1000);
if (hours > 9)
{
@@ -110,12 +110,12 @@ std::string TimeStamp::dayOfWeekShort() const
size_t TimeStamp::deltaMS(const TimeStamp& other) const
{
return abs((m_time - other.m_time).total_milliseconds());
return static_cast<size_t>(abs((m_time - other.m_time).total_milliseconds()));
}
size_t TimeStamp::deltaS(const TimeStamp& other) const
{
return abs((m_time - other.m_time).total_seconds());
return static_cast<size_t>(abs((m_time - other.m_time).total_seconds()));
}
bool TimeStamp::isSameDay(const TimeStamp& other) const
@@ -139,5 +139,5 @@ size_t TimeStamp::deltaDays(const TimeStamp& other) const
size_t TimeStamp::deltaHours(const TimeStamp& other) const
{
boost::posix_time::time_duration delta = m_time - other.m_time;
return abs(delta.total_seconds() / 3600);
return static_cast<size_t>(abs(delta.total_seconds() / 3600));
}
+3
View File
@@ -261,8 +261,11 @@ std::vector<FilePath> FilePath::expandEnvironmentVariables() const
std::smatch match;
while (std::regex_search(text, match, env))
{
#pragma warning(push)
#pragma warning(disable : 4996)
const char* s = match[1].matched ? getenv(match[1].str().c_str())
: getenv(match[2].str().c_str());
#pragma warning(pop)
if (s == nullptr)
{
LOG_ERROR_STREAM(<< match[1].str() << " is not an environment variable in: " << text);
+1 -1
View File
@@ -28,7 +28,7 @@ std::vector<FilePath> utility::partitionFilePathsBySize(std::vector<FilePath> fi
sourceFileSizesToCommands.end(),
[](const PairType& p, const PairType& q) { return p.first > q.first; });
if (0 < partitionCount && partitionCount < sourceFileSizesToCommands.size())
if (0 < partitionCount && partitionCount < static_cast<int>(sourceFileSizesToCommands.size()))
{
for (int i = 0; i < partitionCount; i++)
{
@@ -195,7 +195,6 @@ SharedMemory::~SharedMemory()
LOG_ERROR_STREAM(
<< "boost exception thrown at shared memory destruction - " << getMemoryName() << ": "
<< e.what());
throw e;
}
}
+4
View File
@@ -13,6 +13,9 @@ std::wstring FileLogger::generateDatedFileName(
{
time_t time;
std::time(&time);
#pragma warning(push)
#pragma warning(disable : 4996)
tm t = *std::localtime(&time);
if (offsetDays != 0)
@@ -20,6 +23,7 @@ std::wstring FileLogger::generateDatedFileName(
time = mktime(&t) + offsetDays * 24 * 60 * 60;
t = *std::localtime(&time);
}
#pragma warning(pop)
std::wstringstream filename;
if (!prefix.empty())
@@ -79,7 +79,7 @@ void LogManagerImplementation::clearLoggers()
int LogManagerImplementation::getLoggerCount() const
{
std::lock_guard<std::mutex> lockGuard(m_loggerMutex);
return m_loggers.size();
return static_cast<int>(m_loggers.size());
}
void LogManagerImplementation::logInfo(
@@ -128,7 +128,12 @@ tm LogManagerImplementation::getTime()
{
time_t time;
std::time(&time);
#pragma warning(push)
#pragma warning(disable : 4996)
tm result = *std::localtime(&time); // this is done because localtime returns a pointer to a
// statically allocated object
#pragma warning(pop)
return result;
}
+2 -2
View File
@@ -70,7 +70,7 @@ void MatrixDynamicBase<T>::setValue(
template <class T>
unsigned int MatrixDynamicBase<T>::getColumnsCount() const
{
return m_values.size();
return static_cast<unsigned int>(m_values.size());
}
template <class T>
@@ -78,7 +78,7 @@ unsigned int MatrixDynamicBase<T>::getRowsCount() const
{
if (m_values.size() > 0)
{
return m_values[0].size();
return static_cast<unsigned int>(m_values[0].size());
}
return 0;
@@ -22,7 +22,7 @@ void TaskGroupParallel::doEnter(std::shared_ptr<Blackboard> blackboard)
if (m_needsToStartThreads)
{
m_needsToStartThreads = false;
m_activeTaskCount = m_tasks.size();
m_activeTaskCount = static_cast<int>(m_tasks.size());
for (size_t i = 0; i < m_tasks.size(); i++)
{
m_tasks[i]->active = true;
+1 -1
View File
@@ -81,7 +81,7 @@ TextAccess::~TextAccess() {}
unsigned int TextAccess::getLineCount() const
{
return m_lines.size();
return static_cast<unsigned int>(m_lines.size());
}
bool TextAccess::isEmpty() const
+2 -2
View File
@@ -119,12 +119,12 @@ void Tracer::printTraces()
if (p.second)
{
acc->event = event.get();
acc->time = event->time;
acc->time = static_cast<float>(event->time);
acc->count = 1;
}
else
{
acc->time += event->time;
acc->time += static_cast<float>(event->time);
acc->count++;
}
}
+4 -4
View File
@@ -7,9 +7,9 @@
unsigned long utility::getLargestByteSizeOfAllocatableMemory()
{
MEMORY_BASIC_INFORMATION mbi;
unsigned long start = 0;
__int64 start = 0;
bool recording = false;
unsigned long freestart = 0, largestFreestart = 0;
__int64 freestart = 0, largestFreestart = 0;
__int64 free = 0, largestFree = 0;
while (true)
@@ -39,10 +39,10 @@ unsigned long utility::getLargestByteSizeOfAllocatableMemory()
free = 0;
recording = false;
}
start += mbi.RegionSize;
start += static_cast<unsigned long>(mbi.RegionSize);
}
return largestFree;
return static_cast<unsigned int>(largestFree);
}
#endif // WIN32