diff --git a/channels/audin/client/alsa/audin_alsa.c b/channels/audin/client/alsa/audin_alsa.c index be3e52a94adc..b1edb82429d2 100644 --- a/channels/audin/client/alsa/audin_alsa.c +++ b/channels/audin/client/alsa/audin_alsa.c @@ -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) diff --git a/channels/audin/client/oss/audin_oss.c b/channels/audin/client/oss/audin_oss.c index 979a800e9a90..7bd9fa9affeb 100644 --- a/channels/audin/client/oss/audin_oss.c +++ b/channels/audin/client/oss/audin_oss.c @@ -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) diff --git a/channels/client/addin.c b/channels/client/addin.c index 6d87f6c917e5..2f3b990bae44 100644 --- a/channels/client/addin.c +++ b/channels/client/addin.c @@ -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; diff --git a/channels/cliprdr/cliprdr_common.c b/channels/cliprdr/cliprdr_common.c index d346cb13d10b..f587f3038b03 100644 --- a/channels/cliprdr/cliprdr_common.c +++ b/channels/cliprdr/cliprdr_common.c @@ -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 }; diff --git a/channels/rdpsnd/client/alsa/rdpsnd_alsa.c b/channels/rdpsnd/client/alsa/rdpsnd_alsa.c index 97f0ba06fef0..9751bbe22383 100644 --- a/channels/rdpsnd/client/alsa/rdpsnd_alsa.c +++ b/channels/rdpsnd/client/alsa/rdpsnd_alsa.c @@ -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) diff --git a/channels/rdpsnd/client/oss/rdpsnd_oss.c b/channels/rdpsnd/client/oss/rdpsnd_oss.c index 54869abf8f8d..d303f1dbc4e8 100644 --- a/channels/rdpsnd/client/oss/rdpsnd_oss.c +++ b/channels/rdpsnd/client/oss/rdpsnd_oss.c @@ -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) diff --git a/client/X11/xf_event.c b/client/X11/xf_event.c index 6bc4c4daf628..355f3f829980 100644 --- a/client/X11/xf_event.c +++ b/client/X11/xf_event.c @@ -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) { diff --git a/libfreerdp/codec/rfx_rlgr.c b/libfreerdp/codec/rfx_rlgr.c index da1b63f93749..6ecbfbe5f161 100644 --- a/libfreerdp/codec/rfx_rlgr.c +++ b/libfreerdp/codec/rfx_rlgr.c @@ -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 */ diff --git a/libfreerdp/core/aad.c b/libfreerdp/core/aad.c index 72204d712b06..15eabedf8e7d 100644 --- a/libfreerdp/core/aad.c +++ b/libfreerdp/core/aad.c @@ -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)