mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
[warnings,channels] fix integer casts
This commit is contained in:
@@ -187,7 +187,8 @@ static DWORD WINAPI audin_alsa_thread_func(LPVOID arg)
|
||||
break;
|
||||
}
|
||||
|
||||
error = alsa->receive(&alsa->aformat, buffer, (long)framesRead * alsa->bytes_per_frame,
|
||||
error = alsa->receive(&alsa->aformat, buffer,
|
||||
WINPR_ASSERTING_INT_CAST(size_t, framesRead) * alsa->bytes_per_frame,
|
||||
alsa->user_data);
|
||||
|
||||
if (error)
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/cmdline.h>
|
||||
#include <winpr/wlog.h>
|
||||
#include <winpr/cast.h>
|
||||
|
||||
#include <pulse/pulseaudio.h>
|
||||
|
||||
@@ -259,7 +260,8 @@ static UINT audin_pulse_set_format(IAudinDevice* device, const AUDIO_FORMAT* for
|
||||
pulse->frames_per_packet = FramesPerPacket;
|
||||
|
||||
sample_spec.rate = format->nSamplesPerSec;
|
||||
sample_spec.channels = format->nChannels;
|
||||
|
||||
sample_spec.channels = WINPR_ASSERTING_INT_CAST(uint8_t, format->nChannels);
|
||||
|
||||
switch (format->wFormatTag)
|
||||
{
|
||||
@@ -382,7 +384,8 @@ static UINT audin_pulse_open(IAudinDevice* device, AudinReceive receive, void* u
|
||||
pa_threaded_mainloop_unlock(pulse->mainloop);
|
||||
WLog_Print(pulse->log, WLOG_DEBUG, "pa_stream_new failed (%d)",
|
||||
pa_context_errno(pulse->context));
|
||||
return pa_context_errno(pulse->context);
|
||||
const int rc = pa_context_errno(pulse->context);
|
||||
return (UINT)rc;
|
||||
}
|
||||
|
||||
pulse->bytes_per_frame = pa_frame_size(&pulse->sample_spec);
|
||||
@@ -407,7 +410,8 @@ static UINT audin_pulse_open(IAudinDevice* device, AudinReceive receive, void* u
|
||||
pa_threaded_mainloop_unlock(pulse->mainloop);
|
||||
WLog_Print(pulse->log, WLOG_ERROR, "pa_stream_connect_playback failed (%d)",
|
||||
pa_context_errno(pulse->context));
|
||||
return pa_context_errno(pulse->context);
|
||||
const int rc = pa_context_errno(pulse->context);
|
||||
return (UINT)rc;
|
||||
}
|
||||
|
||||
while (pulse->stream)
|
||||
@@ -423,7 +427,8 @@ static UINT audin_pulse_open(IAudinDevice* device, AudinReceive receive, void* u
|
||||
WLog_Print(pulse->log, WLOG_ERROR, "bad stream state (%s: %d)",
|
||||
pulse_stream_state_string(state), pa_context_errno(pulse->context));
|
||||
pa_threaded_mainloop_unlock(pulse->mainloop);
|
||||
return pa_context_errno(pulse->context);
|
||||
const int rc = pa_context_errno(pulse->context);
|
||||
return (UINT)rc;
|
||||
}
|
||||
|
||||
pa_threaded_mainloop_wait(pulse->mainloop);
|
||||
|
||||
@@ -883,7 +883,8 @@ BOOL audin_server_set_formats(audin_server_context* context, SSIZE_T count,
|
||||
}
|
||||
else
|
||||
{
|
||||
AUDIO_FORMAT* audin_server_formats = audio_formats_new(count);
|
||||
const size_t scount = (size_t)count;
|
||||
AUDIO_FORMAT* audin_server_formats = audio_formats_new(scount);
|
||||
if (!audin_server_formats)
|
||||
return count == 0;
|
||||
|
||||
@@ -891,7 +892,7 @@ BOOL audin_server_set_formats(audin_server_context* context, SSIZE_T count,
|
||||
{
|
||||
if (!audio_format_copy(&formats[x], &audin_server_formats[x]))
|
||||
{
|
||||
audio_formats_free(audin_server_formats, count);
|
||||
audio_formats_free(audin_server_formats, scount);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -574,15 +574,15 @@ static UINT cliprdr_client_capabilities(CliprdrClientContext* context,
|
||||
* -> Update clipboard context feature state to what was agreed upon.
|
||||
*/
|
||||
if (!cliprdr->useLongFormatNames)
|
||||
flags &= ~CB_USE_LONG_FORMAT_NAMES;
|
||||
flags &= (uint32_t)~CB_USE_LONG_FORMAT_NAMES;
|
||||
if (!cliprdr->streamFileClipEnabled)
|
||||
flags &= ~CB_STREAM_FILECLIP_ENABLED;
|
||||
flags &= (uint32_t)~CB_STREAM_FILECLIP_ENABLED;
|
||||
if (!cliprdr->fileClipNoFilePaths)
|
||||
flags &= ~CB_FILECLIP_NO_FILE_PATHS;
|
||||
flags &= (uint32_t)~CB_FILECLIP_NO_FILE_PATHS;
|
||||
if (!cliprdr->canLockClipData)
|
||||
flags &= ~CB_CAN_LOCK_CLIPDATA;
|
||||
flags &= (uint32_t)~CB_CAN_LOCK_CLIPDATA;
|
||||
if (!cliprdr->hasHugeFileSupport)
|
||||
flags &= ~CB_HUGE_FILE_SUPPORT_ENABLED;
|
||||
flags &= (uint32_t)~CB_HUGE_FILE_SUPPORT_ENABLED;
|
||||
|
||||
cliprdr->useLongFormatNames = (flags & CB_USE_LONG_FORMAT_NAMES) ? TRUE : FALSE;
|
||||
cliprdr->streamFileClipEnabled = (flags & CB_STREAM_FILECLIP_ENABLED) ? TRUE : FALSE;
|
||||
|
||||
@@ -174,8 +174,8 @@ static UINT disp_recv_display_control_monitor_layout_pdu(wStream* s, DispServerC
|
||||
DISPLAY_CONTROL_MONITOR_LAYOUT* monitor = &(pdu.Monitors[index]);
|
||||
|
||||
Stream_Read_UINT32(s, monitor->Flags); /* Flags (4 bytes) */
|
||||
Stream_Read_UINT32(s, monitor->Left); /* Left (4 bytes) */
|
||||
Stream_Read_UINT32(s, monitor->Top); /* Top (4 bytes) */
|
||||
Stream_Read_INT32(s, monitor->Left); /* Left (4 bytes) */
|
||||
Stream_Read_INT32(s, monitor->Top); /* Top (4 bytes) */
|
||||
Stream_Read_UINT32(s, monitor->Width); /* Width (4 bytes) */
|
||||
Stream_Read_UINT32(s, monitor->Height); /* Height (4 bytes) */
|
||||
Stream_Read_UINT32(s, monitor->PhysicalWidth); /* PhysicalWidth (4 bytes) */
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <freerdp/config.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/cast.h>
|
||||
#include <winpr/stream.h>
|
||||
#include <winpr/interlocked.h>
|
||||
|
||||
@@ -988,7 +989,9 @@ static UINT drdynvc_write_data(drdynvcPlugin* drdynvc, UINT32 ChannelId, const B
|
||||
cbLen = drdynvc_write_variable_uint(data_out, dataSize);
|
||||
pos = Stream_GetPosition(data_out);
|
||||
Stream_SetPosition(data_out, 0);
|
||||
Stream_Write_UINT8(data_out, (DATA_FIRST_PDU << 4) | cbChId | (cbLen << 2));
|
||||
|
||||
const INT32 pdu = (DATA_FIRST_PDU << 4) | cbChId | (cbLen << 2);
|
||||
Stream_Write_UINT8(data_out, WINPR_ASSERTING_INT_CAST(UINT8, pdu));
|
||||
Stream_SetPosition(data_out, pos);
|
||||
chunkLength = CHANNEL_CHUNK_LENGTH - pos;
|
||||
Stream_Write(data_out, data, chunkLength);
|
||||
@@ -1154,14 +1157,15 @@ static UINT32 drdynvc_read_variable_uint(wStream* s, int cbLen)
|
||||
*
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT drdynvc_process_create_request(drdynvcPlugin* drdynvc, int Sp, int cbChId, wStream* s)
|
||||
static UINT drdynvc_process_create_request(drdynvcPlugin* drdynvc, UINT8 Sp, UINT8 cbChId,
|
||||
wStream* s)
|
||||
{
|
||||
UINT status = 0;
|
||||
wStream* data_out = NULL;
|
||||
UINT channel_status = 0;
|
||||
DVCMAN* dvcman = NULL;
|
||||
DVCMAN_CHANNEL* channel = NULL;
|
||||
UINT32 retStatus = 0;
|
||||
INT32 retStatus = 0;
|
||||
|
||||
WINPR_UNUSED(Sp);
|
||||
if (!drdynvc)
|
||||
@@ -1227,14 +1231,14 @@ static UINT drdynvc_process_create_request(drdynvcPlugin* drdynvc, int Sp, int c
|
||||
break;
|
||||
case ERROR_NOT_FOUND:
|
||||
WLog_Print(drdynvc->log, WLOG_DEBUG, "no listener for '%s'", name);
|
||||
retStatus = (UINT32)0xC0000001; /* same code used by mstsc, STATUS_UNSUCCESSFUL */
|
||||
retStatus = STATUS_NOT_FOUND; /* same code used by mstsc, STATUS_UNSUCCESSFUL */
|
||||
break;
|
||||
default:
|
||||
WLog_Print(drdynvc->log, WLOG_DEBUG, "channel creation error");
|
||||
retStatus = (UINT32)0xC0000001; /* same code used by mstsc, STATUS_UNSUCCESSFUL */
|
||||
retStatus = STATUS_UNSUCCESSFUL; /* same code used by mstsc, STATUS_UNSUCCESSFUL */
|
||||
break;
|
||||
}
|
||||
Stream_Write_UINT32(data_out, retStatus);
|
||||
Stream_Write_INT32(data_out, retStatus);
|
||||
|
||||
status = drdynvc_send(drdynvc, data_out);
|
||||
if (status != CHANNEL_RC_OK)
|
||||
|
||||
@@ -64,9 +64,9 @@ typedef struct
|
||||
rdpContext* rdpcontext;
|
||||
} DRIVE_DEVICE;
|
||||
|
||||
static DWORD drive_map_windows_err(DWORD fs_errno)
|
||||
static INT32 drive_map_windows_err(DWORD fs_errno)
|
||||
{
|
||||
DWORD rc = 0;
|
||||
INT32 rc = 0;
|
||||
|
||||
/* try to return NTSTATUS version of error code */
|
||||
|
||||
|
||||
@@ -84,13 +84,16 @@ static int encomsp_read_unicode_string(wStream* s, ENCOMSP_UNICODE_STRING* str)
|
||||
*/
|
||||
static UINT encomsp_recv_change_participant_control_level_pdu(EncomspServerContext* context,
|
||||
wStream* s,
|
||||
ENCOMSP_ORDER_HEADER* header)
|
||||
const ENCOMSP_ORDER_HEADER* header)
|
||||
{
|
||||
int beg = 0;
|
||||
int end = 0;
|
||||
ENCOMSP_CHANGE_PARTICIPANT_CONTROL_LEVEL_PDU pdu;
|
||||
ENCOMSP_CHANGE_PARTICIPANT_CONTROL_LEVEL_PDU pdu = { 0 };
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
beg = ((int)Stream_GetPosition(s)) - ENCOMSP_ORDER_HEADER_SIZE;
|
||||
|
||||
const size_t pos = Stream_GetPosition(s);
|
||||
if (pos < ENCOMSP_ORDER_HEADER_SIZE)
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
|
||||
const size_t beg = pos - ENCOMSP_ORDER_HEADER_SIZE;
|
||||
CopyMemory(&pdu, header, sizeof(ENCOMSP_ORDER_HEADER));
|
||||
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 6))
|
||||
@@ -98,7 +101,7 @@ static UINT encomsp_recv_change_participant_control_level_pdu(EncomspServerConte
|
||||
|
||||
Stream_Read_UINT16(s, pdu.Flags); /* Flags (2 bytes) */
|
||||
Stream_Read_UINT32(s, pdu.ParticipantId); /* ParticipantId (4 bytes) */
|
||||
end = (int)Stream_GetPosition(s);
|
||||
const size_t end = Stream_GetPosition(s);
|
||||
|
||||
if ((beg + header->Length) < end)
|
||||
{
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/assert.h>
|
||||
#include <winpr/cast.h>
|
||||
#include <winpr/stream.h>
|
||||
|
||||
#include <freerdp/client/channels.h>
|
||||
@@ -85,7 +86,7 @@ static BOOL location_write_header(wStream* s, UINT16 pduType, UINT32 pduLength)
|
||||
return Stream_EnsureRemainingCapacity(s, pduLength);
|
||||
}
|
||||
|
||||
static BOOL location_read_server_ready_pdu(LOCATION_CALLBACK* callback, wStream* s, UINT16 pduSize)
|
||||
static BOOL location_read_server_ready_pdu(LOCATION_CALLBACK* callback, wStream* s, UINT32 pduSize)
|
||||
{
|
||||
if (pduSize < 6 + 4)
|
||||
return FALSE; // Short message
|
||||
@@ -244,7 +245,7 @@ static UINT location_send_base_location3d(IWTSVirtualChannel* channel,
|
||||
!freerdp_write_four_byte_float(s, *pdu->horizontalAccuracy))
|
||||
return ERROR_INTERNAL_ERROR;
|
||||
|
||||
Stream_Write_UINT8(s, *pdu->source);
|
||||
Stream_Write_UINT8(s, WINPR_ASSERTING_INT_CAST(UINT8, *pdu->source));
|
||||
}
|
||||
|
||||
return location_channel_send(channel, s);
|
||||
@@ -365,7 +366,7 @@ static UINT location_send(LocationClientContext* context, LOCATION_PDUTYPE type,
|
||||
speed = va_arg(ap, double);
|
||||
heading = va_arg(ap, double);
|
||||
horizontalAccuracy = va_arg(ap, double);
|
||||
source = va_arg(ap, int);
|
||||
source = WINPR_ASSERTING_INT_CAST(LOCATIONSOURCE, va_arg(ap, int));
|
||||
pdu.speed = &speed;
|
||||
pdu.heading = &heading;
|
||||
pdu.horizontalAccuracy = &horizontalAccuracy;
|
||||
|
||||
@@ -238,7 +238,7 @@ static UINT parallel_process_irp_write(PARALLEL_DEVICE* parallel, IRP* irp)
|
||||
break;
|
||||
}
|
||||
|
||||
Stream_Seek(irp->input, status);
|
||||
Stream_Seek(irp->input, WINPR_ASSERTING_INT_CAST(size_t, status));
|
||||
len -= status;
|
||||
}
|
||||
|
||||
@@ -481,7 +481,7 @@ FREERDP_ENTRY_POINT(
|
||||
}
|
||||
|
||||
for (size_t i = 0; i <= length; i++)
|
||||
Stream_Write_UINT8(parallel->device.data, name[i] < 0 ? '_' : name[i]);
|
||||
Stream_Write_INT8(parallel->device.data, name[i] < 0 ? '_' : name[i]);
|
||||
|
||||
parallel->path = path;
|
||||
parallel->queue = MessageQueue_New(NULL);
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
|
||||
#include <winpr/cast.h>
|
||||
|
||||
#include <freerdp/freerdp.h>
|
||||
#include <freerdp/client/rail.h>
|
||||
|
||||
@@ -68,8 +70,12 @@ UINT client_rail_server_start_cmd(RailClientContext* context)
|
||||
sysparam.params |= SPI_MASK_SET_WORK_AREA;
|
||||
sysparam.workArea.left = 0;
|
||||
sysparam.workArea.top = 0;
|
||||
sysparam.workArea.right = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
|
||||
sysparam.workArea.bottom = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
|
||||
|
||||
const UINT32 w = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
|
||||
const UINT32 h = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
|
||||
|
||||
sysparam.workArea.right = WINPR_ASSERTING_INT_CAST(UINT16, w);
|
||||
sysparam.workArea.bottom = WINPR_ASSERTING_INT_CAST(UINT16, h);
|
||||
sysparam.dragFullWindows = FALSE;
|
||||
status = context->ClientSystemParam(context, &sysparam);
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <freerdp/config.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/cast.h>
|
||||
|
||||
#include <freerdp/channels/log.h>
|
||||
#include <freerdp/freerdp.h>
|
||||
@@ -315,7 +316,7 @@ static UINT rail_write_languageime_info_order(wStream* s,
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
|
||||
Stream_Write_UINT32(s, langImeInfo->ProfileType);
|
||||
Stream_Write_UINT16(s, langImeInfo->LanguageID);
|
||||
Stream_Write_UINT16(s, WINPR_ASSERTING_INT_CAST(UINT16, langImeInfo->LanguageID));
|
||||
Stream_Write(s, &langImeInfo->LanguageProfileCLSID, sizeof(langImeInfo->LanguageProfileCLSID));
|
||||
Stream_Write(s, &langImeInfo->ProfileGUID, sizeof(langImeInfo->ProfileGUID));
|
||||
Stream_Write_UINT32(s, langImeInfo->KeyboardLayout);
|
||||
|
||||
@@ -92,8 +92,8 @@ static UINT rail_write_local_move_size_order(wStream* s,
|
||||
Stream_Write_UINT32(s, localMoveSize->windowId); /* WindowId (4 bytes) */
|
||||
Stream_Write_UINT16(s, localMoveSize->isMoveSizeStart ? 1 : 0); /* IsMoveSizeStart (2 bytes) */
|
||||
Stream_Write_UINT16(s, localMoveSize->moveSizeType); /* MoveSizeType (2 bytes) */
|
||||
Stream_Write_UINT16(s, localMoveSize->posX); /* PosX (2 bytes) */
|
||||
Stream_Write_UINT16(s, localMoveSize->posY); /* PosY (2 bytes) */
|
||||
Stream_Write_INT16(s, localMoveSize->posX); /* PosX (2 bytes) */
|
||||
Stream_Write_INT16(s, localMoveSize->posY); /* PosY (2 bytes) */
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ static UINT irp_complete(IRP* irp)
|
||||
|
||||
pos = Stream_GetPosition(irp->output);
|
||||
Stream_SetPosition(irp->output, RDPDR_DEVICE_IO_RESPONSE_LENGTH - 4);
|
||||
Stream_Write_UINT32(irp->output, irp->IoStatus); /* IoStatus (4 bytes) */
|
||||
Stream_Write_INT32(irp->output, irp->IoStatus); /* IoStatus (4 bytes) */
|
||||
Stream_SetPosition(irp->output, pos);
|
||||
|
||||
error = rdpdr_send(rdpdr, irp->output);
|
||||
|
||||
@@ -539,7 +539,7 @@ static UINT handle_hotplug(rdpdrPlugin* rdpdr)
|
||||
{
|
||||
if (pDirent->d_name[0] != '.')
|
||||
{
|
||||
sprintf_s(fullpath, ARRAYSIZE(fullpath), "%s/%s", szdir, pDirent->d_name);
|
||||
(void)sprintf_s(fullpath, ARRAYSIZE(fullpath), "%s/%s", szdir, pDirent->d_name);
|
||||
if (stat(fullpath, &buf) != 0)
|
||||
continue;
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include <winpr/assert.h>
|
||||
#include <winpr/cast.h>
|
||||
|
||||
#include "camera.h"
|
||||
|
||||
@@ -42,8 +43,8 @@ UINT ecam_channel_send_error_response(CameraPlugin* ecam, GENERIC_CHANNEL_CALLBA
|
||||
return ERROR_NOT_ENOUGH_MEMORY;
|
||||
}
|
||||
|
||||
Stream_Write_UINT8(s, ecam->version);
|
||||
Stream_Write_UINT8(s, msg);
|
||||
Stream_Write_UINT8(s, WINPR_ASSERTING_INT_CAST(uint8_t, ecam->version));
|
||||
Stream_Write_UINT8(s, WINPR_ASSERTING_INT_CAST(uint8_t, msg));
|
||||
Stream_Write_UINT32(s, code);
|
||||
|
||||
return ecam_channel_write(ecam, hchannel, msg, s, TRUE);
|
||||
@@ -66,8 +67,8 @@ UINT ecam_channel_send_generic_msg(CameraPlugin* ecam, GENERIC_CHANNEL_CALLBACK*
|
||||
return ERROR_NOT_ENOUGH_MEMORY;
|
||||
}
|
||||
|
||||
Stream_Write_UINT8(s, ecam->version);
|
||||
Stream_Write_UINT8(s, msg);
|
||||
Stream_Write_UINT8(s, WINPR_ASSERTING_INT_CAST(uint8_t, ecam->version));
|
||||
Stream_Write_UINT8(s, WINPR_ASSERTING_INT_CAST(uint8_t, msg));
|
||||
|
||||
return ecam_channel_write(ecam, hchannel, msg, s, TRUE);
|
||||
}
|
||||
@@ -118,8 +119,8 @@ static UINT ecam_send_device_added_notification(CameraPlugin* ecam,
|
||||
return ERROR_NOT_ENOUGH_MEMORY;
|
||||
}
|
||||
|
||||
Stream_Write_UINT8(s, ecam->version);
|
||||
Stream_Write_UINT8(s, msg);
|
||||
Stream_Write_UINT8(s, WINPR_ASSERTING_INT_CAST(uint8_t, ecam->version));
|
||||
Stream_Write_UINT8(s, WINPR_ASSERTING_INT_CAST(uint8_t, msg));
|
||||
|
||||
size_t devNameLen = strlen(deviceName);
|
||||
if (Stream_Write_UTF16_String_From_UTF8(s, devNameLen + 1, deviceName, devNameLen, TRUE) < 0)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include <winpr/assert.h>
|
||||
#include <winpr/cast.h>
|
||||
|
||||
#include "camera.h"
|
||||
|
||||
@@ -46,14 +47,14 @@ static void ecam_dev_write_media_type(wStream* s, CAM_MEDIA_TYPE_DESCRIPTION* me
|
||||
{
|
||||
WINPR_ASSERT(mediaType);
|
||||
|
||||
Stream_Write_UINT8(s, mediaType->Format);
|
||||
Stream_Write_UINT8(s, WINPR_ASSERTING_INT_CAST(uint8_t, mediaType->Format));
|
||||
Stream_Write_UINT32(s, mediaType->Width);
|
||||
Stream_Write_UINT32(s, mediaType->Height);
|
||||
Stream_Write_UINT32(s, mediaType->FrameRateNumerator);
|
||||
Stream_Write_UINT32(s, mediaType->FrameRateDenominator);
|
||||
Stream_Write_UINT32(s, mediaType->PixelAspectRatioNumerator);
|
||||
Stream_Write_UINT32(s, mediaType->PixelAspectRatioDenominator);
|
||||
Stream_Write_UINT8(s, mediaType->Flags);
|
||||
Stream_Write_UINT8(s, WINPR_ASSERTING_INT_CAST(uint8_t, mediaType->Flags));
|
||||
}
|
||||
|
||||
static BOOL ecam_dev_read_media_type(wStream* s, CAM_MEDIA_TYPE_DESCRIPTION* mediaType)
|
||||
@@ -94,9 +95,10 @@ static UINT ecam_dev_send_sample_response(CameraDevice* dev, size_t streamIndex,
|
||||
|
||||
Stream_SetPosition(stream->sampleRespBuffer, 0);
|
||||
|
||||
Stream_Write_UINT8(stream->sampleRespBuffer, dev->ecam->version);
|
||||
Stream_Write_UINT8(stream->sampleRespBuffer, msg);
|
||||
Stream_Write_UINT8(stream->sampleRespBuffer, streamIndex);
|
||||
Stream_Write_UINT8(stream->sampleRespBuffer,
|
||||
WINPR_ASSERTING_INT_CAST(uint8_t, dev->ecam->version));
|
||||
Stream_Write_UINT8(stream->sampleRespBuffer, WINPR_ASSERTING_INT_CAST(uint8_t, msg));
|
||||
Stream_Write_UINT8(stream->sampleRespBuffer, WINPR_ASSERTING_INT_CAST(uint8_t, streamIndex));
|
||||
|
||||
Stream_Write(stream->sampleRespBuffer, sample, size);
|
||||
|
||||
@@ -150,7 +152,8 @@ static UINT ecam_dev_sample_captured_callback(CameraDevice* dev, int streamIndex
|
||||
}
|
||||
stream->nSampleCredits--;
|
||||
|
||||
return ecam_dev_send_sample_response(dev, streamIndex, encodedSample, encodedSize);
|
||||
return ecam_dev_send_sample_response(dev, WINPR_ASSERTING_INT_CAST(size_t, streamIndex),
|
||||
encodedSample, encodedSize);
|
||||
}
|
||||
|
||||
static void ecam_dev_stop_stream(CameraDevice* dev, size_t streamIndex)
|
||||
@@ -313,8 +316,8 @@ static UINT ecam_dev_send_current_media_type_response(CameraDevice* dev,
|
||||
return ERROR_NOT_ENOUGH_MEMORY;
|
||||
}
|
||||
|
||||
Stream_Write_UINT8(s, dev->ecam->version);
|
||||
Stream_Write_UINT8(s, msg);
|
||||
Stream_Write_UINT8(s, WINPR_ASSERTING_INT_CAST(uint8_t, dev->ecam->version));
|
||||
Stream_Write_UINT8(s, WINPR_ASSERTING_INT_CAST(uint8_t, msg));
|
||||
|
||||
ecam_dev_write_media_type(s, mediaType);
|
||||
|
||||
@@ -416,8 +419,8 @@ static UINT ecam_dev_send_media_type_list_response(CameraDevice* dev,
|
||||
return ERROR_NOT_ENOUGH_MEMORY;
|
||||
}
|
||||
|
||||
Stream_Write_UINT8(s, dev->ecam->version);
|
||||
Stream_Write_UINT8(s, msg);
|
||||
Stream_Write_UINT8(s, WINPR_ASSERTING_INT_CAST(uint8_t, dev->ecam->version));
|
||||
Stream_Write_UINT8(s, WINPR_ASSERTING_INT_CAST(uint8_t, msg));
|
||||
|
||||
for (size_t i = 0; i < nMediaTypes; i++, mediaTypes++)
|
||||
{
|
||||
@@ -516,8 +519,8 @@ static UINT ecam_dev_send_stream_list_response(CameraDevice* dev,
|
||||
return ERROR_NOT_ENOUGH_MEMORY;
|
||||
}
|
||||
|
||||
Stream_Write_UINT8(s, dev->ecam->version);
|
||||
Stream_Write_UINT8(s, msg);
|
||||
Stream_Write_UINT8(s, WINPR_ASSERTING_INT_CAST(uint8_t, dev->ecam->version));
|
||||
Stream_Write_UINT8(s, WINPR_ASSERTING_INT_CAST(uint8_t, msg));
|
||||
|
||||
/* single stream description */
|
||||
Stream_Write_UINT16(s, CAM_STREAM_FRAME_SOURCE_TYPE_Color);
|
||||
@@ -796,7 +799,7 @@ void ecam_dev_destroy(CameraDevice* dev)
|
||||
|
||||
free(dev->hlistener);
|
||||
|
||||
for (int i = 0; i < ECAM_DEVICE_MAX_STREAMS; i++)
|
||||
for (size_t i = 0; i < ECAM_DEVICE_MAX_STREAMS; i++)
|
||||
ecam_dev_stop_stream(dev, i);
|
||||
|
||||
free(dev);
|
||||
|
||||
@@ -206,8 +206,8 @@ static BOOL ecam_encoder_compress_h264(CameraDeviceStream* stream, const BYTE* s
|
||||
}
|
||||
|
||||
/* get buffers for YUV420P */
|
||||
if (h264_get_yuv_buffer(stream->h264, srcLineSizes[0], size.width, size.height, yuv420pData,
|
||||
yuv420pStride) < 0)
|
||||
if (h264_get_yuv_buffer(stream->h264, WINPR_ASSERTING_INT_CAST(uint32_t, srcLineSizes[0]),
|
||||
size.width, size.height, yuv420pData, yuv420pStride) < 0)
|
||||
return FALSE;
|
||||
|
||||
/* convert from source format to YUV420P */
|
||||
@@ -288,8 +288,8 @@ static BOOL ecam_init_mjpeg_decoder(CameraDeviceStream* stream)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
stream->avContext->width = stream->currMediaType.Width;
|
||||
stream->avContext->height = stream->currMediaType.Height;
|
||||
stream->avContext->width = WINPR_ASSERTING_INT_CAST(int, stream->currMediaType.Width);
|
||||
stream->avContext->height = WINPR_ASSERTING_INT_CAST(int, stream->currMediaType.Height);
|
||||
|
||||
/* AV_EF_EXPLODE flag is to abort decoding on minor error detection,
|
||||
* return error, so we can skip corrupted frames, if any */
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <winpr/cast.h>
|
||||
|
||||
#include <freerdp/config.h>
|
||||
|
||||
#include <freerdp/freerdp.h>
|
||||
@@ -569,7 +571,8 @@ static UINT enumerator_send_select_version_response_pdu(
|
||||
}
|
||||
|
||||
Stream_Write_UINT8(s, selectVersionResponse->Header.Version);
|
||||
Stream_Write_UINT8(s, selectVersionResponse->Header.MessageId);
|
||||
Stream_Write_UINT8(s,
|
||||
WINPR_ASSERTING_INT_CAST(uint8_t, selectVersionResponse->Header.MessageId));
|
||||
|
||||
return enumerator_server_packet_send(context, s);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <winpr/cast.h>
|
||||
|
||||
#include <freerdp/config.h>
|
||||
|
||||
#include <freerdp/freerdp.h>
|
||||
@@ -176,7 +178,10 @@ static UINT device_server_recv_stream_list_response(CameraDeviceServerContext* c
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 5))
|
||||
return ERROR_NO_DATA;
|
||||
|
||||
pdu.N_Descriptions = MIN(Stream_GetRemainingLength(s) / 5, 255);
|
||||
pdu.N_Descriptions = 255;
|
||||
const size_t len = Stream_GetRemainingLength(s) / 5;
|
||||
if (len < 255)
|
||||
pdu.N_Descriptions = (BYTE)len;
|
||||
|
||||
for (BYTE i = 0; i < pdu.N_Descriptions; ++i)
|
||||
{
|
||||
@@ -825,14 +830,14 @@ device_send_start_streams_request_pdu(CameraDeviceServerContext* context,
|
||||
|
||||
Stream_Write_UINT8(s, info->StreamIndex);
|
||||
|
||||
Stream_Write_UINT8(s, description->Format);
|
||||
Stream_Write_UINT8(s, WINPR_ASSERTING_INT_CAST(uint8_t, description->Format));
|
||||
Stream_Write_UINT32(s, description->Width);
|
||||
Stream_Write_UINT32(s, description->Height);
|
||||
Stream_Write_UINT32(s, description->FrameRateNumerator);
|
||||
Stream_Write_UINT32(s, description->FrameRateDenominator);
|
||||
Stream_Write_UINT32(s, description->PixelAspectRatioNumerator);
|
||||
Stream_Write_UINT32(s, description->PixelAspectRatioDenominator);
|
||||
Stream_Write_UINT8(s, description->Flags);
|
||||
Stream_Write_UINT8(s, WINPR_ASSERTING_INT_CAST(uint8_t, description->Flags));
|
||||
}
|
||||
|
||||
return device_server_packet_send(context, s);
|
||||
@@ -885,7 +890,7 @@ device_send_property_value_request_pdu(CameraDeviceServerContext* context,
|
||||
if (!s)
|
||||
return ERROR_NOT_ENOUGH_MEMORY;
|
||||
|
||||
Stream_Write_UINT8(s, propertyValueRequest->PropertySet);
|
||||
Stream_Write_UINT8(s, WINPR_ASSERTING_INT_CAST(uint8_t, propertyValueRequest->PropertySet));
|
||||
Stream_Write_UINT8(s, propertyValueRequest->PropertyId);
|
||||
|
||||
return device_server_packet_send(context, s);
|
||||
@@ -905,10 +910,11 @@ static UINT device_send_set_property_value_request_pdu(
|
||||
if (!s)
|
||||
return ERROR_NOT_ENOUGH_MEMORY;
|
||||
|
||||
Stream_Write_UINT8(s, setPropertyValueRequest->PropertySet);
|
||||
Stream_Write_UINT8(s, WINPR_ASSERTING_INT_CAST(uint8_t, setPropertyValueRequest->PropertySet));
|
||||
Stream_Write_UINT8(s, setPropertyValueRequest->PropertyId);
|
||||
|
||||
Stream_Write_UINT8(s, setPropertyValueRequest->PropertyValue.Mode);
|
||||
Stream_Write_UINT8(
|
||||
s, WINPR_ASSERTING_INT_CAST(uint8_t, setPropertyValueRequest->PropertyValue.Mode));
|
||||
Stream_Write_INT32(s, setPropertyValueRequest->PropertyValue.Value);
|
||||
|
||||
return device_server_packet_send(context, s);
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/cast.h>
|
||||
#include <winpr/synch.h>
|
||||
#include <winpr/thread.h>
|
||||
#include <winpr/stream.h>
|
||||
@@ -523,7 +524,8 @@ static DWORD WINAPI rdpei_periodic_update(LPVOID arg)
|
||||
break;
|
||||
}
|
||||
|
||||
error = rdpei_poll_run(rdpei->rdpcontext, rdpei);
|
||||
if (!rdpei_poll_run(rdpei->rdpcontext, rdpei))
|
||||
error = ERROR_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
out:
|
||||
@@ -661,7 +663,8 @@ static UINT rdpei_write_touch_frame(wLog* log, wStream* s, RDPINPUT_TOUCH_FRAME*
|
||||
contact->contactFlags);
|
||||
rdpei_print_contact_flags(log, contact->contactFlags);
|
||||
#endif
|
||||
Stream_Write_UINT8(s, contact->contactId); /* contactId (1 byte) */
|
||||
Stream_Write_UINT8(
|
||||
s, WINPR_ASSERTING_INT_CAST(uint8_t, contact->contactId)); /* contactId (1 byte) */
|
||||
/* fieldsPresent (TWO_BYTE_UNSIGNED_INTEGER) */
|
||||
rdpei_write_2byte_unsigned(s, contact->fieldsPresent);
|
||||
rdpei_write_4byte_signed(s, contact->x); /* x (FOUR_BYTE_SIGNED_INTEGER) */
|
||||
@@ -968,7 +971,7 @@ static UINT32 rdpei_get_version(RdpeiClientContext* context)
|
||||
{
|
||||
RDPEI_PLUGIN* rdpei = NULL;
|
||||
if (!context || !context->handle)
|
||||
return -1;
|
||||
return 0;
|
||||
rdpei = (RDPEI_PLUGIN*)context->handle;
|
||||
return rdpei->version;
|
||||
}
|
||||
@@ -977,7 +980,7 @@ static UINT32 rdpei_get_features(RdpeiClientContext* context)
|
||||
{
|
||||
RDPEI_PLUGIN* rdpei = NULL;
|
||||
if (!context || !context->handle)
|
||||
return -1;
|
||||
return 0;
|
||||
rdpei = (RDPEI_PLUGIN*)context->handle;
|
||||
return rdpei->features;
|
||||
}
|
||||
@@ -1075,14 +1078,21 @@ static UINT rdpei_touch_process(RdpeiClientContext* context, INT32 externalId, U
|
||||
contact.y = y;
|
||||
contact.contactId = (UINT32)contactIdlocal;
|
||||
contact.contactFlags = contactFlags;
|
||||
contact.fieldsPresent = fieldFlags;
|
||||
contact.fieldsPresent = WINPR_ASSERTING_INT_CAST(UINT16, fieldFlags);
|
||||
|
||||
if (fieldFlags & CONTACT_DATA_CONTACTRECT_PRESENT)
|
||||
{
|
||||
contact.contactRectLeft = va_arg(ap, INT32);
|
||||
contact.contactRectTop = va_arg(ap, INT32);
|
||||
contact.contactRectRight = va_arg(ap, INT32);
|
||||
contact.contactRectBottom = va_arg(ap, INT32);
|
||||
INT32 val = va_arg(ap, INT32);
|
||||
contact.contactRectLeft = WINPR_ASSERTING_INT_CAST(INT16, val);
|
||||
|
||||
val = va_arg(ap, INT32);
|
||||
contact.contactRectTop = WINPR_ASSERTING_INT_CAST(INT16, val);
|
||||
|
||||
val = va_arg(ap, INT32);
|
||||
contact.contactRectRight = WINPR_ASSERTING_INT_CAST(INT16, val);
|
||||
|
||||
val = va_arg(ap, INT32);
|
||||
contact.contactRectBottom = WINPR_ASSERTING_INT_CAST(INT16, val);
|
||||
}
|
||||
if (fieldFlags & CONTACT_DATA_ORIENTATION_PRESENT)
|
||||
{
|
||||
@@ -1292,19 +1302,35 @@ static UINT rdpei_pen_process(RdpeiClientContext* context, INT32 externalId, UIN
|
||||
|
||||
contact.x = x;
|
||||
contact.y = y;
|
||||
contact.fieldsPresent = fieldFlags;
|
||||
contact.fieldsPresent = WINPR_ASSERTING_INT_CAST(UINT16, fieldFlags);
|
||||
|
||||
contact.contactFlags = contactFlags;
|
||||
if (fieldFlags & RDPINPUT_PEN_CONTACT_PENFLAGS_PRESENT)
|
||||
contact.penFlags = va_arg(ap, UINT32);
|
||||
{
|
||||
const UINT32 val = va_arg(ap, UINT32);
|
||||
contact.penFlags = WINPR_ASSERTING_INT_CAST(UINT16, val);
|
||||
}
|
||||
if (fieldFlags & RDPINPUT_PEN_CONTACT_PRESSURE_PRESENT)
|
||||
contact.pressure = va_arg(ap, UINT32);
|
||||
{
|
||||
const UINT32 val = va_arg(ap, UINT32);
|
||||
contact.pressure = WINPR_ASSERTING_INT_CAST(UINT16, val);
|
||||
}
|
||||
if (fieldFlags & RDPINPUT_PEN_CONTACT_ROTATION_PRESENT)
|
||||
contact.rotation = va_arg(ap, UINT32);
|
||||
{
|
||||
const UINT32 val = va_arg(ap, UINT32);
|
||||
contact.rotation = WINPR_ASSERTING_INT_CAST(UINT16, val);
|
||||
}
|
||||
if (fieldFlags & RDPINPUT_PEN_CONTACT_TILTX_PRESENT)
|
||||
contact.tiltX = va_arg(ap, INT32);
|
||||
{
|
||||
const INT32 val = va_arg(ap, INT32);
|
||||
contact.tiltX = WINPR_ASSERTING_INT_CAST(INT16, val);
|
||||
}
|
||||
if (fieldFlags & RDPINPUT_PEN_CONTACT_TILTY_PRESENT)
|
||||
contact.tiltY = va_arg(ap, INT32);
|
||||
{
|
||||
const INT32 val = va_arg(ap, INT32);
|
||||
WINPR_ASSERT((val >= INT16_MIN) && (val <= INT16_MAX));
|
||||
contact.tiltY = WINPR_ASSERTING_INT_CAST(INT16, val);
|
||||
}
|
||||
|
||||
error = context->AddPen(context, externalId, &contact);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <freerdp/config.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/cast.h>
|
||||
#include <winpr/stream.h>
|
||||
|
||||
#include "rdpei_common.h"
|
||||
@@ -43,7 +44,8 @@ BOOL rdpei_read_2byte_unsigned(wStream* s, UINT16* value)
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
||||
return FALSE;
|
||||
|
||||
*value = (byte & 0x7F) << 8;
|
||||
const INT32 ibyte = ((byte & 0x7F) << 8);
|
||||
*value = WINPR_ASSERTING_INT_CAST(UINT16, ibyte);
|
||||
Stream_Read_UINT8(s, byte);
|
||||
*value |= byte;
|
||||
}
|
||||
@@ -175,25 +177,25 @@ BOOL rdpei_read_4byte_unsigned(wStream* s, UINT32* value)
|
||||
break;
|
||||
|
||||
case 1:
|
||||
*value = (byte & 0x3F) << 8;
|
||||
*value = ((byte & 0x3F) << 8) & 0xFF;
|
||||
Stream_Read_UINT8(s, byte);
|
||||
*value |= byte;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
*value = (byte & 0x3F) << 16;
|
||||
*value = ((byte & 0x3F) << 16) & 0xFF0000;
|
||||
Stream_Read_UINT8(s, byte);
|
||||
*value |= (byte << 8);
|
||||
*value |= ((byte << 8) & 0xFF);
|
||||
Stream_Read_UINT8(s, byte);
|
||||
*value |= byte;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
*value = (byte & 0x3F) << 24;
|
||||
*value = ((byte & 0x3F) << 24) & 0xFF0000;
|
||||
Stream_Read_UINT8(s, byte);
|
||||
*value |= (byte << 16);
|
||||
*value |= ((byte << 16) & 0xFF00);
|
||||
Stream_Read_UINT8(s, byte);
|
||||
*value |= (byte << 8);
|
||||
*value |= ((byte << 8) & 0xFF);
|
||||
Stream_Read_UINT8(s, byte);
|
||||
*value |= byte;
|
||||
break;
|
||||
@@ -214,7 +216,7 @@ BOOL rdpei_write_4byte_unsigned(wStream* s, UINT32 value)
|
||||
|
||||
if (value <= 0x3FUL)
|
||||
{
|
||||
Stream_Write_UINT8(s, value);
|
||||
Stream_Write_UINT8(s, WINPR_ASSERTING_INT_CAST(uint8_t, value));
|
||||
}
|
||||
else if (value <= 0x3FFFUL)
|
||||
{
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <freerdp/config.h>
|
||||
|
||||
#include <winpr/cast.h>
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/print.h>
|
||||
#include <winpr/stream.h>
|
||||
@@ -333,7 +334,7 @@ static UINT read_touch_frame(RdpeiServerContext* context, wStream* s, RDPINPUT_T
|
||||
if ((error = read_touch_contact_data(context, s, contact)))
|
||||
{
|
||||
WLog_ERR(TAG, "read_touch_contact_data failed with error %" PRIu32 "!", error);
|
||||
frame->contactCount = i;
|
||||
frame->contactCount = WINPR_ASSERTING_INT_CAST(UINT16, i);
|
||||
touch_frame_reset(frame);
|
||||
return error;
|
||||
}
|
||||
@@ -365,7 +366,8 @@ static UINT read_pen_frame(RdpeiServerContext* context, wStream* s, RDPINPUT_PEN
|
||||
if ((error = read_pen_contact(context, s, contact)))
|
||||
{
|
||||
WLog_ERR(TAG, "read_touch_contact_data failed with error %" PRIu32 "!", error);
|
||||
frame->contactCount = i;
|
||||
frame->contactCount = WINPR_ASSERTING_INT_CAST(UINT16, i);
|
||||
|
||||
pen_frame_reset(frame);
|
||||
return error;
|
||||
}
|
||||
@@ -405,7 +407,8 @@ static UINT read_touch_event(RdpeiServerContext* context, wStream* s)
|
||||
if ((error = read_touch_frame(context, s, frame)))
|
||||
{
|
||||
WLog_ERR(TAG, "read_touch_contact_data failed with error %" PRIu32 "!", error);
|
||||
event->frameCount = i;
|
||||
event->frameCount = WINPR_ASSERTING_INT_CAST(UINT16, i);
|
||||
|
||||
goto out_cleanup;
|
||||
}
|
||||
}
|
||||
@@ -446,7 +449,8 @@ static UINT read_pen_event(RdpeiServerContext* context, wStream* s)
|
||||
if ((error = read_pen_frame(context, s, frame)))
|
||||
{
|
||||
WLog_ERR(TAG, "read_pen_frame failed with error %" PRIu32 "!", error);
|
||||
event->frameCount = i;
|
||||
event->frameCount = WINPR_ASSERTING_INT_CAST(UINT16, i);
|
||||
|
||||
goto out_cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <freerdp/config.h>
|
||||
|
||||
#include <winpr/assert.h>
|
||||
#include <winpr/cast.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/wlog.h>
|
||||
@@ -1254,8 +1255,8 @@ static UINT rdpgfx_recv_end_frame_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStrea
|
||||
|
||||
qoe.frameId = pdu.frameId;
|
||||
qoe.timestamp = gfx->StartDecodingTime % UINT32_MAX;
|
||||
qoe.timeDiffSE = diff;
|
||||
qoe.timeDiffEDR = EndFrameTime;
|
||||
qoe.timeDiffSE = WINPR_ASSERTING_INT_CAST(UINT16, diff);
|
||||
qoe.timeDiffEDR = WINPR_ASSERTING_INT_CAST(UINT16, EndFrameTime);
|
||||
|
||||
if ((error = rdpgfx_send_qoe_frame_acknowledge_pdu(context, &qoe)))
|
||||
WLog_Print(gfx->log, WLOG_ERROR,
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <winpr/cast.h>
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/synch.h>
|
||||
#include <winpr/thread.h>
|
||||
@@ -608,8 +609,9 @@ static UINT rdpgfx_write_h264_metablock(wLog* log, wStream* s, const RDPGFX_H264
|
||||
for (UINT32 index = 0; index < meta->numRegionRects; index++)
|
||||
{
|
||||
quantQualityVal = &(meta->quantQualityVals[index]);
|
||||
Stream_Write_UINT8(s, quantQualityVal->qp | (quantQualityVal->r << 6) |
|
||||
(quantQualityVal->p << 7)); /* qpVal (1 byte) */
|
||||
Stream_Write_UINT8(s, WINPR_ASSERTING_INT_CAST(
|
||||
uint8_t, quantQualityVal->qp | (quantQualityVal->r << 6) |
|
||||
(quantQualityVal->p << 7))); /* qpVal (1 byte) */
|
||||
/* qualityVal (1 byte) */
|
||||
Stream_Write_UINT8(s, quantQualityVal->qualityVal);
|
||||
}
|
||||
@@ -678,8 +680,10 @@ static UINT rdpgfx_write_surface_command(wLog* log, wStream* s, const RDPGFX_SUR
|
||||
if (!Stream_EnsureRemainingCapacity(s, 13 + cmd->length))
|
||||
return ERROR_INTERNAL_ERROR;
|
||||
/* Write RDPGFX_CMDID_WIRETOSURFACE_2 format for CAPROGRESSIVE */
|
||||
Stream_Write_UINT16(s, cmd->surfaceId); /* surfaceId (2 bytes) */
|
||||
Stream_Write_UINT16(s, cmd->codecId); /* codecId (2 bytes) */
|
||||
Stream_Write_UINT16(
|
||||
s, WINPR_ASSERTING_INT_CAST(uint16_t, cmd->surfaceId)); /* surfaceId (2 bytes) */
|
||||
Stream_Write_UINT16(
|
||||
s, WINPR_ASSERTING_INT_CAST(uint16_t, cmd->codecId)); /* codecId (2 bytes) */
|
||||
Stream_Write_UINT32(s, cmd->contextId); /* codecContextId (4 bytes) */
|
||||
Stream_Write_UINT8(s, pixelFormat); /* pixelFormat (1 byte) */
|
||||
Stream_Write_UINT32(s, cmd->length); /* bitmapDataLength (4 bytes) */
|
||||
@@ -690,13 +694,17 @@ static UINT rdpgfx_write_surface_command(wLog* log, wStream* s, const RDPGFX_SUR
|
||||
/* Write RDPGFX_CMDID_WIRETOSURFACE_1 format for others */
|
||||
if (!Stream_EnsureRemainingCapacity(s, 17))
|
||||
return ERROR_INTERNAL_ERROR;
|
||||
Stream_Write_UINT16(s, cmd->surfaceId); /* surfaceId (2 bytes) */
|
||||
Stream_Write_UINT16(s, cmd->codecId); /* codecId (2 bytes) */
|
||||
Stream_Write_UINT16(
|
||||
s, WINPR_ASSERTING_INT_CAST(uint16_t, cmd->surfaceId)); /* surfaceId (2 bytes) */
|
||||
Stream_Write_UINT16(
|
||||
s, WINPR_ASSERTING_INT_CAST(uint16_t, cmd->codecId)); /* codecId (2 bytes) */
|
||||
Stream_Write_UINT8(s, pixelFormat); /* pixelFormat (1 byte) */
|
||||
Stream_Write_UINT16(s, cmd->left); /* left (2 bytes) */
|
||||
Stream_Write_UINT16(s, cmd->top); /* top (2 bytes) */
|
||||
Stream_Write_UINT16(s, cmd->right); /* right (2 bytes) */
|
||||
Stream_Write_UINT16(s, cmd->bottom); /* bottom (2 bytes) */
|
||||
Stream_Write_UINT16(s, WINPR_ASSERTING_INT_CAST(uint16_t, cmd->left)); /* left (2 bytes) */
|
||||
Stream_Write_UINT16(s, WINPR_ASSERTING_INT_CAST(uint16_t, cmd->top)); /* top (2 bytes) */
|
||||
Stream_Write_UINT16(s,
|
||||
WINPR_ASSERTING_INT_CAST(uint16_t, cmd->right)); /* right (2 bytes) */
|
||||
Stream_Write_UINT16(s,
|
||||
WINPR_ASSERTING_INT_CAST(uint16_t, cmd->bottom)); /* bottom (2 bytes) */
|
||||
Stream_Write_UINT32(s, cmd->length); /* bitmapDataLength (4 bytes) */
|
||||
const size_t bitmapDataStart = Stream_GetPosition(s);
|
||||
|
||||
@@ -718,7 +726,8 @@ static UINT rdpgfx_write_surface_command(wLog* log, wStream* s, const RDPGFX_SUR
|
||||
havc420 = &(havc444->bitstream[0]); /* avc420EncodedBitstreamInfo (4 bytes) */
|
||||
if (!Stream_EnsureRemainingCapacity(s, 4))
|
||||
return ERROR_INTERNAL_ERROR;
|
||||
Stream_Write_UINT32(s, havc444->cbAvc420EncodedBitstream1 | (havc444->LC << 30UL));
|
||||
Stream_Write_UINT32(s, havc444->cbAvc420EncodedBitstream1 |
|
||||
((uint32_t)havc444->LC << 30UL));
|
||||
/* avc420EncodedBitstream1 */
|
||||
error = rdpgfx_write_h264_avc420(log, s, havc420);
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ static int rdpsnd_alsa_set_hw_params(rdpsndAlsaPlugin* alsa)
|
||||
* Commonly this is (2 * period_size), but some hardware can do 8 periods per buffer.
|
||||
* It is also possible for the buffer size to not be an integer multiple of the period size.
|
||||
*/
|
||||
int interrupts_per_sec_near = 50;
|
||||
const size_t interrupts_per_sec_near = 50;
|
||||
const size_t bytes_per_sec =
|
||||
(1ull * alsa->actual_rate * alsa->aformat.wBitsPerSample / 8 * alsa->actual_channels);
|
||||
alsa->buffer_size = buffer_size_max;
|
||||
@@ -352,12 +352,10 @@ static UINT32 rdpsnd_alsa_get_volume(rdpsndDevicePlugin* device)
|
||||
long volume_max = 0;
|
||||
long volume_left = 0;
|
||||
long volume_right = 0;
|
||||
UINT32 dwVolume = 0;
|
||||
UINT16 dwVolumeLeft = 0;
|
||||
UINT16 dwVolumeRight = 0;
|
||||
|
||||
rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*)device;
|
||||
dwVolumeLeft = ((50 * 0xFFFF) / 100); /* 50% */
|
||||
dwVolumeRight = ((50 * 0xFFFF) / 100); /* 50% */
|
||||
UINT32 dwVolumeLeft = ((50 * 0xFFFF) / 100); /* 50% */
|
||||
UINT32 dwVolumeRight = ((50 * 0xFFFF) / 100); /* 50% */
|
||||
|
||||
if (!rdpsnd_alsa_open_mixer(alsa))
|
||||
return 0;
|
||||
@@ -378,8 +376,7 @@ static UINT32 rdpsnd_alsa_get_volume(rdpsndDevicePlugin* device)
|
||||
}
|
||||
}
|
||||
|
||||
dwVolume = (dwVolumeLeft << 16) | dwVolumeRight;
|
||||
return dwVolume;
|
||||
return (dwVolumeLeft << 16) | dwVolumeRight;
|
||||
}
|
||||
|
||||
static BOOL rdpsnd_alsa_set_volume(rdpsndDevicePlugin* device, UINT32 value)
|
||||
@@ -448,7 +445,7 @@ static UINT rdpsnd_alsa_play(rdpsndDevicePlugin* device, const BYTE* data, size_
|
||||
break;
|
||||
}
|
||||
|
||||
offset += status * frame_size;
|
||||
offset += WINPR_ASSERTING_INT_CAST(size_t, status) * frame_size;
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -292,15 +292,14 @@ static void rdpsnd_oss_free(rdpsndDevicePlugin* device)
|
||||
|
||||
static UINT32 rdpsnd_oss_get_volume(rdpsndDevicePlugin* device)
|
||||
{
|
||||
int vol = 0;
|
||||
UINT32 dwVolume = 0;
|
||||
UINT16 dwVolumeLeft = 0;
|
||||
UINT16 dwVolumeRight = 0;
|
||||
rdpsndOssPlugin* oss = (rdpsndOssPlugin*)device;
|
||||
WINPR_ASSERT(oss);
|
||||
int vol = 0;
|
||||
|
||||
/* On error return 50% volume. */
|
||||
dwVolumeLeft = ((50 * 0xFFFF) / 100); /* 50% */
|
||||
dwVolumeRight = ((50 * 0xFFFF) / 100); /* 50% */
|
||||
dwVolume = ((dwVolumeLeft << 16) | dwVolumeRight);
|
||||
UINT32 dwVolumeLeft = ((50 * 0xFFFF) / 100); /* 50% */
|
||||
UINT32 dwVolumeRight = ((50 * 0xFFFF) / 100); /* 50% */
|
||||
UINT32 dwVolume = ((dwVolumeLeft << 16) | dwVolumeRight);
|
||||
|
||||
if (device == NULL || oss->mixer_handle == -1)
|
||||
return dwVolume;
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <time.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/cast.h>
|
||||
#include <winpr/assert.h>
|
||||
#include <winpr/stream.h>
|
||||
#include <winpr/cmdline.h>
|
||||
@@ -306,7 +307,7 @@ static BOOL rdpsnd_pulse_set_format_spec(rdpsndPulsePlugin* pulse, const AUDIO_F
|
||||
return FALSE;
|
||||
|
||||
sample_spec.rate = format->nSamplesPerSec;
|
||||
sample_spec.channels = format->nChannels;
|
||||
sample_spec.channels = WINPR_ASSERTING_INT_CAST(uint8_t, format->nChannels);
|
||||
|
||||
switch (format->wFormatTag)
|
||||
{
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/assert.h>
|
||||
#include <winpr/cast.h>
|
||||
#include <winpr/print.h>
|
||||
#include <winpr/stream.h>
|
||||
|
||||
@@ -68,7 +69,8 @@ static UINT rdpsnd_server_send_formats(RdpsndServerContext* context)
|
||||
Stream_Write_UINT32(s, 0); /* dwVolume */
|
||||
Stream_Write_UINT32(s, 0); /* dwPitch */
|
||||
Stream_Write_UINT16(s, 0); /* wDGramPort */
|
||||
Stream_Write_UINT16(s, context->num_server_formats); /* wNumberOfFormats */
|
||||
Stream_Write_UINT16(
|
||||
s, WINPR_ASSERTING_INT_CAST(uint16_t, context->num_server_formats)); /* wNumberOfFormats */
|
||||
Stream_Write_UINT8(s, context->block_no); /* cLastBlockConfirmed */
|
||||
Stream_Write_UINT16(s, CHANNEL_VERSION_WIN_MAX); /* wVersion */
|
||||
Stream_Write_UINT8(s, 0); /* bPad */
|
||||
@@ -802,7 +804,6 @@ static UINT rdpsnd_server_set_volume(RdpsndServerContext* context, UINT16 left,
|
||||
*/
|
||||
static UINT rdpsnd_server_close(RdpsndServerContext* context)
|
||||
{
|
||||
size_t pos = 0;
|
||||
BOOL status = 0;
|
||||
ULONG written = 0;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
@@ -836,9 +837,10 @@ static UINT rdpsnd_server_close(RdpsndServerContext* context)
|
||||
Stream_Write_UINT8(s, SNDC_CLOSE);
|
||||
Stream_Write_UINT8(s, 0);
|
||||
Stream_Seek_UINT16(s);
|
||||
pos = Stream_GetPosition(s);
|
||||
const size_t pos = Stream_GetPosition(s);
|
||||
WINPR_ASSERT(pos >= 4);
|
||||
Stream_SetPosition(s, 2);
|
||||
Stream_Write_UINT16(s, pos - 4);
|
||||
Stream_Write_UINT16(s, WINPR_ASSERTING_INT_CAST(uint16_t, pos - 4));
|
||||
Stream_SetPosition(s, pos);
|
||||
|
||||
const size_t len = Stream_GetPosition(s);
|
||||
|
||||
@@ -167,8 +167,7 @@ static UINT remdesk_recv_ctl_version_info_pdu(RemdeskServerContext* context, wSt
|
||||
static UINT remdesk_recv_ctl_remote_control_desktop_pdu(RemdeskServerContext* context, wStream* s,
|
||||
REMDESK_CHANNEL_HEADER* header)
|
||||
{
|
||||
SSIZE_T cchStringW = 0;
|
||||
SSIZE_T cbRaConnectionStringW = 0;
|
||||
size_t cchStringW = 0;
|
||||
REMDESK_CTL_REMOTE_CONTROL_DESKTOP_PDU pdu = { 0 };
|
||||
UINT error = 0;
|
||||
UINT32 msgLength = header->DataLength - 4;
|
||||
@@ -185,7 +184,7 @@ static UINT remdesk_recv_ctl_remote_control_desktop_pdu(RemdeskServerContext* co
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
cchStringW++;
|
||||
cbRaConnectionStringW = cchStringW * 2;
|
||||
const size_t cbRaConnectionStringW = cchStringW * 2;
|
||||
pdu.raConnectionString =
|
||||
ConvertWCharNToUtf8Alloc(raConnectionStringW, cbRaConnectionStringW / sizeof(WCHAR), NULL);
|
||||
if (!pdu.raConnectionString)
|
||||
@@ -208,31 +207,28 @@ static UINT remdesk_recv_ctl_remote_control_desktop_pdu(RemdeskServerContext* co
|
||||
static UINT remdesk_recv_ctl_authenticate_pdu(RemdeskServerContext* context, wStream* s,
|
||||
REMDESK_CHANNEL_HEADER* header)
|
||||
{
|
||||
int cchStringW = 0;
|
||||
UINT32 msgLength = 0;
|
||||
int cbExpertBlobW = 0;
|
||||
size_t cchTmpStringW = 0;
|
||||
const WCHAR* expertBlobW = NULL;
|
||||
int cbRaConnectionStringW = 0;
|
||||
REMDESK_CTL_AUTHENTICATE_PDU pdu = { 0 };
|
||||
msgLength = header->DataLength - 4;
|
||||
UINT32 msgLength = header->DataLength - 4;
|
||||
const WCHAR* pStringW = Stream_ConstPointer(s);
|
||||
const WCHAR* raConnectionStringW = pStringW;
|
||||
|
||||
while ((msgLength > 0) && pStringW[cchStringW])
|
||||
while ((msgLength > 0) && pStringW[cchTmpStringW])
|
||||
{
|
||||
msgLength -= 2;
|
||||
cchStringW++;
|
||||
cchTmpStringW++;
|
||||
}
|
||||
|
||||
if (pStringW[cchStringW] || !cchStringW)
|
||||
if (pStringW[cchTmpStringW] || !cchTmpStringW)
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
cchStringW++;
|
||||
cbRaConnectionStringW = cchStringW * 2;
|
||||
pStringW += cchStringW;
|
||||
cchTmpStringW++;
|
||||
const size_t cbRaConnectionStringW = cchTmpStringW * sizeof(WCHAR);
|
||||
pStringW += cchTmpStringW;
|
||||
expertBlobW = pStringW;
|
||||
cchStringW = 0;
|
||||
|
||||
size_t cchStringW = 0;
|
||||
while ((msgLength > 0) && pStringW[cchStringW])
|
||||
{
|
||||
msgLength -= 2;
|
||||
@@ -243,7 +239,7 @@ static UINT remdesk_recv_ctl_authenticate_pdu(RemdeskServerContext* context, wSt
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
cchStringW++;
|
||||
cbExpertBlobW = cchStringW * 2;
|
||||
const size_t cbExpertBlobW = cchStringW * 2;
|
||||
pdu.raConnectionString =
|
||||
ConvertWCharNToUtf8Alloc(raConnectionStringW, cbRaConnectionStringW / sizeof(WCHAR), NULL);
|
||||
if (!pdu.raConnectionString)
|
||||
@@ -270,7 +266,6 @@ static UINT remdesk_recv_ctl_authenticate_pdu(RemdeskServerContext* context, wSt
|
||||
static UINT remdesk_recv_ctl_verify_password_pdu(RemdeskServerContext* context, wStream* s,
|
||||
REMDESK_CHANNEL_HEADER* header)
|
||||
{
|
||||
SSIZE_T cbExpertBlobW = 0;
|
||||
REMDESK_CTL_VERIFY_PASSWORD_PDU pdu;
|
||||
UINT error = 0;
|
||||
|
||||
@@ -278,7 +273,10 @@ static UINT remdesk_recv_ctl_verify_password_pdu(RemdeskServerContext* context,
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
const WCHAR* expertBlobW = Stream_ConstPointer(s);
|
||||
cbExpertBlobW = header->DataLength - 4;
|
||||
if (header->DataLength < 4)
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
|
||||
const size_t cbExpertBlobW = header->DataLength - 4;
|
||||
|
||||
pdu.expertBlob = ConvertWCharNToUtf8Alloc(expertBlobW, cbExpertBlobW / sizeof(WCHAR), NULL);
|
||||
if (pdu.expertBlob)
|
||||
|
||||
@@ -69,7 +69,7 @@ typedef struct
|
||||
} IRP_THREAD_DATA;
|
||||
|
||||
static void close_terminated_irp_thread_handles(SERIAL_DEVICE* serial, BOOL forceClose);
|
||||
static UINT32 GetLastErrorToIoStatus(SERIAL_DEVICE* serial)
|
||||
static INT32 GetLastErrorToIoStatus(SERIAL_DEVICE* serial)
|
||||
{
|
||||
/* http://msdn.microsoft.com/en-us/library/ff547466%28v=vs.85%29.aspx#generic_status_values_for_serial_device_control_requests
|
||||
*/
|
||||
@@ -899,7 +899,7 @@ FREERDP_ENTRY_POINT(
|
||||
}
|
||||
|
||||
for (size_t i = 0; i <= len; i++)
|
||||
Stream_Write_UINT8(serial->device.data, name[i] < 0 ? '_' : name[i]);
|
||||
Stream_Write_INT8(serial->device.data, name[i] < 0 ? '_' : name[i]);
|
||||
|
||||
if (driver != NULL)
|
||||
{
|
||||
|
||||
@@ -155,7 +155,7 @@ static DWORD WINAPI smartcard_context_thread(LPVOID arg)
|
||||
if (status && smartcard->rdpcontext)
|
||||
setChannelError(smartcard->rdpcontext, error, "smartcard_context_thread reported an error");
|
||||
|
||||
ExitThread(status);
|
||||
ExitThread((uint32_t)status);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -387,7 +387,7 @@ static UINT smartcard_process_irp(SMARTCARD_DEVICE* smartcard, IRP* irp, BOOL* h
|
||||
UINT error = 0;
|
||||
|
||||
smartcard_operation_free(&element->operation, TRUE);
|
||||
irp->IoStatus = (UINT32)STATUS_UNSUCCESSFUL;
|
||||
irp->IoStatus = STATUS_UNSUCCESSFUL;
|
||||
|
||||
if ((error = smartcard_complete_irp(smartcard, irp, handled)))
|
||||
{
|
||||
@@ -505,7 +505,7 @@ static UINT smartcard_process_irp(SMARTCARD_DEVICE* smartcard, IRP* irp, BOOL* h
|
||||
UINT ustatus = 0;
|
||||
WLog_ERR(TAG, "Unexpected SmartCard IRP: MajorFunction %s, MinorFunction: 0x%08" PRIX32 "",
|
||||
rdpdr_irp_string(irp->MajorFunction), irp->MinorFunction);
|
||||
irp->IoStatus = (UINT32)STATUS_NOT_SUPPORTED;
|
||||
irp->IoStatus = STATUS_NOT_SUPPORTED;
|
||||
|
||||
if ((ustatus = smartcard_complete_irp(smartcard, irp, handled)))
|
||||
{
|
||||
|
||||
@@ -187,6 +187,8 @@ static UINT telemetry_process_message(telemetry_server* telemetry)
|
||||
|
||||
Stream_Read_UINT8(s, MessageId);
|
||||
Stream_Read_UINT8(s, Length);
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, Length))
|
||||
return ERROR_NO_DATA;
|
||||
|
||||
switch (MessageId)
|
||||
{
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <winpr/sysinfo.h>
|
||||
#include <winpr/cast.h>
|
||||
|
||||
#include <urbdrc_helpers.h>
|
||||
|
||||
@@ -419,7 +420,7 @@ static UINT urb_select_configuration(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* c
|
||||
UINT32 usbd_status = 0;
|
||||
BYTE ConfigurationDescriptorIsValid = 0;
|
||||
wStream* out = NULL;
|
||||
int MsOutSize = 0;
|
||||
size_t MsOutSize = 0;
|
||||
URBDRC_PLUGIN* urbdrc = NULL;
|
||||
const BOOL noAck = (RequestField & 0x80000000U) != 0;
|
||||
const UINT32 RequestId = RequestField & 0x7FFFFFFF;
|
||||
@@ -468,11 +469,11 @@ static UINT urb_select_configuration(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* c
|
||||
}
|
||||
|
||||
if (MsConfig)
|
||||
MsOutSize = MsConfig->MsOutSize;
|
||||
MsOutSize = WINPR_ASSERTING_INT_CAST(size_t, MsConfig->MsOutSize);
|
||||
|
||||
if (MsOutSize > 0)
|
||||
{
|
||||
if ((size_t)MsOutSize > SIZE_MAX - 36)
|
||||
if (MsOutSize > SIZE_MAX - 36)
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
out_size = 36 + MsOutSize;
|
||||
@@ -495,7 +496,7 @@ static UINT urb_select_configuration(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* c
|
||||
/** CbTsUrbResult */
|
||||
Stream_Write_UINT32(out, 8U + (UINT32)MsOutSize);
|
||||
/** TS_URB_RESULT_HEADER Size*/
|
||||
Stream_Write_UINT16(out, 8U + (UINT32)MsOutSize);
|
||||
Stream_Write_UINT16(out, WINPR_ASSERTING_INT_CAST(uint16_t, 8U + (UINT32)MsOutSize));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -601,7 +602,7 @@ static UINT urb_select_interface(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* callb
|
||||
Stream_Write_UINT32(out, RequestId); /** RequestId */
|
||||
Stream_Write_UINT32(out, 8 + interface_size); /** CbTsUrbResult */
|
||||
/** TS_URB_RESULT_HEADER */
|
||||
Stream_Write_UINT16(out, 8 + interface_size); /** Size */
|
||||
Stream_Write_UINT16(out, WINPR_ASSERTING_INT_CAST(uint16_t, 8 + interface_size)); /** Size */
|
||||
/** Padding, MUST be ignored upon receipt */
|
||||
Stream_Write_UINT16(out, TS_URB_SELECT_INTERFACE);
|
||||
Stream_Write_UINT32(out, USBD_STATUS_SUCCESS); /** UsbdStatus */
|
||||
@@ -767,10 +768,12 @@ static UINT urb_bulk_or_interrupt_transfer(IUDEVICE* pdev, GENERIC_CHANNEL_CALLB
|
||||
}
|
||||
|
||||
/** process TS_URB_BULK_OR_INTERRUPT_TRANSFER */
|
||||
return pdev->bulk_or_interrupt_transfer(
|
||||
const int rc = pdev->bulk_or_interrupt_transfer(
|
||||
pdev, callback, MessageId, RequestId, EndpointAddress, TransferFlags, noAck,
|
||||
OutputBufferSize, (transferDir == USBD_TRANSFER_DIRECTION_OUT) ? Stream_Pointer(s) : NULL,
|
||||
urb_bulk_transfer_cb, 10000);
|
||||
|
||||
return (uint32_t)rc;
|
||||
}
|
||||
|
||||
static void urb_isoch_transfer_cb(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* callback, wStream* out,
|
||||
@@ -794,7 +797,7 @@ static void urb_isoch_transfer_cb(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* call
|
||||
Stream_Write_UINT32(out, RequestId); /** RequestId */
|
||||
Stream_Write_UINT32(out, 20 + packetSize); /** CbTsUrbResult */
|
||||
/** TsUrbResult TS_URB_RESULT_HEADER */
|
||||
Stream_Write_UINT16(out, 20 + packetSize); /** Size */
|
||||
Stream_Write_UINT16(out, WINPR_ASSERTING_INT_CAST(uint16_t, 20 + packetSize)); /** Size */
|
||||
Stream_Write_UINT16(out, 0); /* Padding */
|
||||
Stream_Write_UINT32(out, status); /** UsbdStatus */
|
||||
Stream_Write_UINT32(out, StartFrame); /** StartFrame */
|
||||
@@ -948,8 +951,8 @@ static UINT urb_control_descriptor_request(IUDEVICE* pdev, GENERIC_CHANNEL_CALLB
|
||||
/** process get usb device descriptor */
|
||||
if (!pdev->control_transfer(pdev, RequestId, 0, 0, bmRequestType,
|
||||
0x06, /* REQUEST_GET_DESCRIPTOR */
|
||||
(desc_type << 8) | desc_index, langId, &usbd_status,
|
||||
&OutputBufferSize, Stream_Pointer(out), 1000))
|
||||
WINPR_ASSERTING_INT_CAST(UINT16, ((desc_type << 8) | desc_index)),
|
||||
langId, &usbd_status, &OutputBufferSize, Stream_Pointer(out), 1000))
|
||||
{
|
||||
WLog_Print(urbdrc->log, WLOG_ERROR, "get_descriptor failed");
|
||||
Stream_Free(out, TRUE);
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <winpr/assert.h>
|
||||
#include <winpr/cast.h>
|
||||
#include <winpr/wtypes.h>
|
||||
#include <winpr/sysinfo.h>
|
||||
#include <winpr/collections.h>
|
||||
@@ -265,7 +267,8 @@ static void LIBUSB_CALL func_iso_callback(struct libusb_transfer* transfer)
|
||||
Stream_SetPosition(user_data->data,
|
||||
40); /* TS_URB_ISOCH_TRANSFER_RESULT IsoPacket offset */
|
||||
|
||||
for (int i = 0; i < transfer->num_iso_packets; i++)
|
||||
for (uint32_t i = 0; i < WINPR_ASSERTING_INT_CAST(uint32_t, transfer->num_iso_packets);
|
||||
i++)
|
||||
{
|
||||
const UINT32 act_len = transfer->iso_packet_desc[i].actual_length;
|
||||
Stream_Write_UINT32(user_data->data, index);
|
||||
@@ -307,8 +310,8 @@ static void LIBUSB_CALL func_iso_callback(struct libusb_transfer* transfer)
|
||||
const UINT32 RequestID = streamID & INTERFACE_ID_MASK;
|
||||
user_data->cb(user_data->idev, user_data->callback, user_data->data,
|
||||
InterfaceId, user_data->noack, user_data->MessageId, RequestID,
|
||||
transfer->num_iso_packets, transfer->status,
|
||||
user_data->StartFrame, user_data->ErrorCount,
|
||||
WINPR_ASSERTING_INT_CAST(uint32_t, transfer->num_iso_packets),
|
||||
transfer->status, user_data->StartFrame, user_data->ErrorCount,
|
||||
user_data->OutputBufferSize);
|
||||
user_data->data = NULL;
|
||||
}
|
||||
@@ -369,9 +372,10 @@ static void LIBUSB_CALL func_bulk_transfer_cb(struct libusb_transfer* transfer)
|
||||
const UINT32 RequestID = streamID & INTERFACE_ID_MASK;
|
||||
|
||||
user_data->cb(user_data->idev, user_data->callback, user_data->data, InterfaceId,
|
||||
user_data->noack, user_data->MessageId, RequestID, transfer->num_iso_packets,
|
||||
user_data->noack, user_data->MessageId, RequestID,
|
||||
WINPR_ASSERTING_INT_CAST(uint32_t, transfer->num_iso_packets),
|
||||
transfer->status, user_data->StartFrame, user_data->ErrorCount,
|
||||
transfer->actual_length);
|
||||
WINPR_ASSERTING_INT_CAST(uint32_t, transfer->actual_length));
|
||||
user_data->data = NULL;
|
||||
ArrayList_Remove(list, transfer);
|
||||
}
|
||||
@@ -655,8 +659,9 @@ libusb_udev_complete_msconfig_setup(IUDEVICE* idev, MSUSB_CONFIG_DESCRIPTOR* MsC
|
||||
* || bus_number | dev_number | bConfigurationValue ||
|
||||
* ---------------------------------------------------------------
|
||||
* ***********************/
|
||||
MsConfig->ConfigurationHandle =
|
||||
MsConfig->bConfigurationValue | (pdev->bus_number << 24) | (pdev->dev_number << 16);
|
||||
MsConfig->ConfigurationHandle = (uint32_t)MsConfig->bConfigurationValue |
|
||||
((uint32_t)pdev->bus_number << 24) |
|
||||
(((uint32_t)pdev->dev_number << 16) & 0xFF0000);
|
||||
MsInterfaces = MsConfig->MsInterfaces;
|
||||
|
||||
for (UINT32 inum = 0; inum < MsConfig->NumInterfaces; inum++)
|
||||
@@ -672,10 +677,12 @@ libusb_udev_complete_msconfig_setup(IUDEVICE* idev, MSUSB_CONFIG_DESCRIPTOR* MsC
|
||||
* || bus_number | dev_number | altsetting | interfaceNum ||
|
||||
* ---------------------------------------------------------------
|
||||
* ***********************/
|
||||
MsInterface->InterfaceHandle = LibusbAltsetting->bInterfaceNumber |
|
||||
(LibusbAltsetting->bAlternateSetting << 8) |
|
||||
(pdev->dev_number << 16) | (pdev->bus_number << 24);
|
||||
MsInterface->Length = 16 + (MsInterface->NumberOfPipes * 20);
|
||||
MsInterface->InterfaceHandle =
|
||||
WINPR_ASSERTING_INT_CAST(UINT32, (LibusbAltsetting->bInterfaceNumber |
|
||||
(LibusbAltsetting->bAlternateSetting << 8) |
|
||||
(pdev->dev_number << 16) | (pdev->bus_number << 24)));
|
||||
const size_t len = 16 + (MsInterface->NumberOfPipes * 20);
|
||||
MsInterface->Length = WINPR_ASSERTING_INT_CAST(UINT16, len);
|
||||
MsInterface->bInterfaceClass = LibusbAltsetting->bInterfaceClass;
|
||||
MsInterface->bInterfaceSubClass = LibusbAltsetting->bInterfaceSubClass;
|
||||
MsInterface->bInterfaceProtocol = LibusbAltsetting->bInterfaceProtocol;
|
||||
@@ -695,10 +702,11 @@ libusb_udev_complete_msconfig_setup(IUDEVICE* idev, MSUSB_CONFIG_DESCRIPTOR* MsC
|
||||
* || bus_number | dev_number | bEndpointAddress ||
|
||||
* ---------------------------------------------------------------
|
||||
* ***********************/
|
||||
MsPipe->PipeHandle = LibusbEndpoint->bEndpointAddress | (pdev->dev_number << 16) |
|
||||
(pdev->bus_number << 24);
|
||||
MsPipe->PipeHandle = LibusbEndpoint->bEndpointAddress |
|
||||
(((uint32_t)pdev->dev_number << 16) & 0xFF0000) |
|
||||
(((uint32_t)pdev->bus_number << 24) & 0xFF000000);
|
||||
/* count endpoint max packet size */
|
||||
int max = LibusbEndpoint->wMaxPacketSize & 0x07ff;
|
||||
unsigned max = LibusbEndpoint->wMaxPacketSize & 0x07ff;
|
||||
BYTE attr = LibusbEndpoint->bmAttributes;
|
||||
|
||||
if ((attr & 0x3) == 1 || (attr & 0x3) == 3)
|
||||
@@ -706,7 +714,7 @@ libusb_udev_complete_msconfig_setup(IUDEVICE* idev, MSUSB_CONFIG_DESCRIPTOR* MsC
|
||||
max *= (1 + ((LibusbEndpoint->wMaxPacketSize >> 11) & 3));
|
||||
}
|
||||
|
||||
MsPipe->MaximumPacketSize = max;
|
||||
MsPipe->MaximumPacketSize = WINPR_ASSERTING_INT_CAST(uint16_t, max);
|
||||
MsPipe->bEndpointAddress = LibusbEndpoint->bEndpointAddress;
|
||||
MsPipe->bInterval = LibusbEndpoint->bInterval;
|
||||
MsPipe->PipeType = attr & 0x3;
|
||||
@@ -714,7 +722,7 @@ libusb_udev_complete_msconfig_setup(IUDEVICE* idev, MSUSB_CONFIG_DESCRIPTOR* MsC
|
||||
}
|
||||
}
|
||||
|
||||
MsConfig->MsOutSize = MsOutSize;
|
||||
MsConfig->MsOutSize = WINPR_ASSERTING_INT_CAST(int, MsOutSize);
|
||||
MsConfig->InitCompleted = 1;
|
||||
|
||||
/* replace device's MsConfig */
|
||||
@@ -756,7 +764,8 @@ static int libusb_udev_select_configuration(IUDEVICE* idev, UINT32 bConfiguratio
|
||||
if (bConfigurationValue == 0)
|
||||
ret = libusb_set_configuration(libusb_handle, -1);
|
||||
else
|
||||
ret = libusb_set_configuration(libusb_handle, bConfigurationValue);
|
||||
ret = libusb_set_configuration(libusb_handle,
|
||||
WINPR_ASSERTING_INT_CAST(int, bConfigurationValue));
|
||||
|
||||
if (log_libusb_result(urbdrc->log, WLOG_ERROR, "libusb_set_configuration", ret))
|
||||
{
|
||||
@@ -1259,9 +1268,10 @@ static int libusb_udev_isoch_transfer(IUDEVICE* idev, GENERIC_CHANNEL_CALLBACK*
|
||||
}
|
||||
|
||||
/** process URB_FUNCTION_IOSCH_TRANSFER */
|
||||
libusb_fill_iso_transfer(iso_transfer, pdev->libusb_handle, EndpointAddress,
|
||||
Stream_Pointer(user_data->data), BufferSize, NumberOfPackets,
|
||||
func_iso_callback, user_data, Timeout);
|
||||
libusb_fill_iso_transfer(
|
||||
iso_transfer, pdev->libusb_handle, WINPR_ASSERTING_INT_CAST(uint8_t, EndpointAddress),
|
||||
Stream_Pointer(user_data->data), WINPR_ASSERTING_INT_CAST(int, BufferSize),
|
||||
WINPR_ASSERTING_INT_CAST(int, NumberOfPackets), func_iso_callback, user_data, Timeout);
|
||||
set_stream_id_for_buffer(iso_transfer, streamID);
|
||||
libusb_set_iso_packet_lengths(iso_transfer, iso_packet_size);
|
||||
|
||||
@@ -1362,16 +1372,18 @@ static int libusb_udev_bulk_or_interrupt_transfer(IUDEVICE* idev,
|
||||
{
|
||||
case BULK_TRANSFER:
|
||||
/** Bulk Transfer */
|
||||
libusb_fill_bulk_transfer(transfer, pdev->libusb_handle, EndpointAddress,
|
||||
Stream_Pointer(user_data->data), BufferSize,
|
||||
func_bulk_transfer_cb, user_data, Timeout);
|
||||
libusb_fill_bulk_transfer(
|
||||
transfer, pdev->libusb_handle, WINPR_ASSERTING_INT_CAST(uint8_t, EndpointAddress),
|
||||
Stream_Pointer(user_data->data), WINPR_ASSERTING_INT_CAST(int, BufferSize),
|
||||
func_bulk_transfer_cb, user_data, Timeout);
|
||||
break;
|
||||
|
||||
case INTERRUPT_TRANSFER:
|
||||
/** Interrupt Transfer */
|
||||
libusb_fill_interrupt_transfer(transfer, pdev->libusb_handle, EndpointAddress,
|
||||
Stream_Pointer(user_data->data), BufferSize,
|
||||
func_bulk_transfer_cb, user_data, Timeout);
|
||||
libusb_fill_interrupt_transfer(
|
||||
transfer, pdev->libusb_handle, WINPR_ASSERTING_INT_CAST(uint8_t, EndpointAddress),
|
||||
Stream_Pointer(user_data->data), WINPR_ASSERTING_INT_CAST(int, BufferSize),
|
||||
func_bulk_transfer_cb, user_data, Timeout);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -624,7 +624,7 @@ static BOOL udevman_initialize(IUDEVMAN* idevman, UINT32 channelId)
|
||||
if (!udevman)
|
||||
return FALSE;
|
||||
|
||||
idevman->status &= ~URBDRC_DEVICE_CHANNEL_CLOSED;
|
||||
idevman->status &= (uint32_t)~URBDRC_DEVICE_CHANNEL_CLOSED;
|
||||
idevman->controlChannelId = channelId;
|
||||
return TRUE;
|
||||
}
|
||||
@@ -787,18 +787,20 @@ static UINT urbdrc_udevman_parse_addin_args(UDEVMAN* udevman, const ADDIN_ARGV*
|
||||
|
||||
static UINT udevman_listener_created_callback(IUDEVMAN* iudevman)
|
||||
{
|
||||
UINT status = 0;
|
||||
UDEVMAN* udevman = (UDEVMAN*)iudevman;
|
||||
WINPR_ASSERT(udevman);
|
||||
|
||||
if (udevman->devices_vid_pid)
|
||||
{
|
||||
status = urbdrc_udevman_register_devices(udevman, udevman->devices_vid_pid, FALSE);
|
||||
if (status != CHANNEL_RC_OK)
|
||||
return status;
|
||||
if (!urbdrc_udevman_register_devices(udevman, udevman->devices_vid_pid, FALSE))
|
||||
return ERROR_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
if (udevman->devices_addr)
|
||||
return urbdrc_udevman_register_devices(udevman, udevman->devices_addr, TRUE);
|
||||
{
|
||||
if (!urbdrc_udevman_register_devices(udevman, udevman->devices_addr, TRUE))
|
||||
return ERROR_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
return CHANNEL_RC_OK;
|
||||
}
|
||||
@@ -898,7 +900,6 @@ FREERDP_ENTRY_POINT(UINT VCAPITYPE libusb_freerdp_urbdrc_client_subsystem_entry(
|
||||
PFREERDP_URBDRC_SERVICE_ENTRY_POINTS pEntryPoints))
|
||||
{
|
||||
wObject* obj = NULL;
|
||||
UINT rc = 0;
|
||||
UINT status = 0;
|
||||
UDEVMAN* udevman = NULL;
|
||||
const ADDIN_ARGV* args = pEntryPoints->args;
|
||||
@@ -916,9 +917,9 @@ FREERDP_ENTRY_POINT(UINT VCAPITYPE libusb_freerdp_urbdrc_client_subsystem_entry(
|
||||
|
||||
udevman->next_device_id = BASE_USBDEVICE_NUM;
|
||||
udevman->iface.plugin = pEntryPoints->plugin;
|
||||
rc = libusb_init(&udevman->context);
|
||||
const int res = libusb_init(&udevman->context);
|
||||
|
||||
if (rc != LIBUSB_SUCCESS)
|
||||
if (res != LIBUSB_SUCCESS)
|
||||
goto fail;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
@@ -360,7 +360,7 @@ static UINT urdbrc_send_usb_device_add(GENERIC_CHANNEL_CALLBACK* callback, IUDEV
|
||||
Stream_Write_UINT32(out, 2); /* UsbBusInterfaceVersion, 0 ,1 or 2 */ // TODO: Get from libusb
|
||||
Stream_Write_UINT32(out, 0x600); /* USBDI_Version, 0x500 or 0x600 */ // TODO: Get from libusb
|
||||
/* Supported_USB_Version, 0x110,0x110 or 0x200(usb2.0) */
|
||||
bcdUSB = pdev->query_device_descriptor(pdev, BCD_USB);
|
||||
bcdUSB = WINPR_ASSERTING_INT_CAST(uint32_t, pdev->query_device_descriptor(pdev, BCD_USB));
|
||||
Stream_Write_UINT32(out, bcdUSB);
|
||||
Stream_Write_UINT32(out, 0x00000000); /* HcdCapabilities, MUST always be zero */
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/assert.h>
|
||||
#include <winpr/cast.h>
|
||||
#include <winpr/synch.h>
|
||||
#include <winpr/print.h>
|
||||
#include <winpr/stream.h>
|
||||
@@ -410,8 +411,10 @@ static BOOL video_onMappedGeometryUpdate(MAPPED_GEOMETRY* geometry)
|
||||
|
||||
r->x, r->y, r->width, r->height);
|
||||
|
||||
presentation->surface->x = geometry->topLevelLeft + geometry->left;
|
||||
presentation->surface->y = geometry->topLevelTop + geometry->top;
|
||||
presentation->surface->x =
|
||||
WINPR_ASSERTING_INT_CAST(uint32_t, geometry->topLevelLeft + geometry->left);
|
||||
presentation->surface->y =
|
||||
WINPR_ASSERTING_INT_CAST(uint32_t, geometry->topLevelTop + geometry->top);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -480,8 +483,10 @@ static UINT video_PresentationRequest(VideoClientContext* video,
|
||||
|
||||
WLog_DBG(TAG, "creating presentation 0x%x", req->PresentationId);
|
||||
priv->currentPresentation = PresentationContext_new(
|
||||
video, req->PresentationId, geom->topLevelLeft + geom->left,
|
||||
geom->topLevelTop + geom->top, req->SourceWidth, req->SourceHeight);
|
||||
video, req->PresentationId,
|
||||
WINPR_ASSERTING_INT_CAST(uint32_t, geom->topLevelLeft + geom->left),
|
||||
WINPR_ASSERTING_INT_CAST(uint32_t, geom->topLevelTop + geom->top), req->SourceWidth,
|
||||
req->SourceHeight);
|
||||
if (!priv->currentPresentation)
|
||||
{
|
||||
WLog_ERR(TAG, "unable to create presentation video");
|
||||
@@ -845,7 +850,8 @@ static UINT video_VideoData(VideoClientContext* context, const TSMM_VIDEO_DATA*
|
||||
UINT64 timeAfterH264 = 0;
|
||||
MAPPED_GEOMETRY* geom = presentation->geometry;
|
||||
|
||||
const RECTANGLE_16 rect = { 0, 0, surface->alignedWidth, surface->alignedHeight };
|
||||
const RECTANGLE_16 rect = { 0, 0, WINPR_ASSERTING_INT_CAST(UINT16, surface->alignedWidth),
|
||||
WINPR_ASSERTING_INT_CAST(UINT16, surface->alignedHeight) };
|
||||
Stream_SealLength(presentation->currentSample);
|
||||
Stream_SetPosition(presentation->currentSample, 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user