diff --git a/test/cfg/windows.cpp b/test/cfg/windows.cpp index 5f2e6555ead8..1ff314028fc3 100644 --- a/test/cfg/windows.cpp +++ b/test/cfg/windows.cpp @@ -22,6 +22,26 @@ #include #include +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);