Skip to content

Commit 29103af

Browse files
authored
Enable bugprone-implicit-widening-of-multiplication-result clang-tidy check (#421)
1 parent 88f23cd commit 29103af

File tree

8 files changed

+16
-15
lines changed

8 files changed

+16
-15
lines changed

.clang-tidy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Checks: >
1313
readability-*,
1414
-bugprone-casting-through-void,
1515
-bugprone-easily-swappable-parameters,
16-
-bugprone-implicit-widening-of-multiplication-result,
1716
-cppcoreguidelines-avoid-magic-numbers,
1817
-cppcoreguidelines-non-private-member-variables-in-classes,
1918
-cppcoreguidelines-owning-memory,

tasks/all/example/func_tests/main.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <gtest/gtest.h>
22

3+
#include <cstddef>
34
#include <cstdint>
45
#include <stb_library.hpp>
56
#include <string>
@@ -15,7 +16,7 @@ class NesterovATestTaskAll : public ::testing::TestWithParam<int> {
1516
std::string abs_path = ppc::util::GetAbsolutePath("all/example/data/pic_all.jpg");
1617
data = stbi_load(abs_path.c_str(), &width, &height, &channels, 0);
1718
ASSERT_TRUE(data != nullptr) << "Failed to load image: " << stbi_failure_reason();
18-
img = std::vector<uint8_t>(data, data + (width * height * channels));
19+
img = std::vector<uint8_t>(data, data + (static_cast<size_t>(width) * height * channels));
1920
stbi_image_free(data);
2021

2122
ASSERT_EQ(width, height);
@@ -28,10 +29,10 @@ class NesterovATestTaskAll : public ::testing::TestWithParam<int> {
2829

2930
TEST_P(NesterovATestTaskAll, MatmulFromPic) {
3031
int divider = GetParam();
31-
const int k_count = (width + height) / divider;
32+
const size_t k_count = (width + height) / divider;
3233

3334
std::vector<int> in(k_count * k_count, 0);
34-
for (int i = 0; i < k_count; i++) {
35+
for (size_t i = 0; i < k_count; i++) {
3536
in[(i * k_count) + i] = 1;
3637
}
3738

@@ -45,10 +46,10 @@ TEST_P(NesterovATestTaskAll, MatmulFromPic) {
4546

4647
TEST_P(NesterovATestTaskAll, MatMulUtilFromPic) {
4748
int divider = GetParam();
48-
const int k_count = (width + height) / divider;
49+
const size_t k_count = (width + height) / divider;
4950

5051
std::vector<int> in(k_count * k_count, 0);
51-
for (int i = 0; i < k_count; i++) {
52+
for (size_t i = 0; i < k_count; i++) {
5253
in[(i * k_count) + i] = 1;
5354
}
5455
std::vector<int> out(k_count * k_count, 0);
@@ -59,10 +60,10 @@ TEST_P(NesterovATestTaskAll, MatMulUtilFromPic) {
5960

6061
TEST_P(NesterovATestTaskAll, MatMulTBBUtilFromPic) {
6162
int divider = GetParam();
62-
const int k_count = (width + height) / divider;
63+
const size_t k_count = (width + height) / divider;
6364

6465
std::vector<int> in(k_count * k_count, 0);
65-
for (int i = 0; i < k_count; i++) {
66+
for (size_t i = 0; i < k_count; i++) {
6667
in[(i * k_count) + i] = 1;
6768
}
6869
std::vector<int> out(k_count * k_count, 0);

tasks/all/example/perf_tests/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <mpi.h>
33

44
#include <chrono>
5+
#include <cstddef>
56
#include <memory>
67
#include <vector>
78

@@ -11,12 +12,12 @@
1112

1213
class NesterovAllRunTest : public ::testing::TestWithParam<ppc::core::PerfResults::TypeOfRunning> {
1314
protected:
14-
static constexpr int kCount = 400;
15+
static constexpr size_t kCount = 400;
1516
std::vector<int> input_data;
1617

1718
void SetUp() override {
1819
input_data.assign(kCount * kCount, 0);
19-
for (int i = 0; i < kCount; ++i) {
20+
for (size_t i = 0; i < kCount; ++i) {
2021
input_data[(i * kCount) + i] = 1;
2122
}
2223
}

tasks/mpi/example/perf_tests/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
class NesterovATaskMPITest : public ::testing::TestWithParam<ppc::core::PerfResults::TypeOfRunning> {
1515
protected:
1616
static void RunTest(ppc::core::PerfResults::TypeOfRunning mode) {
17-
constexpr int kCount = 500;
17+
constexpr size_t kCount = 500;
1818

1919
// Create data
2020
std::vector<int> in(kCount * kCount, 0);

tasks/omp/example/perf_tests/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
class NesterovTaskOMPTest : public ::testing::TestWithParam<ppc::core::PerfResults::TypeOfRunning> {
1414
protected:
1515
static void RunTest(ppc::core::PerfResults::TypeOfRunning mode) {
16-
constexpr int kCount = 300;
16+
constexpr size_t kCount = 300;
1717

1818
// Create data
1919
std::vector<int> in(kCount * kCount, 0);

tasks/seq/example/perf_tests/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
class NesterovTaskSeqTest : public ::testing::TestWithParam<ppc::core::PerfResults::TypeOfRunning> {
1414
protected:
1515
static void RunTest(ppc::core::PerfResults::TypeOfRunning mode) {
16-
constexpr int kCount = 500;
16+
constexpr size_t kCount = 500;
1717

1818
// Create data
1919
std::vector<int> in(kCount * kCount, 0);

tasks/stl/example/perf_tests/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
class NesterovTaskSTLTest : public ::testing::TestWithParam<ppc::core::PerfResults::TypeOfRunning> {
1414
protected:
1515
static void RunTest(ppc::core::PerfResults::TypeOfRunning mode) {
16-
constexpr int kCount = 450;
16+
constexpr size_t kCount = 450;
1717

1818
// Create data
1919
std::vector<int> in(kCount * kCount, 0);

tasks/tbb/example/perf_tests/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
class NesterovTaskTBBTest : public ::testing::TestWithParam<ppc::core::PerfResults::TypeOfRunning> {
1414
protected:
1515
static void RunTest(ppc::core::PerfResults::TypeOfRunning mode) {
16-
constexpr int kCount = 450;
16+
constexpr size_t kCount = 450;
1717

1818
// Create data
1919
std::vector<int> in(kCount * kCount, 0);

0 commit comments

Comments
 (0)