Notice to GitKraken users: A vulnerability has been found in the SSH key generation of GitKraken versions 7.6.0 to 8.0.0 (https://www.gitkraken.com/blog/weak-ssh-key-fix). If you use GitKraken and have generated a SSH key using one of these versions, please remove it both from your local workstation and from your LRZ GitLab profile.

21.10.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

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 {
* \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.
*/
size_t getArrayIndex(size_t* bucketNumbers) const;
size_t getArrayIndex(size_t bucketNumbers[ND]) const;
T _min[ND]; ///< minimum value for each dimension
T _max[ND]; ///< maximum value for each dimension
......@@ -189,11 +189,14 @@ namespace campvis {
}
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>
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 multiplier = 1;
for (size_t i = 0; i < ND; ++i) {
......
......@@ -50,7 +50,7 @@ protected:
max = new int[ND];
min = new int[ND];
numBuckets = new size_t[ND];
for (int i = 0; i < ND; i++) {
for (size_t i = 0; i < ND; i++) {
min[i] = 0;
max[i] = 100;
numBuckets[i] = max[i] - min[i] + 1;
......@@ -135,7 +135,8 @@ TEST_F(ConcurrentHistogram1DTest, concurrentAddSampleTest) {
for (int i = 0; i < getND(); i++) {
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) {
for (int i = 0; i < getND(); i++) {
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;
}
......@@ -183,7 +185,7 @@ protected:
max = new int[ND];
min = new int[ND];
numBuckets = new size_t[ND];
for (int i = 0; i < ND; i++) {
for (size_t i = 0; i < ND; i++) {
min[i] = 0;
max[i] = 9999;
numBuckets[i] = 2;
......@@ -270,7 +272,8 @@ TEST_F(ConcurrentHistogram1DTestSpecific, concurrentAddSampleTest) {
for (int i = 0; i < getND(); i++) {
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) {
for (int i = 0; i < getND(); i++) {
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;
}
......
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