[channels,location] fix Wimplicit-int-enum-cast warnings

This commit is contained in:
Armin Novak
2026-01-14 10:13:17 +01:00
parent 8cd987dacd
commit a30cbe2a94
2 changed files with 44 additions and 27 deletions

View File

@@ -358,14 +358,18 @@ static UINT location_send(LocationClientContext* context, LOCATION_PDUTYPE type,
res = ERROR_INVALID_PARAMETER;
else
{
RDPLOCATION_BASE_LOCATION3D_PDU pdu = { 0 };
LOCATIONSOURCE source = LOCATIONSOURCE_IP;
double speed = FP_NAN;
double heading = FP_NAN;
double horizontalAccuracy = FP_NAN;
pdu.latitude = va_arg(ap, double);
pdu.longitude = va_arg(ap, double);
pdu.altitude = va_arg(ap, INT32);
RDPLOCATION_BASE_LOCATION3D_PDU pdu = { .latitude = va_arg(ap, double),
.longitude = va_arg(ap, double),
.altitude = va_arg(ap, INT32),
.speed = NULL,
.heading = NULL,
.horizontalAccuracy = NULL,
.source = NULL };
if ((count > 3) && (callback->clientVersion >= RDPLOCATION_PROTOCOL_VERSION_200))
{
speed = va_arg(ap, double);
@@ -385,10 +389,10 @@ static UINT location_send(LocationClientContext* context, LOCATION_PDUTYPE type,
res = ERROR_INVALID_PARAMETER;
else
{
RDPLOCATION_LOCATION2D_DELTA_PDU pdu = { 0 };
pdu.latitudeDelta = va_arg(ap, double);
pdu.longitudeDelta = va_arg(ap, double);
RDPLOCATION_LOCATION2D_DELTA_PDU pdu = { .latitudeDelta = va_arg(ap, double),
.longitudeDelta = va_arg(ap, double),
.speedDelta = NULL,
.headingDelta = NULL };
double speedDelta = FP_NAN;
double headingDelta = FP_NAN;
@@ -407,13 +411,14 @@ static UINT location_send(LocationClientContext* context, LOCATION_PDUTYPE type,
res = ERROR_INVALID_PARAMETER;
else
{
RDPLOCATION_LOCATION3D_DELTA_PDU pdu = { 0 };
double speedDelta = FP_NAN;
double headingDelta = FP_NAN;
pdu.latitudeDelta = va_arg(ap, double);
pdu.longitudeDelta = va_arg(ap, double);
pdu.altitudeDelta = va_arg(ap, INT32);
RDPLOCATION_LOCATION3D_DELTA_PDU pdu = { .latitudeDelta = va_arg(ap, double),
.longitudeDelta = va_arg(ap, double),
.altitudeDelta = va_arg(ap, INT32),
pdu.speedDelta = NULL,
.headingDelta = NULL };
if ((count > 3) && (callback->clientVersion >= RDPLOCATION_PROTOCOL_VERSION_200))
{
speedDelta = va_arg(ap, double);

View File

@@ -17,6 +17,8 @@
* limitations under the License.
*/
#include <math.h>
#include <freerdp/config.h>
#include <freerdp/freerdp.h>
@@ -125,14 +127,15 @@ static UINT location_server_open_channel(location_server* location)
static UINT location_server_recv_client_ready(LocationServerContext* context, wStream* s,
const RDPLOCATION_HEADER* header)
{
RDPLOCATION_CLIENT_READY_PDU pdu = { 0 };
UINT error = CHANNEL_RC_OK;
WINPR_ASSERT(context);
WINPR_ASSERT(s);
WINPR_ASSERT(header);
pdu.header = *header;
RDPLOCATION_CLIENT_READY_PDU pdu = { .header = *header,
.protocolVersion = RDPLOCATION_PROTOCOL_VERSION_100,
.flags = 0 };
if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
return ERROR_NO_DATA;
@@ -170,7 +173,6 @@ static UINT location_server_recv_client_ready(LocationServerContext* context, wS
static UINT location_server_recv_base_location3d(LocationServerContext* context, wStream* s,
const RDPLOCATION_HEADER* header)
{
RDPLOCATION_BASE_LOCATION3D_PDU pdu = { 0 };
UINT error = CHANNEL_RC_OK;
double speed = 0.0;
double heading = 0.0;
@@ -181,7 +183,14 @@ static UINT location_server_recv_base_location3d(LocationServerContext* context,
WINPR_ASSERT(s);
WINPR_ASSERT(header);
pdu.header = *header;
RDPLOCATION_BASE_LOCATION3D_PDU pdu = { .header = *header,
.latitude = FP_NAN,
.longitude = FP_NAN,
.altitude = 0,
.speed = NULL,
.heading = NULL,
.horizontalAccuracy = NULL,
.source = NULL };
if (!freerdp_read_four_byte_float(s, &pdu.latitude) ||
!freerdp_read_four_byte_float(s, &pdu.longitude) ||
@@ -228,7 +237,6 @@ static UINT location_server_recv_base_location3d(LocationServerContext* context,
static UINT location_server_recv_location2d_delta(LocationServerContext* context, wStream* s,
const RDPLOCATION_HEADER* header)
{
RDPLOCATION_LOCATION2D_DELTA_PDU pdu = { 0 };
UINT error = CHANNEL_RC_OK;
double speedDelta = 0.0;
double headingDelta = 0.0;
@@ -237,7 +245,11 @@ static UINT location_server_recv_location2d_delta(LocationServerContext* context
WINPR_ASSERT(s);
WINPR_ASSERT(header);
pdu.header = *header;
RDPLOCATION_LOCATION2D_DELTA_PDU pdu = { .header = *header,
.latitudeDelta = FP_NAN,
.longitudeDelta = FP_NAN,
.speedDelta = NULL,
.headingDelta = NULL };
if (!freerdp_read_four_byte_float(s, &pdu.latitudeDelta) ||
!freerdp_read_four_byte_float(s, &pdu.longitudeDelta))
@@ -263,7 +275,6 @@ static UINT location_server_recv_location2d_delta(LocationServerContext* context
static UINT location_server_recv_location3d_delta(LocationServerContext* context, wStream* s,
const RDPLOCATION_HEADER* header)
{
RDPLOCATION_LOCATION3D_DELTA_PDU pdu = { 0 };
UINT error = CHANNEL_RC_OK;
double speedDelta = 0.0;
double headingDelta = 0.0;
@@ -272,7 +283,11 @@ static UINT location_server_recv_location3d_delta(LocationServerContext* context
WINPR_ASSERT(s);
WINPR_ASSERT(header);
pdu.header = *header;
RDPLOCATION_LOCATION3D_DELTA_PDU pdu = { .header = *header,
.latitudeDelta = FP_NAN,
.longitudeDelta = FP_NAN,
.speedDelta = NULL,
.headingDelta = NULL };
if (!freerdp_read_four_byte_float(s, &pdu.latitudeDelta) ||
!freerdp_read_four_byte_float(s, &pdu.longitudeDelta) ||
@@ -298,20 +313,17 @@ static UINT location_server_recv_location3d_delta(LocationServerContext* context
static UINT location_process_message(location_server* location)
{
BOOL rc = 0;
UINT error = ERROR_INTERNAL_ERROR;
ULONG BytesReturned = 0;
RDPLOCATION_HEADER header = { 0 };
wStream* s = NULL;
WINPR_ASSERT(location);
WINPR_ASSERT(location->location_channel);
s = location->buffer;
wStream* s = location->buffer;
WINPR_ASSERT(s);
Stream_SetPosition(s, 0);
rc = WTSVirtualChannelRead(location->location_channel, 0, NULL, 0, &BytesReturned);
const BOOL rc = WTSVirtualChannelRead(location->location_channel, 0, NULL, 0, &BytesReturned);
if (!rc)
goto out;
@@ -341,8 +353,8 @@ static UINT location_process_message(location_server* location)
{
const UINT16 pduType = Stream_Get_UINT16(s);
header.pduType = (LOCATION_PDUTYPE)pduType;
header.pduLength = Stream_Get_UINT32(s);
const RDPLOCATION_HEADER header = { .pduType = (LOCATION_PDUTYPE)pduType,
.pduLength = Stream_Get_UINT32(s) };
switch (pduType)
{