Skip to content

Commit a54dea2

Browse files
committed
api: relax IsPoolMember estimation
Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent ce3b661 commit a54dea2

File tree

1 file changed

+14
-27
lines changed

1 file changed

+14
-27
lines changed

api/adapter.c

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -471,40 +471,27 @@ static BOOL
471471
IsPoolMember(_In_z_ const WCHAR *Pool, _In_ HDEVINFO DevInfo, _In_ SP_DEVINFO_DATA *DevInfoData)
472472
{
473473
WCHAR *DeviceDesc = GetDeviceRegistryString(DevInfo, DevInfoData, SPDRP_DEVICEDESC);
474-
if (!DeviceDesc)
475-
{
476-
LOG(WINTUN_LOG_ERR, L"Failed to get adapter description");
477-
return FALSE;
478-
}
474+
WCHAR *FriendlyName = GetDeviceRegistryString(DevInfo, DevInfoData, SPDRP_FRIENDLYNAME);
479475
DWORD LastError = ERROR_SUCCESS;
480476
BOOL Ret = FALSE;
481-
WCHAR *FriendlyName = GetDeviceRegistryString(DevInfo, DevInfoData, SPDRP_FRIENDLYNAME);
482-
if (!FriendlyName)
483-
{
484-
LastError = LOG(WINTUN_LOG_ERR, L"Failed to get adapter friendly name");
485-
goto cleanupDeviceDesc;
486-
}
487477
WCHAR PoolDeviceTypeName[MAX_POOL_DEVICE_TYPE];
488478
if (!GetPoolDeviceTypeName(Pool, PoolDeviceTypeName))
489479
{
490480
LastError = GetLastError();
491-
goto cleanupFriendlyName;
492-
}
493-
if (!_wcsicmp(FriendlyName, PoolDeviceTypeName) || !_wcsicmp(DeviceDesc, PoolDeviceTypeName))
494-
{
495-
Ret = TRUE;
496-
goto cleanupFriendlyName;
497-
}
498-
RemoveNumberedSuffix(FriendlyName);
499-
RemoveNumberedSuffix(DeviceDesc);
500-
if (!_wcsicmp(FriendlyName, PoolDeviceTypeName) || !_wcsicmp(DeviceDesc, PoolDeviceTypeName))
501-
{
502-
Ret = TRUE;
503-
goto cleanupFriendlyName;
504-
}
505-
cleanupFriendlyName:
481+
goto cleanupNames;
482+
}
483+
Ret = (FriendlyName && !_wcsicmp(FriendlyName, PoolDeviceTypeName)) ||
484+
(DeviceDesc && !_wcsicmp(DeviceDesc, PoolDeviceTypeName));
485+
if (Ret)
486+
goto cleanupNames;
487+
if (FriendlyName)
488+
RemoveNumberedSuffix(FriendlyName);
489+
if (DeviceDesc)
490+
RemoveNumberedSuffix(DeviceDesc);
491+
Ret = (FriendlyName && !_wcsicmp(FriendlyName, PoolDeviceTypeName)) ||
492+
(DeviceDesc && !_wcsicmp(DeviceDesc, PoolDeviceTypeName));
493+
cleanupNames:
506494
Free(FriendlyName);
507-
cleanupDeviceDesc:
508495
Free(DeviceDesc);
509496
SetLastError(LastError);
510497
return Ret;

0 commit comments

Comments
 (0)