Commit 231a7c0f authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Fixed some false positive GCC warnings.

parent 1d009b00
...@@ -117,7 +117,7 @@ namespace campvis { ...@@ -117,7 +117,7 @@ namespace campvis {
* \param bucketNumbers Array of the bucket number for each dimension (must have at least ND elements). * \param bucketNumbers Array of the bucket number for each dimension (must have at least ND elements).
* \return The array index for the given bucket numbers. * \return The array index for the given bucket numbers.
*/ */
size_t getArrayIndex(size_t* bucketNumbers) const; size_t getArrayIndex(size_t bucketNumbers[ND]) const;
T _min[ND]; ///< minimum value for each dimension T _min[ND]; ///< minimum value for each dimension
T _max[ND]; ///< maximum value for each dimension T _max[ND]; ///< maximum value for each dimension
...@@ -189,11 +189,14 @@ namespace campvis { ...@@ -189,11 +189,14 @@ namespace campvis {
} }
double ratio = static_cast<double>(sample - _min[dimension]) / static_cast<double>(_max[dimension] - _min[dimension]); double ratio = static_cast<double>(sample - _min[dimension]) / static_cast<double>(_max[dimension] - _min[dimension]);
return static_cast<size_t>(tgt::clamp(static_cast<int>(ratio * _numBuckets[dimension]), static_cast<int>(0), static_cast<int>(_numBuckets[dimension]) - 1)); int toReturn = static_cast<int>(ratio * _numBuckets[dimension]);
toReturn = std::max(toReturn, 0);
toReturn = std::min(toReturn, static_cast<int>(_numBuckets[dimension]) - 1);
return toReturn;
} }
template<typename T, size_t ND> template<typename T, size_t ND>
size_t campvis::ConcurrentGenericHistogramND<T, ND>::getArrayIndex(size_t* bucketNumbers) const { size_t campvis::ConcurrentGenericHistogramND<T, ND>::getArrayIndex(size_t bucketNumbers[ND]) const {
size_t index = 0; size_t index = 0;
size_t multiplier = 1; size_t multiplier = 1;
for (size_t i = 0; i < ND; ++i) { for (size_t i = 0; i < ND; ++i) {
......
...@@ -50,7 +50,7 @@ protected: ...@@ -50,7 +50,7 @@ protected:
max = new int[ND]; max = new int[ND];
min = new int[ND]; min = new int[ND];
numBuckets = new size_t[ND]; numBuckets = new size_t[ND];
for (int i = 0; i < ND; i++) { for (size_t i = 0; i < ND; i++) {
min[i] = 0; min[i] = 0;
max[i] = 100; max[i] = 100;
numBuckets[i] = max[i] - min[i] + 1; numBuckets[i] = max[i] - min[i] + 1;
...@@ -135,7 +135,8 @@ TEST_F(ConcurrentHistogram1DTest, concurrentAddSampleTest) { ...@@ -135,7 +135,8 @@ TEST_F(ConcurrentHistogram1DTest, concurrentAddSampleTest) {
for (int i = 0; i < getND(); i++) { for (int i = 0; i < getND(); i++) {
for (size_t j = 0; j < numBuckets[i]; j ++) { for (size_t j = 0; j < numBuckets[i]; j ++) {
EXPECT_EQ(histogram[i], _cgh->getNumElements(j)); size_t expected = static_cast<size_t>(histogram[i]);
EXPECT_EQ(expected, _cgh->getNumElements(j));
} }
} }
} }
...@@ -162,7 +163,8 @@ TEST_F(ConcurrentHistogram2DTest, concurrentAddSampleTest) { ...@@ -162,7 +163,8 @@ TEST_F(ConcurrentHistogram2DTest, concurrentAddSampleTest) {
for (int i = 0; i < getND(); i++) { for (int i = 0; i < getND(); i++) {
for (size_t j = 0; j < numBuckets[i]; j ++) { for (size_t j = 0; j < numBuckets[i]; j ++) {
EXPECT_EQ(histogram[i], _cgh->getNumElements(j)); size_t expected = static_cast<size_t>(histogram[i]);
EXPECT_EQ(expected, _cgh->getNumElements(j));
} }
break; break;
} }
...@@ -183,7 +185,7 @@ protected: ...@@ -183,7 +185,7 @@ protected:
max = new int[ND]; max = new int[ND];
min = new int[ND]; min = new int[ND];
numBuckets = new size_t[ND]; numBuckets = new size_t[ND];
for (int i = 0; i < ND; i++) { for (size_t i = 0; i < ND; i++) {
min[i] = 0; min[i] = 0;
max[i] = 9999; max[i] = 9999;
numBuckets[i] = 2; numBuckets[i] = 2;
...@@ -270,7 +272,8 @@ TEST_F(ConcurrentHistogram1DTestSpecific, concurrentAddSampleTest) { ...@@ -270,7 +272,8 @@ TEST_F(ConcurrentHistogram1DTestSpecific, concurrentAddSampleTest) {
for (int i = 0; i < getND(); i++) { for (int i = 0; i < getND(); i++) {
for (size_t j = 0; j < numBuckets[i]; j ++) { for (size_t j = 0; j < numBuckets[i]; j ++) {
EXPECT_EQ(histogram[i], _cgh->getNumElements(j)); size_t expected = static_cast<size_t>(histogram[i]);
EXPECT_EQ(expected, _cgh->getNumElements(j));
} }
} }
} }
...@@ -297,7 +300,8 @@ TEST_F(ConcurrentHistogram2DTestSpecific, concurrentAddSampleTest) { ...@@ -297,7 +300,8 @@ TEST_F(ConcurrentHistogram2DTestSpecific, concurrentAddSampleTest) {
for (int i = 0; i < getND(); i++) { for (int i = 0; i < getND(); i++) {
for (size_t j = 0; j < numBuckets[i]; j ++) { for (size_t j = 0; j < numBuckets[i]; j ++) {
EXPECT_EQ(histogram[i], _cgh->getNumElements(j)); size_t expected = static_cast<size_t>(histogram[i]);
EXPECT_EQ(expected, _cgh->getNumElements(j));
} }
break; break;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment