Skip to content

Commit 2336476

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

8 files changed

Lines changed: 14 additions & 15 deletions

File tree

.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: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class NesterovATestTaskAll : public ::testing::TestWithParam<int> {
1515
std::string abs_path = ppc::util::GetAbsolutePath("all/example/data/pic_all.jpg");
1616
data = stbi_load(abs_path.c_str(), &width, &height, &channels, 0);
1717
ASSERT_TRUE(data != nullptr) << "Failed to load image: " << stbi_failure_reason();
18-
img = std::vector<uint8_t>(data, data + (width * height * channels));
18+
img = std::vector<uint8_t>(data, data + (static_cast<size_t>(width) * height * channels));
1919
stbi_image_free(data);
2020

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

2929
TEST_P(NesterovATestTaskAll, MatmulFromPic) {
3030
int divider = GetParam();
31-
const int k_count = (width + height) / divider;
31+
const size_t k_count = (width + height) / divider;
3232

3333
std::vector<int> in(k_count * k_count, 0);
34-
for (int i = 0; i < k_count; i++) {
34+
for (size_t i = 0; i < k_count; i++) {
3535
in[(i * k_count) + i] = 1;
3636
}
3737

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

4646
TEST_P(NesterovATestTaskAll, MatMulUtilFromPic) {
4747
int divider = GetParam();
48-
const int k_count = (width + height) / divider;
48+
const size_t k_count = (width + height) / divider;
4949

5050
std::vector<int> in(k_count * k_count, 0);
51-
for (int i = 0; i < k_count; i++) {
51+
for (size_t i = 0; i < k_count; i++) {
5252
in[(i * k_count) + i] = 1;
5353
}
5454
std::vector<int> out(k_count * k_count, 0);
@@ -59,10 +59,10 @@ TEST_P(NesterovATestTaskAll, MatMulUtilFromPic) {
5959

6060
TEST_P(NesterovATestTaskAll, MatMulTBBUtilFromPic) {
6161
int divider = GetParam();
62-
const int k_count = (width + height) / divider;
62+
const size_t k_count = (width + height) / divider;
6363

6464
std::vector<int> in(k_count * k_count, 0);
65-
for (int i = 0; i < k_count; i++) {
65+
for (size_t i = 0; i < k_count; i++) {
6666
in[(i * k_count) + i] = 1;
6767
}
6868
std::vector<int> out(k_count * k_count, 0);

tasks/all/example/perf_tests/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111

1212
class NesterovAllRunTest : public ::testing::TestWithParam<ppc::core::PerfResults::TypeOfRunning> {
1313
protected:
14-
static constexpr int kCount = 400;
14+
static constexpr size_t kCount = 400;
1515
std::vector<int> input_data;
1616

1717
void SetUp() override {
1818
input_data.assign(kCount * kCount, 0);
19-
for (int i = 0; i < kCount; ++i) {
19+
for (size_t i = 0; i < kCount; ++i) {
2020
input_data[(i * kCount) + i] = 1;
2121
}
2222
}

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)