Fixed formatting and warnings.

This commit is contained in:
Armin Novak 2017-11-14 13:55:58 +01:00
parent 44dfaf7841
commit 90e1d39fec

View File

@ -60,7 +60,7 @@ static BOOL TimerIsHandled(HANDLE handle)
static int TimerGetFd(HANDLE handle) static int TimerGetFd(HANDLE handle)
{ {
WINPR_TIMER *timer = (WINPR_TIMER *)handle; WINPR_TIMER* timer = (WINPR_TIMER*)handle;
if (!TimerIsHandled(handle)) if (!TimerIsHandled(handle))
return -1; return -1;
@ -72,12 +72,12 @@ static DWORD TimerCleanupHandle(HANDLE handle)
{ {
int length; int length;
UINT64 expirations; UINT64 expirations;
WINPR_TIMER *timer = (WINPR_TIMER *)handle; WINPR_TIMER* timer = (WINPR_TIMER*)handle;
if (!TimerIsHandled(handle)) if (!TimerIsHandled(handle))
return WAIT_FAILED; return WAIT_FAILED;
length = read(timer->fd, (void *) &expirations, sizeof(UINT64)); length = read(timer->fd, (void*) &expirations, sizeof(UINT64));
if (length != 8) if (length != 8)
{ {
@ -99,7 +99,8 @@ static DWORD TimerCleanupHandle(HANDLE handle)
return WAIT_OBJECT_0; return WAIT_OBJECT_0;
} }
BOOL TimerCloseHandle(HANDLE handle) { BOOL TimerCloseHandle(HANDLE handle)
{
WINPR_TIMER* timer; WINPR_TIMER* timer;
timer = (WINPR_TIMER*) handle; timer = (WINPR_TIMER*) handle;
@ -113,7 +114,6 @@ BOOL TimerCloseHandle(HANDLE handle) {
#endif #endif
free(timer); free(timer);
return TRUE; return TRUE;
} }
@ -139,7 +139,7 @@ static void WaitableTimerSignalHandler(int signum, siginfo_t* siginfo, void* arg
if ((timer_settime(timer->tid, 0, &(timer->timeout), NULL)) != 0) if ((timer_settime(timer->tid, 0, &(timer->timeout), NULL)) != 0)
{ {
WLog_ERR(TAG,"timer_settime"); WLog_ERR(TAG, "timer_settime");
} }
} }
} }
@ -186,6 +186,7 @@ int InitializeWaitableTimer(WINPR_TIMER* timer)
close(timer->fd); close(timer->fd);
return -1; return -1;
} }
#else #else
WLog_ERR(TAG, "%s: os specific implementation is missing", __FUNCTION__); WLog_ERR(TAG, "%s: os specific implementation is missing", __FUNCTION__);
result = -1; result = -1;
@ -203,9 +204,10 @@ int InitializeWaitableTimer(WINPR_TIMER* timer)
if ((timer_create(CLOCK_MONOTONIC, &sigev, &(timer->tid))) != 0) if ((timer_create(CLOCK_MONOTONIC, &sigev, &(timer->tid))) != 0)
{ {
WLog_ERR(TAG,"timer_create"); WLog_ERR(TAG, "timer_create");
return -1; return -1;
} }
#else #else
WLog_ERR(TAG, "%s: os specific implementation is missing", __FUNCTION__); WLog_ERR(TAG, "%s: os specific implementation is missing", __FUNCTION__);
result = -1; result = -1;
@ -217,7 +219,8 @@ int InitializeWaitableTimer(WINPR_TIMER* timer)
} }
static HANDLE_OPS ops = { static HANDLE_OPS ops =
{
TimerIsHandled, TimerIsHandled,
TimerCloseHandle, TimerCloseHandle,
TimerGetFd, TimerGetFd,
@ -228,12 +231,13 @@ static HANDLE_OPS ops = {
* Waitable Timer * Waitable Timer
*/ */
HANDLE CreateWaitableTimerA(LPSECURITY_ATTRIBUTES lpTimerAttributes, BOOL bManualReset, LPCSTR lpTimerName) HANDLE CreateWaitableTimerA(LPSECURITY_ATTRIBUTES lpTimerAttributes, BOOL bManualReset,
LPCSTR lpTimerName)
{ {
HANDLE handle = NULL; HANDLE handle = NULL;
WINPR_TIMER* timer; WINPR_TIMER* timer;
timer = (WINPR_TIMER*) calloc(1, sizeof(WINPR_TIMER)); timer = (WINPR_TIMER*) calloc(1, sizeof(WINPR_TIMER));
if (timer) if (timer)
{ {
WINPR_HANDLE_SET_TYPE_AND_MODE(timer, HANDLE_TYPE_TIMER, WINPR_FD_READ); WINPR_HANDLE_SET_TYPE_AND_MODE(timer, HANDLE_TYPE_TIMER, WINPR_FD_READ);
@ -250,19 +254,22 @@ HANDLE CreateWaitableTimerA(LPSECURITY_ATTRIBUTES lpTimerAttributes, BOOL bManua
return handle; return handle;
} }
HANDLE CreateWaitableTimerW(LPSECURITY_ATTRIBUTES lpTimerAttributes, BOOL bManualReset, LPCWSTR lpTimerName) HANDLE CreateWaitableTimerW(LPSECURITY_ATTRIBUTES lpTimerAttributes, BOOL bManualReset,
LPCWSTR lpTimerName)
{ {
return NULL; return NULL;
} }
HANDLE CreateWaitableTimerExA(LPSECURITY_ATTRIBUTES lpTimerAttributes, LPCSTR lpTimerName, DWORD dwFlags, DWORD dwDesiredAccess) HANDLE CreateWaitableTimerExA(LPSECURITY_ATTRIBUTES lpTimerAttributes, LPCSTR lpTimerName,
DWORD dwFlags, DWORD dwDesiredAccess)
{ {
BOOL bManualReset; BOOL bManualReset;
bManualReset = (dwFlags & CREATE_WAITABLE_TIMER_MANUAL_RESET) ? TRUE : FALSE; bManualReset = (dwFlags & CREATE_WAITABLE_TIMER_MANUAL_RESET) ? TRUE : FALSE;
return CreateWaitableTimerA(lpTimerAttributes, bManualReset, lpTimerName); return CreateWaitableTimerA(lpTimerAttributes, bManualReset, lpTimerName);
} }
HANDLE CreateWaitableTimerExW(LPSECURITY_ATTRIBUTES lpTimerAttributes, LPCWSTR lpTimerName, DWORD dwFlags, DWORD dwDesiredAccess) HANDLE CreateWaitableTimerExW(LPSECURITY_ATTRIBUTES lpTimerAttributes, LPCWSTR lpTimerName,
DWORD dwFlags, DWORD dwDesiredAccess)
{ {
return NULL; return NULL;
} }
@ -358,7 +365,7 @@ BOOL SetWaitableTimer(HANDLE hTimer, const LARGE_INTEGER* lpDueTime, LONG lPerio
{ {
if ((timer_settime(timer->tid, 0, &(timer->timeout), NULL)) != 0) if ((timer_settime(timer->tid, 0, &(timer->timeout), NULL)) != 0)
{ {
WLog_ERR(TAG,"timer_settime"); WLog_ERR(TAG, "timer_settime");
return FALSE; return FALSE;
} }
} }
@ -368,20 +375,19 @@ BOOL SetWaitableTimer(HANDLE hTimer, const LARGE_INTEGER* lpDueTime, LONG lPerio
} }
BOOL SetWaitableTimerEx(HANDLE hTimer, const LARGE_INTEGER* lpDueTime, LONG lPeriod, BOOL SetWaitableTimerEx(HANDLE hTimer, const LARGE_INTEGER* lpDueTime, LONG lPeriod,
PTIMERAPCROUTINE pfnCompletionRoutine, LPVOID lpArgToCompletionRoutine, PREASON_CONTEXT WakeContext, ULONG TolerableDelay) PTIMERAPCROUTINE pfnCompletionRoutine, LPVOID lpArgToCompletionRoutine, PREASON_CONTEXT WakeContext,
ULONG TolerableDelay)
{ {
ULONG Type; ULONG Type;
WINPR_HANDLE* Object; WINPR_HANDLE* Object;
WINPR_TIMER* timer;
if (!winpr_Handle_GetInfo(hTimer, &Type, &Object)) if (!winpr_Handle_GetInfo(hTimer, &Type, &Object))
return FALSE; return FALSE;
(void)Object;
if (Type == HANDLE_TYPE_TIMER) if (Type == HANDLE_TYPE_TIMER)
{
timer = (WINPR_TIMER*) Object;
return TRUE; return TRUE;
}
return TRUE; return TRUE;
} }
@ -590,6 +596,9 @@ static void* TimerQueueThread(void* arg)
FireExpiredTimerQueueTimers(timerQueue); FireExpiredTimerQueueTimers(timerQueue);
pthread_mutex_unlock(&(timerQueue->cond_mutex)); pthread_mutex_unlock(&(timerQueue->cond_mutex));
if ((status != ETIMEDOUT) && (status != 0))
break;
if (timerQueue->bCancelled) if (timerQueue->bCancelled)
break; break;
} }
@ -646,7 +655,6 @@ BOOL DeleteTimerQueueEx(HANDLE TimerQueue, HANDLE CompletionEvent)
pthread_cond_signal(&(timerQueue->cond)); pthread_cond_signal(&(timerQueue->cond));
pthread_mutex_unlock(&(timerQueue->cond_mutex)); pthread_mutex_unlock(&(timerQueue->cond_mutex));
pthread_join(timerQueue->thread, &rvalue); pthread_join(timerQueue->thread, &rvalue);
/** /**
* Quote from MSDN regarding CompletionEvent: * Quote from MSDN regarding CompletionEvent:
* If this parameter is INVALID_HANDLE_VALUE, the function waits for * If this parameter is INVALID_HANDLE_VALUE, the function waits for
@ -657,7 +665,6 @@ BOOL DeleteTimerQueueEx(HANDLE TimerQueue, HANDLE CompletionEvent)
* Note: The current WinPR implementation implicitly waits for any * Note: The current WinPR implementation implicitly waits for any
* callback functions to complete (see pthread_join above) * callback functions to complete (see pthread_join above)
*/ */
{ {
/* Move all active timers to the inactive timer list */ /* Move all active timers to the inactive timer list */
node = timerQueue->activeHead; node = timerQueue->activeHead;
@ -681,7 +688,6 @@ BOOL DeleteTimerQueueEx(HANDLE TimerQueue, HANDLE CompletionEvent)
timerQueue->inactiveHead = NULL; timerQueue->inactiveHead = NULL;
} }
/* Delete timer queue */ /* Delete timer queue */
pthread_cond_destroy(&(timerQueue->cond)); pthread_cond_destroy(&(timerQueue->cond));
pthread_mutex_destroy(&(timerQueue->cond_mutex)); pthread_mutex_destroy(&(timerQueue->cond_mutex));
@ -775,7 +781,6 @@ BOOL DeleteTimerQueueTimer(HANDLE TimerQueue, HANDLE Timer, HANDLE CompletionEve
timerQueue = (WINPR_TIMER_QUEUE*) TimerQueue; timerQueue = (WINPR_TIMER_QUEUE*) TimerQueue;
timer = (WINPR_TIMER_QUEUE_TIMER*) Timer; timer = (WINPR_TIMER_QUEUE_TIMER*) Timer;
pthread_mutex_lock(&(timerQueue->cond_mutex)); pthread_mutex_lock(&(timerQueue->cond_mutex));
/** /**
* Quote from MSDN regarding CompletionEvent: * Quote from MSDN regarding CompletionEvent:
* If this parameter is INVALID_HANDLE_VALUE, the function waits for * If this parameter is INVALID_HANDLE_VALUE, the function waits for
@ -786,9 +791,7 @@ BOOL DeleteTimerQueueTimer(HANDLE TimerQueue, HANDLE Timer, HANDLE CompletionEve
* Note: The current WinPR implementation implicitly waits for any * Note: The current WinPR implementation implicitly waits for any
* callback functions to complete (see cond_mutex usage) * callback functions to complete (see cond_mutex usage)
*/ */
RemoveTimerQueueTimer(&(timerQueue->activeHead), timer); RemoveTimerQueueTimer(&(timerQueue->activeHead), timer);
pthread_cond_signal(&(timerQueue->cond)); pthread_cond_signal(&(timerQueue->cond));
pthread_mutex_unlock(&(timerQueue->cond_mutex)); pthread_mutex_unlock(&(timerQueue->cond_mutex));
free(timer); free(timer);