Skip to content

Commit

Permalink
Add tests for windows config
Browse files Browse the repository at this point in the history
There should be no Cppcheck warning when checking for 0 and
`INVALID_HANDLE_VALUE` or `INVALID_SOCKET`
  • Loading branch information
ChristophStrehle committed Jun 10, 2024
1 parent fe7ddf8 commit c8c131f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/cfg/windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,26 @@
#include <atlstr.h>
#include <string>

void invalidHandle_CreateFile(LPCWSTR lpFileName)
{
HANDLE file = CreateFile(lpFileName, GENERIC_READ, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);

// INVALID_HANDLE_VALUE is not the same as 0
if (file != INVALID_HANDLE_VALUE && file) {}

// cppcheck-suppress resourceLeak
}

void invalid_socket()
{
SOCKET sock = socket(AF_INET, SOCK_RAW, IPPROTO_TCP);

// INVALID_SOCKET is not the same as 0
if (sock != INVALID_SOCKET && sock) {}

// cppcheck-suppress resourceLeak
}

void resourceLeak_OpenThread(const DWORD dwDesiredAccess, const BOOL bInheritHandle, const DWORD dwThreadId)
{
HANDLE proc = OpenThread(dwDesiredAccess, bInheritHandle, dwThreadId);
Expand Down

0 comments on commit c8c131f

Please sign in to comment.