[warnings] fix various clang-tidy warnings

This commit is contained in:
akallabeth 2024-08-29 16:13:43 +02:00
parent 500495dc00
commit bd637c6cd1
No known key found for this signature in database
GPG Key ID: A49454A3FC909FD5
18 changed files with 35 additions and 36 deletions

View File

@ -406,7 +406,8 @@ static UINT parallel_free_int(PARALLEL_DEVICE* parallel)
static UINT parallel_free(DEVICE* device)
{
if (device)
parallel_free_int(device);
return parallel_free_int((PARALLEL_DEVICE*)device);
return CHANNEL_RC_OK;
}
static void parallel_message_free(void* obj)

View File

@ -838,7 +838,8 @@ static struct mntent* getmntent_x(FILE* f, struct mntent* buffer, char* pathbuff
size_t pathbuffersize)
{
#if defined(FREERDP_HAVE_GETMNTENT_R)
return getmntent_r(f, buffer, pathbuffer, pathbuffersize);
WINPR_ASSERT(pathbuffersize <= INT32_MAX);
return getmntent_r(f, buffer, pathbuffer, (int)pathbuffersize);
#else
(void)buffer;
(void)pathbuffer;

View File

@ -1010,7 +1010,7 @@ static UINT rdpei_touch_process(RdpeiClientContext* context, INT32 externalId, U
if (p >= 360)
{
WLog_WARN(TAG,
"TouchContact %" PRIu32 ": Invalid orientation value %" PRIu32
"TouchContact %" PRId64 ": Invalid orientation value %" PRIu32
"degree, clamping to 359 degree",
contactIdlocal, p);
p = 359;
@ -1023,7 +1023,7 @@ static UINT rdpei_touch_process(RdpeiClientContext* context, INT32 externalId, U
if (p > 1024)
{
WLog_WARN(TAG,
"TouchContact %" PRIu32 ": Invalid pressure value %" PRIu32
"TouchContact %" PRId64 ": Invalid pressure value %" PRIu32
", clamping to 1024",
contactIdlocal, p);
p = 1024;
@ -1035,7 +1035,7 @@ static UINT rdpei_touch_process(RdpeiClientContext* context, INT32 externalId, U
}
if (contactId)
*contactId = contactIdlocal;
*contactId = (INT32)contactIdlocal;
return error;
}

View File

@ -101,7 +101,7 @@ BOOL rdpei_read_2byte_signed(wStream* s, INT16* value)
return FALSE;
Stream_Read_UINT8(s, byte);
*value = (*value << 8) | byte;
*value = ((*value & 0xFF) << 8) | byte;
}
if (negative)

View File

@ -502,7 +502,6 @@ fail:
*/
static UINT rdpgfx_recv_reset_graphics_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s)
{
int pad = 0;
MONITOR_DEF* monitor = NULL;
RDPGFX_RESET_GRAPHICS_PDU pdu = { 0 };
WINPR_ASSERT(callback);
@ -543,7 +542,13 @@ static UINT rdpgfx_recv_reset_graphics_pdu(GENERIC_CHANNEL_CALLBACK* callback, w
Stream_Read_UINT32(s, monitor->flags); /* flags (4 bytes) */
}
pad = 340 - (RDPGFX_HEADER_SIZE + 12 + (pdu.monitorCount * 20));
const size_t size = (RDPGFX_HEADER_SIZE + 12ULL + (pdu.monitorCount * 20ULL));
if (size > 340)
{
free(pdu.monitorDefArray);
return CHANNEL_RC_NULL_DATA;
}
const size_t pad = 340ULL - size;
if (!Stream_CheckAndLogRequiredLength(TAG, s, (size_t)pad))
{

View File

@ -454,12 +454,8 @@ static UINT rdpsnd_alsa_play(rdpsndDevicePlugin* device, const BYTE* data, size_
snd_pcm_sframes_t delay = 0;
int rc = snd_pcm_avail_delay(alsa->pcm_handle, &available, &delay);
if (rc != 0)
latency = 0;
else if (available == 0) /* Get [ms] from number of samples */
if ((rc == 0) && (available == 0)) /* Get [ms] from number of samples */
latency = delay * 1000 / alsa->actual_rate;
else
latency = 0;
}
return latency + alsa->latency;

View File

@ -21,7 +21,6 @@
#include <freerdp/config.h>
#include <winpr/assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdint.h>

View File

@ -44,9 +44,6 @@ static void usb_process_get_port_status(IUDEVICE* pdev, wStream* out)
break;
case USB_v2_0:
Stream_Write_UINT32(out, 0x503);
break;
default:
Stream_Write_UINT32(out, 0x503);
break;

View File

@ -69,7 +69,7 @@ typedef UDEVICE* PUDEVICE;
size_t udev_new_by_id(URBDRC_PLUGIN* urbdrc, libusb_context* ctx, UINT16 idVendor, UINT16 idProduct,
IUDEVICE*** devArray);
IUDEVICE* udev_new_by_addr(URBDRC_PLUGIN* urbdrc, libusb_context* ctx, BYTE bus_number,
IUDEVICE* udev_new_by_addr(URBDRC_PLUGIN* urbdrc, libusb_context* context, BYTE bus_number,
BYTE dev_number);
const char* usb_interface_class_to_string(uint8_t class);

View File

@ -217,6 +217,6 @@ FREERDP_API BOOL add_device(IUDEVMAN* idevman, UINT32 flags, BYTE busnum, BYTE d
FREERDP_API BOOL del_device(IUDEVMAN* idevman, UINT32 flags, BYTE busnum, BYTE devnum,
UINT16 idVendor, UINT16 idProduct);
UINT stream_write_and_free(IWTSPlugin* plugin, IWTSVirtualChannel* channel, wStream* s);
UINT stream_write_and_free(IWTSPlugin* plugin, IWTSVirtualChannel* channel, wStream* out);
#endif /* FREERDP_CHANNEL_URBDRC_CLIENT_MAIN_H */

View File

@ -310,7 +310,7 @@ static VideoFrame* VideoFrame_new(VideoClientContextPriv* priv, PresentationCont
frame->h = surface->alignedHeight;
frame->scanline = surface->scanline;
frame->surfaceData = BufferPool_Take(priv->surfacePool, 1ull * frame->scanline * frame->h);
frame->surfaceData = BufferPool_Take(priv->surfacePool, 1ll * frame->scanline * frame->h);
if (!frame->surfaceData)
goto fail;

View File

@ -191,7 +191,7 @@ BOOL sdl_register_pointer(rdpGraphics* graphics)
const rdpPointer pointer = { sizeof(sdlPointer), sdl_Pointer_New,
sdl_Pointer_Free, sdl_Pointer_Set,
sdl_Pointer_SetNull, sdl_Pointer_SetDefault,
sdl_Pointer_SetPosition, 0 };
sdl_Pointer_SetPosition, { 0 } };
graphics_register_pointer(graphics, &pointer);
return TRUE;
}

View File

@ -189,7 +189,7 @@ BOOL sdl_register_pointer(rdpGraphics* graphics)
const rdpPointer pointer = { sizeof(sdlPointer), sdl_Pointer_New,
sdl_Pointer_Free, sdl_Pointer_Set,
sdl_Pointer_SetNull, sdl_Pointer_SetDefault,
sdl_Pointer_SetPosition, 0 };
sdl_Pointer_SetPosition, { 0 } };
graphics_register_pointer(graphics, &pointer);
return TRUE;
}

View File

@ -277,7 +277,7 @@ static BOOL ffmpeg_open_context(FREERDP_DSP_CONTEXT* WINPR_RESTRICT context)
#endif
context->context->sample_rate = (int)format->nSamplesPerSec;
context->context->block_align = format->nBlockAlign;
context->context->bit_rate = format->nAvgBytesPerSec * 8;
context->context->bit_rate = format->nAvgBytesPerSec * 8LL;
context->context->sample_fmt = ffmpeg_sample_format(format);
context->context->time_base = av_make_q(1, context->context->sample_rate);

View File

@ -266,7 +266,7 @@ static BOOL rdp_write_client_persistent_key_list_pdu(wStream* s,
for (UINT32 index = 0; index < info->keyCount; index++)
{
const UINT32 key1 = (UINT32)info->keyList[index];
const UINT32 key1 = (UINT32)(info->keyList[index] & UINT32_MAX);
const UINT32 key2 = (UINT32)(info->keyList[index] >> 32);
Stream_Write_UINT32(s, key1);
Stream_Write_UINT32(s, key2);

View File

@ -138,11 +138,15 @@ static BOOL add_cert_to_list(SmartcardCertInfo*** certInfoList, size_t* count,
}
}
curInfoList = realloc(curInfoList, sizeof(SmartcardCertInfo*) * (curCount + 1));
if (!curInfoList)
{
WLog_ERR(TAG, "unable to reallocate certs");
return FALSE;
SmartcardCertInfo** tmpInfoList =
realloc(curInfoList, sizeof(SmartcardCertInfo*) * (curCount + 1));
if (!tmpInfoList)
{
WLog_ERR(TAG, "unable to reallocate certs");
return FALSE;
}
curInfoList = tmpInfoList;
}
curInfoList[curCount++] = certInfo;

View File

@ -1239,10 +1239,10 @@ int freerdp_tcp_default_connect(rdpContext* context, rdpSettings* settings, cons
sockfd = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol);
if (sockfd < 0)
{
const int rc = get_next_addrinfo(context, addr->ai_next, &addr,
FREERDP_ERROR_CONNECT_FAILED);
if (rc < 0)
return rc;
const int lrc = get_next_addrinfo(context, addr->ai_next, &addr,
FREERDP_ERROR_CONNECT_FAILED);
if (lrc < 0)
return lrc;
}
} while (sockfd < 0);

View File

@ -670,7 +670,6 @@ BOOL CancelWaitableTimer(HANDLE hTimer)
int GetTimerFileDescriptor(HANDLE hTimer)
{
#ifndef _WIN32
WINPR_HANDLE* hdl = NULL;
ULONG type = 0;
@ -682,9 +681,6 @@ int GetTimerFileDescriptor(HANDLE hTimer)
}
return winpr_Handle_getFd(hTimer);
#else
return -1;
#endif
}
/**