[clang,tidy] fix a few warnings

This commit is contained in:
akallabeth 2024-02-27 10:12:04 +01:00 committed by akallabeth
parent 43a70ccb90
commit 9a7d30d174
9 changed files with 64 additions and 61 deletions

View File

@ -55,7 +55,7 @@ typedef struct
rdpContext* rdpcontext;
wLog* log;
int bytes_per_frame;
size_t bytes_per_frame;
} AudinALSADevice;
static snd_pcm_format_t audin_alsa_format(UINT32 wFormatTag, UINT32 bitPerChannel)

View File

@ -67,15 +67,15 @@ typedef struct
rdpContext* rdpcontext;
} AudinOSSDevice;
#define OSS_LOG_ERR(_text, _error) \
do \
{ \
if (_error != 0) \
{ \
char buffer[256] = { 0 }; \
WLog_ERR(TAG, "%s: %i - %s\n", _text, _error, \
winpr_strerror(_error, buffer, sizeof(buffer))); \
} \
#define OSS_LOG_ERR(_text, _error) \
do \
{ \
if ((_error) != 0) \
{ \
char buffer[256] = { 0 }; \
WLog_ERR(TAG, "%s: %i - %s\n", (_text), (_error), \
winpr_strerror((_error), buffer, sizeof(buffer))); \
} \
} while (0)
static UINT32 audin_oss_get_format(const AUDIO_FORMAT* format)
@ -233,7 +233,8 @@ static DWORD WINAPI audin_oss_thread_func(LPVOID arg)
if (ioctl(pcm_handle, SNDCTL_DSP_SETFRAGMENT, &tmp) == -1)
OSS_LOG_ERR("SNDCTL_DSP_SETFRAGMENT failed", errno);
buffer_size = (oss->FramesPerPacket * oss->format.nChannels * (oss->format.wBitsPerSample / 8));
buffer_size =
(1ull * oss->FramesPerPacket * oss->format.nChannels * (oss->format.wBitsPerSample / 8ull));
buffer = (BYTE*)calloc((buffer_size + sizeof(void*)), sizeof(BYTE));
if (NULL == buffer)

View File

@ -104,19 +104,19 @@ static FREERDP_ADDIN** freerdp_channels_list_client_static_addins(LPCSTR pszName
for (size_t i = 0; CLIENT_STATIC_ADDIN_TABLE[i].name != NULL; i++)
{
FREERDP_ADDIN* pAddin = (FREERDP_ADDIN*)calloc(1, sizeof(FREERDP_ADDIN));
const STATIC_ADDIN_TABLE* table = &CLIENT_STATIC_ADDIN_TABLE[i];
if (!pAddin)
{
WLog_ERR(TAG, "calloc failed!");
goto error_out;
}
sprintf_s(pAddin->cName, ARRAYSIZE(pAddin->cName), "%s", CLIENT_STATIC_ADDIN_TABLE[i].name);
sprintf_s(pAddin->cName, ARRAYSIZE(pAddin->cName), "%s", table->name);
pAddin->dwFlags = FREERDP_ADDIN_CLIENT;
pAddin->dwFlags |= FREERDP_ADDIN_STATIC;
pAddin->dwFlags |= FREERDP_ADDIN_NAME;
ppAddins[nAddins++] = pAddin;
subsystems = (const STATIC_SUBSYSTEM_ENTRY*)CLIENT_STATIC_ADDIN_TABLE[i].table;
subsystems = table->table;
for (size_t j = 0; subsystems[j].name != NULL; j++)
{
@ -128,8 +128,7 @@ static FREERDP_ADDIN** freerdp_channels_list_client_static_addins(LPCSTR pszName
goto error_out;
}
sprintf_s(pAddin->cName, ARRAYSIZE(pAddin->cName), "%s",
CLIENT_STATIC_ADDIN_TABLE[i].name);
sprintf_s(pAddin->cName, ARRAYSIZE(pAddin->cName), "%s", table->name);
sprintf_s(pAddin->cSubsystem, ARRAYSIZE(pAddin->cSubsystem), "%s", subsystems[j].name);
pAddin->dwFlags = FREERDP_ADDIN_CLIENT;
pAddin->dwFlags |= FREERDP_ADDIN_STATIC;

View File

@ -388,7 +388,7 @@ UINT cliprdr_read_file_contents_response(wStream* s, CLIPRDR_FILE_CONTENTS_RESPO
UINT cliprdr_read_format_list(wStream* s, CLIPRDR_FORMAT_LIST* formatList, BOOL useLongFormatNames)
{
UINT32 index = 0;
int formatNameLength = 0;
size_t formatNameLength = 0;
const char* szFormatName = NULL;
const WCHAR* wszFormatName = NULL;
wStream sub1buffer = { 0 };

View File

@ -57,14 +57,14 @@ typedef struct
snd_pcm_uframes_t period_size;
} rdpsndAlsaPlugin;
#define SND_PCM_CHECK(_func, _status) \
do \
{ \
if (_status < 0) \
{ \
WLog_ERR(TAG, "%s: %d\n", _func, _status); \
return -1; \
} \
#define SND_PCM_CHECK(_func, _status) \
do \
{ \
if ((_status) < 0) \
{ \
WLog_ERR(TAG, "%s: %d\n", (_func), (_status)); \
return -1; \
} \
} while (0)
static int rdpsnd_alsa_set_hw_params(rdpsndAlsaPlugin* alsa)

View File

@ -64,15 +64,15 @@ typedef struct
AUDIO_FORMAT format;
} rdpsndOssPlugin;
#define OSS_LOG_ERR(_text, _error) \
do \
{ \
if (_error != 0) \
{ \
char ebuffer[256] = { 0 }; \
WLog_ERR(TAG, "%s: %i - %s", _text, _error, \
winpr_strerror(_error, ebuffer, sizeof(ebuffer))); \
} \
#define OSS_LOG_ERR(_text, _error) \
do \
{ \
if ((_error) != 0) \
{ \
char ebuffer[256] = { 0 }; \
WLog_ERR(TAG, "%s: %i - %s", (_text), (_error), \
winpr_strerror((_error), ebuffer, sizeof(ebuffer))); \
} \
} while (0)
static int rdpsnd_oss_get_format(const AUDIO_FORMAT* format)

View File

@ -41,10 +41,13 @@
#define TAG CLIENT_TAG("x11")
#define CLAMP_COORDINATES(x, y) \
if (x < 0) \
x = 0; \
if (y < 0) \
y = 0
do \
{ \
if ((x) < 0) \
(x) = 0; \
if ((y) < 0) \
(y) = 0; \
} while (0)
const char* x11_event_string(int event)
{

View File

@ -50,12 +50,12 @@
#define GetMinBits(_val, _nbits) \
do \
{ \
UINT32 _v = _val; \
_nbits = 0; \
UINT32 _v = (_val); \
(_nbits) = 0; \
while (_v) \
{ \
_v >>= 1; \
_nbits++; \
(_nbits)++; \
} \
} while (0)
@ -66,12 +66,12 @@
#define UpdateParam(_param, _deltaP, _k) \
do \
{ \
_param += _deltaP; \
if (_param > KPMAX) \
_param = KPMAX; \
if (_param < 0) \
_param = 0; \
_k = (_param >> LSGR); \
(_param) += (_deltaP); \
if ((_param) > KPMAX) \
(_param) = KPMAX; \
if ((_param) < 0) \
(_param) = 0; \
(_k) = ((_param) >> LSGR); \
} while (0)
static BOOL g_LZCNT = FALSE;
@ -568,18 +568,18 @@ int rfx_rlgr_decode(RLGR_MODE mode, const BYTE* WINPR_RESTRICT pSrcData, UINT32
}
/* Returns the next coefficient (a signed int) to encode, from the input stream */
#define GetNextInput(_n) \
do \
{ \
if (data_size > 0) \
{ \
_n = *data++; \
data_size--; \
} \
else \
{ \
_n = 0; \
} \
#define GetNextInput(_n) \
do \
{ \
if (data_size > 0) \
{ \
(_n) = *data++; \
data_size--; \
} \
else \
{ \
(_n) = 0; \
} \
} while (0)
/* Emit bitPattern to the output bitstream */

View File

@ -210,8 +210,8 @@ cJSON* cJSON_ParseWithLength(const char* value, size_t buffer_length)
static INLINE const char* aad_auth_result_to_string(DWORD code)
{
#define ERROR_CASE(cd, x) \
if (cd == (DWORD)(x)) \
#define ERROR_CASE(cd, x) \
if ((cd) == (DWORD)(x)) \
return #x;
ERROR_CASE(code, S_OK)