Skip to content

Commit

Permalink
[clang,tidy] fix a few warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
akallabeth committed Feb 27, 2024
1 parent 43a70cc commit 9a7d30d
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 61 deletions.
2 changes: 1 addition & 1 deletion channels/audin/client/alsa/audin_alsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 11 additions & 10 deletions channels/audin/client/oss/audin_oss.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 4 additions & 5 deletions channels/client/addin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
{
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion channels/cliprdr/cliprdr_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
16 changes: 8 additions & 8 deletions channels/rdpsnd/client/alsa/rdpsnd_alsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 9 additions & 9 deletions channels/rdpsnd/client/oss/rdpsnd_oss.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 7 additions & 4 deletions client/X11/xf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
42 changes: 21 additions & 21 deletions libfreerdp/codec/rfx_rlgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down
4 changes: 2 additions & 2 deletions libfreerdp/core/aad.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9a7d30d

Please sign in to comment.