mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
[c23] simplify boolean checks
This commit is contained in:
@@ -1806,7 +1806,7 @@ static BOOL CommStatusErrorEx(WINPR_COMM* pComm, unsigned long int ctl, const ch
|
||||
const char* fkt, size_t line)
|
||||
{
|
||||
WINPR_ASSERT(pComm);
|
||||
BOOL rc = pComm->permissive ? TRUE : FALSE;
|
||||
BOOL rc = (pComm->permissive);
|
||||
const DWORD level = rc ? WLOG_DEBUG : WLOG_WARN;
|
||||
char ebuffer[256] = WINPR_C_ARRAY_INIT;
|
||||
const char* str = CommIoCtlToStr(ctl);
|
||||
|
||||
@@ -1424,12 +1424,7 @@ static BOOL refresh_PendingEvents(WINPR_COMM* pComm)
|
||||
WINPR_ASSERT(pComm);
|
||||
|
||||
/* NB: also ensures PendingEvents to be up to date */
|
||||
if (!get_commstatus(pComm, &serialStatus))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return (get_commstatus(pComm, &serialStatus));
|
||||
}
|
||||
|
||||
static void consume_event(WINPR_COMM* pComm, ULONG* pOutputMask, ULONG event)
|
||||
|
||||
@@ -239,8 +239,7 @@ BOOL winpr_HMAC_Init(WINPR_HMAC_CTX* ctx, WINPR_MD_TYPE md, const void* key, siz
|
||||
const OSSL_PARAM param[] = { OSSL_PARAM_construct_utf8_string(param_name, hash, 0),
|
||||
OSSL_PARAM_construct_end() };
|
||||
|
||||
if (EVP_MAC_init(ctx->xhmac, key, keylen, param) == 1)
|
||||
return TRUE;
|
||||
return EVP_MAC_init(ctx->xhmac, key, keylen, param) == 1;
|
||||
#else
|
||||
HMAC_CTX* hmac = ctx->hmac;
|
||||
const EVP_MD* evp = winpr_openssl_get_evp_md(md);
|
||||
@@ -301,8 +300,7 @@ BOOL winpr_HMAC_Update(WINPR_HMAC_CTX* ctx, const void* input, size_t ilen)
|
||||
|
||||
#if defined(WITH_OPENSSL)
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
|
||||
if (EVP_MAC_update(ctx->xhmac, input, ilen) == 1)
|
||||
return TRUE;
|
||||
return EVP_MAC_update(ctx->xhmac, input, ilen) == 1;
|
||||
#else
|
||||
HMAC_CTX* hmac = ctx->hmac;
|
||||
#if (OPENSSL_VERSION_NUMBER < 0x10000000L) || \
|
||||
@@ -345,8 +343,7 @@ BOOL winpr_HMAC_Final(WINPR_HMAC_CTX* ctx, void* output, size_t olen)
|
||||
#if defined(WITH_OPENSSL)
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
|
||||
const int rc = EVP_MAC_final(ctx->xhmac, output, NULL, olen);
|
||||
if (rc == 1)
|
||||
return TRUE;
|
||||
return (rc == 1);
|
||||
#else
|
||||
HMAC_CTX* hmac = ctx->hmac;
|
||||
#if (OPENSSL_VERSION_NUMBER < 0x10000000L) || \
|
||||
@@ -616,8 +613,7 @@ BOOL winpr_Digest_Update(WINPR_DIGEST_CTX* ctx, const void* input, size_t ilen)
|
||||
#if defined(WITH_OPENSSL)
|
||||
EVP_MD_CTX* mdctx = ctx->mdctx;
|
||||
|
||||
if (EVP_DigestUpdate(mdctx, input, ilen) != 1)
|
||||
return FALSE;
|
||||
return EVP_DigestUpdate(mdctx, input, ilen) == 1;
|
||||
|
||||
#elif defined(WITH_MBEDTLS)
|
||||
mbedtls_md_context_t* mdctx = ctx->mdctx;
|
||||
@@ -657,8 +653,7 @@ BOOL winpr_Digest_Final(WINPR_DIGEST_CTX* ctx, void* output, WINPR_ATTR_UNUSED s
|
||||
#if defined(WITH_OPENSSL)
|
||||
EVP_MD_CTX* mdctx = ctx->mdctx;
|
||||
|
||||
if (EVP_DigestFinal_ex(mdctx, output, NULL) == 1)
|
||||
return TRUE;
|
||||
return EVP_DigestFinal_ex(mdctx, output, NULL) == 1;
|
||||
|
||||
#elif defined(WITH_MBEDTLS)
|
||||
mbedtls_md_context_t* mdctx = ctx->mdctx;
|
||||
@@ -680,9 +675,7 @@ BOOL winpr_DigestSign_Init(WINPR_DIGEST_CTX* ctx, WINPR_MD_TYPE md, void* key)
|
||||
return FALSE;
|
||||
|
||||
const int rdsi = EVP_DigestSignInit(ctx->mdctx, NULL, evp, NULL, key);
|
||||
if (rdsi <= 0)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
return (rdsi > 0);
|
||||
#else
|
||||
return FALSE;
|
||||
#endif
|
||||
@@ -695,9 +688,7 @@ BOOL winpr_DigestSign_Update(WINPR_DIGEST_CTX* ctx, const void* input, size_t il
|
||||
#if defined(WITH_OPENSSL)
|
||||
EVP_MD_CTX* mdctx = ctx->mdctx;
|
||||
|
||||
if (EVP_DigestSignUpdate(mdctx, input, ilen) != 1)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
return (EVP_DigestSignUpdate(mdctx, input, ilen) == 1);
|
||||
#else
|
||||
return FALSE;
|
||||
#endif
|
||||
|
||||
@@ -1237,10 +1237,7 @@ BOOL FindClose(HANDLE hFindFile)
|
||||
BOOL CreateDirectoryA(LPCSTR lpPathName,
|
||||
WINPR_ATTR_UNUSED LPSECURITY_ATTRIBUTES lpSecurityAttributes)
|
||||
{
|
||||
if (!mkdir(lpPathName, S_IRUSR | S_IWUSR | S_IXUSR))
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
return mkdir(lpPathName, S_IRUSR | S_IWUSR | S_IXUSR) == 0;
|
||||
}
|
||||
|
||||
BOOL CreateDirectoryW(LPCWSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
|
||||
|
||||
@@ -225,10 +225,7 @@ const HANDLE_CREATOR* GetNamedPipeClientHandleCreator(void)
|
||||
|
||||
BOOL IsNamedPipeFileNameA(LPCSTR lpName)
|
||||
{
|
||||
if (strncmp(lpName, NAMED_PIPE_PREFIX_PATH, sizeof(NAMED_PIPE_PREFIX_PATH) - 1) != 0)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
return (strncmp(lpName, NAMED_PIPE_PREFIX_PATH, sizeof(NAMED_PIPE_PREFIX_PATH) - 1) == 0);
|
||||
}
|
||||
|
||||
char* GetNamedPipeNameWithoutPrefixA(LPCSTR lpName)
|
||||
|
||||
@@ -190,9 +190,7 @@ static BOOL list_directory_star(const char* BasePath, wArrayList* files)
|
||||
fcount++;
|
||||
}
|
||||
|
||||
if (fcount != count)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
return (fcount == count);
|
||||
}
|
||||
|
||||
static BOOL find_first_file_fail(const char* FilePath)
|
||||
|
||||
@@ -201,10 +201,7 @@ BOOL FreeLibrary(HMODULE hLibModule)
|
||||
int status = 0;
|
||||
status = dlclose(hLibModule);
|
||||
|
||||
if (status != 0)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
return (status == 0);
|
||||
}
|
||||
|
||||
HMODULE GetModuleHandleA(LPCSTR lpModuleName)
|
||||
|
||||
@@ -718,9 +718,7 @@ HRESULT PathCchStripPrefixA(PSTR pszPath, size_t cchPath)
|
||||
return E_INVALIDARG;
|
||||
|
||||
hasPrefix = ((pszPath[0] == '\\') && (pszPath[1] == '\\') && (pszPath[2] == '?') &&
|
||||
(pszPath[3] == '\\'))
|
||||
? TRUE
|
||||
: FALSE;
|
||||
(pszPath[3] == '\\'));
|
||||
|
||||
if (hasPrefix)
|
||||
{
|
||||
@@ -753,9 +751,7 @@ HRESULT PathCchStripPrefixW(PWSTR pszPath, size_t cchPath)
|
||||
return E_INVALIDARG;
|
||||
|
||||
hasPrefix = ((pszPath[0] == '\\') && (pszPath[1] == '\\') && (pszPath[2] == '?') &&
|
||||
(pszPath[3] == '\\'))
|
||||
? TRUE
|
||||
: FALSE;
|
||||
(pszPath[3] == '\\'));
|
||||
|
||||
if (hasPrefix)
|
||||
{
|
||||
|
||||
@@ -689,10 +689,7 @@ BOOL PathFileExistsA(LPCSTR pszPath)
|
||||
{
|
||||
struct stat stat_info;
|
||||
|
||||
if (stat(pszPath, &stat_info) != 0)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
return (stat(pszPath, &stat_info) == 0);
|
||||
}
|
||||
|
||||
BOOL PathFileExistsW(LPCWSTR pszPath)
|
||||
@@ -818,7 +815,7 @@ BOOL winpr_DeleteFile(const char* lpFileName)
|
||||
return FALSE;
|
||||
|
||||
const int status = unlink(lpFileName);
|
||||
return (status != -1) ? TRUE : FALSE;
|
||||
return (status != -1);
|
||||
#else
|
||||
LPWSTR lpFileNameW = NULL;
|
||||
BOOL result = FALSE;
|
||||
|
||||
@@ -946,7 +946,7 @@ RPC_STATUS UuidCreateNil(UUID* NilUuid)
|
||||
|
||||
int UuidEqual(const UUID* Uuid1, const UUID* Uuid2, RPC_STATUS* Status)
|
||||
{
|
||||
return ((UuidCompare(Uuid1, Uuid2, Status) == 0) ? TRUE : FALSE);
|
||||
return UuidCompare(Uuid1, Uuid2, Status) == 0;
|
||||
}
|
||||
|
||||
unsigned short UuidHash(WINPR_ATTR_UNUSED const UUID* Uuid, WINPR_ATTR_UNUSED RPC_STATUS* Status)
|
||||
|
||||
@@ -1719,7 +1719,7 @@ static LONG WINAPI PCSC_SCardConnect_Internal(SCARDCONTEXT hContext, LPCSTR szRe
|
||||
if (!g_PCSC.pfnSCardConnect)
|
||||
return PCSC_SCard_LogError("g_PCSC.pfnSCardConnect");
|
||||
|
||||
shared = (dwShareMode == SCARD_SHARE_DIRECT) ? TRUE : FALSE;
|
||||
shared = (dwShareMode == SCARD_SHARE_DIRECT) != 0;
|
||||
PCSC_WaitForCardAccess(hContext, 0, shared);
|
||||
szReaderPCSC = szReader;
|
||||
|
||||
@@ -1811,7 +1811,7 @@ static LONG WINAPI PCSC_SCardReconnect(SCARDHANDLE hCard, DWORD dwShareMode,
|
||||
if (!g_PCSC.pfnSCardReconnect)
|
||||
return PCSC_SCard_LogError("g_PCSC.pfnSCardReconnect");
|
||||
|
||||
shared = (dwShareMode == SCARD_SHARE_DIRECT) ? TRUE : FALSE;
|
||||
shared = (dwShareMode == SCARD_SHARE_DIRECT) != 0;
|
||||
PCSC_WaitForCardAccess(0, hCard, shared);
|
||||
pcsc_dwPreferredProtocols = (PCSC_DWORD)PCSC_ConvertProtocolsFromWinSCard(dwPreferredProtocols);
|
||||
status = g_PCSC.pfnSCardReconnect(hCard, pcsc_dwShareMode, pcsc_dwPreferredProtocols,
|
||||
|
||||
@@ -471,9 +471,8 @@ static BOOL ntlm_compute_ntlm_v2_hash(NTLM_CONTEXT* context, BYTE* hash)
|
||||
}
|
||||
else if (context->HashCallback)
|
||||
{
|
||||
int ret = 0;
|
||||
SecBuffer proofValue;
|
||||
SecBuffer micValue;
|
||||
SecBuffer proofValue = WINPR_C_ARRAY_INIT;
|
||||
SecBuffer micValue = WINPR_C_ARRAY_INIT;
|
||||
|
||||
if (ntlm_computeProofValue(context, &proofValue) != SEC_E_OK)
|
||||
return FALSE;
|
||||
@@ -484,13 +483,13 @@ static BOOL ntlm_compute_ntlm_v2_hash(NTLM_CONTEXT* context, BYTE* hash)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ret = context->HashCallback(context->HashCallbackArg, &credentials->identity, &proofValue,
|
||||
context->EncryptedRandomSessionKey,
|
||||
context->AUTHENTICATE_MESSAGE.MessageIntegrityCheck, &micValue,
|
||||
hash);
|
||||
const SECURITY_STATUS ret = context->HashCallback(
|
||||
context->HashCallbackArg, &credentials->identity, &proofValue,
|
||||
context->EncryptedRandomSessionKey, context->AUTHENTICATE_MESSAGE.MessageIntegrityCheck,
|
||||
&micValue, hash);
|
||||
sspi_SecBufferFree(&proofValue);
|
||||
sspi_SecBufferFree(&micValue);
|
||||
return ret ? TRUE : FALSE;
|
||||
return ret == SEC_E_OK;
|
||||
}
|
||||
else if (context->UseSamFileDatabase)
|
||||
{
|
||||
|
||||
@@ -986,8 +986,7 @@ SECURITY_STATUS ntlm_read_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer
|
||||
if (!ntlm_read_negotiate_flags(s, &message->NegotiateFlags, 0, "NTLM_AUTHENTICATE_MESSAGE"))
|
||||
goto fail;
|
||||
|
||||
context->NegotiateKeyExchange =
|
||||
(message->NegotiateFlags & NTLMSSP_NEGOTIATE_KEY_EXCH) ? TRUE : FALSE;
|
||||
context->NegotiateKeyExchange = (message->NegotiateFlags & NTLMSSP_NEGOTIATE_KEY_EXCH) != 0;
|
||||
|
||||
if ((context->NegotiateKeyExchange && !message->EncryptedRandomSessionKey.Len) ||
|
||||
(!context->NegotiateKeyExchange && message->EncryptedRandomSessionKey.Len))
|
||||
|
||||
@@ -353,14 +353,14 @@ static BOOL negotiate_get_config(void* pAuthData, BOOL* kerberos, BOOL* ntlm, BO
|
||||
DWORD dwValue = 0;
|
||||
|
||||
if (negotiate_get_dword(hKey, PACKAGE_NAME_KERBEROS, &dwValue))
|
||||
*kerberos = (dwValue != 0) ? TRUE : FALSE;
|
||||
*kerberos = (dwValue != 0);
|
||||
|
||||
if (negotiate_get_dword(hKey, PACKAGE_NAME_KERBEROS_U2U, &dwValue))
|
||||
*u2u = (dwValue != 0) ? TRUE : FALSE;
|
||||
*u2u = (dwValue != 0);
|
||||
|
||||
#if !defined(WITH_KRB5_NO_NTLM_FALLBACK)
|
||||
if (negotiate_get_dword(hKey, PACKAGE_NAME_NTLM, &dwValue))
|
||||
*ntlm = (dwValue != 0) ? TRUE : FALSE;
|
||||
*ntlm = (dwValue != 0);
|
||||
#endif
|
||||
|
||||
RegCloseKey(hKey);
|
||||
|
||||
@@ -179,8 +179,8 @@ BOOL WINAPI winpr_EnterSynchronizationBarrier(LPSYNCHRONIZATION_BARRIER lpBarrie
|
||||
if (remainingThreads > 0)
|
||||
{
|
||||
DWORD dwProcessors = lpBarrier->Reserved4;
|
||||
BOOL spinOnly = (dwFlags & SYNCHRONIZATION_BARRIER_FLAGS_SPIN_ONLY) ? TRUE : FALSE;
|
||||
BOOL blockOnly = (dwFlags & SYNCHRONIZATION_BARRIER_FLAGS_BLOCK_ONLY) ? TRUE : FALSE;
|
||||
BOOL spinOnly = (dwFlags & SYNCHRONIZATION_BARRIER_FLAGS_SPIN_ONLY) != 0;
|
||||
BOOL blockOnly = (dwFlags & SYNCHRONIZATION_BARRIER_FLAGS_BLOCK_ONLY) != 0;
|
||||
BOOL block = TRUE;
|
||||
|
||||
/**
|
||||
|
||||
@@ -396,7 +396,7 @@ HANDLE CreateWaitableTimerW(LPSECURITY_ATTRIBUTES lpTimerAttributes, BOOL bManua
|
||||
HANDLE CreateWaitableTimerExA(LPSECURITY_ATTRIBUTES lpTimerAttributes, LPCSTR lpTimerName,
|
||||
DWORD dwFlags, DWORD dwDesiredAccess)
|
||||
{
|
||||
BOOL bManualReset = (dwFlags & CREATE_WAITABLE_TIMER_MANUAL_RESET) ? TRUE : FALSE;
|
||||
BOOL bManualReset = (dwFlags & CREATE_WAITABLE_TIMER_MANUAL_RESET) != 0;
|
||||
|
||||
if (dwDesiredAccess != 0)
|
||||
WLog_WARN(TAG, "[%s] does not support dwDesiredAccess 0x%08" PRIx32, lpTimerName,
|
||||
|
||||
@@ -309,11 +309,8 @@ int CommandLineParseArgumentsA(int argc, LPSTR* argv, COMMAND_LINE_ARGUMENT_A* o
|
||||
value_present = 0;
|
||||
}
|
||||
|
||||
if ((cur->Flags & COMMAND_LINE_VALUE_REQUIRED) ||
|
||||
(cur->Flags & COMMAND_LINE_VALUE_OPTIONAL))
|
||||
argument = TRUE;
|
||||
else
|
||||
argument = FALSE;
|
||||
argument = (((cur->Flags & COMMAND_LINE_VALUE_REQUIRED) != 0) ||
|
||||
((cur->Flags & COMMAND_LINE_VALUE_OPTIONAL) != 0));
|
||||
|
||||
if (value_present && argument)
|
||||
{
|
||||
@@ -712,9 +709,7 @@ static BOOL is_valid_fullquoted(const char* string)
|
||||
}
|
||||
|
||||
/* The string did not terminate with the same quote as it started. */
|
||||
if (last != quote)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
return (last == quote);
|
||||
}
|
||||
|
||||
char** CommandLineParseCommaSeparatedValuesEx(const char* name, const char* list, size_t* count)
|
||||
|
||||
@@ -523,7 +523,7 @@ SSIZE_T ArrayList_LastIndexOf(wArrayList* arrayList, const void* obj, SSIZE_T st
|
||||
|
||||
static BOOL ArrayList_DefaultCompare(const void* objA, const void* objB)
|
||||
{
|
||||
return objA == objB ? TRUE : FALSE;
|
||||
return (objA == objB);
|
||||
}
|
||||
|
||||
wObject* ArrayList_Object(wArrayList* arrayList)
|
||||
|
||||
@@ -116,7 +116,7 @@ BOOL LinkedList_Contains(wLinkedList* list, const void* value)
|
||||
item = item->next;
|
||||
}
|
||||
|
||||
return (item) ? TRUE : FALSE;
|
||||
return (item != NULL);
|
||||
}
|
||||
|
||||
static wLinkedListNode* LinkedList_FreeNode(wLinkedList* list, wLinkedListNode* node)
|
||||
|
||||
@@ -339,7 +339,7 @@ BOOL ListDictionary_Contains(wListDictionary* listDictionary, const void* key)
|
||||
if (listDictionary->synchronized)
|
||||
ListDictionary_Unlock(listDictionary);
|
||||
|
||||
return (item) ? TRUE : FALSE;
|
||||
return (item != NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -514,7 +514,7 @@ BOOL ListDictionary_SetItemValue(wListDictionary* listDictionary, const void* ke
|
||||
if (item)
|
||||
item_set(listDictionary, item, value);
|
||||
|
||||
status = (item) ? TRUE : FALSE;
|
||||
status = (item != NULL);
|
||||
}
|
||||
|
||||
if (listDictionary->synchronized)
|
||||
|
||||
@@ -83,7 +83,7 @@ static BOOL IniFile_Load_NextLine(wIniFile* ini, char* str)
|
||||
ini->nextLine = NULL;
|
||||
}
|
||||
|
||||
return (ini->nextLine) ? TRUE : FALSE;
|
||||
return (ini->nextLine != NULL);
|
||||
}
|
||||
|
||||
static BOOL IniFile_BufferResize(wIniFile* ini, size_t size)
|
||||
@@ -195,7 +195,7 @@ static BOOL IniFile_Load_HasNextLine(wIniFile* ini)
|
||||
{
|
||||
WINPR_ASSERT(ini);
|
||||
|
||||
return (ini->nextLine) ? TRUE : FALSE;
|
||||
return (ini->nextLine != NULL);
|
||||
}
|
||||
|
||||
static char* IniFile_Load_GetNextLine(wIniFile* ini)
|
||||
|
||||
@@ -309,9 +309,7 @@ static BOOL foreachFn2(const void* key, void* value, void* arg)
|
||||
WINPR_UNUSED(value);
|
||||
d->foreachCalls++;
|
||||
|
||||
if (d->foreachCalls == 2)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
return (d->foreachCalls != 2);
|
||||
}
|
||||
|
||||
static BOOL foreachFn3(const void* key, void* value, void* arg)
|
||||
|
||||
@@ -183,7 +183,7 @@ static BOOL test_load_file(const char* name)
|
||||
goto fail;
|
||||
|
||||
const int res = winpr_image_read(image, name);
|
||||
rc = (res > 0) ? TRUE : FALSE;
|
||||
rc = (res > 0);
|
||||
|
||||
fail:
|
||||
winpr_image_free(image, TRUE);
|
||||
|
||||
@@ -161,10 +161,7 @@ static bool test_operation_run(wMessageQueue* queue, HANDLE thread)
|
||||
return false;
|
||||
|
||||
const DWORD status = WaitForSingleObject(thread, INFINITE);
|
||||
if (status != WAIT_OBJECT_0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return (status == WAIT_OBJECT_0);
|
||||
}
|
||||
|
||||
static bool test_operation(wMessageQueue* queue)
|
||||
|
||||
@@ -113,9 +113,7 @@ static bool check_size(wQueue* queue, size_t expected)
|
||||
WINPR_ASSERT(queue);
|
||||
const size_t count = Queue_Count(queue);
|
||||
printf("queue count: %" PRIuz "\n", count);
|
||||
if (count != expected)
|
||||
return false;
|
||||
return true;
|
||||
return (count == expected);
|
||||
}
|
||||
|
||||
static bool enqueue(wQueue* queue, size_t val)
|
||||
@@ -130,9 +128,7 @@ static bool dequeue(wQueue* queue, size_t expected)
|
||||
WINPR_ASSERT(queue);
|
||||
const void* pexpect = (void*)(23 + expected);
|
||||
void* ptr = Queue_Dequeue(queue);
|
||||
if (pexpect != ptr)
|
||||
return false;
|
||||
return true;
|
||||
return (pexpect == ptr);
|
||||
}
|
||||
|
||||
static bool legacy_test(wQueue* queue)
|
||||
@@ -214,9 +210,7 @@ static bool legacy_test(wQueue* queue)
|
||||
|
||||
Queue_Clear(queue);
|
||||
|
||||
if (!check_size(queue, 0))
|
||||
return false;
|
||||
return true;
|
||||
return check_size(queue, 0);
|
||||
}
|
||||
|
||||
int TestQueue(WINPR_ATTR_UNUSED int argc, WINPR_ATTR_UNUSED char* argv[])
|
||||
|
||||
@@ -188,7 +188,7 @@ static BOOL TestStream_Create(size_t count, BOOL selfAlloc)
|
||||
}
|
||||
}
|
||||
|
||||
Stream_Free(s, buffer ? FALSE : TRUE);
|
||||
Stream_Free(s, buffer == NULL);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ fail:
|
||||
|
||||
if (s)
|
||||
{
|
||||
Stream_Free(s, buffer ? FALSE : TRUE);
|
||||
Stream_Free(s, buffer == NULL);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
||||
@@ -78,10 +78,7 @@ static BOOL WLog_BinaryAppender_Open(wLog* log, wLogAppender* appender)
|
||||
|
||||
binaryAppender->FileDescriptor = winpr_fopen(binaryAppender->FullFileName, "a+");
|
||||
|
||||
if (!binaryAppender->FileDescriptor)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
return binaryAppender->FileDescriptor != NULL;
|
||||
}
|
||||
|
||||
static BOOL WLog_BinaryAppender_Close(WINPR_ATTR_UNUSED wLog* log, wLogAppender* appender)
|
||||
|
||||
@@ -39,22 +39,19 @@ typedef struct
|
||||
|
||||
static BOOL WLog_FileAppender_SetOutputFileName(wLogFileAppender* appender, const char* filename)
|
||||
{
|
||||
WINPR_ASSERT(appender);
|
||||
WINPR_ASSERT(filename);
|
||||
|
||||
appender->FileName = _strdup(filename);
|
||||
|
||||
if (!appender->FileName)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
return appender->FileName != NULL;
|
||||
}
|
||||
|
||||
static BOOL WLog_FileAppender_SetOutputFilePath(wLogFileAppender* appender, const char* filepath)
|
||||
{
|
||||
appender->FilePath = _strdup(filepath);
|
||||
|
||||
if (!appender->FilePath)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
return appender->FilePath != NULL;
|
||||
}
|
||||
|
||||
static BOOL WLog_FileAppender_Open(wLog* log, wLogAppender* appender)
|
||||
@@ -103,10 +100,7 @@ static BOOL WLog_FileAppender_Open(wLog* log, wLogAppender* appender)
|
||||
|
||||
fileAppender->FileDescriptor = winpr_fopen(fileAppender->FullFileName, "a+");
|
||||
|
||||
if (!fileAppender->FileDescriptor)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
return fileAppender->FileDescriptor != NULL;
|
||||
}
|
||||
|
||||
static BOOL WLog_FileAppender_Close(wLog* log, wLogAppender* appender)
|
||||
|
||||
@@ -26,12 +26,6 @@
|
||||
|
||||
BOOL WLog_ImageMessage_Write(char* filename, void* data, size_t width, size_t height, size_t bpp)
|
||||
{
|
||||
int status = 0;
|
||||
|
||||
status = winpr_bitmap_write(filename, data, width, height, bpp);
|
||||
|
||||
if (status < 0)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
const int status = winpr_bitmap_write(filename, data, width, height, bpp);
|
||||
return (status >= 0);
|
||||
}
|
||||
|
||||
@@ -65,9 +65,17 @@ static BOOL WLog_JournaldAppender_Open(wLog* log, wLogAppender* appender)
|
||||
|
||||
static BOOL WLog_JournaldAppender_Close(wLog* log, wLogAppender* appender)
|
||||
{
|
||||
wLogJournaldAppender* journaldAppender = (wLogJournaldAppender*)appender;
|
||||
if (!log || !appender)
|
||||
return FALSE;
|
||||
|
||||
if (journaldAppender->stream)
|
||||
(void)fclose(journaldAppender->stream);
|
||||
|
||||
free(journaldAppender->identifier);
|
||||
|
||||
journaldAppender->stream = NULL;
|
||||
journaldAppender->identifier = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -124,6 +132,7 @@ static BOOL WLog_JournaldAppender_WriteDataMessage(wLog* log, wLogAppender* appe
|
||||
if (!log || !appender || !message)
|
||||
return FALSE;
|
||||
|
||||
(void)fprintf(stderr, "[TODO: %s] data messages not implemented! Ignoring.\n", __func__);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -133,6 +142,7 @@ static BOOL WLog_JournaldAppender_WriteImageMessage(wLog* log, wLogAppender* app
|
||||
if (!log || !appender || !message)
|
||||
return FALSE;
|
||||
|
||||
(void)fprintf(stderr, "[TODO: %s] image messages not implemented! Ignoring.\n", __func__);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -230,9 +230,7 @@ static BOOL replace_format_string(const char* FormatString, struct format_option
|
||||
}
|
||||
}
|
||||
|
||||
if (!check_and_log_format_size(format, formatlen, index, 0))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
return check_and_log_format_size(format, formatlen, index, 0);
|
||||
}
|
||||
|
||||
BOOL WLog_Layout_GetMessagePrefix(wLog* log, wLogLayout* layout, const wLogMessage* message,
|
||||
|
||||
@@ -36,30 +36,22 @@
|
||||
|
||||
static BOOL Pcap_Read_Header(wPcap* pcap, wPcapHeader* header)
|
||||
{
|
||||
if (pcap && pcap->fp && fread((void*)header, sizeof(wPcapHeader), 1, pcap->fp) == 1)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
return (pcap && pcap->fp && fread((void*)header, sizeof(wPcapHeader), 1, pcap->fp) == 1);
|
||||
}
|
||||
|
||||
static BOOL Pcap_Write_Header(wPcap* pcap, wPcapHeader* header)
|
||||
{
|
||||
if (pcap && pcap->fp && fwrite((void*)header, sizeof(wPcapHeader), 1, pcap->fp) == 1)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
return (pcap && pcap->fp && fwrite((void*)header, sizeof(wPcapHeader), 1, pcap->fp) == 1);
|
||||
}
|
||||
|
||||
static BOOL Pcap_Write_RecordHeader(wPcap* pcap, wPcapRecordHeader* record)
|
||||
{
|
||||
if (pcap && pcap->fp && fwrite((void*)record, sizeof(wPcapRecordHeader), 1, pcap->fp) == 1)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
return (pcap && pcap->fp && fwrite((void*)record, sizeof(wPcapRecordHeader), 1, pcap->fp) == 1);
|
||||
}
|
||||
|
||||
static BOOL Pcap_Write_RecordContent(wPcap* pcap, wPcapRecord* record)
|
||||
{
|
||||
if (pcap && pcap->fp && fwrite(record->data, record->length, 1, pcap->fp) == 1)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
return (pcap && pcap->fp && fwrite(record->data, record->length, 1, pcap->fp) == 1);
|
||||
}
|
||||
|
||||
static BOOL Pcap_Write_Record(wPcap* pcap, wPcapRecord* record)
|
||||
|
||||
@@ -51,18 +51,12 @@ static int getSyslogLevel(DWORD level)
|
||||
|
||||
static BOOL WLog_SyslogAppender_Open(wLog* log, wLogAppender* appender)
|
||||
{
|
||||
if (!log || !appender)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
return !(!log || !appender);
|
||||
}
|
||||
|
||||
static BOOL WLog_SyslogAppender_Close(wLog* log, wLogAppender* appender)
|
||||
{
|
||||
if (!log || !appender)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
return !(!log || !appender);
|
||||
}
|
||||
|
||||
static BOOL WLog_SyslogAppender_WriteMessage(wLog* log, wLogAppender* appender,
|
||||
|
||||
@@ -81,10 +81,7 @@ static BOOL WLog_UdpAppender_Open(WINPR_ATTR_UNUSED wLog* log, wLogAppender* app
|
||||
|
||||
static BOOL WLog_UdpAppender_Close(wLog* log, wLogAppender* appender)
|
||||
{
|
||||
if (!log || !appender)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
return !(!log || !appender);
|
||||
}
|
||||
|
||||
static BOOL WLog_UdpAppender_WriteMessage(wLog* log, wLogAppender* appender,
|
||||
@@ -111,19 +108,13 @@ static BOOL WLog_UdpAppender_WriteMessage(wLog* log, wLogAppender* appender,
|
||||
static BOOL WLog_UdpAppender_WriteDataMessage(wLog* log, wLogAppender* appender,
|
||||
const wLogMessage* message)
|
||||
{
|
||||
if (!log || !appender || !message)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
return !(!log || !appender || !message);
|
||||
}
|
||||
|
||||
static BOOL WLog_UdpAppender_WriteImageMessage(wLog* log, wLogAppender* appender,
|
||||
const wLogMessage* message)
|
||||
{
|
||||
if (!log || !appender || !message)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
return !(!log || !appender || !message);
|
||||
}
|
||||
|
||||
static BOOL WLog_UdpAppender_Set(wLogAppender* appender, const char* setting, void* value)
|
||||
|
||||
@@ -611,7 +611,7 @@ BOOL WLog_SetLogLevel(wLog* log, DWORD logLevel)
|
||||
logLevel = WLOG_OFF;
|
||||
|
||||
log->Level = logLevel;
|
||||
log->inherit = (logLevel == WLOG_LEVEL_INHERIT) ? TRUE : FALSE;
|
||||
log->inherit = (logLevel == WLOG_LEVEL_INHERIT);
|
||||
|
||||
for (DWORD x = 0; x < log->ChildrenCount; x++)
|
||||
{
|
||||
|
||||
@@ -690,9 +690,7 @@ BOOL WTSRegisterWtsApiFunctionTable(const WtsApiFunctionTable* table)
|
||||
} cnv;
|
||||
cnv.cpv = table;
|
||||
InitOnceExecuteOnce(&wtsapiInitOnce, InitializeWtsApiStubs, cnv.pv, NULL);
|
||||
if (!g_WtsApi)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
return g_WtsApi != NULL;
|
||||
}
|
||||
|
||||
static BOOL LoadAndInitialize(char* library)
|
||||
|
||||
Reference in New Issue
Block a user