Fixed sign-compare warnings, removed internal functions from API

This commit is contained in:
Armin Novak 2019-02-07 14:38:16 +01:00
parent 29741ca849
commit 1c24450fe0
5 changed files with 24 additions and 19 deletions

View File

@ -1282,7 +1282,7 @@ static BOOL freerdp_client_detect_command_line(int argc, char** argv,
DWORD* flags)
{
int old_cli_status;
int old_cli_count;
size_t old_cli_count;
int posix_cli_status;
size_t posix_cli_count;
int windows_cli_status;

View File

@ -404,7 +404,7 @@ static int freerdp_client_old_command_line_post_filter(void* context, COMMAND_LI
{
return 0;
}
int freerdp_detect_old_command_line_syntax(int argc, char** argv, int* count)
int freerdp_detect_old_command_line_syntax(int argc, char** argv, size_t* count)
{
int status;
DWORD flags;

View File

@ -23,8 +23,8 @@
#include <freerdp/api.h>
#include <freerdp/freerdp.h>
FREERDP_API int freerdp_detect_old_command_line_syntax(int argc, char** argv, int* count);
FREERDP_API int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSettings* settings);
FREERDP_LOCAL int freerdp_detect_old_command_line_syntax(int argc, char** argv, size_t* count);
FREERDP_LOCAL int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSettings* settings);
#endif /* FREERDP_CLIENT_COMMON_COMPATIBILITY_H */

View File

@ -636,21 +636,15 @@ BOOL freerdp_client_populate_rdp_file_from_settings(rdpFile* file, const rdpSett
BOOL freerdp_client_write_rdp_file(const rdpFile* file, const char* name, BOOL unicode)
{
FILE* fp;
int length;
size_t size;
char* buffer;
int status = 0;
WCHAR* unicodestr = NULL;
length = (int) freerdp_client_write_rdp_file_buffer(file, NULL, 0);
size = freerdp_client_write_rdp_file_buffer(file, NULL, 0);
if (length < 0)
{
WLog_ERR(TAG, "freerdp_client_write_rdp_file: error determining buffer size.");
return FALSE;
}
buffer = (char*) calloc((size + 1), sizeof(char));
buffer = (char*) calloc((length + 1), sizeof(char));
if (freerdp_client_write_rdp_file_buffer(file, buffer, length + 1) != length)
if (freerdp_client_write_rdp_file_buffer(file, buffer, size + 1) != size)
{
WLog_ERR(TAG, "freerdp_client_write_rdp_file: error writing to output buffer");
free(buffer);
@ -663,11 +657,22 @@ BOOL freerdp_client_write_rdp_file(const rdpFile* file, const char* name, BOOL u
{
if (unicode)
{
int length;
if (size > INT_MAX)
{
free(buffer);
free(unicodestr);
fclose(fp);
return FALSE;
}
length = (int)size;
ConvertToUnicode(CP_UTF8, 0, buffer, length, &unicodestr, 0);
/* Write multi-byte header */
if (fwrite(BOM_UTF16_LE, sizeof(BYTE), 2, fp) != 2 ||
fwrite(unicodestr, 2, length, fp) != length)
if ((length < 0) ||
(fwrite(BOM_UTF16_LE, sizeof(BYTE), 2, fp) != 2) ||
(fwrite(unicodestr, 2, (size_t)length, fp) != (size_t)length))
{
free(buffer);
free(unicodestr);
@ -679,7 +684,7 @@ BOOL freerdp_client_write_rdp_file(const rdpFile* file, const char* name, BOOL u
}
else
{
if (fwrite(buffer, 1, length, fp) != length)
if (fwrite(buffer, 1, size, fp) != size)
{
free(buffer);
fclose(fp);
@ -838,7 +843,7 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
(file->ScreenModeId == 2) ? TRUE : FALSE);
}
if (~((size_t) file->SmartSizing))
if (~(file->SmartSizing))
{
freerdp_set_param_bool(settings, FreeRDP_SmartSizing,
(file->SmartSizing == 1) ? TRUE : FALSE);

View File

@ -259,7 +259,7 @@ void check_modified_arguments(test* test, char** command_line, int* rc)
int TestClientCmdLine(int argc, char* argv[])
{
int rc = 0;
int i;
size_t i;
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i ++)
{