Skip to content

Commit

Permalink
Add clang-tidy bugprone-* checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisThrasher committed Apr 13, 2023
1 parent 9269edc commit 82b9821
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 12 deletions.
14 changes: 14 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
Checks: >
-*,
bugprone-*,
clang-analyzer-*,
misc-*,
modernize-*,
performance-*,
portability-*,
readability-*,
-bugprone-assignment-in-if-condition,
-bugprone-branch-clone,
-bugprone-easily-swappable-parameters,
-bugprone-exception-escape,
-bugprone-implicit-widening-of-multiplication-result,
-bugprone-incorrect-roundings,
-bugprone-integer-division,
-bugprone-misplaced-widening-cast,
-bugprone-narrowing-conversions,
-bugprone-signed-char-misuse,
-bugprone-string-integer-assignment,
-bugprone-suspicious-include,
-bugprone-unchecked-optional-access,
-clang-analyzer-nullability.NullablePassedToNonnull,
-clang-analyzer-optin.cplusplus.VirtualCall,
-clang-analyzer-optin.osx.*,
Expand Down
3 changes: 0 additions & 3 deletions include/SFML/Window/GlResource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@

namespace sf
{

class Context;

using ContextDestroyCallback = void (*)(void*);

////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion include/SFML/Window/WindowHandle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

// Windows' HWND is a type alias for struct HWND__*
#if defined(SFML_SYSTEM_WINDOWS)
struct HWND__;
struct HWND__; // NOLINT(bugprone-reserved-identifier)
#endif

namespace sf
Expand Down
4 changes: 2 additions & 2 deletions src/SFML/System/Win32/WindowsHeader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#endif

#ifndef _WIN32_WINDOWS
#define _WIN32_WINDOWS 0x0501
#define _WIN32_WINDOWS 0x0501 // NOLINT(bugprone-reserved-identifier)
#endif

#ifndef _WIN32_WINNT
Expand All @@ -49,7 +49,7 @@
#endif

#ifndef _UNICODE
#define _UNICODE 1
#define _UNICODE 1 // NOLINT(bugprone-reserved-identifier)
#endif

#include <windows.h>
8 changes: 4 additions & 4 deletions src/SFML/Window/DRM/InputImplUDev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ void uninitFileDescriptors()
}

#define BITS_PER_LONG (sizeof(unsigned long) * 8)
#define NBITS(x) (((x - 1) / BITS_PER_LONG) + 1)
#define OFF(x) (x % BITS_PER_LONG)
#define LONG(x) (x / BITS_PER_LONG)
#define TEST_BIT(bit, array) ((array[LONG(bit)] >> OFF(bit)) & 1)
#define NBITS(x) ((((x)-1) / BITS_PER_LONG) + 1)
#define OFF(x) ((x) % BITS_PER_LONG)
#define LONG(x) ((x) / BITS_PER_LONG)
#define TEST_BIT(bit, array) (((array)[LONG(bit)] >> OFF(bit)) & 1)

// Only keep fileDescriptors that we think are a keyboard, mouse or touchpad/touchscreen
// Joysticks are handled in /src/SFML/Window/Unix/JoystickImpl.cpp
Expand Down
4 changes: 2 additions & 2 deletions test/Network/Packet.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ static_assert(std::is_nothrow_move_assignable_v<sf::Packet>);
do \
{ \
sf::Packet packet; \
packet << expected; \
packet << (expected); \
CHECK(packet.getReadPosition() == 0); \
CHECK(packet.getData() != nullptr); \
CHECK(packet.getDataSize() == sizeof(expected)); \
Expand All @@ -29,7 +29,7 @@ static_assert(std::is_nothrow_move_assignable_v<sf::Packet>);
CHECK(packet.getDataSize() == sizeof(expected)); \
CHECK(packet.endOfPacket()); \
CHECK(static_cast<bool>(packet)); \
CHECK(expected == received); \
CHECK((expected) == received); \
} while (false)

TEST_CASE("[Network] sf::Packet")
Expand Down

0 comments on commit 82b9821

Please sign in to comment.