Skip to content

Commit

Permalink
use nullptr instead of NULL with Win32 API
Browse files Browse the repository at this point in the history
Signed-off-by: Heiko Hund <[email protected]>
  • Loading branch information
d12fk committed Nov 15, 2024
1 parent 56fe984 commit 7fcf624
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
14 changes: 7 additions & 7 deletions openvpn/tun/win/dns.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,14 +533,14 @@ class Dns
SC_HANDLE scm = static_cast<SC_HANDLE>(INVALID_HANDLE_VALUE);
SC_HANDLE dnssvc = static_cast<SC_HANDLE>(INVALID_HANDLE_VALUE);

scm = ::OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if (scm == NULL)
scm = ::OpenSCManager(nullptr, nullptr, SC_MANAGER_ALL_ACCESS);
if (scm == nullptr)
{
goto out;
}

dnssvc = ::OpenServiceA(scm, "Dnscache", SERVICE_PAUSE_CONTINUE);
if (dnssvc == NULL)
if (dnssvc == nullptr)
{
goto out;
}
Expand Down Expand Up @@ -599,11 +599,11 @@ class Dns
constexpr DWORD WNF_GPOL_SYSTEM_CHANGES_LO = 0xA3BC0875;

HMODULE ntdll = ::LoadLibraryA("ntdll.dll");
if (ntdll == NULL)
if (ntdll == nullptr)
return false;

RtlPublishWnfStateData = reinterpret_cast<publish_fn_t>(::GetProcAddress(ntdll, "RtlPublishWnfStateData"));
if (RtlPublishWnfStateData == NULL)
if (RtlPublishWnfStateData == nullptr)
return false;

if (RtlPublishWnfStateData(WNF_GPOL_SYSTEM_CHANGES_LO, WNF_GPOL_SYSTEM_CHANGES_HI, 0, 0, 0, 0) != ERROR_SUCCESS)
Expand All @@ -630,11 +630,11 @@ class Dns
constexpr INT64 WNF_GPOL_SYSTEM_CHANGES = 0x0D891E2AA3BC0875;

HMODULE ntdll = ::LoadLibraryA("ntdll.dll");
if (ntdll == NULL)
if (ntdll == nullptr)
return false;

RtlPublishWnfStateData = reinterpret_cast<publish_fn_t>(::GetProcAddress(ntdll, "RtlPublishWnfStateData"));
if (RtlPublishWnfStateData == NULL)
if (RtlPublishWnfStateData == nullptr)
return false;

if (RtlPublishWnfStateData(WNF_GPOL_SYSTEM_CHANGES, 0, 0, 0, 0) != ERROR_SUCCESS)
Expand Down
18 changes: 9 additions & 9 deletions openvpn/win/reg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ struct Reg
error = ::RegCreateKeyExW(key,
subkey.c_str(),
0,
NULL,
nullptr,
0,
KEY_ALL_ACCESS,
NULL,
nullptr,
&key_,
NULL);
nullptr);
}
else
{
Expand Down Expand Up @@ -186,7 +186,7 @@ struct Reg
status = ::RegQueryInfoKeyA(key(),
nullptr,
nullptr,
NULL,
nullptr,
&subkeys_num,
nullptr,
nullptr,
Expand Down Expand Up @@ -247,7 +247,7 @@ struct Reg
PBYTE data = reinterpret_cast<PBYTE>(&value);
LSTATUS err;

err = ::RegGetValueW(key(), NULL, name, RRF_RT_REG_DWORD, &type, data, &size);
err = ::RegGetValueW(key(), nullptr, name, RRF_RT_REG_DWORD, &type, data, &size);
if (err)
{
return {0, err};
Expand All @@ -274,7 +274,7 @@ struct Reg
LSTATUS err;
DWORD size = 0;
DWORD type;
err = ::RegGetValueW(key(), NULL, name, RRF_RT_REG_SZ, &type, NULL, &size);
err = ::RegGetValueW(key(), nullptr, name, RRF_RT_REG_SZ, &type, nullptr, &size);
if (err)
{
return {{}, err};
Expand All @@ -286,7 +286,7 @@ struct Reg

std::wstring str(size / sizeof(std::wstring::value_type) + 1, '\0');
PBYTE data = reinterpret_cast<PBYTE>(str.data());
err = ::RegGetValueW(key(), NULL, name, RRF_RT_REG_SZ, NULL, data, &size);
err = ::RegGetValueW(key(), nullptr, name, RRF_RT_REG_SZ, nullptr, data, &size);
if (err)
{
return {{}, err};
Expand All @@ -311,7 +311,7 @@ struct Reg
LSTATUS err;
DWORD size = 0;
DWORD type;
err = ::RegGetValueW(key(), NULL, name, RRF_RT_REG_BINARY, &type, NULL, &size);
err = ::RegGetValueW(key(), nullptr, name, RRF_RT_REG_BINARY, &type, nullptr, &size);
if (err)
{
return {{}, err};
Expand All @@ -323,7 +323,7 @@ struct Reg

std::string str(size, '\0');
PBYTE data = reinterpret_cast<PBYTE>(str.data());
err = ::RegGetValueW(key(), NULL, name, RRF_RT_REG_BINARY, NULL, data, &size);
err = ::RegGetValueW(key(), nullptr, name, RRF_RT_REG_BINARY, nullptr, data, &size);
if (err)
{
return {{}, err};
Expand Down

0 comments on commit 7fcf624

Please sign in to comment.