[warnings] fix integer casting

* use WINPR_ASSERTING_INT_CAST where possible
 * fix a few inconsistencies
This commit is contained in:
akallabeth
2024-12-19 12:32:40 +01:00
parent 411c3b4e06
commit 26eac974fe
9 changed files with 91 additions and 62 deletions

View File

@@ -26,6 +26,7 @@
#include <winpr/winpr.h>
#include <winpr/crt.h>
#include <winpr/cast.h>
#include <winpr/assert.h>
#include <winpr/ssl.h>
#include <winpr/synch.h>
@@ -404,8 +405,9 @@ static void test_peer_draw_icon(freerdp_peer* client, UINT32 x, UINT32 y)
rect.x = 0;
rect.y = 0;
rect.width = context->image->width;
rect.height = context->image->height;
rect.width = WINPR_ASSERTING_INT_CAST(UINT16, context->image->width);
rect.height = WINPR_ASSERTING_INT_CAST(UINT16, context->image->height);
const UINT32 w = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
const UINT32 h = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
@@ -1347,7 +1349,7 @@ static void print_entry(FILE* fp, WINPR_FORMAT_ARG const char* fmt, const char*
}
WINPR_PRAGMA_DIAG_POP
static WINPR_NORETURN(void usage(const char* app, const char* invalid))
static int usage(const char* app, const char* invalid)
{
FILE* fp = stdout;
@@ -1360,7 +1362,7 @@ static WINPR_NORETURN(void usage(const char* app, const char* invalid))
print_entry(fp, "\t%s\n", options.sfast, sizeof(options.sfast));
print_entry(fp, "\t%s<port>\n", options.sport, sizeof(options.sport));
print_entry(fp, "\t%s\n", options.slocal_only, sizeof(options.slocal_only));
exit(-1);
return -1;
}
int main(int argc, char* argv[])
@@ -1392,7 +1394,7 @@ int main(int argc, char* argv[])
port = strtol(sport, NULL, 10);
if ((port < 1) || (port > UINT16_MAX) || (errno != 0))
usage(app, arg);
return usage(app, arg);
}
else if (strncmp(arg, options.slocal_only, sizeof(options.slocal_only)) == 0)
localOnly = TRUE;
@@ -1400,22 +1402,22 @@ int main(int argc, char* argv[])
{
info.test_pcap_file = &arg[sizeof(options.spcap)];
if (!winpr_PathFileExists(info.test_pcap_file))
usage(app, arg);
return usage(app, arg);
}
else if (strncmp(arg, options.scert, sizeof(options.scert)) == 0)
{
info.cert = &arg[sizeof(options.scert)];
if (!winpr_PathFileExists(info.cert))
usage(app, arg);
return usage(app, arg);
}
else if (strncmp(arg, options.skey, sizeof(options.skey)) == 0)
{
info.key = &arg[sizeof(options.skey)];
if (!winpr_PathFileExists(info.key))
usage(app, arg);
return usage(app, arg);
}
else
usage(app, arg);
return usage(app, arg);
}
WTSRegisterWtsApiFunctionTable(FreeRDP_InitWtsApi());