Fixed compilation warnings

This commit is contained in:
Armin Novak 2021-06-16 12:59:25 +02:00 committed by akallabeth
parent 8f7b3258ef
commit 1fd72ded43
14 changed files with 75 additions and 51 deletions

View File

@ -27,6 +27,7 @@
#include <signal.h>
#include <winpr/crt.h>
#include <winpr/assert.h>
#include <winpr/ssl.h>
#include <winpr/synch.h>
#include <winpr/file.h>
@ -78,8 +79,8 @@ static BOOL test_peer_context_new(freerdp_peer* client, rdpContext* ctx)
if (!(context->s = Stream_New(NULL, 65536)))
goto fail_stream_new;
context->icon_x = -1;
context->icon_y = -1;
context->icon_x = UINT32_MAX;
context->icon_y = UINT32_MAX;
context->vcm = WTSOpenServerA((LPSTR)client->context);
if (!context->vcm || context->vcm == INVALID_HANDLE_VALUE)
@ -177,20 +178,31 @@ static BOOL test_peer_draw_background(freerdp_peer* client)
wStream* s;
RFX_RECT rect;
BYTE* rgb_data;
const rdpSettings* settings;
rdpUpdate* update = client->update;
SURFACE_BITS_COMMAND cmd = { 0 };
testPeerContext* context = (testPeerContext*)client->context;
testPeerContext* context;
BOOL ret = FALSE;
if (!client->settings->RemoteFxCodec && !client->settings->NSCodec)
WINPR_ASSERT(client);
context = (testPeerContext*)client->context;
WINPR_ASSERT(context);
settings = client->settings;
WINPR_ASSERT(settings);
if (!settings->RemoteFxCodec && !client->settings->NSCodec)
return FALSE;
WINPR_ASSERT(settings->DesktopWidth <= UINT16_MAX);
WINPR_ASSERT(settings->DesktopHeight <= UINT16_MAX);
s = test_peer_stream_init(context);
rect.x = 0;
rect.y = 0;
rect.width = client->settings->DesktopWidth;
rect.height = client->settings->DesktopHeight;
size = rect.width * rect.height * 3;
rect.width = (UINT16)settings->DesktopWidth;
rect.height = (UINT16)settings->DesktopHeight;
size = rect.width * rect.height * 3ULL;
if (!(rgb_data = malloc(size)))
{
@ -200,7 +212,7 @@ static BOOL test_peer_draw_background(freerdp_peer* client)
memset(rgb_data, 0xA0, size);
if (client->settings->RemoteFxCodec)
if (settings->RemoteFxCodec)
{
WLog_DBG(TAG, "Using RemoteFX codec");
if (!rfx_compose_message(context->rfx_context, s, &rect, 1, rgb_data, rect.width,
@ -209,15 +221,17 @@ static BOOL test_peer_draw_background(freerdp_peer* client)
goto out;
}
cmd.bmp.codecID = client->settings->RemoteFxCodecId;
WINPR_ASSERT(settings->RemoteFxCodecId <= UINT16_MAX);
cmd.bmp.codecID = (UINT16)settings->RemoteFxCodecId;
cmd.cmdType = CMDTYPE_STREAM_SURFACE_BITS;
}
else
{
WLog_DBG(TAG, "Using NSCodec");
nsc_compose_message(context->nsc_context, s, rgb_data, rect.width, rect.height,
rect.width * 3);
cmd.bmp.codecID = client->settings->NSCodecId;
rect.width * 3ULL);
WINPR_ASSERT(settings->NSCodecId <= UINT16_MAX);
cmd.bmp.codecID = (UINT16)settings->NSCodecId;
cmd.cmdType = CMDTYPE_SET_SURFACE_BITS;
}
@ -229,7 +243,8 @@ static BOOL test_peer_draw_background(freerdp_peer* client)
cmd.bmp.flags = 0;
cmd.bmp.width = rect.width;
cmd.bmp.height = rect.height;
cmd.bmp.bitmapDataLength = Stream_GetPosition(s);
WINPR_ASSERT(Stream_GetPosition(s) <= UINT32_MAX);
cmd.bmp.bitmapDataLength = (UINT32)Stream_GetPosition(s);
cmd.bmp.bitmapData = Stream_Buffer(s);
test_peer_begin_frame(client);
update->SurfaceBits(update->context, &cmd);
@ -268,7 +283,7 @@ static BOOL test_peer_load_icon(freerdp_peer* client)
/* width height */
fgets(line, sizeof(line), fp);
if (sscanf(line, "%d %d", &context->icon_width, &context->icon_height) < 2)
if (sscanf(line, "%hu %hu", &context->icon_width, &context->icon_height) < 2)
{
WLog_ERR(TAG, "Problem while extracting width/height from the icon file");
goto out_fail;
@ -303,20 +318,22 @@ out_fail:
return FALSE;
}
static void test_peer_draw_icon(freerdp_peer* client, int x, int y)
static void test_peer_draw_icon(freerdp_peer* client, UINT32 x, UINT32 y)
{
wStream* s;
RFX_RECT rect;
rdpUpdate* update = client->update;
SURFACE_BITS_COMMAND cmd = { 0 };
testPeerContext* context = (testPeerContext*)client->context;
testPeerContext* context;
WINPR_ASSERT(client);
context = (testPeerContext*)client->context;
WINPR_ASSERT(context);
WINPR_ASSERT(context->update);
if (client->update->dump_rfx)
return;
if (!context)
return;
if (context->icon_width < 1 || !context->activated)
return;
@ -328,16 +345,18 @@ static void test_peer_draw_icon(freerdp_peer* client, int x, int y)
if (client->settings->RemoteFxCodec)
{
cmd.bmp.codecID = client->settings->RemoteFxCodecId;
WINPR_ASSERT(client->settings->RemoteFxCodecId <= UINT16_MAX);
cmd.bmp.codecID = (UINT16)client->settings->RemoteFxCodecId;
cmd.cmdType = CMDTYPE_STREAM_SURFACE_BITS;
}
else
{
cmd.bmp.codecID = client->settings->NSCodecId;
WINPR_ASSERT(client->settings->NSCodecId <= UINT16_MAX);
cmd.bmp.codecID = (UINT16)client->settings->NSCodecId;
cmd.cmdType = CMDTYPE_SET_SURFACE_BITS;
}
if (context->icon_x >= 0)
if (context->icon_x != UINT32_MAX)
{
s = test_peer_stream_init(context);
@ -356,7 +375,7 @@ static void test_peer_draw_icon(freerdp_peer* client, int x, int y)
cmd.bmp.flags = 0;
cmd.bmp.width = context->icon_width;
cmd.bmp.height = context->icon_height;
cmd.bmp.bitmapDataLength = Stream_GetPosition(s);
cmd.bmp.bitmapDataLength = (UINT32)Stream_GetPosition(s);
cmd.bmp.bitmapData = Stream_Buffer(s);
update->SurfaceBits(update->context, &cmd);
}
@ -377,7 +396,7 @@ static void test_peer_draw_icon(freerdp_peer* client, int x, int y)
cmd.bmp.bpp = 32;
cmd.bmp.width = context->icon_width;
cmd.bmp.height = context->icon_height;
cmd.bmp.bitmapDataLength = Stream_GetPosition(s);
cmd.bmp.bitmapDataLength = (UINT32)Stream_GetPosition(s);
cmd.bmp.bitmapData = Stream_Buffer(s);
update->SurfaceBits(update->context, &cmd);
context->icon_x = x;
@ -503,7 +522,7 @@ static DWORD WINAPI tf_debug_channel_thread_func(LPVOID arg)
Stream_SetPosition(s, 0);
if (WTSVirtualChannelRead(context->debug_channel, 0, (PCHAR)Stream_Buffer(s),
Stream_Capacity(s), &BytesReturned) == FALSE)
(ULONG)Stream_Capacity(s), &BytesReturned) == FALSE)
{
if (BytesReturned == 0)
break;
@ -511,7 +530,7 @@ static DWORD WINAPI tf_debug_channel_thread_func(LPVOID arg)
Stream_EnsureRemainingCapacity(s, BytesReturned);
if (WTSVirtualChannelRead(context->debug_channel, 0, (PCHAR)Stream_Buffer(s),
Stream_Capacity(s), &BytesReturned) == FALSE)
(ULONG)Stream_Capacity(s), &BytesReturned) == FALSE)
{
/* should not happen */
break;
@ -951,7 +970,7 @@ int main(int argc, char* argv[])
port = strtol(arg, NULL, 10);
if ((port < 1) || (port > 0xFFFF) || (errno != 0))
if ((port < 1) || (port > UINT16_MAX) || (errno != 0))
return -1;
}
else if (strncmp(arg, slocal_only, sizeof(slocal_only)) == 0)
@ -986,7 +1005,8 @@ int main(int argc, char* argv[])
return -1;
}
if ((localOnly || instance->Open(instance, NULL, port)) && instance->OpenLocal(instance, file))
if ((localOnly || instance->Open(instance, NULL, (UINT16)port)) &&
instance->OpenLocal(instance, file))
{
/* Entering the server main loop. In a real server the listener can be run in its own
* thread. */

View File

@ -42,10 +42,10 @@ struct test_peer_context
wStream* s;
BYTE* icon_data;
BYTE* bg_data;
int icon_width;
int icon_height;
int icon_x;
int icon_y;
UINT16 icon_width;
UINT16 icon_height;
UINT32 icon_x;
UINT32 icon_y;
BOOL activated;
HANDLE event;
HANDLE stopEvent;

View File

@ -44,7 +44,7 @@ typedef struct proxy_plugin
const char* name; /* unique module name */
const char* description; /* module description */
BOOL (*PluginUnload)();
BOOL (*PluginUnload)(void);
/* proxy hooks. a module can set these function pointers to register hooks */
proxyHookFn ClientPreConnect;

View File

@ -163,4 +163,4 @@ BOOL pf_register_graphics(rdpGraphics* graphics)
glyph.EndDraw = pf_Glyph_EndDraw;
graphics_register_glyph(graphics, &glyph);
return TRUE;
}
}

View File

@ -47,4 +47,4 @@
WLog_WARN(TAG, "[SessionID=%s][%s]: " _format, _context->pdata->session_id, __FUNCTION__, \
##__VA_ARGS__)
#endif /* FREERDP_SERVER_PROXY_PFLOG_H */
#endif /* FREERDP_SERVER_PROXY_PFLOG_H */

View File

@ -109,6 +109,7 @@ static BOOL pf_modules_proxy_ArrayList_ForEachFkt(void* data, size_t index, va_l
IFCALLRET(plugin->ServerSessionEnd, ok, pdata);
break;
case HOOK_LAST:
default:
WLog_ERR(TAG, "invalid hook called");
}
@ -171,6 +172,7 @@ static BOOL pf_modules_ArrayList_ForEachFkt(void* data, size_t index, va_list ap
IFCALLRET(plugin->ServerFetchTargetAddr, result, pdata, param);
break;
case FILTER_LAST:
default:
WLog_ERR(TAG, "invalid filter called");
}

View File

@ -26,7 +26,6 @@
#include "modules/modules_api.h"
typedef enum _PF_FILTER_TYPE PF_FILTER_TYPE;
enum _PF_FILTER_TYPE
{
FILTER_TYPE_KEYBOARD,
@ -38,8 +37,8 @@ enum _PF_FILTER_TYPE
FILTER_LAST
};
typedef enum _PF_FILTER_TYPE PF_FILTER_TYPE;
typedef enum _PF_HOOK_TYPE PF_HOOK_TYPE;
enum _PF_HOOK_TYPE
{
HOOK_TYPE_CLIENT_PRE_CONNECT,
@ -54,6 +53,7 @@ enum _PF_HOOK_TYPE
HOOK_LAST
};
typedef enum _PF_HOOK_TYPE PF_HOOK_TYPE;
BOOL pf_modules_init(const char* root_dir, const char** modules, size_t count);
BOOL pf_modules_is_plugin_loaded(const char* plugin_name);

View File

@ -32,4 +32,4 @@ BOOL pf_server_rdpgfx_init(pServerContext* ps);
void pf_rdpgfx_pipeline_init(RdpgfxClientContext* gfx, RdpgfxServerContext* server,
proxyData* pdata);
#endif /*FREERDP_SERVER_PROXY_PFRDPGFX_H*/
#endif /*FREERDP_SERVER_PROXY_PFRDPGFX_H*/

View File

@ -77,4 +77,4 @@ BOOL pf_server_rdpsnd_init(pServerContext* ps)
rdpsnd->Activated = rdpsnd_activated;
return TRUE;
}
}

View File

@ -272,7 +272,7 @@ static BOOL pf_server_receive_channel_data_hook(freerdp_peer* peer, UINT16 chann
if (!pf_modules_run_filter(FILTER_TYPE_SERVER_PASSTHROUGH_CHANNEL_DATA, pdata, &ev))
return FALSE;
client_channel_id = (UINT64)HashTable_GetItemValue(pc->vc_ids, (void*)channel_name);
client_channel_id = (UINT64)HashTable_GetItemValue(pc->vc_ids, channel_name);
return pc->context.instance->SendChannelData(pc->context.instance,
(UINT16)client_channel_id, data, size);

View File

@ -1009,7 +1009,8 @@ static BOOL shadow_client_send_surface_bits(rdpShadowClient* client, BYTE* pSrcD
}
rfx_message_free(encoder->rfx, &messages[i]);
cmd.bmp.bitmapDataLength = Stream_GetPosition(s);
WINPR_ASSERT(Stream_GetPosition(s) <= UINT32_MAX);
cmd.bmp.bitmapDataLength = (UINT32)Stream_GetPosition(s);
cmd.bmp.bitmapData = Stream_Buffer(s);
first = (i == 0) ? TRUE : FALSE;
last = ((i + 1) == numMessages) ? TRUE : FALSE;
@ -1051,7 +1052,8 @@ static BOOL shadow_client_send_surface_bits(rdpShadowClient* client, BYTE* pSrcD
cmd.destBottom = cmd.destTop + nHeight;
cmd.bmp.width = nWidth;
cmd.bmp.height = nHeight;
cmd.bmp.bitmapDataLength = Stream_GetPosition(s);
WINPR_ASSERT(Stream_GetPosition(s) <= UINT32_MAX);
cmd.bmp.bitmapDataLength = (UINT32)Stream_GetPosition(s);
cmd.bmp.bitmapData = Stream_Buffer(s);
first = TRUE;
last = TRUE;

View File

@ -262,7 +262,7 @@ static int shadow_encoder_init(rdpShadowEncoder* encoder)
shadow_encoder_init_grid(encoder);
if (!encoder->bs)
encoder->bs = Stream_New(NULL, encoder->maxTileWidth * encoder->maxTileHeight * 4);
encoder->bs = Stream_New(NULL, encoder->maxTileWidth * encoder->maxTileHeight * 4ULL);
if (!encoder->bs)
return -1;

View File

@ -32,16 +32,16 @@ struct rdp_shadow_encoder
rdpShadowClient* client;
rdpShadowServer* server;
int width;
int height;
UINT32 width;
UINT32 height;
UINT32 codecs;
BYTE** grid;
int gridWidth;
int gridHeight;
UINT32 gridWidth;
UINT32 gridHeight;
BYTE* gridBuffer;
int maxTileWidth;
int maxTileHeight;
UINT32 maxTileWidth;
UINT32 maxTileHeight;
wStream* bs;

View File

@ -373,7 +373,7 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a
if (arg && (arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
{
int index;
int numMonitors;
UINT32 numMonitors;
MONITOR_DEF monitors[16];
numMonitors = shadow_enum_monitors(monitors, 16);
@ -382,10 +382,10 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a
/* Select monitors */
long val = strtol(arg->Value, NULL, 0);
if ((val < 0) || (errno != 0) || (val >= numMonitors))
if ((val < 0) || (errno != 0) || ((UINT32)val >= numMonitors))
status = COMMAND_LINE_STATUS_PRINT;
server->selectedMonitor = val;
server->selectedMonitor = (int)val;
}
else
{