Skip to content

Commit

Permalink
消除cpp规范的警告。
Browse files Browse the repository at this point in the history
  • Loading branch information
kouzhudong committed Oct 26, 2023
1 parent 541cb15 commit a019193
Show file tree
Hide file tree
Showing 24 changed files with 41 additions and 41 deletions.
Binary file modified libnet/Adapter.cpp
Binary file not shown.
Binary file modified libnet/Firewall.cpp
Binary file not shown.
Binary file modified libnet/IOCTL.cpp
Binary file not shown.
Binary file modified libnet/IpHelper.cpp
Binary file not shown.
Binary file modified libnet/NetApi.cpp
Binary file not shown.
2 changes: 1 addition & 1 deletion libnet/NetBIOS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ BOOL NBListNames(int nLana, LPCSTR szName)
// Allocate the largest buffer that might be needed.
cbBuffer = sizeof(ADAPTER_STATUS) + 255 * sizeof(NAME_BUFFER);
pStatus = (ADAPTER_STATUS *)HeapAlloc(hHeap, 0, cbBuffer);
if (NULL == pStatus)
if (nullptr == pStatus)
return FALSE;

if (!NBAdapterStatus(nLana, (PVOID)pStatus, cbBuffer, szName)) {
Expand Down
20 changes: 10 additions & 10 deletions libnet/NetworkListManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@ void WINAPI TestNetworkListManager()
{
HRESULT hr = S_OK;

hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
if (FAILED(hr)) {//COM initialize failed
wprintf(L"CoInitialize failed: 0x%08lx\n", hr);
return;
}

INetworkListManager * pNetworkListManager = NULL;
hr = CoCreateInstance(CLSID_NetworkListManager, NULL,
INetworkListManager * pNetworkListManager = nullptr;
hr = CoCreateInstance(CLSID_NetworkListManager, nullptr,
CLSCTX_ALL, IID_INetworkListManager,
(LPVOID *)&pNetworkListManager);

Expand Down Expand Up @@ -249,21 +249,21 @@ void WINAPI TestNetworkListManagerEvents()
https://www.cxyzjd.com/article/chouhuan1877/100808606
*/
{
(void)CoInitialize(NULL);
(void)CoInitialize(nullptr);

INetworkListManager * pNetworkListManager = NULL;
INetworkListManager * pNetworkListManager = nullptr;
HRESULT hr = CoCreateInstance(CLSID_NetworkListManager,
NULL,
nullptr,
CLSCTX_ALL,
IID_INetworkListManager,
(LPVOID *)&pNetworkListManager);

VARIANT_BOOL bConnected = VARIANT_FALSE;
hr = pNetworkListManager->get_IsConnected(&bConnected);

IConnectionPointContainer * pCPContainer = NULL;
IConnectionPointContainer * pCPContainer = nullptr;
hr = pNetworkListManager->QueryInterface(IID_IConnectionPointContainer, (void **)&pCPContainer);
IConnectionPoint * pConnectPoint = NULL;
IConnectionPoint * pConnectPoint = nullptr;
hr = pCPContainer->FindConnectionPoint(IID_INetworkListManagerEvents, &pConnectPoint);

DWORD Cookie = 0;
Expand All @@ -272,7 +272,7 @@ void WINAPI TestNetworkListManagerEvents()

// 必须有下面这个消息循环
MSG msg;
while (GetMessage(&msg, NULL, 0, 0)) {
while (GetMessage(&msg, nullptr, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
if (msg.message == WM_QUIT) {
Expand Down Expand Up @@ -470,7 +470,7 @@ void WINAPI ListenToNetworkConnectivityChangesSample(BOOL optedIn)
有待改进。
*/
{
(void)CoInitialize(NULL);
(void)CoInitialize(nullptr);

std::wcout << "Listening to network connectivity changes." << std::endl;
if (optedIn) {
Expand Down
Binary file modified libnet/Sock.cpp
Binary file not shown.
Binary file modified libnet/WebBrowser.cpp
Binary file not shown.
Binary file modified libnet/WinINet.cpp
Binary file not shown.
Binary file modified libnet/Winhttp.cpp
Binary file not shown.
38 changes: 19 additions & 19 deletions libnet/Wlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Windows Server 2008 R2 if the Wireless LAN Service is not installed and started.
*/
{
// Declare and initialize variables.
HANDLE hClient = NULL;
HANDLE hClient = nullptr;
DWORD dwMaxClient = 2;
DWORD dwCurVersion = 0;
DWORD dwResult = 0;
Expand All @@ -26,17 +26,17 @@ Windows Server 2008 R2 if the Wireless LAN Service is not installed and started.
int i;

/* variables used for WlanEnumInterfaces */
PWLAN_INTERFACE_INFO_LIST pIfList = NULL;
PWLAN_INTERFACE_INFO pIfInfo = NULL;
PWLAN_INTERFACE_INFO_LIST pIfList = nullptr;
PWLAN_INTERFACE_INFO pIfInfo = nullptr;

dwResult = WlanOpenHandle(dwMaxClient, NULL, &dwCurVersion, &hClient);
dwResult = WlanOpenHandle(dwMaxClient, nullptr, &dwCurVersion, &hClient);
if (dwResult != ERROR_SUCCESS) {
wprintf(L"WlanOpenHandle failed with error: %u\n", dwResult);
// FormatMessage can be used to find out why the function failed
return 1;
}

dwResult = WlanEnumInterfaces(hClient, NULL, &pIfList);
dwResult = WlanEnumInterfaces(hClient, nullptr, &pIfList);
if (dwResult != ERROR_SUCCESS) {
wprintf(L"WlanEnumInterfaces failed with error: %u\n", dwResult);
// FormatMessage can be used to find out why the function failed
Expand Down Expand Up @@ -91,9 +91,9 @@ Windows Server 2008 R2 if the Wireless LAN Service is not installed and started.
}
}

if (pIfList != NULL) {
if (pIfList != nullptr) {
WlanFreeMemory(pIfList);
pIfList = NULL;
pIfList = nullptr;
}
return 0;
}
Expand All @@ -112,7 +112,7 @@ Note This example will fail to load on Windows Server 2008 and Windows Server 2
*/
{
// Declare and initialize variables.
HANDLE hClient = NULL;
HANDLE hClient = nullptr;
DWORD dwMaxClient = 2;
DWORD dwCurVersion = 0;
DWORD dwResult = 0;
Expand All @@ -123,22 +123,22 @@ Note This example will fail to load on Windows Server 2008 and Windows Server 2

/* variables used for WlanEnumInterfaces */

PWLAN_INTERFACE_INFO_LIST pIfList = NULL;
PWLAN_INTERFACE_INFO pIfInfo = NULL;
PWLAN_INTERFACE_INFO_LIST pIfList = nullptr;
PWLAN_INTERFACE_INFO pIfInfo = nullptr;

PWLAN_AVAILABLE_NETWORK_LIST pBssList = NULL;
PWLAN_AVAILABLE_NETWORK pBssEntry = NULL;
PWLAN_AVAILABLE_NETWORK_LIST pBssList = nullptr;
PWLAN_AVAILABLE_NETWORK pBssEntry = nullptr;

int iRSSI = 0;

dwResult = WlanOpenHandle(dwMaxClient, NULL, &dwCurVersion, &hClient);
dwResult = WlanOpenHandle(dwMaxClient, nullptr, &dwCurVersion, &hClient);
if (dwResult != ERROR_SUCCESS) {
wprintf(L"WlanOpenHandle failed with error: %u\n", dwResult);
return 1;
// You can use FormatMessage here to find out why the function failed
}

dwResult = WlanEnumInterfaces(hClient, NULL, &pIfList);
dwResult = WlanEnumInterfaces(hClient, nullptr, &pIfList);
if (dwResult != ERROR_SUCCESS) {
wprintf(L"WlanEnumInterfaces failed with error: %u\n", dwResult);
return 1;
Expand Down Expand Up @@ -196,7 +196,7 @@ Note This example will fail to load on Windows Server 2008 and Windows Server 2
dwResult = WlanGetAvailableNetworkList(hClient,
&pIfInfo->InterfaceGuid,
0,
NULL,
nullptr,
&pBssList);
if (dwResult != ERROR_SUCCESS) {
wprintf(L"WlanGetAvailableNetworkList failed with error: %u\n", dwResult);
Expand Down Expand Up @@ -331,14 +331,14 @@ Note This example will fail to load on Windows Server 2008 and Windows Server 2
}

}
if (pBssList != NULL) {
if (pBssList != nullptr) {
WlanFreeMemory(pBssList);
pBssList = NULL;
pBssList = nullptr;
}

if (pIfList != NULL) {
if (pIfList != nullptr) {
WlanFreeMemory(pIfList);
pIfList = NULL;
pIfList = nullptr;
}

return dwRetVal;
Expand Down
14 changes: 7 additions & 7 deletions libnet/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,34 @@
void init()
{
HMODULE hNtDLL = GetModuleHandle(TEXT("ntdll.dll"));
if (NULL != hNtDLL) {
if (nullptr != hNtDLL) {
pNtCreateFile = (P_NT_CREATE_FILE)GetProcAddress(hNtDLL, "NtCreateFile");
if (NULL == pNtCreateFile) {
if (nullptr == pNtCreateFile) {
printf("没有找到NtCreateFile函数\n");
}

Ipv4AddressToStringW = (PRtlIpv4AddressToString)GetProcAddress(hNtDLL, "RtlIpv4AddressToStringW");
if (NULL == Ipv4AddressToStringW) {
if (nullptr == Ipv4AddressToStringW) {
printf("没有找到RtlIpv4AddressToStringW函数\n");
}

Ipv4StringToAddressW = (RtlIpv4StringToAddressRoutine)GetProcAddress(hNtDLL, "RtlIpv4StringToAddressW");
if (NULL == Ipv4StringToAddressW) {
if (nullptr == Ipv4StringToAddressW) {
printf("没有找到RtlIpv4StringToAddressW函数\n");
}

Ipv6AddressToStringW = (PRtlIpv6AddressToString)GetProcAddress(hNtDLL, "RtlIpv6AddressToStringW");
if (NULL == Ipv6AddressToStringW) {
if (nullptr == Ipv6AddressToStringW) {
printf("没有找到RtlIpv6AddressToStringW函数\n");
}

Ipv6StringToAddressW = (RtlIpv6StringToAddressRoutine)GetProcAddress(hNtDLL, "RtlIpv6StringToAddressW");
if (NULL == Ipv6StringToAddressW) {
if (nullptr == Ipv6StringToAddressW) {
printf("没有找到RtlIpv6StringToAddressW函数\n");
}

Ipv6AddressToStringA = (PRtlIpv6AddressToStringA)GetProcAddress(hNtDLL, "RtlIpv6AddressToStringA");
if (NULL == Ipv6AddressToStringA) {
if (nullptr == Ipv6AddressToStringA) {
printf("没有找到RtlIpv6AddressToStringA函数\n");
}
}
Expand Down
Binary file modified libnet/dns.cpp
Binary file not shown.
Binary file modified libnet/html.cpp
Binary file not shown.
Binary file modified libnet/notify.cpp
Binary file not shown.
Binary file modified libnet/pathping.cpp
Binary file not shown.
Binary file modified libnet/spi.cpp
Binary file not shown.
Binary file modified libnet/tcp.cpp
Binary file not shown.
Binary file modified libnet/tracert.cpp
Binary file not shown.
Binary file modified libnet/udp.cpp
Binary file not shown.
Binary file modified libnet/wfp.cpp
Binary file not shown.
6 changes: 3 additions & 3 deletions test/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ RtlEthernetAddressToStringW_Fn EthernetAddressToStringW;
void get_api_address()
{
HMODULE ModuleHandle = GetModuleHandle(TEXT("ntdll.dll"));
if (NULL != ModuleHandle) {
if (nullptr != ModuleHandle) {
EthernetStringToAddressW = (RtlEthernetStringToAddressW_Fn)
GetProcAddress(ModuleHandle, "RtlEthernetStringToAddressW");
if (NULL == EthernetStringToAddressW) {
if (nullptr == EthernetStringToAddressW) {
printf("没有找到RtlEthernetStringToAddressW函数\n");
}

EthernetAddressToStringW = (RtlEthernetAddressToStringW_Fn)
GetProcAddress(ModuleHandle, "RtlEthernetAddressToStringW");
if (NULL == EthernetAddressToStringW) {
if (nullptr == EthernetAddressToStringW) {
printf("没有找到RtlEthernetStringToAddressW函数\n");
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ int _cdecl main(_In_ int argc, _In_reads_(argc) CHAR * argv[])

int Args;
LPWSTR * Arglist = CommandLineToArgvW(GetCommandLineW(), &Args);
if (NULL == Arglist) {
if (nullptr == Arglist) {
printf("LastError:%d", GetLastError());
return 0;
}
Expand Down

0 comments on commit a019193

Please sign in to comment.