Skip to content

Commit 47ab930

Browse files
Add tests for windows config
There should be no Cppcheck warning when checking for 0 and `INVALID_HANDLE_VALUE` or `INVALID_SOCKET`
1 parent 0603244 commit 47ab930

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Diff for: test/cfg/windows.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,22 @@
2222
#include <atlstr.h>
2323
#include <string>
2424

25+
void invalidHandle_CreateFile(LPCWSTR lpFileName)
26+
{
27+
HANDLE file = CreateFile(lpFileName, GENERIC_READ, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
28+
29+
// INVALID_HANDLE_VALUE is not the same as 0
30+
if (file != INVALID_HANDLE_VALUE && file) {}
31+
}
32+
33+
void invalid_socket()
34+
{
35+
SOCKET sock = socket(AF_INET, SOCK_RAW, IPPROTO_TCP);
36+
37+
// INVALID_SOCKET is not the same as 0
38+
if (sock != INVALID_SOCKET && sock) {}
39+
}
40+
2541
void resourceLeak_OpenThread(const DWORD dwDesiredAccess, const BOOL bInheritHandle, const DWORD dwThreadId)
2642
{
2743
HANDLE proc = OpenThread(dwDesiredAccess, bInheritHandle, dwThreadId);

0 commit comments

Comments
 (0)