[warnings] integer cast and checks

This commit is contained in:
akallabeth 2024-08-29 15:49:21 +02:00
parent ceae258e37
commit cc626276d0
No known key found for this signature in database
GPG Key ID: A49454A3FC909FD5
8 changed files with 37 additions and 18 deletions

View File

@ -174,7 +174,7 @@ static DWORD WINAPI audin_alsa_thread_func(LPVOID arg)
if (err == -EPIPE)
{
snd_pcm_recover(capture_handle, err, 0);
snd_pcm_recover(capture_handle, (int)err, 0);
continue;
}
else if (err < 0)

View File

@ -19,6 +19,12 @@
define_channel_client("rdpdr")
include (CheckFunctionExists)
check_function_exists(getmntent_r FREERDP_HAVE_GETMNTENT_R)
if (FREERDP_HAVE_GETMNTENT_R)
add_definitions(-DFREERDP_HAVE_GETMNTENT_R)
endif()
set(${MODULE_PREFIX}_SRCS
irp.c
irp.h

View File

@ -834,9 +834,24 @@ static UINT handle_platform_mounts_bsd(wLog* log, hotplug_dev* dev_array, size_t
#if defined(__LINUX__) || defined(__linux__)
#include <mntent.h>
static struct mntent* getmntent_x(FILE* f, struct mntent* buffer, char* pathbuffer,
size_t pathbuffersize)
{
#if defined(FREERDP_HAVE_GETMNTENT_R)
return getmntent_r(f, buffer, pathbuffer, pathbuffersize);
#else
(void)buffer;
(void)pathbuffer;
(void)pathbuffersize;
return getmntent(f);
#endif
}
static UINT handle_platform_mounts_linux(wLog* log, hotplug_dev* dev_array, size_t* size)
{
FILE* f = NULL;
struct mntent mnt = { 0 };
char pathbuffer[PATH_MAX] = { 0 };
struct mntent* ent = NULL;
f = winpr_fopen("/proc/mounts", "r");
if (f == NULL)
@ -844,7 +859,7 @@ static UINT handle_platform_mounts_linux(wLog* log, hotplug_dev* dev_array, size
WLog_Print(log, WLOG_ERROR, "fopen failed!");
return ERROR_OPEN_FAILED;
}
while ((ent = getmntent(f)) != NULL)
while ((ent = getmntent_x(f, &mnt, pathbuffer, sizeof(pathbuffer))) != NULL)
{
handle_mountpoint(dev_array, size, ent->mnt_dir);
}

View File

@ -772,13 +772,11 @@ static UINT rdpgfx_send_cache_import_offer_pdu(RdpgfxClientContext* context,
wStream* s = NULL;
RDPGFX_HEADER header;
GENERIC_CHANNEL_CALLBACK* callback = NULL;
WINPR_ASSERT(context);
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)context->handle;
if (!context || !pdu)
return ERROR_BAD_ARGUMENTS;
gfx = (RDPGFX_PLUGIN*)context->handle;
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)context->handle;
if (!gfx || !gfx->base.listener_callback)
return ERROR_BAD_CONFIGURATION;

View File

@ -111,8 +111,8 @@ static int rdpsnd_alsa_set_hw_params(rdpsndAlsaPlugin* alsa)
* It is also possible for the buffer size to not be an integer multiple of the period size.
*/
int interrupts_per_sec_near = 50;
int bytes_per_sec =
(alsa->actual_rate * alsa->aformat.wBitsPerSample / 8 * alsa->actual_channels);
const size_t bytes_per_sec =
(1ull * alsa->actual_rate * alsa->aformat.wBitsPerSample / 8 * alsa->actual_channels);
alsa->buffer_size = buffer_size_max;
alsa->period_size = (bytes_per_sec / interrupts_per_sec_near);
@ -423,12 +423,11 @@ static UINT rdpsnd_alsa_play(rdpsndDevicePlugin* device, const BYTE* data, size_
{
UINT latency = 0;
size_t offset = 0;
int frame_size = 0;
rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*)device;
WINPR_ASSERT(alsa);
WINPR_ASSERT(data || (size == 0));
frame_size = alsa->actual_channels * alsa->aformat.wBitsPerSample / 8;
if (frame_size <= 0)
const size_t frame_size = 1ull * alsa->actual_channels * alsa->aformat.wBitsPerSample / 8;
if (frame_size == 0)
return 0;
while (offset < size)
@ -437,7 +436,7 @@ static UINT rdpsnd_alsa_play(rdpsndDevicePlugin* device, const BYTE* data, size_
snd_pcm_writei(alsa->pcm_handle, &data[offset], (size - offset) / frame_size);
if (status < 0)
status = snd_pcm_recover(alsa->pcm_handle, status, 0);
status = snd_pcm_recover(alsa->pcm_handle, (int)status, 0);
if (status < 0)
{

View File

@ -163,7 +163,7 @@ static BOOL rdpsnd_oss_set_format(rdpsndDevicePlugin* device, const AUDIO_FORMAT
return FALSE;
}
tmp = format->nSamplesPerSec;
tmp = (int)format->nSamplesPerSec;
if (ioctl(oss->pcm_handle, SNDCTL_DSP_SPEED, &tmp) == -1)
{
@ -321,15 +321,14 @@ static UINT32 rdpsnd_oss_get_volume(rdpsndDevicePlugin* device)
static BOOL rdpsnd_oss_set_volume(rdpsndDevicePlugin* device, UINT32 value)
{
int left = 0;
int right = 0;
rdpsndOssPlugin* oss = (rdpsndOssPlugin*)device;
WINPR_ASSERT(oss);
if (device == NULL || oss->mixer_handle == -1)
return FALSE;
left = (((value & 0xFFFF) * 100) / 0xFFFF);
right = ((((value >> 16) & 0xFFFF) * 100) / 0xFFFF);
unsigned left = (((value & 0xFFFF) * 100) / 0xFFFF);
unsigned right = ((((value >> 16) & 0xFFFF) * 100) / 0xFFFF);
if (left < 0)
left = 0;
@ -425,7 +424,7 @@ static int rdpsnd_oss_parse_addin_args(rdpsndDevicePlugin* device, const ADDIN_A
return CHANNEL_RC_NULL_DATA;
}
oss->dev_unit = val;
oss->dev_unit = (int)val;
}
if (oss->dev_unit < 0 || *eptr != '\0')

View File

@ -696,7 +696,7 @@ static UINT rdpsnd_pulse_parse_addin_args(rdpsndDevicePlugin* device, const ADDI
if ((errno != 0) || (val > INT32_MAX))
return ERROR_INVALID_DATA;
pulse->reconnect_delay_seconds = val;
pulse->reconnect_delay_seconds = (time_t)val;
}
CommandLineSwitchEnd(arg)
} while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);

View File

@ -302,6 +302,8 @@ static UINT rdpsnd_recv_server_audio_formats_pdu(rdpsndPlugin* rdpsnd, wStream*
WINPR_ASSERT(rdpsnd->device);
ret = IFCALLRESULT(CHANNEL_RC_OK, rdpsnd->device->ServerFormatAnnounce, rdpsnd->device,
rdpsnd->ServerFormats, rdpsnd->NumberOfServerFormats);
if (ret != CHANNEL_RC_OK)
goto out_fail;
rdpsnd_select_supported_audio_formats(rdpsnd);
WLog_Print(rdpsnd->log, WLOG_DEBUG, "%s Server Audio Formats",