aboutsummaryrefslogtreecommitdiffstats
path: root/api/driver.c
diff options
context:
space:
mode:
authorSimon Rozman <simon@rozman.si>2020-10-15 12:21:55 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2020-10-30 16:51:00 +0100
commit0ad302c11ddae5a8bb6de2c59e908d815f918ab9 (patch)
treea80d3db316ab65a45858d6fa41afd5e928fe2863 /api/driver.c
parentapi: internal reorganization (diff)
downloadwintun-0ad302c11ddae5a8bb6de2c59e908d815f918ab9.tar.xz
wintun-0ad302c11ddae5a8bb6de2c59e908d815f918ab9.zip
api: stop double error status reporting
When an internal function logs an error and its cause, it bloats the log when the caller logs the cause again. Signed-off-by: Simon Rozman <simon@rozman.si>
Diffstat (limited to 'api/driver.c')
-rw-r--r--api/driver.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/api/driver.c b/api/driver.c
index 60d9a25..edd144b 100644
--- a/api/driver.c
+++ b/api/driver.c
@@ -120,7 +120,7 @@ DriverGetVersion(_Out_ FILETIME *DriverDate, _Out_ DWORDLONG *DriverVersion)
DWORD SizeResource;
DWORD Result = ResourceGetAddress(HaveWHQL() ? L"wintun-whql.inf" : L"wintun.inf", &LockedResource, &SizeResource);
if (Result != ERROR_SUCCESS)
- return LOG_ERROR(L"Failed to locate resource", Result);
+ return LOG(WINTUN_LOG_ERR, L"Failed to locate resource"), Result;
enum
{
SectNone,
@@ -287,7 +287,7 @@ InstallCertificate(_In_z_ const WCHAR *SignedResource)
DWORD SizeResource;
DWORD Result = ResourceGetAddress(SignedResource, &LockedResource, &SizeResource);
if (Result != ERROR_SUCCESS)
- return LOG_ERROR(L"Failed to locate resource", Result);
+ return LOG(WINTUN_LOG_ERR, L"Failed to locate resource"), Result;
const CERT_BLOB CertBlob = { .cbData = SizeResource, .pbData = (BYTE *)LockedResource };
HCERTSTORE QueriedStore;
if (!CryptQueryObject(
@@ -397,7 +397,7 @@ InstallDriver(_In_ BOOL UpdateExisting)
BOOL UseWHQL = HaveWHQL();
if (!UseWHQL && (Result = InstallCertificate(L"wintun.sys")) != ERROR_SUCCESS)
- LOG_ERROR(L"Unable to install code signing certificate", Result);
+ LOG(WINTUN_LOG_WARN, L"Unable to install code signing certificate");
LOG(WINTUN_LOG_INFO, L"Copying resources to temporary path");
if ((Result = ResourceCopyToFile(CatPath, &SecurityAttributes, UseWHQL ? L"wintun-whql.cat" : L"wintun.cat")) !=
@@ -407,7 +407,7 @@ InstallDriver(_In_ BOOL UpdateExisting)
(Result = ResourceCopyToFile(InfPath, &SecurityAttributes, UseWHQL ? L"wintun-whql.inf" : L"wintun.inf")) !=
ERROR_SUCCESS)
{
- Result = LOG_LAST_ERROR(L"Failed to copy resources");
+ LOG(WINTUN_LOG_ERR, L"Failed to copy resources");
goto cleanupDelete;
}
@@ -460,7 +460,10 @@ static WINTUN_STATUS RemoveDriver(VOID)
}
SP_DRVINFO_DETAIL_DATA_W *DrvInfoDetailData;
if (AdapterGetDrvInfoDetail(DevInfo, NULL, &DrvInfoData, &DrvInfoDetailData) != ERROR_SUCCESS)
+ {
+ LOG(WINTUN_LOG_WARN, L"Failed getting driver info detail");
continue;
+ }
if (!DriverIsOurDrvInfoDetail(DrvInfoDetailData))
{
HeapFree(Heap, 0, DrvInfoDetailData);
@@ -503,12 +506,12 @@ WINTUN_STATUS DriverInstallOrUpdate(VOID)
DWORD Result = ERROR_SUCCESS;
if ((Result = RemoveDriver()) != ERROR_SUCCESS)
{
- LOG_ERROR(L"Failed to uninstall old drivers", Result);
+ LOG(WINTUN_LOG_ERR, L"Failed to uninstall old drivers");
goto cleanupAdapters;
}
if ((Result = InstallDriver(!!ExistingAdapters)) != ERROR_SUCCESS)
{
- LOG_ERROR(L"Failed to install driver", Result);
+ LOG(WINTUN_LOG_ERR, L"Failed to install driver");
goto cleanupAdapters;
}
LOG(WINTUN_LOG_INFO, L"Installation successful");
@@ -537,10 +540,10 @@ WINTUN_STATUS DriverUninstall(VOID)
{
AdapterDeleteAllOurs();
DWORD Result = RemoveDriver();
- if (Result != ERROR_SUCCESS)
- LOG_ERROR(L"Failed to uninstall driver", Result);
- else
+ if (Result == ERROR_SUCCESS)
LOG(WINTUN_LOG_INFO, L"Uninstallation successful");
+ else
+ LOG(WINTUN_LOG_ERR, L"Failed to uninstall driver");
return Result;
}