Skip to content

Commit

Permalink
- Fixed some warnings related to comparisons with signed/unsigned
Browse files Browse the repository at this point in the history
- Ignore warnings related to exported STL types
  • Loading branch information
GeertLitjens committed Sep 1, 2016
1 parent c238915 commit d91c398
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 27 deletions.
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ IF(NOT WIN32)
SET(CMAKE_INSTALL_RPATH "\$ORIGIN/../lib:$ORIGIN/")
ENDIF(NOT WIN32)

# Set compile definitions to ignore some warnings
if (WIN32)
set(DEFAULT_COMPILE_DEFINITIONS ${DEFAULT_COMPILE_DEFINITIONS}
/D"_SCL_SECURE_NO_WARNINGS" # Calling any one of the potentially unsafe methods in the Standard C++ Library
/D"_CRT_SECURE_NO_WARNINGS" # Calling any one of the potentially unsafe methods in the CRT Library
/wd4251
)
add_definitions(${DEFAULT_COMPILE_DEFINITIONS})
endif()

# Use boost for cross-platform use of threading, file system and date_time handling
FIND_PACKAGE(Boost REQUIRED COMPONENTS date_time filesystem program_options regex system thread)

Expand Down
2 changes: 1 addition & 1 deletion core/CmdLineProgressMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void CmdLineProgressMonitor::setProgress(const unsigned int& progress) {
} else if (progress == 0) {
disp->restart(100);
}
(*disp) += ((100 * static_cast<float>(progress) / static_cast<float>(_maxProgress)) - disp->count());
(*disp) += static_cast<unsigned long>(((100 * static_cast<float>(progress) / static_cast<float>(_maxProgress)) - disp->count()));
}

void CmdLineProgressMonitor::setStatus(const std::string& status) {
Expand Down
2 changes: 1 addition & 1 deletion core/Patch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ double Patch<T>::getMaxValue(int channel) {
template<typename T>
const int Patch<T>::getSamplesPerPixel() const {
if (!_dimensions.empty()) {
return _dimensions.back();
return static_cast<int>(_dimensions.back());
}
else {
return 0;
Expand Down
2 changes: 1 addition & 1 deletion core/ProgressMonitor.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "ProgressMonitor.h"
#include <iostream>

ProgressMonitor::ProgressMonitor() : _status(""), _progress(0.0), _maxProgress(100)
ProgressMonitor::ProgressMonitor() : _status(""), _progress(0), _maxProgress(100)
{

}
Expand Down
6 changes: 3 additions & 3 deletions core/filetools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ namespace core
long int fileSize(const std::string &name)
{
if (!fileExists(name)) return -1;
long int length = file_size(name);
long int length = static_cast<long int>(file_size(name));
/*
FILE *handle = fopen(name.c_str(), "rb");
Expand Down Expand Up @@ -943,7 +943,7 @@ namespace core
s.clear();
s.resize(n);
//char *in = new char[n];
long bytes = fread(&(s[0]), sizeof(char), n, fpIO);
long bytes = static_cast<long>(fread(&(s[0]), sizeof(char), n, fpIO));
//delete in;
fclose(fpIO);
return (bytes == n);
Expand Down Expand Up @@ -994,7 +994,7 @@ namespace core
while (c != EOF);
*/
tail.resize(nBytesToRead);
long bytes = fread(&(tail[0]), sizeof(char), nBytesToRead, pFile);
long bytes = static_cast<long>(fread(&(tail[0]), sizeof(char), nBytesToRead, pFile));

}
else //smaller than nBytesToRead
Expand Down
10 changes: 5 additions & 5 deletions io/multiresolutionimageinterface/JPEG2000Codec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void JPEG2000Codec::decode(char* buf, const unsigned int& inSize, const unsigned
}
for (int j = 0; j < components.size(); ++j) {
jas_matrix_t* cmp = components[j];
for (int i = j; i < outSize; i += image->numcmpts_) {
for (unsigned int i = j; i < outSize; i += image->numcmpts_) {
buf[i] = cmp->data_[i / image->numcmpts_];
}
}
Expand All @@ -48,7 +48,7 @@ void JPEG2000Codec::decode(char* buf, const unsigned int& inSize, const unsigned
void JPEG2000Codec::encode(char* data, unsigned int& size, const unsigned int& tileSize, const unsigned int& depth, const unsigned int& nrComponents, float& rate, bool colorImage) const
{
jas_image_cmptparm_t* component_info = new jas_image_cmptparm_t[4];
for( int i = 0; i < nrComponents; i++ )
for(unsigned int i = 0; i < nrComponents; i++ )
{
component_info[i].tlx = 0;
component_info[i].tly = 0;
Expand Down Expand Up @@ -80,12 +80,12 @@ void JPEG2000Codec::encode(char* data, unsigned int& size, const unsigned int& t
}

jas_matrix_t *row = jas_matrix_create( 1, tileSize );
for( int y = 0; y < tileSize; ++y)
for(unsigned int y = 0; y < tileSize; ++y)
{
unsigned char* tmp = (unsigned char*)data + tileSize*y*nrComponents;
for( int i = 0; i < nrComponents; i++ )
for (unsigned int i = 0; i < nrComponents; i++)
{
for( int x = 0; x < tileSize; x++) {
for (unsigned int x = 0; x < tileSize; x++) {
jas_matrix_setv( row, x, tmp[x * nrComponents + i] );
}
jas_image_writecmpt( img, i, 0, y, tileSize, 1, row );
Expand Down
18 changes: 9 additions & 9 deletions io/multiresolutionimageinterface/MultiResolutionImageWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ int MultiResolutionImageWriter::writeImageInformation(const unsigned long long&
}
_min_vals = new double[cDepth];
_max_vals = new double[cDepth];
for (int i = 0; i < cDepth; ++i) {
for (unsigned int i = 0; i < cDepth; ++i) {
_min_vals[i] = std::numeric_limits<double>::max();
_max_vals[i] = std::numeric_limits<double>::min();
}
Expand Down Expand Up @@ -174,8 +174,8 @@ void MultiResolutionImageWriter::writeBaseImagePartToTIFFTile(void* data, unsign
//Determine min/max of tile part
if (_dType == pathology::UInt32) {
unsigned int *temp = (unsigned int*)data;
for (int i = 0; i < _tileSize*_tileSize*cDepth; i += cDepth) {
for (int j = 0; j < cDepth; ++j) {
for (unsigned int i = 0; i < _tileSize*_tileSize*cDepth; i += cDepth) {
for (unsigned int j = 0; j < cDepth; ++j) {
double val = temp[i + j];
if (val > _max_vals[j]) {
_max_vals[j] = val;
Expand All @@ -188,8 +188,8 @@ void MultiResolutionImageWriter::writeBaseImagePartToTIFFTile(void* data, unsign
}
else if (_dType == pathology::UInt16) {
unsigned short *temp = (unsigned short*)data;
for (int i = 0; i < _tileSize*_tileSize*cDepth; i += cDepth) {
for (int j = 0; j < cDepth; ++j) {
for (unsigned int i = 0; i < _tileSize*_tileSize*cDepth; i += cDepth) {
for (unsigned int j = 0; j < cDepth; ++j) {
double val = temp[i + j];
if (val > _max_vals[j]) {
_max_vals[j] = val;
Expand All @@ -202,8 +202,8 @@ void MultiResolutionImageWriter::writeBaseImagePartToTIFFTile(void* data, unsign
}
else if (_dType == pathology::Float) {
float *temp = (float*)data;
for (int i = 0; i < _tileSize*_tileSize*cDepth; i += cDepth) {
for (int j = 0; j < cDepth; ++j) {
for (unsigned int i = 0; i < _tileSize*_tileSize*cDepth; i += cDepth) {
for (unsigned int j = 0; j < cDepth; ++j) {
double val = temp[i + j];
if (val > _max_vals[j]) {
_max_vals[j] = val;
Expand All @@ -216,8 +216,8 @@ void MultiResolutionImageWriter::writeBaseImagePartToTIFFTile(void* data, unsign
}
else if (_dType == pathology::UChar) {
unsigned char *temp = (unsigned char*)data;
for (int i = 0; i < _tileSize*_tileSize*cDepth; i += cDepth) {
for (int j = 0; j < cDepth; ++j) {
for (unsigned int i = 0; i < _tileSize*_tileSize*cDepth; i += cDepth) {
for (unsigned int j = 0; j < cDepth; ++j) {
double val = temp[i + j];
if (val > _max_vals[j]) {
_max_vals[j] = val;
Expand Down
14 changes: 7 additions & 7 deletions io/multiresolutionimageinterface/TIFFImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,23 +154,23 @@ bool TIFFImage::initializeType(const std::string& imagePath) {
TIFFSetField(_tiff, TIFFTAG_PERSAMPLE, PERSAMPLE_MULTI);
double* min_values;
if (TIFFGetField(_tiff, TIFFTAG_SMINSAMPLEVALUE, &min_values)) {
for (int i = 0; i < _samplesPerPixel; ++i) {
for (unsigned int i = 0; i < _samplesPerPixel; ++i) {
_minValues.push_back(min_values[i]);
}
}
else {
for (int i = 0; i < _samplesPerPixel; ++i) {
for (unsigned int i = 0; i < _samplesPerPixel; ++i) {
_minValues.push_back(0.);
}
}
double* max_values;
if (TIFFGetField(_tiff, TIFFTAG_SMAXSAMPLEVALUE, &max_values)) {
for (int i = 0; i < _samplesPerPixel; ++i) {
for (unsigned int i = 0; i < _samplesPerPixel; ++i) {
_maxValues.push_back(max_values[i]);
}
}
else {
for (int i = 0; i < _samplesPerPixel; ++i) {
for (unsigned int i = 0; i < _samplesPerPixel; ++i) {
_maxValues.push_back(255.);
}
}
Expand Down Expand Up @@ -262,7 +262,7 @@ template <typename T> T* TIFFImage::FillRequestedRegionFromTIFF(const long long&
{
boost::shared_lock<boost::shared_mutex> l(*_openCloseMutex);
T* temp = new T[width*height*nrSamples];
std::fill(temp,temp+width*height*nrSamples,0);
std::fill(temp,temp+width*height*nrSamples,static_cast<T>(0));
unsigned int tileW=_tileSizesPerLevel[level][0], tileH=_tileSizesPerLevel[level][1], levelH=_levelDimensions[level][1], levelW=_levelDimensions[level][0];

long long levelStartX = startX / getLevelDownsample(level);
Expand Down Expand Up @@ -325,15 +325,15 @@ template <typename T> T* TIFFImage::FillRequestedRegionFromTIFF(const long long&
long long lyh = levelStartY + height;
long long lxw = levelStartX + width;
long long ixw = ixx + tileW;
long long rowLength = ixw > width ? (tileW - (ixw - width))*nrSamples : tileW*nrSamples;
long long rowLength = ixw > static_cast<long long>(width) ? (tileW - (ixw - width))*nrSamples : tileW*nrSamples;
long long tileDeltaX = 0;
if (ixx < 0) {
rowLength += ixx*nrSamples;
tileDeltaX -= ixx*nrSamples;
ixx = 0;
}
for (unsigned int ty = 0; ty < tileH; ++ty) {
if ((iyy + ty >= 0) && (ixx >= 0) && (iyy + ty < height) && lxw > 0){
if ((iyy + ty >= 0) && (ixx >= 0) && (iyy + ty < static_cast<long long>(height)) && lxw > 0){
long long idx = (ty+iyy)*width*nrSamples + ixx*nrSamples;
long long tids = (ty*tileW)*nrSamples;
std::copy(tile+tids+tileDeltaX, tile+tids+rowLength+tileDeltaX, temp + idx);
Expand Down

0 comments on commit d91c398

Please sign in to comment.