mirror of https://github.com/FreeRDP/FreeRDP
[warnings] fix clang-tidy issues in winpr
This commit is contained in:
parent
c44f89bc68
commit
6a3564407e
|
@ -625,7 +625,7 @@ char* parse_uri_to_local_file(const char* uri, size_t uri_len)
|
|||
|
||||
WLog_VRB(TAG, "processing URI: %.*s", uri_len, uri);
|
||||
|
||||
if ((uri_len <= prefixLen) || strncmp(uri, prefix, prefixLen))
|
||||
if ((uri_len <= prefixLen) || strncmp(uri, prefix, prefixLen) != 0)
|
||||
{
|
||||
WLog_ERR(TAG, "non-'file:' URI schemes are not supported");
|
||||
return NULL;
|
||||
|
@ -692,7 +692,7 @@ char* parse_uri_to_local_file(const char* uri, size_t uri_len)
|
|||
* "file:///path/to/file"
|
||||
*/
|
||||
if ((uri_len < prefixTraditionalLen) ||
|
||||
strncmp(uri, prefixTraditional, prefixTraditionalLen))
|
||||
strncmp(uri, prefixTraditional, prefixTraditionalLen) != 0)
|
||||
{
|
||||
WLog_ERR(TAG, "non-'file:' URI schemes are not supported");
|
||||
return NULL;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
WINPR_PRAGMA_DIAG_PUSH
|
||||
WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO
|
||||
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
#define _FILE_OFFSET_BITS 64 // NOLINT(bugprone-reserved-identifier)
|
||||
|
||||
WINPR_PRAGMA_DIAG_POP
|
||||
|
||||
|
|
|
@ -41,6 +41,9 @@
|
|||
|
||||
#include "comm_ioctl.h"
|
||||
|
||||
#include "../log.h"
|
||||
#define TAG WINPR_TAG("comm")
|
||||
|
||||
/**
|
||||
* Communication Resources:
|
||||
* http://msdn.microsoft.com/en-us/library/windows/desktop/aa363196/
|
||||
|
@ -48,7 +51,7 @@
|
|||
|
||||
#include "comm.h"
|
||||
|
||||
static wLog* _Log = NULL;
|
||||
static wLog* sLog = NULL;
|
||||
|
||||
struct comm_device
|
||||
{
|
||||
|
@ -61,12 +64,12 @@ typedef struct comm_device COMM_DEVICE;
|
|||
/* FIXME: get a clever data structure, see also io.h functions */
|
||||
/* _CommDevices is a NULL-terminated array with a maximun of COMM_DEVICE_MAX COMM_DEVICE */
|
||||
#define COMM_DEVICE_MAX 128
|
||||
static COMM_DEVICE** _CommDevices = NULL;
|
||||
static CRITICAL_SECTION _CommDevicesLock;
|
||||
static COMM_DEVICE** sCommDevices = NULL;
|
||||
static CRITICAL_SECTION sCommDevicesLock;
|
||||
|
||||
static HANDLE_CREATOR _CommHandleCreator;
|
||||
static HANDLE_CREATOR sCommHandleCreator = { 0 };
|
||||
|
||||
static pthread_once_t _CommInitialized = PTHREAD_ONCE_INIT;
|
||||
static pthread_once_t sCommInitialized = PTHREAD_ONCE_INIT;
|
||||
|
||||
static int CommGetFd(HANDLE handle)
|
||||
{
|
||||
|
@ -80,30 +83,30 @@ static int CommGetFd(HANDLE handle)
|
|||
|
||||
HANDLE_CREATOR* GetCommHandleCreator(void)
|
||||
{
|
||||
_CommHandleCreator.IsHandled = IsCommDevice;
|
||||
_CommHandleCreator.CreateFileA = CommCreateFileA;
|
||||
return &_CommHandleCreator;
|
||||
sCommHandleCreator.IsHandled = IsCommDevice;
|
||||
sCommHandleCreator.CreateFileA = CommCreateFileA;
|
||||
return &sCommHandleCreator;
|
||||
}
|
||||
|
||||
static void _CommInit(void)
|
||||
static void CommInit(void)
|
||||
{
|
||||
/* NB: error management to be done outside of this function */
|
||||
WINPR_ASSERT(_Log == NULL);
|
||||
WINPR_ASSERT(_CommDevices == NULL);
|
||||
_CommDevices = (COMM_DEVICE**)calloc(COMM_DEVICE_MAX + 1, sizeof(COMM_DEVICE*));
|
||||
WINPR_ASSERT(sLog == NULL);
|
||||
WINPR_ASSERT(sCommDevices == NULL);
|
||||
sCommDevices = (COMM_DEVICE**)calloc(COMM_DEVICE_MAX + 1, sizeof(COMM_DEVICE*));
|
||||
|
||||
if (!_CommDevices)
|
||||
if (!sCommDevices)
|
||||
return;
|
||||
|
||||
if (!InitializeCriticalSectionEx(&_CommDevicesLock, 0, 0))
|
||||
if (!InitializeCriticalSectionEx(&sCommDevicesLock, 0, 0))
|
||||
{
|
||||
free(_CommDevices);
|
||||
_CommDevices = NULL;
|
||||
free(sCommDevices);
|
||||
sCommDevices = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
_Log = WLog_Get("com.winpr.comm");
|
||||
WINPR_ASSERT(_Log != NULL);
|
||||
sLog = WLog_Get(TAG);
|
||||
WINPR_ASSERT(sLog != NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -112,7 +115,7 @@ static void _CommInit(void)
|
|||
*/
|
||||
static BOOL CommInitialized(void)
|
||||
{
|
||||
if (pthread_once(&_CommInitialized, _CommInit) != 0)
|
||||
if (pthread_once(&sCommInitialized, CommInit) != 0)
|
||||
{
|
||||
SetLastError(ERROR_DLL_INIT_FAILED);
|
||||
return FALSE;
|
||||
|
@ -128,7 +131,7 @@ void CommLog_Print(DWORD level, ...)
|
|||
|
||||
va_list ap;
|
||||
va_start(ap, level);
|
||||
WLog_PrintVA(_Log, level, ap);
|
||||
WLog_PrintVA(sLog, level, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
@ -936,9 +939,9 @@ BOOL DefineCommDevice(/* DWORD dwFlags,*/ LPCTSTR lpDeviceName, LPCTSTR lpTarget
|
|||
if (!CommInitialized())
|
||||
return FALSE;
|
||||
|
||||
EnterCriticalSection(&_CommDevicesLock);
|
||||
EnterCriticalSection(&sCommDevicesLock);
|
||||
|
||||
if (_CommDevices == NULL)
|
||||
if (sCommDevices == NULL)
|
||||
{
|
||||
SetLastError(ERROR_DLL_INIT_FAILED);
|
||||
goto error_handle;
|
||||
|
@ -963,31 +966,31 @@ BOOL DefineCommDevice(/* DWORD dwFlags,*/ LPCTSTR lpDeviceName, LPCTSTR lpTarget
|
|||
int i = 0;
|
||||
for (; i < COMM_DEVICE_MAX; i++)
|
||||
{
|
||||
if (_CommDevices[i] != NULL)
|
||||
if (sCommDevices[i] != NULL)
|
||||
{
|
||||
if (_tcscmp(_CommDevices[i]->name, storedDeviceName) == 0)
|
||||
if (_tcscmp(sCommDevices[i]->name, storedDeviceName) == 0)
|
||||
{
|
||||
/* take over the emplacement */
|
||||
free(_CommDevices[i]->name);
|
||||
free(_CommDevices[i]->path);
|
||||
_CommDevices[i]->name = storedDeviceName;
|
||||
_CommDevices[i]->path = storedTargetPath;
|
||||
free(sCommDevices[i]->name);
|
||||
free(sCommDevices[i]->path);
|
||||
sCommDevices[i]->name = storedDeviceName;
|
||||
sCommDevices[i]->path = storedTargetPath;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* new emplacement */
|
||||
_CommDevices[i] = (COMM_DEVICE*)calloc(1, sizeof(COMM_DEVICE));
|
||||
sCommDevices[i] = (COMM_DEVICE*)calloc(1, sizeof(COMM_DEVICE));
|
||||
|
||||
if (_CommDevices[i] == NULL)
|
||||
if (sCommDevices[i] == NULL)
|
||||
{
|
||||
SetLastError(ERROR_OUTOFMEMORY);
|
||||
goto error_handle;
|
||||
}
|
||||
|
||||
_CommDevices[i]->name = storedDeviceName;
|
||||
_CommDevices[i]->path = storedTargetPath;
|
||||
sCommDevices[i]->name = storedDeviceName;
|
||||
sCommDevices[i]->path = storedTargetPath;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -998,12 +1001,12 @@ BOOL DefineCommDevice(/* DWORD dwFlags,*/ LPCTSTR lpDeviceName, LPCTSTR lpTarget
|
|||
goto error_handle;
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&_CommDevicesLock);
|
||||
LeaveCriticalSection(&sCommDevicesLock);
|
||||
return TRUE;
|
||||
error_handle:
|
||||
free(storedDeviceName);
|
||||
free(storedTargetPath);
|
||||
LeaveCriticalSection(&_CommDevicesLock);
|
||||
LeaveCriticalSection(&sCommDevicesLock);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -1031,7 +1034,7 @@ DWORD QueryCommDevice(LPCTSTR lpDeviceName, LPTSTR lpTargetPath, DWORD ucchMax)
|
|||
if (!CommInitialized())
|
||||
return 0;
|
||||
|
||||
if (_CommDevices == NULL)
|
||||
if (sCommDevices == NULL)
|
||||
{
|
||||
SetLastError(ERROR_DLL_INIT_FAILED);
|
||||
return 0;
|
||||
|
@ -1043,16 +1046,16 @@ DWORD QueryCommDevice(LPCTSTR lpDeviceName, LPTSTR lpTargetPath, DWORD ucchMax)
|
|||
return 0;
|
||||
}
|
||||
|
||||
EnterCriticalSection(&_CommDevicesLock);
|
||||
EnterCriticalSection(&sCommDevicesLock);
|
||||
storedTargetPath = NULL;
|
||||
|
||||
for (int i = 0; i < COMM_DEVICE_MAX; i++)
|
||||
{
|
||||
if (_CommDevices[i] != NULL)
|
||||
if (sCommDevices[i] != NULL)
|
||||
{
|
||||
if (_tcscmp(_CommDevices[i]->name, lpDeviceName) == 0)
|
||||
if (_tcscmp(sCommDevices[i]->name, lpDeviceName) == 0)
|
||||
{
|
||||
storedTargetPath = _CommDevices[i]->path;
|
||||
storedTargetPath = sCommDevices[i]->path;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1062,7 +1065,7 @@ DWORD QueryCommDevice(LPCTSTR lpDeviceName, LPTSTR lpTargetPath, DWORD ucchMax)
|
|||
break;
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&_CommDevicesLock);
|
||||
LeaveCriticalSection(&sCommDevicesLock);
|
||||
|
||||
if (storedTargetPath == NULL)
|
||||
{
|
||||
|
|
|
@ -42,7 +42,7 @@ BOOL _comm_set_permissive(HANDLE hDevice, BOOL permissive)
|
|||
}
|
||||
|
||||
/* Computes VTIME in deciseconds from Ti in milliseconds */
|
||||
static UCHAR _vtime(ULONG Ti)
|
||||
static UCHAR svtime(ULONG Ti)
|
||||
{
|
||||
/* FIXME: look for an equivalent math function otherwise let
|
||||
* do the compiler do the optimization */
|
||||
|
@ -169,7 +169,7 @@ BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
|
|||
if ((pTimeouts->ReadIntervalTimeout > 0) && (pTimeouts->ReadIntervalTimeout < MAXULONG))
|
||||
{
|
||||
/* Ti */
|
||||
vtime = _vtime(pTimeouts->ReadIntervalTimeout);
|
||||
vtime = svtime(pTimeouts->ReadIntervalTimeout);
|
||||
}
|
||||
|
||||
/* TMAX */
|
||||
|
|
|
@ -58,7 +58,7 @@ static BOOL get_serial_chars(WINPR_COMM* pComm, SERIAL_CHARS* pSerialChars)
|
|||
|
||||
/* http://msdn.microsoft.com/en-us/library/windows/hardware/hh439605%28v=vs.85%29.aspx */
|
||||
/* FIXME: only using the Serial.sys' events, complete the support of the remaining events */
|
||||
static const ULONG _SERCX2_SYS_SUPPORTED_EV_MASK =
|
||||
static const ULONG SERCX2_SYS_SUPPORTED_EV_MASK =
|
||||
SERIAL_EV_RXCHAR | SERIAL_EV_RXFLAG | SERIAL_EV_TXEMPTY | SERIAL_EV_CTS | SERIAL_EV_DSR |
|
||||
SERIAL_EV_RLSD | SERIAL_EV_BREAK | SERIAL_EV_ERR | SERIAL_EV_RING |
|
||||
/* SERIAL_EV_PERR | */
|
||||
|
@ -77,7 +77,7 @@ static BOOL set_wait_mask(WINPR_COMM* pComm, const ULONG* pWaitMask)
|
|||
WINPR_ASSERT(pWaitMask);
|
||||
WINPR_ASSERT(pSerialSys);
|
||||
|
||||
possibleMask = *pWaitMask & _SERCX2_SYS_SUPPORTED_EV_MASK;
|
||||
possibleMask = *pWaitMask & SERCX2_SYS_SUPPORTED_EV_MASK;
|
||||
|
||||
if (possibleMask != *pWaitMask)
|
||||
{
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "comm_serial_sys.h"
|
||||
#include "comm_sercx_sys.h"
|
||||
|
||||
static BOOL _set_handflow(WINPR_COMM* pComm, const SERIAL_HANDFLOW* pHandflow)
|
||||
static BOOL set_handflow(WINPR_COMM* pComm, const SERIAL_HANDFLOW* pHandflow)
|
||||
{
|
||||
SERIAL_HANDFLOW SerCxHandflow;
|
||||
BOOL result = TRUE;
|
||||
|
@ -121,7 +121,7 @@ static BOOL _set_handflow(WINPR_COMM* pComm, const SERIAL_HANDFLOW* pHandflow)
|
|||
return result;
|
||||
}
|
||||
|
||||
static BOOL _get_handflow(WINPR_COMM* pComm, SERIAL_HANDFLOW* pHandflow)
|
||||
static BOOL get_handflow(WINPR_COMM* pComm, SERIAL_HANDFLOW* pHandflow)
|
||||
{
|
||||
BOOL result = 0;
|
||||
SERIAL_DRIVER* pSerialSys = SerialSys_s();
|
||||
|
@ -142,23 +142,23 @@ static BOOL _get_handflow(WINPR_COMM* pComm, SERIAL_HANDFLOW* pHandflow)
|
|||
}
|
||||
|
||||
/* http://msdn.microsoft.com/en-us/library/windows/hardware/hh439605%28v=vs.85%29.aspx */
|
||||
static const ULONG _SERCX_SYS_SUPPORTED_EV_MASK = SERIAL_EV_RXCHAR |
|
||||
/* SERIAL_EV_RXFLAG | */
|
||||
SERIAL_EV_TXEMPTY | SERIAL_EV_CTS |
|
||||
SERIAL_EV_DSR | SERIAL_EV_RLSD | SERIAL_EV_BREAK |
|
||||
SERIAL_EV_ERR | SERIAL_EV_RING /* |
|
||||
SERIAL_EV_PERR |
|
||||
SERIAL_EV_RX80FULL |
|
||||
SERIAL_EV_EVENT1 |
|
||||
SERIAL_EV_EVENT2*/
|
||||
static const ULONG SERCX_SYS_SUPPORTED_EV_MASK = SERIAL_EV_RXCHAR |
|
||||
/* SERIAL_EV_RXFLAG | */
|
||||
SERIAL_EV_TXEMPTY | SERIAL_EV_CTS | SERIAL_EV_DSR |
|
||||
SERIAL_EV_RLSD | SERIAL_EV_BREAK | SERIAL_EV_ERR |
|
||||
SERIAL_EV_RING /* |
|
||||
SERIAL_EV_PERR |
|
||||
SERIAL_EV_RX80FULL |
|
||||
SERIAL_EV_EVENT1 |
|
||||
SERIAL_EV_EVENT2*/
|
||||
;
|
||||
|
||||
static BOOL _set_wait_mask(WINPR_COMM* pComm, const ULONG* pWaitMask)
|
||||
static BOOL set_wait_mask(WINPR_COMM* pComm, const ULONG* pWaitMask)
|
||||
{
|
||||
ULONG possibleMask = 0;
|
||||
SERIAL_DRIVER* pSerialSys = SerialSys_s();
|
||||
|
||||
possibleMask = *pWaitMask & _SERCX_SYS_SUPPORTED_EV_MASK;
|
||||
possibleMask = *pWaitMask & SERCX_SYS_SUPPORTED_EV_MASK;
|
||||
|
||||
if (possibleMask != *pWaitMask)
|
||||
{
|
||||
|
@ -177,7 +177,7 @@ static BOOL _set_wait_mask(WINPR_COMM* pComm, const ULONG* pWaitMask)
|
|||
}
|
||||
|
||||
/* specific functions only */
|
||||
static SERIAL_DRIVER _SerCxSys = {
|
||||
static SERIAL_DRIVER SerCxSys = {
|
||||
.id = SerialDriverSerCxSys,
|
||||
.name = _T("SerCx.sys"),
|
||||
.set_baud_rate = NULL,
|
||||
|
@ -187,8 +187,8 @@ static SERIAL_DRIVER _SerCxSys = {
|
|||
.get_serial_chars = NULL,
|
||||
.set_line_control = NULL,
|
||||
.get_line_control = NULL,
|
||||
.set_handflow = _set_handflow,
|
||||
.get_handflow = _get_handflow,
|
||||
.set_handflow = set_handflow,
|
||||
.get_handflow = get_handflow,
|
||||
.set_timeouts = NULL,
|
||||
.get_timeouts = NULL,
|
||||
.set_dtr = NULL,
|
||||
|
@ -196,7 +196,7 @@ static SERIAL_DRIVER _SerCxSys = {
|
|||
.set_rts = NULL,
|
||||
.clear_rts = NULL,
|
||||
.get_modemstatus = NULL,
|
||||
.set_wait_mask = _set_wait_mask,
|
||||
.set_wait_mask = set_wait_mask,
|
||||
.get_wait_mask = NULL,
|
||||
.wait_on_mask = NULL,
|
||||
.set_queue_size = NULL,
|
||||
|
@ -219,48 +219,48 @@ SERIAL_DRIVER* SerCxSys_s(void)
|
|||
if (!pSerialSys)
|
||||
return NULL;
|
||||
|
||||
_SerCxSys.set_baud_rate = pSerialSys->set_baud_rate;
|
||||
_SerCxSys.get_baud_rate = pSerialSys->get_baud_rate;
|
||||
SerCxSys.set_baud_rate = pSerialSys->set_baud_rate;
|
||||
SerCxSys.get_baud_rate = pSerialSys->get_baud_rate;
|
||||
|
||||
_SerCxSys.get_properties = pSerialSys->get_properties;
|
||||
SerCxSys.get_properties = pSerialSys->get_properties;
|
||||
|
||||
_SerCxSys.set_serial_chars = pSerialSys->set_serial_chars;
|
||||
_SerCxSys.get_serial_chars = pSerialSys->get_serial_chars;
|
||||
_SerCxSys.set_line_control = pSerialSys->set_line_control;
|
||||
_SerCxSys.get_line_control = pSerialSys->get_line_control;
|
||||
SerCxSys.set_serial_chars = pSerialSys->set_serial_chars;
|
||||
SerCxSys.get_serial_chars = pSerialSys->get_serial_chars;
|
||||
SerCxSys.set_line_control = pSerialSys->set_line_control;
|
||||
SerCxSys.get_line_control = pSerialSys->get_line_control;
|
||||
|
||||
_SerCxSys.set_timeouts = pSerialSys->set_timeouts;
|
||||
_SerCxSys.get_timeouts = pSerialSys->get_timeouts;
|
||||
SerCxSys.set_timeouts = pSerialSys->set_timeouts;
|
||||
SerCxSys.get_timeouts = pSerialSys->get_timeouts;
|
||||
|
||||
_SerCxSys.set_dtr = pSerialSys->set_dtr;
|
||||
_SerCxSys.clear_dtr = pSerialSys->clear_dtr;
|
||||
SerCxSys.set_dtr = pSerialSys->set_dtr;
|
||||
SerCxSys.clear_dtr = pSerialSys->clear_dtr;
|
||||
|
||||
_SerCxSys.set_rts = pSerialSys->set_rts;
|
||||
_SerCxSys.clear_rts = pSerialSys->clear_rts;
|
||||
SerCxSys.set_rts = pSerialSys->set_rts;
|
||||
SerCxSys.clear_rts = pSerialSys->clear_rts;
|
||||
|
||||
_SerCxSys.get_modemstatus = pSerialSys->get_modemstatus;
|
||||
SerCxSys.get_modemstatus = pSerialSys->get_modemstatus;
|
||||
|
||||
_SerCxSys.set_wait_mask = pSerialSys->set_wait_mask;
|
||||
_SerCxSys.get_wait_mask = pSerialSys->get_wait_mask;
|
||||
_SerCxSys.wait_on_mask = pSerialSys->wait_on_mask;
|
||||
SerCxSys.set_wait_mask = pSerialSys->set_wait_mask;
|
||||
SerCxSys.get_wait_mask = pSerialSys->get_wait_mask;
|
||||
SerCxSys.wait_on_mask = pSerialSys->wait_on_mask;
|
||||
|
||||
_SerCxSys.set_queue_size = pSerialSys->set_queue_size;
|
||||
SerCxSys.set_queue_size = pSerialSys->set_queue_size;
|
||||
|
||||
_SerCxSys.purge = pSerialSys->purge;
|
||||
SerCxSys.purge = pSerialSys->purge;
|
||||
|
||||
_SerCxSys.get_commstatus = pSerialSys->get_commstatus;
|
||||
SerCxSys.get_commstatus = pSerialSys->get_commstatus;
|
||||
|
||||
_SerCxSys.set_break_on = pSerialSys->set_break_on;
|
||||
_SerCxSys.set_break_off = pSerialSys->set_break_off;
|
||||
SerCxSys.set_break_on = pSerialSys->set_break_on;
|
||||
SerCxSys.set_break_off = pSerialSys->set_break_off;
|
||||
|
||||
_SerCxSys.set_xoff = pSerialSys->set_xoff;
|
||||
_SerCxSys.set_xon = pSerialSys->set_xon;
|
||||
SerCxSys.set_xoff = pSerialSys->set_xoff;
|
||||
SerCxSys.set_xon = pSerialSys->set_xon;
|
||||
|
||||
_SerCxSys.get_dtrrts = pSerialSys->get_dtrrts;
|
||||
SerCxSys.get_dtrrts = pSerialSys->get_dtrrts;
|
||||
|
||||
_SerCxSys.immediate_char = pSerialSys->immediate_char;
|
||||
SerCxSys.immediate_char = pSerialSys->immediate_char;
|
||||
|
||||
return &_SerCxSys;
|
||||
return &SerCxSys;
|
||||
}
|
||||
|
||||
#endif /* __linux__ */
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
* 1: CBR_* or actual baud rate
|
||||
* 2: BAUD_* (identical to SERIAL_BAUD_*)
|
||||
*/
|
||||
static const speed_t _BAUD_TABLE[][3] = {
|
||||
static const speed_t BAUD_TABLE[][3] = {
|
||||
#ifdef B0
|
||||
{ B0, 0, 0 }, /* hang up */
|
||||
#endif
|
||||
|
@ -199,9 +199,9 @@ static BOOL get_properties(WINPR_COMM* pComm, COMMPROP* pProperties)
|
|||
SP_PARITY_CHECK | /*SP_RLSD |*/ SP_STOPBITS;
|
||||
|
||||
pProperties->dwSettableBaud = 0;
|
||||
for (int i = 0; _BAUD_TABLE[i][0] < BAUD_TABLE_END; i++)
|
||||
for (int i = 0; BAUD_TABLE[i][0] < BAUD_TABLE_END; i++)
|
||||
{
|
||||
pProperties->dwSettableBaud |= _BAUD_TABLE[i][2];
|
||||
pProperties->dwSettableBaud |= BAUD_TABLE[i][2];
|
||||
}
|
||||
|
||||
pProperties->wSettableData =
|
||||
|
@ -236,11 +236,11 @@ static BOOL set_baud_rate(WINPR_COMM* pComm, const SERIAL_BAUD_RATE* pBaudRate)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
for (int i = 0; _BAUD_TABLE[i][0] < BAUD_TABLE_END; i++)
|
||||
for (int i = 0; BAUD_TABLE[i][0] < BAUD_TABLE_END; i++)
|
||||
{
|
||||
if (_BAUD_TABLE[i][1] == pBaudRate->BaudRate)
|
||||
if (BAUD_TABLE[i][1] == pBaudRate->BaudRate)
|
||||
{
|
||||
newSpeed = _BAUD_TABLE[i][0];
|
||||
newSpeed = BAUD_TABLE[i][0];
|
||||
if (cfsetspeed(&futureState, newSpeed) < 0)
|
||||
{
|
||||
CommLog_Print(WLOG_WARN, "failed to set speed 0x%x (%" PRIu32 ")", newSpeed,
|
||||
|
@ -283,11 +283,11 @@ static BOOL get_baud_rate(WINPR_COMM* pComm, SERIAL_BAUD_RATE* pBaudRate)
|
|||
|
||||
currentSpeed = cfgetispeed(¤tState);
|
||||
|
||||
for (int i = 0; _BAUD_TABLE[i][0] < BAUD_TABLE_END; i++)
|
||||
for (int i = 0; BAUD_TABLE[i][0] < BAUD_TABLE_END; i++)
|
||||
{
|
||||
if (_BAUD_TABLE[i][0] == currentSpeed)
|
||||
if (BAUD_TABLE[i][0] == currentSpeed)
|
||||
{
|
||||
pBaudRate->BaudRate = _BAUD_TABLE[i][1];
|
||||
pBaudRate->BaudRate = BAUD_TABLE[i][1];
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,13 +29,13 @@
|
|||
int TestCommConfig(int argc, char* argv[])
|
||||
{
|
||||
DCB dcb = { 0 };
|
||||
HANDLE hComm;
|
||||
BOOL success;
|
||||
BOOL success = FALSE;
|
||||
LPCSTR lpFileName = "\\\\.\\COM1";
|
||||
COMMPROP commProp = { 0 };
|
||||
struct stat statbuf = { 0 };
|
||||
|
||||
hComm = CreateFileA(lpFileName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
|
||||
HANDLE hComm =
|
||||
CreateFileA(lpFileName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
|
||||
|
||||
if (hComm && (hComm != INVALID_HANDLE_VALUE))
|
||||
{
|
||||
|
|
|
@ -24,11 +24,10 @@
|
|||
|
||||
static int test_CommDevice(LPCTSTR lpDeviceName, BOOL expectedResult)
|
||||
{
|
||||
BOOL result;
|
||||
TCHAR lpTargetPath[MAX_PATH];
|
||||
size_t tcslen;
|
||||
TCHAR lpTargetPath[MAX_PATH] = { 0 };
|
||||
size_t tcslen = 0;
|
||||
|
||||
result = DefineCommDevice(lpDeviceName, _T("/dev/test"));
|
||||
BOOL result = DefineCommDevice(lpDeviceName, _T("/dev/test"));
|
||||
if ((!expectedResult && result) || (expectedResult && !result)) /* logical XOR */
|
||||
{
|
||||
_tprintf(_T("DefineCommDevice failure: device name: %s, expected result: %s, result: %s\n"),
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
|
||||
int TestCommMonitor(int argc, char* argv[])
|
||||
{
|
||||
HANDLE hComm;
|
||||
DWORD dwError;
|
||||
BOOL fSuccess;
|
||||
DWORD dwEvtMask;
|
||||
HANDLE hComm = NULL;
|
||||
DWORD dwError = 0;
|
||||
BOOL fSuccess = 0;
|
||||
DWORD dwEvtMask = 0;
|
||||
OVERLAPPED overlapped = { 0 };
|
||||
LPCSTR lpFileName = "\\\\.\\COM1";
|
||||
|
||||
|
|
|
@ -28,10 +28,10 @@
|
|||
|
||||
int TestControlSettings(int argc, char* argv[])
|
||||
{
|
||||
struct stat statbuf;
|
||||
BOOL result;
|
||||
HANDLE hComm;
|
||||
DCB dcb;
|
||||
struct stat statbuf = { 0 };
|
||||
BOOL result = 0;
|
||||
HANDLE hComm = NULL;
|
||||
DCB dcb = { 0 };
|
||||
|
||||
if (stat("/dev/ttyS0", &statbuf) < 0)
|
||||
{
|
||||
|
|
|
@ -27,8 +27,9 @@
|
|||
|
||||
static BOOL test_generic(HANDLE hComm)
|
||||
{
|
||||
DCB dcb, *pDcb;
|
||||
BOOL result;
|
||||
DCB dcb = { 0 };
|
||||
DCB* pDcb = NULL;
|
||||
BOOL result = 0;
|
||||
|
||||
ZeroMemory(&dcb, sizeof(DCB));
|
||||
result = GetCommState(hComm, &dcb);
|
||||
|
@ -76,9 +77,9 @@ static BOOL test_generic(HANDLE hComm)
|
|||
|
||||
int TestGetCommState(int argc, char* argv[])
|
||||
{
|
||||
struct stat statbuf;
|
||||
BOOL result;
|
||||
HANDLE hComm;
|
||||
struct stat statbuf = { 0 };
|
||||
BOOL result = 0;
|
||||
HANDLE hComm = NULL;
|
||||
|
||||
if (stat("/dev/ttyS0", &statbuf) < 0)
|
||||
{
|
||||
|
|
|
@ -37,9 +37,9 @@ static BOOL test_SerialSys(HANDLE hComm)
|
|||
|
||||
int TestHandflow(int argc, char* argv[])
|
||||
{
|
||||
struct stat statbuf;
|
||||
BOOL result;
|
||||
HANDLE hComm;
|
||||
struct stat statbuf = { 0 };
|
||||
BOOL result = 0;
|
||||
HANDLE hComm = NULL;
|
||||
|
||||
if (stat("/dev/ttyS0", &statbuf) < 0)
|
||||
{
|
||||
|
|
|
@ -32,7 +32,8 @@
|
|||
static BOOL test_SerCxSys(HANDLE hComm)
|
||||
{
|
||||
DCB dcb = { 0 };
|
||||
UCHAR XonChar, XoffChar;
|
||||
UCHAR XonChar = 0;
|
||||
UCHAR XoffChar = 0;
|
||||
|
||||
struct termios currentTermios = { 0 };
|
||||
|
||||
|
@ -130,9 +131,9 @@ static BOOL test_SerCx2Sys(HANDLE hComm)
|
|||
|
||||
int TestSerialChars(int argc, char* argv[])
|
||||
{
|
||||
struct stat statbuf;
|
||||
BOOL result;
|
||||
HANDLE hComm;
|
||||
struct stat statbuf = { 0 };
|
||||
BOOL result = 0;
|
||||
HANDLE hComm = NULL;
|
||||
|
||||
if (stat("/dev/ttyS0", &statbuf) < 0)
|
||||
{
|
||||
|
|
|
@ -37,8 +37,8 @@ static void init_empty_dcb(DCB* pDcb)
|
|||
|
||||
static BOOL test_fParity(HANDLE hComm)
|
||||
{
|
||||
DCB dcb;
|
||||
BOOL result;
|
||||
DCB dcb = { 0 };
|
||||
BOOL result = 0;
|
||||
|
||||
init_empty_dcb(&dcb);
|
||||
result = GetCommState(hComm, &dcb);
|
||||
|
@ -122,8 +122,8 @@ static BOOL test_fParity(HANDLE hComm)
|
|||
|
||||
static BOOL test_SerialSys(HANDLE hComm)
|
||||
{
|
||||
DCB dcb;
|
||||
BOOL result;
|
||||
DCB dcb = { 0 };
|
||||
BOOL result = 0;
|
||||
|
||||
init_empty_dcb(&dcb);
|
||||
result = GetCommState(hComm, &dcb);
|
||||
|
@ -206,8 +206,9 @@ static BOOL test_SerCx2Sys(HANDLE hComm)
|
|||
|
||||
static BOOL test_generic(HANDLE hComm)
|
||||
{
|
||||
DCB dcb, dcb2;
|
||||
BOOL result;
|
||||
DCB dcb = { 0 };
|
||||
DCB dcb2 = { 0 };
|
||||
BOOL result = 0;
|
||||
|
||||
init_empty_dcb(&dcb);
|
||||
result = GetCommState(hComm, &dcb);
|
||||
|
@ -256,9 +257,9 @@ static BOOL test_generic(HANDLE hComm)
|
|||
|
||||
int TestSetCommState(int argc, char* argv[])
|
||||
{
|
||||
struct stat statbuf;
|
||||
BOOL result;
|
||||
HANDLE hComm;
|
||||
struct stat statbuf = { 0 };
|
||||
BOOL result = 0;
|
||||
HANDLE hComm = NULL;
|
||||
|
||||
if (stat("/dev/ttyS0", &statbuf) < 0)
|
||||
{
|
||||
|
|
|
@ -31,7 +31,8 @@
|
|||
|
||||
static BOOL test_generic(HANDLE hComm)
|
||||
{
|
||||
COMMTIMEOUTS timeouts = { 0 }, timeouts2 = { 0 };
|
||||
COMMTIMEOUTS timeouts = { 0 };
|
||||
COMMTIMEOUTS timeouts2 = { 0 };
|
||||
|
||||
timeouts.ReadIntervalTimeout = 1;
|
||||
timeouts.ReadTotalTimeoutMultiplier = 2;
|
||||
|
@ -84,8 +85,8 @@ static BOOL test_generic(HANDLE hComm)
|
|||
int TestTimeouts(int argc, char* argv[])
|
||||
{
|
||||
struct stat statbuf;
|
||||
BOOL result;
|
||||
HANDLE hComm;
|
||||
BOOL result = 0;
|
||||
HANDLE hComm = NULL;
|
||||
|
||||
if (stat("/dev/ttyS0", &statbuf) < 0)
|
||||
{
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#define WINPR_ALIGNED_MEM_SIGNATURE 0x0BA0BAB
|
||||
|
||||
#define WINPR_ALIGNED_MEM_STRUCT_FROM_PTR(_memptr) \
|
||||
(WINPR_ALIGNED_MEM*)(((size_t)(((BYTE*)_memptr) - sizeof(WINPR_ALIGNED_MEM))))
|
||||
(WINPR_ALIGNED_MEM*)(((size_t)(((BYTE*)(_memptr)) - sizeof(WINPR_ALIGNED_MEM))))
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ int TestFormatSpecifiers(int argc, char* argv[])
|
|||
(void)sprintf_s(fmt, sizeof(fmt), "uz:%" PRIuz " oz:%" PRIoz " xz:%" PRIxz " Xz:%" PRIXz "",
|
||||
arg, arg, arg, arg);
|
||||
|
||||
if (strcmp(fmt, chk))
|
||||
if (strcmp(fmt, chk) != 0)
|
||||
{
|
||||
(void)fprintf(stderr, "%s failed size_t test: got [%s] instead of [%s]\n", __func__,
|
||||
fmt, chk);
|
||||
|
@ -35,7 +35,7 @@ int TestFormatSpecifiers(int argc, char* argv[])
|
|||
(void)sprintf_s(fmt, sizeof(fmt), "d8:%" PRId8 " x8:%" PRIx8 " X8:%" PRIX8 "", arg,
|
||||
(UINT8)arg, (UINT8)arg);
|
||||
|
||||
if (strcmp(fmt, chk))
|
||||
if (strcmp(fmt, chk) != 0)
|
||||
{
|
||||
(void)fprintf(stderr, "%s failed INT8 test: got [%s] instead of [%s]\n", __func__, fmt,
|
||||
chk);
|
||||
|
@ -52,7 +52,7 @@ int TestFormatSpecifiers(int argc, char* argv[])
|
|||
"u8:%" PRIu8 " o8:%" PRIo8 " x8:%" PRIx8 " X8:%" PRIX8 "", arg, arg,
|
||||
arg, arg);
|
||||
|
||||
if (strcmp(fmt, chk))
|
||||
if (strcmp(fmt, chk) != 0)
|
||||
{
|
||||
(void)fprintf(stderr, "%s failed UINT8 test: got [%s] instead of [%s]\n", __func__, fmt,
|
||||
chk);
|
||||
|
@ -68,7 +68,7 @@ int TestFormatSpecifiers(int argc, char* argv[])
|
|||
(void)sprintf_s(fmt, sizeof(fmt), "d16:%" PRId16 " x16:%" PRIx16 " X16:%" PRIX16 "", arg,
|
||||
(UINT16)arg, (UINT16)arg);
|
||||
|
||||
if (strcmp(fmt, chk))
|
||||
if (strcmp(fmt, chk) != 0)
|
||||
{
|
||||
(void)fprintf(stderr, "%s failed INT16 test: got [%s] instead of [%s]\n", __func__, fmt,
|
||||
chk);
|
||||
|
@ -85,7 +85,7 @@ int TestFormatSpecifiers(int argc, char* argv[])
|
|||
"u16:%" PRIu16 " o16:%" PRIo16 " x16:%" PRIx16 " X16:%" PRIX16 "", arg, arg,
|
||||
arg, arg);
|
||||
|
||||
if (strcmp(fmt, chk))
|
||||
if (strcmp(fmt, chk) != 0)
|
||||
{
|
||||
(void)fprintf(stderr, "%s failed UINT16 test: got [%s] instead of [%s]\n", __func__,
|
||||
fmt, chk);
|
||||
|
@ -101,7 +101,7 @@ int TestFormatSpecifiers(int argc, char* argv[])
|
|||
(void)sprintf_s(fmt, sizeof(fmt), "d32:%" PRId32 " x32:%" PRIx32 " X32:%" PRIX32 "", arg,
|
||||
(UINT32)arg, (UINT32)arg);
|
||||
|
||||
if (strcmp(fmt, chk))
|
||||
if (strcmp(fmt, chk) != 0)
|
||||
{
|
||||
(void)fprintf(stderr, "%s failed INT32 test: got [%s] instead of [%s]\n", __func__, fmt,
|
||||
chk);
|
||||
|
@ -118,7 +118,7 @@ int TestFormatSpecifiers(int argc, char* argv[])
|
|||
"u32:%" PRIu32 " o32:%" PRIo32 " x32:%" PRIx32 " X32:%" PRIX32 "", arg, arg,
|
||||
arg, arg);
|
||||
|
||||
if (strcmp(fmt, chk))
|
||||
if (strcmp(fmt, chk) != 0)
|
||||
{
|
||||
(void)fprintf(stderr, "%s failed UINT16 test: got [%s] instead of [%s]\n", __func__,
|
||||
fmt, chk);
|
||||
|
@ -134,7 +134,7 @@ int TestFormatSpecifiers(int argc, char* argv[])
|
|||
(void)sprintf_s(fmt, sizeof(fmt), "d64:%" PRId64 " x64:%" PRIx64 " X64:%" PRIX64 "", arg,
|
||||
(UINT64)arg, (UINT64)arg);
|
||||
|
||||
if (strcmp(fmt, chk))
|
||||
if (strcmp(fmt, chk) != 0)
|
||||
{
|
||||
(void)fprintf(stderr, "%s failed INT64 test: got [%s] instead of [%s]\n", __func__, fmt,
|
||||
chk);
|
||||
|
@ -152,7 +152,7 @@ int TestFormatSpecifiers(int argc, char* argv[])
|
|||
"u64:%" PRIu64 " o64:%" PRIo64 " x64:%016" PRIx64 " X64:%016" PRIX64 "",
|
||||
arg, arg, arg, arg);
|
||||
|
||||
if (strcmp(fmt, chk))
|
||||
if (strcmp(fmt, chk) != 0)
|
||||
{
|
||||
(void)fprintf(stderr, "%s failed UINT64 test: got [%s] instead of [%s]\n", __func__,
|
||||
fmt, chk);
|
||||
|
|
|
@ -93,7 +93,7 @@ static BOOL test_crypto_cipher_aes_128_cbc(void)
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (strcmp((const char*)obuf, plaintext))
|
||||
if (strcmp((const char*)obuf, plaintext) != 0)
|
||||
{
|
||||
(void)fprintf(stderr, "%s: error, decrypted data does not match plaintext\n", __func__);
|
||||
goto out;
|
||||
|
@ -186,7 +186,8 @@ static BOOL test_crypto_cipher_key(void)
|
|||
status = winpr_Cipher_BytesToKey(WINPR_CIPHER_AES_256_CBC, WINPR_MD_SHA1, salt, TEST_RAND_DATA,
|
||||
64, 4, key, iv);
|
||||
|
||||
if (status != 32 || memcmp(key, TEST_CIPHER_KEY, 32) || memcmp(iv, TEST_CIPHER_IV, 16))
|
||||
if (status != 32 || memcmp(key, TEST_CIPHER_KEY, 32) != 0 ||
|
||||
memcmp(iv, TEST_CIPHER_IV, 16) != 0)
|
||||
{
|
||||
char* akstr = NULL;
|
||||
char* ekstr = NULL;
|
||||
|
|
|
@ -116,8 +116,8 @@ static BOOL FileSetEndOfFile(HANDLE hFile)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static DWORD FileSetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh,
|
||||
DWORD dwMoveMethod)
|
||||
static DWORD FileSetFilePointer(HANDLE hFile, LONG lDistanceToMove,
|
||||
const PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
|
||||
{
|
||||
WINPR_FILE* pFile = (WINPR_FILE*)hFile;
|
||||
INT64 offset = 0;
|
||||
|
@ -974,11 +974,11 @@ static BOOL IsFileDevice(LPCTSTR lpDeviceName)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static HANDLE_CREATOR _FileHandleCreator = { IsFileDevice, FileCreateFileA };
|
||||
static HANDLE_CREATOR FileHandleCreator = { IsFileDevice, FileCreateFileA };
|
||||
|
||||
HANDLE_CREATOR* GetFileHandleCreator(void)
|
||||
{
|
||||
return &_FileHandleCreator;
|
||||
return &FileHandleCreator;
|
||||
}
|
||||
|
||||
static WINPR_FILE* FileHandle_New(FILE* fp)
|
||||
|
|
|
@ -174,9 +174,9 @@
|
|||
* Asynchronous I/O User Guide:
|
||||
* http://code.google.com/p/kernel/wiki/AIOUserGuide
|
||||
*/
|
||||
static wArrayList* _HandleCreators;
|
||||
static wArrayList* HandleCreators;
|
||||
|
||||
static pthread_once_t _HandleCreatorsInitialized = PTHREAD_ONCE_INIT;
|
||||
static pthread_once_t HandleCreatorsInitialized = PTHREAD_ONCE_INIT;
|
||||
|
||||
extern HANDLE_CREATOR* GetNamedPipeClientHandleCreator(void);
|
||||
|
||||
|
@ -184,22 +184,22 @@ extern HANDLE_CREATOR* GetNamedPipeClientHandleCreator(void);
|
|||
#include "../comm/comm.h"
|
||||
#endif /* __linux__ && !defined ANDROID */
|
||||
|
||||
static void _HandleCreatorsInit(void)
|
||||
static void HandleCreatorsInit(void)
|
||||
{
|
||||
WINPR_ASSERT(_HandleCreators == NULL);
|
||||
_HandleCreators = ArrayList_New(TRUE);
|
||||
WINPR_ASSERT(HandleCreators == NULL);
|
||||
HandleCreators = ArrayList_New(TRUE);
|
||||
|
||||
if (!_HandleCreators)
|
||||
if (!HandleCreators)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Register all file handle creators.
|
||||
*/
|
||||
ArrayList_Append(_HandleCreators, GetNamedPipeClientHandleCreator());
|
||||
ArrayList_Append(HandleCreators, GetNamedPipeClientHandleCreator());
|
||||
#if defined __linux__ && !defined ANDROID
|
||||
ArrayList_Append(_HandleCreators, GetCommHandleCreator());
|
||||
ArrayList_Append(HandleCreators, GetCommHandleCreator());
|
||||
#endif /* __linux__ && !defined ANDROID */
|
||||
ArrayList_Append(_HandleCreators, GetFileHandleCreator());
|
||||
ArrayList_Append(HandleCreators, GetFileHandleCreator());
|
||||
}
|
||||
|
||||
#ifdef WINPR_HAVE_AIO_H
|
||||
|
@ -236,35 +236,35 @@ HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
|
|||
if (!lpFileName)
|
||||
return INVALID_HANDLE_VALUE;
|
||||
|
||||
if (pthread_once(&_HandleCreatorsInitialized, _HandleCreatorsInit) != 0)
|
||||
if (pthread_once(&HandleCreatorsInitialized, HandleCreatorsInit) != 0)
|
||||
{
|
||||
SetLastError(ERROR_DLL_INIT_FAILED);
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
if (_HandleCreators == NULL)
|
||||
if (HandleCreators == NULL)
|
||||
{
|
||||
SetLastError(ERROR_DLL_INIT_FAILED);
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
ArrayList_Lock(_HandleCreators);
|
||||
ArrayList_Lock(HandleCreators);
|
||||
|
||||
for (size_t i = 0; i <= ArrayList_Count(_HandleCreators); i++)
|
||||
for (size_t i = 0; i <= ArrayList_Count(HandleCreators); i++)
|
||||
{
|
||||
HANDLE_CREATOR* creator = ArrayList_GetItem(_HandleCreators, i);
|
||||
HANDLE_CREATOR* creator = ArrayList_GetItem(HandleCreators, i);
|
||||
|
||||
if (creator && creator->IsHandled(lpFileName))
|
||||
{
|
||||
HANDLE newHandle =
|
||||
creator->CreateFileA(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes,
|
||||
dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
|
||||
ArrayList_Unlock(_HandleCreators);
|
||||
ArrayList_Unlock(HandleCreators);
|
||||
return newHandle;
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList_Unlock(_HandleCreators);
|
||||
ArrayList_Unlock(HandleCreators);
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
|
||||
#include "../pipe/pipe.h"
|
||||
|
||||
static HANDLE_CREATOR _NamedPipeClientHandleCreator;
|
||||
static HANDLE_CREATOR NamedPipeClientHandleCreator;
|
||||
|
||||
static BOOL NamedPipeClientIsHandled(HANDLE handle)
|
||||
{
|
||||
|
@ -228,9 +228,9 @@ static HANDLE NamedPipeClientCreateFileA(LPCSTR lpFileName, DWORD dwDesiredAcces
|
|||
extern HANDLE_CREATOR* GetNamedPipeClientHandleCreator(void);
|
||||
HANDLE_CREATOR* GetNamedPipeClientHandleCreator(void)
|
||||
{
|
||||
_NamedPipeClientHandleCreator.IsHandled = IsNamedPipeFileNameA;
|
||||
_NamedPipeClientHandleCreator.CreateFileA = NamedPipeClientCreateFileA;
|
||||
return &_NamedPipeClientHandleCreator;
|
||||
NamedPipeClientHandleCreator.IsHandled = IsNamedPipeFileNameA;
|
||||
NamedPipeClientHandleCreator.CreateFileA = NamedPipeClientCreateFileA;
|
||||
return &NamedPipeClientHandleCreator;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -77,7 +77,7 @@ int TestFileCreateFile(int argc, char* argv[])
|
|||
if (written != sizeof(cmp))
|
||||
rc = -1;
|
||||
|
||||
if (memcmp(buffer, cmp, sizeof(buffer)))
|
||||
if (memcmp(buffer, cmp, sizeof(buffer)) != 0)
|
||||
rc = -1;
|
||||
|
||||
if (!CloseHandle(handle))
|
||||
|
|
|
@ -291,8 +291,8 @@ out_free_lib:
|
|||
|
||||
const char* winpr_NCryptSecurityStatusError(SECURITY_STATUS status)
|
||||
{
|
||||
#define NTE_CASE(S) \
|
||||
case (SECURITY_STATUS)S: \
|
||||
#define NTE_CASE(S) \
|
||||
case (SECURITY_STATUS)(S): \
|
||||
return #S
|
||||
|
||||
switch (status)
|
||||
|
|
|
@ -104,7 +104,7 @@ int TestPathCchFindExtension(int argc, char* argv[])
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (!pszExt || strcmp(pszExt, ".exe"))
|
||||
if (!pszExt || strcmp(pszExt, ".exe") != 0)
|
||||
{
|
||||
printf("PathCchFindExtensionA failure: unexpected extension\n");
|
||||
return -1;
|
||||
|
|
|
@ -107,7 +107,7 @@ int TestPathCchStripPrefix(int argc, char* argv[])
|
|||
status);
|
||||
return -1;
|
||||
}
|
||||
if (_tcscmp(Path, testPathNoPrefixFileNamespaceMinimum))
|
||||
if (_tcscmp(Path, testPathNoPrefixFileNamespaceMinimum) != 0)
|
||||
{
|
||||
_tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path,
|
||||
testPathNoPrefixFileNamespaceMinimum);
|
||||
|
|
|
@ -218,7 +218,7 @@ static DWORD WINAPI named_pipe_single_thread(LPVOID arg)
|
|||
{
|
||||
WINPR_NAMED_PIPE* p = (WINPR_NAMED_PIPE*)servers[i];
|
||||
|
||||
if (strcmp(lpszPipeNameSt, p->name))
|
||||
if (strcmp(lpszPipeNameSt, p->name) != 0)
|
||||
{
|
||||
printf("%s: Pipe name mismatch for pipe #%d ([%s] instead of [%s])\n", __func__, i,
|
||||
p->name, lpszPipeNameSt);
|
||||
|
@ -317,7 +317,7 @@ static DWORD WINAPI named_pipe_single_thread(LPVOID arg)
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (memcmp(sndbuf, rcvbuf, sizeof(sndbuf)))
|
||||
if (memcmp(sndbuf, rcvbuf, sizeof(sndbuf)) != 0)
|
||||
{
|
||||
printf("%s: Error data read on server end of pipe #%d is corrupted\n", __func__, i);
|
||||
goto out;
|
||||
|
@ -344,7 +344,7 @@ static DWORD WINAPI named_pipe_single_thread(LPVOID arg)
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (memcmp(sndbuf, rcvbuf, sizeof(sndbuf)))
|
||||
if (memcmp(sndbuf, rcvbuf, sizeof(sndbuf)) != 0)
|
||||
{
|
||||
printf("%s: Error data read on client end of pipe #%d is corrupted\n", __func__, i);
|
||||
goto out;
|
||||
|
|
|
@ -134,7 +134,7 @@ static DWORD WINAPI named_pipe_client_thread(LPVOID arg)
|
|||
winpr_HexDump("pipe.test", WLOG_DEBUG, lpReadBuffer, NumberOfBytesTransferred);
|
||||
|
||||
if (NumberOfBytesTransferred != PIPE_BUFFER_SIZE ||
|
||||
memcmp(lpReadBuffer, SERVER_MESSAGE, PIPE_BUFFER_SIZE))
|
||||
memcmp(lpReadBuffer, SERVER_MESSAGE, PIPE_BUFFER_SIZE) != 0)
|
||||
{
|
||||
printf("client: received unexpected data from server\n");
|
||||
goto finish;
|
||||
|
@ -281,7 +281,7 @@ static DWORD WINAPI named_pipe_server_thread(LPVOID arg)
|
|||
winpr_HexDump("pipe.test", WLOG_DEBUG, lpReadBuffer, NumberOfBytesTransferred);
|
||||
|
||||
if (NumberOfBytesTransferred != PIPE_BUFFER_SIZE ||
|
||||
memcmp(lpReadBuffer, CLIENT_MESSAGE, PIPE_BUFFER_SIZE))
|
||||
memcmp(lpReadBuffer, CLIENT_MESSAGE, PIPE_BUFFER_SIZE) != 0)
|
||||
{
|
||||
printf("server: received unexpected data from client\n");
|
||||
goto finish;
|
||||
|
|
|
@ -1814,7 +1814,7 @@ static SECURITY_STATUS SEC_ENTRY kerberos_VerifySignature(PCtxtHandle phContext,
|
|||
if ((flags & FLAG_SENDER_IS_ACCEPTOR) == context->acceptor || flags & FLAG_WRAP_CONFIDENTIAL)
|
||||
return SEC_E_INVALID_TOKEN;
|
||||
|
||||
if (memcmp(header + 3, cmp_filler, sizeof(cmp_filler)))
|
||||
if (memcmp(header + 3, cmp_filler, sizeof(cmp_filler)) != 0)
|
||||
return SEC_E_INVALID_TOKEN;
|
||||
|
||||
if (context->flags & ISC_REQ_SEQUENCE_DETECT && seq_no != context->remote_seq + MessageSeqNo)
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
WINPR_PRAGMA_DIAG_PUSH
|
||||
WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO
|
||||
|
||||
#define _NO_KSECDD_IMPORT_ 1
|
||||
#define _NO_KSECDD_IMPORT_ 1 // NOLINT(bugprone-reserved-identifier)
|
||||
|
||||
WINPR_PRAGMA_DIAG_POP
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ DWORD SetCriticalSectionSpinCount(LPCRITICAL_SECTION lpCriticalSection, DWORD dw
|
|||
#endif
|
||||
}
|
||||
|
||||
static VOID _WaitForCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
|
||||
static VOID WaitForCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
|
||||
{
|
||||
WINPR_ASSERT(lpCriticalSection);
|
||||
#if defined(__APPLE__)
|
||||
|
@ -135,7 +135,7 @@ static VOID _WaitForCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
|
|||
#endif
|
||||
}
|
||||
|
||||
static VOID _UnWaitCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
|
||||
static VOID UnWaitCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
|
||||
{
|
||||
WINPR_ASSERT(lpCriticalSection);
|
||||
#if defined __APPLE__
|
||||
|
@ -192,7 +192,7 @@ VOID EnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
|
|||
}
|
||||
|
||||
/* Section is locked by another thread. We have to wait. */
|
||||
_WaitForCriticalSection(lpCriticalSection);
|
||||
WaitForCriticalSection(lpCriticalSection);
|
||||
}
|
||||
|
||||
/* We got the lock. Own it ... */
|
||||
|
@ -239,7 +239,7 @@ VOID LeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
|
|||
if (InterlockedDecrement(&lpCriticalSection->LockCount) >= 0)
|
||||
{
|
||||
/* ...signal the semaphore to unblock the next waiting thread */
|
||||
_UnWaitCriticalSection(lpCriticalSection);
|
||||
UnWaitCriticalSection(lpCriticalSection);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -40,7 +40,7 @@ WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO
|
|||
|
||||
#ifdef WINPR_HAVE_UNISTD_H
|
||||
#ifndef _XOPEN_SOURCE
|
||||
#define _XOPEN_SOURCE 500
|
||||
#define _XOPEN_SOURCE 500 // NOLINT(bugprone-reserved-identifier)
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
|
|
@ -128,7 +128,7 @@ static BOOL Test_GetComputerName(void)
|
|||
}
|
||||
|
||||
/* compare the results */
|
||||
if (strcmp(netbiosName1, netbiosName2))
|
||||
if (strcmp(netbiosName1, netbiosName2) != 0)
|
||||
{
|
||||
(void)fprintf(stderr, "%s: (12) string compare mismatch\n", __func__);
|
||||
return FALSE;
|
||||
|
@ -306,7 +306,7 @@ static BOOL Test_GetComputerNameEx_Format(COMPUTER_NAME_FORMAT format)
|
|||
}
|
||||
|
||||
/* compare the results */
|
||||
if (strcmp(computerName1, computerName2))
|
||||
if (strcmp(computerName1, computerName2) != 0)
|
||||
{
|
||||
(void)fprintf(stderr, "%s: (12/%d) string compare mismatch\n", __func__, format);
|
||||
return FALSE;
|
||||
|
|
|
@ -150,12 +150,12 @@ static char* FindApplicationPath(char* application)
|
|||
static HANDLE CreateProcessHandle(pid_t pid);
|
||||
static BOOL ProcessHandleCloseHandle(HANDLE handle);
|
||||
|
||||
static BOOL _CreateProcessExA(HANDLE hToken, DWORD dwLogonFlags, LPCSTR lpApplicationName,
|
||||
LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes,
|
||||
LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles,
|
||||
DWORD dwCreationFlags, LPVOID lpEnvironment,
|
||||
LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo,
|
||||
LPPROCESS_INFORMATION lpProcessInformation)
|
||||
static BOOL CreateProcessExA(HANDLE hToken, DWORD dwLogonFlags, LPCSTR lpApplicationName,
|
||||
LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes,
|
||||
LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles,
|
||||
DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory,
|
||||
LPSTARTUPINFOA lpStartupInfo,
|
||||
LPPROCESS_INFORMATION lpProcessInformation)
|
||||
{
|
||||
pid_t pid = 0;
|
||||
int numArgs = 0;
|
||||
|
@ -367,9 +367,9 @@ BOOL CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine,
|
|||
DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory,
|
||||
LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
|
||||
{
|
||||
return _CreateProcessExA(NULL, 0, lpApplicationName, lpCommandLine, lpProcessAttributes,
|
||||
lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment,
|
||||
lpCurrentDirectory, lpStartupInfo, lpProcessInformation);
|
||||
return CreateProcessExA(NULL, 0, lpApplicationName, lpCommandLine, lpProcessAttributes,
|
||||
lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment,
|
||||
lpCurrentDirectory, lpStartupInfo, lpProcessInformation);
|
||||
}
|
||||
|
||||
BOOL CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine,
|
||||
|
@ -387,9 +387,9 @@ BOOL CreateProcessAsUserA(HANDLE hToken, LPCSTR lpApplicationName, LPSTR lpComma
|
|||
DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory,
|
||||
LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
|
||||
{
|
||||
return _CreateProcessExA(hToken, 0, lpApplicationName, lpCommandLine, lpProcessAttributes,
|
||||
lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment,
|
||||
lpCurrentDirectory, lpStartupInfo, lpProcessInformation);
|
||||
return CreateProcessExA(hToken, 0, lpApplicationName, lpCommandLine, lpProcessAttributes,
|
||||
lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment,
|
||||
lpCurrentDirectory, lpStartupInfo, lpProcessInformation);
|
||||
}
|
||||
|
||||
BOOL CreateProcessAsUserW(HANDLE hToken, LPCWSTR lpApplicationName, LPWSTR lpCommandLine,
|
||||
|
@ -424,9 +424,9 @@ BOOL CreateProcessWithTokenA(HANDLE hToken, DWORD dwLogonFlags, LPCSTR lpApplica
|
|||
LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo,
|
||||
LPPROCESS_INFORMATION lpProcessInformation)
|
||||
{
|
||||
return _CreateProcessExA(NULL, 0, lpApplicationName, lpCommandLine, NULL, NULL, FALSE,
|
||||
dwCreationFlags, lpEnvironment, lpCurrentDirectory, lpStartupInfo,
|
||||
lpProcessInformation);
|
||||
return CreateProcessExA(NULL, 0, lpApplicationName, lpCommandLine, NULL, NULL, FALSE,
|
||||
dwCreationFlags, lpEnvironment, lpCurrentDirectory, lpStartupInfo,
|
||||
lpProcessInformation);
|
||||
}
|
||||
|
||||
BOOL CreateProcessWithTokenW(HANDLE hToken, DWORD dwLogonFlags, LPCWSTR lpApplicationName,
|
||||
|
@ -544,7 +544,7 @@ static HANDLE_OPS ops = { ProcessHandleIsHandle,
|
|||
NULL,
|
||||
NULL };
|
||||
|
||||
static int _pidfd_open(pid_t pid)
|
||||
static int pidfd_open(pid_t pid)
|
||||
{
|
||||
#ifdef __linux__
|
||||
#if !defined(__NR_pidfd_open)
|
||||
|
@ -589,7 +589,7 @@ HANDLE CreateProcessHandle(pid_t pid)
|
|||
process->pid = pid;
|
||||
process->common.Type = HANDLE_TYPE_PROCESS;
|
||||
process->common.ops = &ops;
|
||||
process->fd = _pidfd_open(pid);
|
||||
process->fd = pidfd_open(pid);
|
||||
if (process->fd >= 0)
|
||||
process->common.Mode = WINPR_FD_READ;
|
||||
return (HANDLE)process;
|
||||
|
|
|
@ -72,7 +72,7 @@ struct WinPrAsn1Encoder
|
|||
size_t containerCapacity;
|
||||
};
|
||||
|
||||
#define WINPR_ASSERT_VALID_TAG(t) WINPR_ASSERT(t < 64)
|
||||
#define WINPR_ASSERT_VALID_TAG(t) WINPR_ASSERT((t) < 64)
|
||||
|
||||
void WinPrAsn1FreeOID(WinPrAsn1_OID* poid)
|
||||
{
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#include <winpr/config.h>
|
||||
|
||||
#define __STDC_WANT_LIB_EXT1__ 1
|
||||
#define __STDC_WANT_LIB_EXT1__ 1 // NOLINT(bugprone-reserved-identifier)
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -225,11 +225,11 @@ fail:
|
|||
char* winpr_strerror(DWORD dw, char* dmsg, size_t size)
|
||||
{
|
||||
#ifdef __STDC_LIB_EXT1__
|
||||
strerror_s(dw, dmsg, size);
|
||||
strerror_s((int)dw, dmsg, size);
|
||||
#elif defined(WINPR_HAVE_STRERROR_R)
|
||||
strerror_r(dw, dmsg, size);
|
||||
strerror_r((int)dw, dmsg, size);
|
||||
#else
|
||||
(void)_snprintf(dmsg, size, "%s", strerror(dw));
|
||||
(void)_snprintf(dmsg, size, "%s", strerror((int)dw));
|
||||
#endif
|
||||
return dmsg;
|
||||
}
|
||||
|
|
|
@ -688,7 +688,9 @@ SSIZE_T winpr_convert_from_jpeg(const BYTE* comp_data, size_t comp_data_bytes, U
|
|||
if (jpeg_read_scanlines(&cinfo, &row, 1) != 1)
|
||||
goto fail;
|
||||
}
|
||||
size = stride * cinfo.image_height;
|
||||
const size_t ssize = stride * cinfo.image_height;
|
||||
WINPR_ASSERT(ssize < SSIZE_MAX);
|
||||
size = (SSIZE_T)ssize;
|
||||
}
|
||||
jpeg_finish_decompress(&cinfo);
|
||||
|
||||
|
@ -712,13 +714,16 @@ static void* winpr_convert_to_webp(const void* data, size_t size, UINT32 width,
|
|||
#else
|
||||
size_t dstSize = 0;
|
||||
uint8_t* pDstData = NULL;
|
||||
WINPR_ASSERT(width <= INT32_MAX);
|
||||
WINPR_ASSERT(height <= INT32_MAX);
|
||||
WINPR_ASSERT(stride <= INT32_MAX);
|
||||
switch (bpp)
|
||||
{
|
||||
case 32:
|
||||
dstSize = WebPEncodeLosslessBGRA(data, width, height, stride, &pDstData);
|
||||
dstSize = WebPEncodeLosslessBGRA(data, (int)width, (int)height, (int)stride, &pDstData);
|
||||
break;
|
||||
case 24:
|
||||
dstSize = WebPEncodeLosslessBGR(data, width, height, stride, &pDstData);
|
||||
dstSize = WebPEncodeLosslessBGR(data, (int)width, (int)height, (int)stride, &pDstData);
|
||||
break;
|
||||
default:
|
||||
return NULL;
|
||||
|
@ -805,7 +810,7 @@ static void png_flush(png_structp png_ptr)
|
|||
static SSIZE_T save_png_to_buffer(UINT32 bpp, UINT32 width, UINT32 height, const uint8_t* data,
|
||||
size_t size, void** pDstData)
|
||||
{
|
||||
int rc = -1;
|
||||
SSIZE_T rc = -1;
|
||||
png_structp png_ptr = NULL;
|
||||
png_infop info_ptr = NULL;
|
||||
png_byte** row_pointers = NULL;
|
||||
|
|
|
@ -74,10 +74,20 @@ static BOOL SamAreEntriesEqual(const WINPR_SAM_ENTRY* a, const WINPR_SAM_ENTRY*
|
|||
return FALSE;
|
||||
if (a->DomainLength != b->DomainLength)
|
||||
return FALSE;
|
||||
if (strncmp(a->User, b->User, a->UserLength) != 0)
|
||||
return FALSE;
|
||||
if (strncmp(a->Domain, b->Domain, a->DomainLength) != 0)
|
||||
return FALSE;
|
||||
if (a->UserLength > 0)
|
||||
{
|
||||
if (!a->User || !b->User)
|
||||
return FALSE;
|
||||
if (strncmp(a->User, b->User, a->UserLength) != 0)
|
||||
return FALSE;
|
||||
}
|
||||
if (a->DomainLength > 0)
|
||||
{
|
||||
if (!a->Domain || !b->Domain)
|
||||
return FALSE;
|
||||
if (strncmp(a->Domain, b->Domain, a->DomainLength) != 0)
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ int TestASN1Read(int argc, char* argv[])
|
|||
Stream_StaticConstInit(&staticS, oidContent, sizeof(oidContent));
|
||||
WinPrAsn1Decoder_Init(&decoder, WINPR_ASN1_DER, &staticS);
|
||||
if (!WinPrAsn1DecReadOID(&decoder, &oidV, TRUE) || oidV.len != 3 ||
|
||||
memcmp(oidV.data, oidValue, oidV.len))
|
||||
(memcmp(oidV.data, oidValue, oidV.len) != 0))
|
||||
return -15;
|
||||
WinPrAsn1FreeOID(&oidV);
|
||||
|
||||
|
@ -79,7 +79,7 @@ int TestASN1Read(int argc, char* argv[])
|
|||
Stream_StaticConstInit(&staticS, ia5stringContent, sizeof(ia5stringContent));
|
||||
WinPrAsn1Decoder_Init(&decoder, WINPR_ASN1_DER, &staticS);
|
||||
if (!WinPrAsn1DecReadIA5String(&decoder, &ia5stringV) ||
|
||||
strcmp(ia5stringV, "http://cps.root-x1.letsencrypt.org"))
|
||||
(strcmp(ia5stringV, "http://cps.root-x1.letsencrypt.org") != 0))
|
||||
return -16;
|
||||
free(ia5stringV);
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
int TestArrayList(int argc, char* argv[])
|
||||
{
|
||||
int count = 0;
|
||||
SSIZE_T count = 0;
|
||||
SSIZE_T rc = 0;
|
||||
size_t val = 0;
|
||||
wArrayList* arrayList = NULL;
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
int TestBufferPool(int argc, char* argv[])
|
||||
{
|
||||
DWORD PoolSize = 0;
|
||||
int BufferSize = 0;
|
||||
SSIZE_T BufferSize = 0;
|
||||
wBufferPool* pool = NULL;
|
||||
BYTE* Buffers[10];
|
||||
BYTE* Buffers[10] = { 0 };
|
||||
int DefaultSize = 1234;
|
||||
|
||||
WINPR_UNUSED(argc);
|
||||
|
|
|
@ -288,8 +288,8 @@ fail:
|
|||
typedef struct
|
||||
{
|
||||
wHashTable* table;
|
||||
int strlenCounter;
|
||||
int foreachCalls;
|
||||
size_t strlenCounter;
|
||||
size_t foreachCalls;
|
||||
|
||||
BOOL test3error;
|
||||
} ForeachData;
|
||||
|
|
|
@ -135,7 +135,7 @@ int TestListDictionary(int argc, char* argv[])
|
|||
|
||||
value = ListDictionary_Take_Head(list);
|
||||
count = ListDictionary_Count(list);
|
||||
if (strncmp(value, val1, 4) || count != 1)
|
||||
if ((strncmp(value, val1, 4) != 0) || (count != 1))
|
||||
{
|
||||
printf("ListDictionary_Remove_Head: Expected : %s, Actual: %s Count: %" PRIuz "\n", val1,
|
||||
value, count);
|
||||
|
@ -144,7 +144,7 @@ int TestListDictionary(int argc, char* argv[])
|
|||
|
||||
value = ListDictionary_Take_Head(list);
|
||||
count = ListDictionary_Count(list);
|
||||
if (strncmp(value, val3, 4) || count != 0)
|
||||
if ((strncmp(value, val3, 4) != 0) || (count != 0))
|
||||
{
|
||||
printf("ListDictionary_Remove_Head: Expected : %s, Actual: %s Count: %" PRIuz "\n", val3,
|
||||
value, count);
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* http://www.codingunit.com/printf-format-specifiers-format-conversions-and-formatted-output
|
||||
*/
|
||||
|
||||
#define _printf printf
|
||||
#define _printf printf // NOLINT(bugprone-reserved-identifier)
|
||||
|
||||
static BOOL test_bin_tohex_string(void)
|
||||
{
|
||||
|
|
|
@ -178,9 +178,9 @@ static BOOL TestStream_Create(size_t count, BOOL selfAlloc)
|
|||
|
||||
if (selfAlloc)
|
||||
{
|
||||
memset(buffer, i % 256, cap);
|
||||
memset(buffer, (BYTE)(i % 256), cap);
|
||||
|
||||
if (memcmp(buffer, Stream_Buffer(s), cap))
|
||||
if (memcmp(buffer, Stream_Buffer(s), cap) != 0)
|
||||
{
|
||||
printf("%s: buffer memory corruption\n", __func__);
|
||||
goto fail;
|
||||
|
@ -265,14 +265,14 @@ fail:
|
|||
if (_a != _b) \
|
||||
{ \
|
||||
printf("%s: test1 " #_t "_LE failed\n", __func__); \
|
||||
_r = FALSE; \
|
||||
(_r) = FALSE; \
|
||||
} \
|
||||
for (size_t _i = 0; _i < sizeof(_t); _i++) \
|
||||
{ \
|
||||
if (((_a >> (_i * 8)) & 0xFF) != _p[_i]) \
|
||||
{ \
|
||||
printf("%s: test2 " #_t "_LE failed\n", __func__); \
|
||||
_r = FALSE; \
|
||||
(_r) = FALSE; \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
|
@ -283,14 +283,14 @@ fail:
|
|||
if (_a != _b) \
|
||||
{ \
|
||||
printf("%s: test1 " #_t "_BE failed\n", __func__); \
|
||||
_r = FALSE; \
|
||||
(_r) = FALSE; \
|
||||
} \
|
||||
for (size_t _i = 0; _i < sizeof(_t); _i++) \
|
||||
{ \
|
||||
if (((_a >> (_i * 8)) & 0xFF) != _p[sizeof(_t) - _i - 1]) \
|
||||
{ \
|
||||
printf("%s: test2 " #_t "_BE failed\n", __func__); \
|
||||
_r = FALSE; \
|
||||
(_r) = FALSE; \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
|
|
|
@ -35,7 +35,7 @@ int TestVersion(int argc, char* argv[])
|
|||
if (!git)
|
||||
return -1;
|
||||
|
||||
if (strncmp(git, WINPR_GIT_REVISION, sizeof(WINPR_GIT_REVISION)))
|
||||
if (strncmp(git, WINPR_GIT_REVISION, sizeof(WINPR_GIT_REVISION)) != 0)
|
||||
return -1;
|
||||
|
||||
build = winpr_get_build_config();
|
||||
|
|
|
@ -30,15 +30,15 @@ static BOOL check(const wLogMessage* msg)
|
|||
BOOL rc = TRUE;
|
||||
if (!msg)
|
||||
rc = FALSE;
|
||||
else if (strcmp(msg->FileName, __FILE__))
|
||||
else if (strcmp(msg->FileName, __FILE__) != 0)
|
||||
rc = FALSE;
|
||||
else if (strcmp(msg->FunctionName, function))
|
||||
else if (strcmp(msg->FunctionName, function) != 0)
|
||||
rc = FALSE;
|
||||
else if (strcmp(msg->PrefixString, messages[pos].channel))
|
||||
else if (strcmp(msg->PrefixString, messages[pos].channel) != 0)
|
||||
rc = FALSE;
|
||||
else if (msg->Level != messages[pos].level)
|
||||
rc = FALSE;
|
||||
else if (strcmp(msg->FormatString, messages[pos].msg))
|
||||
else if (strcmp(msg->FormatString, messages[pos].msg) != 0)
|
||||
rc = FALSE;
|
||||
pos++;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
*/
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#define _GNU_SOURCE // NOLINT(bugprone-reserved-identifier)
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
|
|
|
@ -119,7 +119,7 @@ static BOOL WLog_CallbackAppender_Set(wLogAppender* appender, const char* settin
|
|||
{
|
||||
wLogCallbackAppender* callbackAppender = (wLogCallbackAppender*)appender;
|
||||
|
||||
if (!value || strcmp(setting, "callbacks"))
|
||||
if (!value || (strcmp(setting, "callbacks") != 0))
|
||||
return FALSE;
|
||||
|
||||
if (!(callbackAppender->callbacks = calloc(1, sizeof(wLogCallbacks))))
|
||||
|
|
|
@ -215,7 +215,7 @@ static BOOL WLog_ConsoleAppender_Set(wLogAppender* appender, const char* setting
|
|||
if (!value || (strnlen(value, 2) == 0))
|
||||
return FALSE;
|
||||
|
||||
if (strcmp("outputstream", setting))
|
||||
if (strcmp("outputstream", setting) != 0)
|
||||
return FALSE;
|
||||
|
||||
if (!strcmp("stdout", value))
|
||||
|
|
|
@ -235,7 +235,6 @@ void Pcap_Flush(wPcap* pcap)
|
|||
}
|
||||
|
||||
(void)fflush(pcap->fp);
|
||||
return;
|
||||
}
|
||||
|
||||
void Pcap_Close(wPcap* pcap)
|
||||
|
|
|
@ -134,7 +134,7 @@ static BOOL WLog_UdpAppender_Set(wLogAppender* appender, const char* setting, vo
|
|||
if (!value || (strnlen(value, 2) == 0))
|
||||
return FALSE;
|
||||
|
||||
if (strncmp(target, setting, sizeof(target)))
|
||||
if (strncmp(target, setting, sizeof(target)) != 0)
|
||||
return FALSE;
|
||||
|
||||
udpAppender->targetAddrLen = 0;
|
||||
|
|
|
@ -44,8 +44,8 @@ typedef struct
|
|||
size_t NameCount;
|
||||
} wLogFilter;
|
||||
|
||||
#define WLOG_FILTER_NOT_FILTERED -1
|
||||
#define WLOG_FILTER_NOT_INITIALIZED -2
|
||||
#define WLOG_FILTER_NOT_FILTERED (-1)
|
||||
#define WLOG_FILTER_NOT_INITIALIZED (-2)
|
||||
/**
|
||||
* References for general logging concepts:
|
||||
*
|
||||
|
@ -58,7 +58,7 @@ typedef struct
|
|||
|
||||
LPCSTR WLOG_LEVELS[7] = { "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL", "OFF" };
|
||||
|
||||
static INIT_ONCE _WLogInitialized = INIT_ONCE_STATIC_INIT;
|
||||
static INIT_ONCE g_WLogInitialized = INIT_ONCE_STATIC_INIT;
|
||||
static DWORD g_FilterCount = 0;
|
||||
static wLogFilter* g_Filters = NULL;
|
||||
static wLog* g_RootLog = NULL;
|
||||
|
@ -923,7 +923,7 @@ void WLog_Free(wLog* log)
|
|||
|
||||
wLog* WLog_GetRoot(void)
|
||||
{
|
||||
if (!InitOnceExecuteOnce(&_WLogInitialized, WLog_InitializeRoot, NULL, NULL))
|
||||
if (!InitOnceExecuteOnce(&g_WLogInitialized, WLog_InitializeRoot, NULL, NULL))
|
||||
return NULL;
|
||||
|
||||
return g_RootLog;
|
||||
|
|
|
@ -798,13 +798,13 @@ int WSAIoctl(SOCKET s, DWORD dwIoControlCode, LPVOID lpvInBuffer, DWORD cbInBuff
|
|||
size_t offset = 0;
|
||||
size_t ifreq_len = 0;
|
||||
struct ifreq* ifreq = NULL;
|
||||
struct ifconf ifconf;
|
||||
char address[128];
|
||||
char broadcast[128];
|
||||
char netmask[128];
|
||||
char buffer[4096];
|
||||
int numInterfaces = 0;
|
||||
int maxNumInterfaces = 0;
|
||||
struct ifconf ifconf = { 0 };
|
||||
char address[128] = { 0 };
|
||||
char broadcast[128] = { 0 };
|
||||
char netmask[128] = { 0 };
|
||||
char buffer[4096] = { 0 };
|
||||
size_t numInterfaces = 0;
|
||||
size_t maxNumInterfaces = 0;
|
||||
INTERFACE_INFO* pInterface = NULL;
|
||||
INTERFACE_INFO* pInterfaces = NULL;
|
||||
struct sockaddr_in* pAddress = NULL;
|
||||
|
|
Loading…
Reference in New Issue