Skip to content

Commit 4c52be1

Browse files
committed
lint: fix clang-tidy warnings
1 parent 08be3f5 commit 4c52be1

File tree

7 files changed

+18
-16
lines changed

7 files changed

+18
-16
lines changed

src/graphics/window.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
Window::Window(const std::string& title, WindowPosition position, u32 width, u32 height)
77
: Window{ title, static_cast<u32>(position), static_cast<u32>(position), width, height } { }
88

9-
Window::Window(const std::string& title, u32 x, u32 y, u32 width, u32 height)
9+
Window::Window(const std::string& title, u32 x_pos, u32 y_pos, u32 width, u32 height)
1010
: m_window{ SDL_CreateWindow(
1111
title.c_str(),
12-
static_cast<int>(x),
13-
static_cast<int>(y),
12+
static_cast<int>(x_pos),
13+
static_cast<int>(y_pos),
1414
static_cast<int>(width),
1515
static_cast<int>(height),
1616
0
@@ -19,14 +19,14 @@ Window::Window(const std::string& title, u32 x, u32 y, u32 width, u32 height)
1919
Window::Window(const std::string& title, WindowPosition position)
2020
: Window{ title, static_cast<u32>(position), static_cast<u32>(position) } { }
2121

22-
Window::Window(const std::string& title, u32 x, u32 y) {
22+
Window::Window(const std::string& title, u32 x_pos, u32 y_pos) {
2323

2424
SDL_DisplayMode mode{};
2525
const int result = SDL_GetCurrentDisplayMode(0, &mode);
2626
if (result != 0) {
2727
throw std::runtime_error{ "failed in getting display mode: " + std::string{ SDL_GetError() } };
2828
}
29-
m_window = SDL_CreateWindow(title.c_str(), static_cast<int>(x), static_cast<int>(y), mode.w, mode.h, 0);
29+
m_window = SDL_CreateWindow(title.c_str(), static_cast<int>(x_pos), static_cast<int>(y_pos), mode.w, mode.h, 0);
3030
if (m_window == nullptr) {
3131
throw std::runtime_error{ "failed in creating window: " + std::string{ SDL_GetError() } };
3232
}

src/graphics/window.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ struct Window final {
2222

2323
public:
2424
OOPETRIS_GRAPHICS_EXPORTED Window(const std::string& title, WindowPosition position, u32 width, u32 height);
25-
OOPETRIS_GRAPHICS_EXPORTED Window(const std::string& title, u32 x, u32 y, u32 width, u32 height);
25+
OOPETRIS_GRAPHICS_EXPORTED Window(const std::string& title, u32 x_pos, u32 y_pos, u32 width, u32 height);
2626
OOPETRIS_GRAPHICS_EXPORTED Window(const std::string& title, WindowPosition position);
27-
OOPETRIS_GRAPHICS_EXPORTED Window(const std::string& title, u32 x, u32 y);
27+
OOPETRIS_GRAPHICS_EXPORTED Window(const std::string& title, u32 x_pos, u32 y_pos);
2828
OOPETRIS_GRAPHICS_EXPORTED Window(const Window&) = delete;
2929
OOPETRIS_GRAPHICS_EXPORTED Window(Window&&) = delete;
3030
OOPETRIS_GRAPHICS_EXPORTED Window& operator=(const Window&) = delete;

src/libs/core/helper/date.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ date::ISO8601Date::ISO8601Date(std::tm tm) {
2323
date::ISO8601Date date::ISO8601Date::now() {
2424
auto now = std::chrono::system_clock::now();
2525
const std::time_t time = std::chrono::system_clock::to_time_t(now);
26-
return { static_cast<u64>(time) };
26+
return ISO8601Date{ static_cast<u64>(time) };
2727
}
2828

2929

src/libs/core/helper/date.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace date {
1818
static constexpr const char* iso_8601_format_string = "%Y%m%dT%H%M%S";
1919

2020
public:
21-
OOPETRIS_CORE_EXPORTED ISO8601Date(u64 value);
21+
OOPETRIS_CORE_EXPORTED explicit ISO8601Date(u64 value);
2222

2323
OOPETRIS_CORE_EXPORTED static ISO8601Date now();
2424
OOPETRIS_CORE_EXPORTED static helper::expected<ISO8601Date, std::string> from_string(const std::string& input);

src/libs/core/helper/sleep.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ using namespace std::chrono_literals;
1717
#endif
1818

1919

20-
bool helper::sleep_nanoseconds(std::chrono::nanoseconds ns) {
20+
bool helper::sleep_nanoseconds(std::chrono::nanoseconds nano_seconds) {
2121

2222
#if defined(_MSC_VER)
2323
// windows supports more than 100 ns precision, see here: https://randomascii.wordpress.com/2020/10/04/windows-timer-resolution-the-great-rule-change/
@@ -30,7 +30,7 @@ bool helper::sleep_nanoseconds(std::chrono::nanoseconds ns) {
3030
return false;
3131
}
3232
// use negative ns to set relative intervals
33-
li.QuadPart = -ns.count();
33+
li.QuadPart = -nano_seconds.count();
3434
if (!SetWaitableTimer(timer, &li, 0, nullptr, nullptr, false)) {
3535
CloseHandle(timer);
3636
return false;
@@ -46,9 +46,11 @@ bool helper::sleep_nanoseconds(std::chrono::nanoseconds ns) {
4646
int result{};
4747
struct timespec remaining{};
4848
struct timespec current{
49-
static_cast<decltype(remaining.tv_sec)>(std::chrono::duration_cast<std::chrono::seconds>(ns).count()),
50-
static_cast<decltype(remaining.tv_nsec)>(
51-
ns.count() % std::chrono::duration_cast<std::chrono::nanoseconds>(1s).count()
49+
.tv_sec = static_cast<decltype(remaining.tv_sec)>(
50+
std::chrono::duration_cast<std::chrono::seconds>(nano_seconds).count()
51+
),
52+
.tv_nsec = static_cast<decltype(remaining.tv_nsec)>(
53+
nano_seconds.count() % std::chrono::duration_cast<std::chrono::nanoseconds>(1s).count()
5254
),
5355
};
5456

src/libs/core/helper/sleep.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88

99
namespace helper {
1010

11-
OOPETRIS_CORE_EXPORTED bool sleep_nanoseconds(std::chrono::nanoseconds ns);
11+
OOPETRIS_CORE_EXPORTED bool sleep_nanoseconds(std::chrono::nanoseconds nano_seconds);
1212

1313
}

src/ui/layouts/scroll_layout.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace ui {
2929
};
3030

3131
struct AbsolutItemSize : public ItemSize {
32-
OOPETRIS_GRAPHICS_EXPORTED AbsolutItemSize(u32 height);
32+
OOPETRIS_GRAPHICS_EXPORTED explicit AbsolutItemSize(u32 height);
3333
};
3434

3535

0 commit comments

Comments
 (0)