提交 4c1b8f1e 编写于 作者: T Tomoki Sekiyama 提交者: Michael Roth

qga: vss-win32: Use NULL as an invalid pointer for OpenEvent and CreateEvent

OpenEvent and CreateEvent WinAPI return NULL when failed to open/create
events handles, instead of INVALID_HANDLE_VALUE (although their return
types are HANDLE).
This replaces INVALID_HANDLE_VALUE related to event handles with NULL.
Signed-off-by: NTomoki Sekiyama <tomoki.sekiyama@hds.com>
Reviewed-by: NGal Hammer <ghammer@redhat.com>
Reviewed-by: NYan Vugenfirer <yvugenfi@redhat.com>
Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
上级 105a0601
...@@ -342,18 +342,18 @@ STDMETHODIMP CQGAVssProvider::CommitSnapshots(VSS_ID SnapshotSetId) ...@@ -342,18 +342,18 @@ STDMETHODIMP CQGAVssProvider::CommitSnapshots(VSS_ID SnapshotSetId)
HANDLE hEventFrozen, hEventThaw, hEventTimeout; HANDLE hEventFrozen, hEventThaw, hEventTimeout;
hEventFrozen = OpenEvent(EVENT_ALL_ACCESS, FALSE, EVENT_NAME_FROZEN); hEventFrozen = OpenEvent(EVENT_ALL_ACCESS, FALSE, EVENT_NAME_FROZEN);
if (hEventFrozen == INVALID_HANDLE_VALUE) { if (!hEventFrozen) {
return E_FAIL; return E_FAIL;
} }
hEventThaw = OpenEvent(EVENT_ALL_ACCESS, FALSE, EVENT_NAME_THAW); hEventThaw = OpenEvent(EVENT_ALL_ACCESS, FALSE, EVENT_NAME_THAW);
if (hEventThaw == INVALID_HANDLE_VALUE) { if (!hEventThaw) {
CloseHandle(hEventFrozen); CloseHandle(hEventFrozen);
return E_FAIL; return E_FAIL;
} }
hEventTimeout = OpenEvent(EVENT_ALL_ACCESS, FALSE, EVENT_NAME_TIMEOUT); hEventTimeout = OpenEvent(EVENT_ALL_ACCESS, FALSE, EVENT_NAME_TIMEOUT);
if (hEventTimeout == INVALID_HANDLE_VALUE) { if (!hEventTimeout) {
CloseHandle(hEventFrozen); CloseHandle(hEventFrozen);
CloseHandle(hEventThaw); CloseHandle(hEventThaw);
return E_FAIL; return E_FAIL;
......
...@@ -50,10 +50,6 @@ static struct QGAVSSContext { ...@@ -50,10 +50,6 @@ static struct QGAVSSContext {
STDAPI requester_init(void) STDAPI requester_init(void)
{ {
vss_ctx.hEventFrozen = INVALID_HANDLE_VALUE;
vss_ctx.hEventThaw = INVALID_HANDLE_VALUE;
vss_ctx.hEventTimeout = INVALID_HANDLE_VALUE;
COMInitializer initializer; /* to call CoInitializeSecurity */ COMInitializer initializer; /* to call CoInitializeSecurity */
HRESULT hr = CoInitializeSecurity( HRESULT hr = CoInitializeSecurity(
NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_PKT_PRIVACY, NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_PKT_PRIVACY,
...@@ -94,17 +90,17 @@ STDAPI requester_init(void) ...@@ -94,17 +90,17 @@ STDAPI requester_init(void)
static void requester_cleanup(void) static void requester_cleanup(void)
{ {
if (vss_ctx.hEventFrozen != INVALID_HANDLE_VALUE) { if (vss_ctx.hEventFrozen) {
CloseHandle(vss_ctx.hEventFrozen); CloseHandle(vss_ctx.hEventFrozen);
vss_ctx.hEventFrozen = INVALID_HANDLE_VALUE; vss_ctx.hEventFrozen = NULL;
} }
if (vss_ctx.hEventThaw != INVALID_HANDLE_VALUE) { if (vss_ctx.hEventThaw) {
CloseHandle(vss_ctx.hEventThaw); CloseHandle(vss_ctx.hEventThaw);
vss_ctx.hEventThaw = INVALID_HANDLE_VALUE; vss_ctx.hEventThaw = NULL;
} }
if (vss_ctx.hEventTimeout != INVALID_HANDLE_VALUE) { if (vss_ctx.hEventTimeout) {
CloseHandle(vss_ctx.hEventTimeout); CloseHandle(vss_ctx.hEventTimeout);
vss_ctx.hEventTimeout = INVALID_HANDLE_VALUE; vss_ctx.hEventTimeout = NULL;
} }
if (vss_ctx.pAsyncSnapshot) { if (vss_ctx.pAsyncSnapshot) {
vss_ctx.pAsyncSnapshot->Release(); vss_ctx.pAsyncSnapshot->Release();
...@@ -374,19 +370,19 @@ void requester_freeze(int *num_vols, ErrorSet *errset) ...@@ -374,19 +370,19 @@ void requester_freeze(int *num_vols, ErrorSet *errset)
sa.bInheritHandle = FALSE; sa.bInheritHandle = FALSE;
vss_ctx.hEventFrozen = CreateEvent(&sa, TRUE, FALSE, EVENT_NAME_FROZEN); vss_ctx.hEventFrozen = CreateEvent(&sa, TRUE, FALSE, EVENT_NAME_FROZEN);
if (vss_ctx.hEventFrozen == INVALID_HANDLE_VALUE) { if (!vss_ctx.hEventFrozen) {
err_set(errset, GetLastError(), "failed to create event %s", err_set(errset, GetLastError(), "failed to create event %s",
EVENT_NAME_FROZEN); EVENT_NAME_FROZEN);
goto out; goto out;
} }
vss_ctx.hEventThaw = CreateEvent(&sa, TRUE, FALSE, EVENT_NAME_THAW); vss_ctx.hEventThaw = CreateEvent(&sa, TRUE, FALSE, EVENT_NAME_THAW);
if (vss_ctx.hEventThaw == INVALID_HANDLE_VALUE) { if (!vss_ctx.hEventThaw) {
err_set(errset, GetLastError(), "failed to create event %s", err_set(errset, GetLastError(), "failed to create event %s",
EVENT_NAME_THAW); EVENT_NAME_THAW);
goto out; goto out;
} }
vss_ctx.hEventTimeout = CreateEvent(&sa, TRUE, FALSE, EVENT_NAME_TIMEOUT); vss_ctx.hEventTimeout = CreateEvent(&sa, TRUE, FALSE, EVENT_NAME_TIMEOUT);
if (vss_ctx.hEventTimeout == INVALID_HANDLE_VALUE) { if (!vss_ctx.hEventTimeout) {
err_set(errset, GetLastError(), "failed to create event %s", err_set(errset, GetLastError(), "failed to create event %s",
EVENT_NAME_TIMEOUT); EVENT_NAME_TIMEOUT);
goto out; goto out;
...@@ -443,7 +439,7 @@ void requester_thaw(int *num_vols, ErrorSet *errset) ...@@ -443,7 +439,7 @@ void requester_thaw(int *num_vols, ErrorSet *errset)
{ {
COMPointer<IVssAsync> pAsync; COMPointer<IVssAsync> pAsync;
if (vss_ctx.hEventThaw == INVALID_HANDLE_VALUE) { if (!vss_ctx.hEventThaw) {
/* /*
* In this case, DoSnapshotSet is aborted or not started, * In this case, DoSnapshotSet is aborted or not started,
* and no volumes must be frozen. We return without an error. * and no volumes must be frozen. We return without an error.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册