Skip to content

Commit 08e035c

Browse files
committed
fix clang x86
1 parent d0349f5 commit 08e035c

4 files changed

Lines changed: 13 additions & 19 deletions

File tree

.clang-tidy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,6 @@ CheckOptions:
8787
value: 1
8888
# Functions with scores beyond 15 are typically flagged as potentially problematic (empirically)
8989
- key: readability-function-cognitive-complexity.Threshold
90-
value: 15 # default: 25
90+
value: 20 # default: 25
9191
- key: misc-include-cleaner.IgnoreHeaders
9292
value: '(opencv2/.*|__chrono/.*)'

3rdparty/stb_library.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#pragma clang diagnostic push
2+
#pragma clang diagnostic ignored "-Wcast-align"
3+
#define STB_IMAGE_IMPLEMENTATION
4+
#include <stb/stb_image.h>
5+
#pragma clang diagnostic pop

tasks/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ foreach(TASK_TYPE ${LIST_OF_TASKS})
132132
endif()
133133
endif ()
134134

135-
target_include_directories(stb_image INTERFACE ${CMAKE_SOURCE_DIR}/3rdparty/stb)
136-
target_link_libraries(${exec_func_tests} PUBLIC stb_image)
135+
target_link_directories(stb_image INTERFACE ${CMAKE_SOURCE_DIR}/3rdparty/stb)
136+
target_link_libraries(${EXEC_FUNC} PUBLIC stb_image)
137137

138138
add_dependencies(${EXEC_FUNC} ppc_googletest)
139139
target_link_directories(${EXEC_FUNC} PUBLIC "${CMAKE_BINARY_DIR}/ppc_googletest/install/lib")

tasks/all/example/func_tests/func_all.cpp

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22

33
#include <cstddef>
44
#include <cstdint>
5-
#include <iostream>
65
#include <memory>
76
#include <vector>
87

98
#include "all/example/include/ops_all.hpp"
109
#include "core/task/include/task.hpp"
1110
#include "core/util/include/util.hpp"
12-
#define STB_IMAGE_IMPLEMENTATION
13-
#include <stb/stb_image.h>
1411

12+
#include <stb_library.hpp>
1513
#include <string>
1614

1715
TEST(nesterov_a_test_task_all, test_matmul_50) {
@@ -45,20 +43,11 @@ TEST(nesterov_a_test_task_all, test_matmul_from_pic) {
4543
int width = -1;
4644
int height = -1;
4745
int channels = -1;
48-
std::vector<uint8_t> img;
4946
std::string abs_path = ppc::util::GetAbsolutePath("all/example/data/pic_all.jpg");
50-
51-
auto get_image_data = [&]() -> bool {
52-
unsigned char *data = stbi_load(abs_path.c_str(), &width, &height, &channels, 0);
53-
if (data == nullptr) {
54-
std::cerr << "Failed to load image: " << stbi_failure_reason() << '\n';
55-
return false;
56-
}
57-
img = std::vector<uint8_t>(data, data + (width * height * channels));
58-
stbi_image_free(data);
59-
return true;
60-
};
61-
EXPECT_TRUE(get_image_data());
47+
unsigned char *data = stbi_load(abs_path.c_str(), &width, &height, &channels, 0);
48+
EXPECT_TRUE(data != nullptr) << "Failed to load image: " << stbi_failure_reason() << '\n';
49+
std::vector<uint8_t> img = std::vector<uint8_t>(data, data + (width * height * channels));
50+
stbi_image_free(data);
6251

6352
EXPECT_EQ(width, height);
6453
const int count = (width + height) / 10;

0 commit comments

Comments
 (0)