[warnings] fixed sign and const

* fix various char/BYTE sign warnings
* fix various const warnings
* fix format string size_t
* remove unused CMake variables
This commit is contained in:
akallabeth 2024-04-17 21:56:37 +02:00 committed by akallabeth
parent c24011b8cb
commit 71e78bedd7
20 changed files with 89 additions and 80 deletions

View File

@ -499,10 +499,6 @@ set(FFMPEG_FEATURE_TYPE "RECOMMENDED")
set(FFMPEG_FEATURE_PURPOSE "multimedia")
set(FFMPEG_FEATURE_DESCRIPTION "multimedia redirection, audio and video playback")
set(VAAPI_FEATURE_TYPE "OPTIONAL")
set(VAAPI_FEATURE_PURPOSE "multimedia")
set(VAAPI_FEATURE_DESCRIPTION "VA-API hardware acceleration for video playback")
set(OPENH264_FEATURE_TYPE "OPTIONAL")
set(OPENH264_FEATURE_PURPOSE "codec")
set(OPENH264_FEATURE_DESCRIPTION "use OpenH264 library")
@ -535,12 +531,10 @@ if(WIN32)
set(WAYLAND_FEATURE_TYPE "DISABLED")
set(PCSC_FEATURE_TYPE "DISABLED")
set(FFMPEG_FEATURE_TYPE "OPTIONAL")
set(VAAPI_FEATURE_TYPE "DISABLED")
endif()
if(APPLE)
set(FFMPEG_FEATURE_TYPE "OPTIONAL")
set(VAAPI_FEATURE_TYPE "DISABLED")
set(WAYLAND_FEATURE_TYPE "DISABLED")
if(IOS)
set(PCSC_FEATURE_TYPE "DISABLED")
@ -550,7 +544,6 @@ endif()
if(ANDROID)
set(WAYLAND_FEATURE_TYPE "DISABLED")
set(PCSC_FEATURE_TYPE "DISABLED")
set(VAAPI_FEATURE_TYPE "DISABLED")
endif()
find_feature(Wayland ${WAYLAND_FEATURE_TYPE} ${WAYLAND_FEATURE_PURPOSE} ${WAYLAND_FEATURE_DESCRIPTION})

View File

@ -110,7 +110,7 @@ static UINT location_channel_send(IWTSVirtualChannel* channel, wStream* s)
static UINT location_send_client_ready_pdu(const LOCATION_CALLBACK* callback)
{
wStream sbuffer = { 0 };
char buffer[32] = { 0 };
BYTE buffer[32] = { 0 };
wStream* s = Stream_StaticInit(&sbuffer, buffer, sizeof(buffer));
WINPR_ASSERT(s);
@ -210,7 +210,7 @@ static UINT location_send_base_location3d(IWTSVirtualChannel* channel,
const RDPLOCATION_BASE_LOCATION3D_PDU* pdu)
{
wStream sbuffer = { 0 };
char buffer[32] = { 0 };
BYTE buffer[32] = { 0 };
wStream* s = Stream_StaticInit(&sbuffer, buffer, sizeof(buffer));
WINPR_ASSERT(s);
WINPR_ASSERT(channel);
@ -251,7 +251,7 @@ static UINT location_send_location2d_delta(IWTSVirtualChannel* channel,
const RDPLOCATION_LOCATION2D_DELTA_PDU* pdu)
{
wStream sbuffer = { 0 };
char buffer[32] = { 0 };
BYTE buffer[32] = { 0 };
wStream* s = Stream_StaticInit(&sbuffer, buffer, sizeof(buffer));
WINPR_ASSERT(s);
@ -287,7 +287,7 @@ static UINT location_send_location3d_delta(IWTSVirtualChannel* channel,
const RDPLOCATION_LOCATION3D_DELTA_PDU* pdu)
{
wStream sbuffer = { 0 };
char buffer[32] = { 0 };
BYTE buffer[32] = { 0 };
wStream* s = Stream_StaticInit(&sbuffer, buffer, sizeof(buffer));
WINPR_ASSERT(s);

View File

@ -112,7 +112,7 @@ UINT rail_send_channel_data(railPlugin* rail, wStream* src)
*/
static UINT rail_client_execute(RailClientContext* context, const RAIL_EXEC_ORDER* exec)
{
char* exeOrFile = NULL;
const char* exeOrFile = NULL;
UINT error = 0;
railPlugin* rail = NULL;
UINT16 flags = 0;

View File

@ -650,7 +650,7 @@ static UINT rail_read_client_status_order(wStream* s, RAIL_CLIENT_STATUS_ORDER*
*
* @return 0 on success, otherwise a Win32 error code
*/
static UINT rail_read_exec_order(wStream* s, RAIL_EXEC_ORDER* exec)
static UINT rail_read_exec_order(wStream* s, RAIL_EXEC_ORDER* exec, char* args[])
{
RAIL_EXEC_ORDER order = { 0 };
UINT16 exeLen = 0;
@ -671,30 +671,31 @@ static UINT rail_read_exec_order(wStream* s, RAIL_EXEC_ORDER* exec)
if (exeLen > 0)
{
const SSIZE_T len = exeLen / sizeof(WCHAR);
exec->RemoteApplicationProgram = Stream_Read_UTF16_String_As_UTF8(s, len, NULL);
exec->RemoteApplicationProgram = args[0] = Stream_Read_UTF16_String_As_UTF8(s, len, NULL);
if (!exec->RemoteApplicationProgram)
goto fail;
}
if (workLen > 0)
{
const SSIZE_T len = workLen / sizeof(WCHAR);
exec->RemoteApplicationWorkingDir = Stream_Read_UTF16_String_As_UTF8(s, len, NULL);
exec->RemoteApplicationWorkingDir = args[1] =
Stream_Read_UTF16_String_As_UTF8(s, len, NULL);
if (!exec->RemoteApplicationWorkingDir)
goto fail;
}
if (argLen > 0)
{
const SSIZE_T len = argLen / sizeof(WCHAR);
exec->RemoteApplicationArguments = Stream_Read_UTF16_String_As_UTF8(s, len, NULL);
exec->RemoteApplicationArguments = args[2] = Stream_Read_UTF16_String_As_UTF8(s, len, NULL);
if (!exec->RemoteApplicationArguments)
goto fail;
}
return CHANNEL_RC_OK;
fail:
free(exec->RemoteApplicationProgram);
free(exec->RemoteApplicationArguments);
free(exec->RemoteApplicationWorkingDir);
free(args[0]);
free(args[1]);
free(args[2]);
*exec = order;
return ERROR_INTERNAL_ERROR;
}
@ -948,12 +949,14 @@ static UINT rail_recv_client_client_status_order(RailServerContext* context,
static UINT rail_recv_client_exec_order(RailServerContext* context, wStream* s)
{
UINT error = 0;
char* args[3] = { 0 };
RAIL_EXEC_ORDER exec = { 0 };
if (!context || !s)
return ERROR_INVALID_PARAMETER;
if ((error = rail_read_exec_order(s, &exec)))
error = rail_read_exec_order(s, &exec, args);
if (error)
{
WLog_ERR(TAG, "rail_read_client_status_order failed with error %" PRIu32 "!", error);
return error;
@ -964,9 +967,9 @@ static UINT rail_recv_client_exec_order(RailServerContext* context, wStream* s)
if (error)
WLog_ERR(TAG, "context.Exec failed with error %" PRIu32 "", error);
free(exec.RemoteApplicationProgram);
free(exec.RemoteApplicationArguments);
free(exec.RemoteApplicationWorkingDir);
free(args[0]);
free(args[1]);
free(args[2]);
return error;
}

View File

@ -69,7 +69,7 @@ static UINT remdesk_virtual_channel_write(remdeskPlugin* remdesk, wStream* s)
*/
static UINT remdesk_generate_expert_blob(remdeskPlugin* remdesk)
{
char* name = NULL;
const char* name = NULL;
char* pass = NULL;
const char* password = NULL;
rdpSettings* settings = NULL;

View File

@ -70,6 +70,13 @@ typedef struct
char* responseMime;
} wlf_request;
typedef struct
{
const FILE* responseFile;
UINT32 responseFormat;
const char* responseMime;
} wlf_const_request;
struct wlf_clipboard
{
wlfContext* wfc;
@ -311,7 +318,7 @@ static BOOL wlf_cliprdr_add_client_format(wfClipboard* clipboard, const char* mi
*
* @return 0 on success, otherwise a Win32 error code
*/
static UINT wlf_cliprdr_send_data_request(wfClipboard* clipboard, const wlf_request* rq)
static UINT wlf_cliprdr_send_data_request(wfClipboard* clipboard, const wlf_const_request* rq)
{
WINPR_ASSERT(rq);
@ -522,7 +529,7 @@ static void wlf_cliprdr_transfer_data(UwacSeat* seat, void* context, const char*
EnterCriticalSection(&clipboard->lock);
wlf_request request = { 0 };
wlf_const_request request = { 0 };
if (wlf_mime_is_html(mime))
{
request.responseMime = mime_html;
@ -720,7 +727,7 @@ wlf_cliprdr_server_format_data_request(CliprdrClientContext* context,
const CLIPRDR_FORMAT_DATA_REQUEST* formatDataRequest)
{
UINT rc = CHANNEL_RC_OK;
BYTE* data = NULL;
char* data = NULL;
size_t size = 0;
const char* mime = NULL;
UINT32 formatId = 0;

View File

@ -5321,7 +5321,7 @@ static void argv_free(int* pargc, char** pargv[])
free(argv);
}
static BOOL argv_append(int* pargc, char** pargv[], const char* what)
static BOOL argv_append(int* pargc, char** pargv[], char* what)
{
WINPR_ASSERT(pargc);
WINPR_ASSERT(pargv);

View File

@ -347,9 +347,9 @@ typedef struct
typedef struct
{
UINT16 flags;
char* RemoteApplicationProgram;
char* RemoteApplicationWorkingDir;
char* RemoteApplicationArguments;
const char* RemoteApplicationProgram;
const char* RemoteApplicationWorkingDir;
const char* RemoteApplicationArguments;
} RAIL_EXEC_ORDER;
typedef struct

View File

@ -636,6 +636,7 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
goto fail_hwdevice_create;
}
}
WLog_Print(h264->log, WLOG_INFO, "Using VAAPI for accelerated H264 decoding");
sys->codecDecoderContext->get_format = libavcodec_get_format;
sys->hw_pix_fmt = AV_PIX_FMT_VAAPI;

View File

@ -716,11 +716,11 @@ static char* bn_to_base64_url(wLog* wlog, rdpPrivateKey* key, enum FREERDP_KEY_P
WINPR_ASSERT(key);
size_t len = 0;
char* bn = freerdp_key_get_param(key, param, &len);
BYTE* bn = freerdp_key_get_param(key, param, &len);
if (!bn)
return NULL;
char* b64 = (char*)crypto_base64url_encode(bn, len);
char* b64 = crypto_base64url_encode(bn, len);
free(bn);
if (!b64)

View File

@ -1765,6 +1765,9 @@ static BOOL gcc_update_server_random(rdpSettings* settings)
*/
BOOL gcc_write_server_security_data(wStream* s, rdpMcs* mcs)
{
if (!gcc_update_server_random(mcs_get_settings(mcs)))
return FALSE;
const rdpSettings* settings = mcs_get_const_settings(mcs);
WINPR_ASSERT(s);
@ -1779,8 +1782,6 @@ BOOL gcc_write_server_security_data(wStream* s, rdpMcs* mcs)
if (settings->EncryptionMethods == ENCRYPTION_METHOD_NONE)
return TRUE;
if (!gcc_update_server_random(settings))
return FALSE;
if (!Stream_EnsureRemainingCapacity(s, sizeof(UINT32) + settings->ServerRandomLength))
return FALSE;

View File

@ -442,7 +442,7 @@ fail:
return rc;
}
char* freerdp_key_get_param(const rdpPrivateKey* key, enum FREERDP_KEY_PARAM param, size_t* plength)
BYTE* freerdp_key_get_param(const rdpPrivateKey* key, enum FREERDP_KEY_PARAM param, size_t* plength)
{
BYTE* buf = NULL;
@ -527,7 +527,7 @@ char* freerdp_key_get_param(const rdpPrivateKey* key, enum FREERDP_KEY_PARAM par
fail:
BN_free(bn);
return (char*)buf;
return buf;
}
WINPR_DIGEST_CTX* freerdp_key_digest_sign(rdpPrivateKey* key, WINPR_MD_TYPE digest)

View File

@ -52,7 +52,7 @@ extern "C"
*/
FREERDP_LOCAL EVP_PKEY* freerdp_key_get_evp_pkey(const rdpPrivateKey* key);
FREERDP_LOCAL char* freerdp_key_get_param(const rdpPrivateKey* key,
FREERDP_LOCAL BYTE* freerdp_key_get_param(const rdpPrivateKey* key,
enum FREERDP_KEY_PARAM param, size_t* plength);
FREERDP_LOCAL WINPR_DIGEST_CTX* freerdp_key_digest_sign(rdpPrivateKey* key,

View File

@ -38,7 +38,7 @@
#define MAX_CACHE_ITEM_SIZE 4096
#define MAX_CACHE_ITEM_VALUES 4096
static const CHAR g_ReaderNameA[] = { 'F', 'r', 'e', 'e', 'R', 'D', 'P', ' ', 'E',
static CHAR g_ReaderNameA[] = { 'F', 'r', 'e', 'e', 'R', 'D', 'P', ' ', 'E',
'm', 'u', 'l', 'a', 't', 'o', 'r', '\0', '\0' };
static INIT_ONCE g_ReaderNameWGuard = INIT_ONCE_STATIC_INIT;
static WCHAR g_ReaderNameW[32] = { 0 };

View File

@ -76,7 +76,7 @@ static BOOL test_YCoCgRToRGB_8u_AC4R_func(UINT32 width, UINT32 height)
if (c != sse)
{
printf("optimized->YCoCgRToRGB FAIL[%s] [%" PRIu32 "]: 0x%08" PRIx32
printf("optimized->YCoCgRToRGB FAIL[%s] [%" PRIuz "]: 0x%08" PRIx32
" -> C 0x%08" PRIx32 " vs optimized 0x%08" PRIx32 "\n",
formatName, i, in[i + 1], c, sse);
status = -1;

View File

@ -379,7 +379,7 @@ static void* clipboard_synthesize_image_format_to_bmp(wClipboard* clipboard, UIN
WINPR_ASSERT(data);
WINPR_ASSERT(pSize);
void* dst = NULL;
BYTE* dst = NULL;
const UINT32 SrcSize = *pSize;
size_t size = 0;
wImage* image = winpr_image_new();

View File

@ -15,9 +15,9 @@
typedef struct
{
char* utf8;
const char* utf8;
size_t utf8len;
WCHAR* utf16;
const WCHAR* utf16;
size_t utf16len;
} testcase_t;

View File

@ -1496,7 +1496,7 @@ static SECURITY_STATUS SEC_ENTRY kerberos_EncryptMessage(PCtxtHandle phContext,
KRB_CONTEXT* context = get_context(phContext);
PSecBuffer sig_buffer = NULL;
PSecBuffer data_buffer = NULL;
BYTE* header = NULL;
char* header = NULL;
BYTE flags = 0;
krb5glue_key key = NULL;
krb5_keyusage usage = 0;
@ -1547,15 +1547,15 @@ static SECURITY_STATUS SEC_ENTRY kerberos_EncryptMessage(PCtxtHandle phContext,
/* Set up the iov array in sig_buffer */
header = sig_buffer->pvBuffer;
encrypt_iov[2].data.data = header + 16;
encrypt_iov[3].data.data = (BYTE*)encrypt_iov[2].data.data + encrypt_iov[2].data.length;
encrypt_iov[4].data.data = (BYTE*)encrypt_iov[3].data.data + encrypt_iov[3].data.length;
encrypt_iov[0].data.data = (BYTE*)encrypt_iov[4].data.data + encrypt_iov[4].data.length;
encrypt_iov[3].data.data = encrypt_iov[2].data.data + encrypt_iov[2].data.length;
encrypt_iov[4].data.data = encrypt_iov[3].data.data + encrypt_iov[3].data.length;
encrypt_iov[0].data.data = encrypt_iov[4].data.data + encrypt_iov[4].data.length;
encrypt_iov[1].data.data = data_buffer->pvBuffer;
/* Write the GSS header with 0 in RRC */
Data_Write_UINT16_BE(header, TOK_ID_WRAP);
header[2] = flags;
header[3] = 0xFF;
header[3] = (char)0xFF;
Data_Write_UINT32(header + 4, 0);
Data_Write_UINT64_BE(header + 8, (context->local_seq + MessageSeqNo));
@ -1656,8 +1656,8 @@ static SECURITY_STATUS SEC_ENTRY kerberos_DecryptMessage(PCtxtHandle phContext,
iov[0].data.data = header + 16 + rrc + ec;
iov[1].data.data = data_buffer->pvBuffer;
iov[2].data.data = header + 16 + ec;
iov[3].data.data = (BYTE*)iov[2].data.data + iov[2].data.length;
iov[4].data.data = (BYTE*)iov[3].data.data + iov[3].data.length;
iov[3].data.data = iov[2].data.data + iov[2].data.length;
iov[4].data.data = iov[3].data.data + iov[3].data.length;
if (krb_log_exec(krb5glue_decrypt_iov, context->ctx, key, usage, iov, ARRAYSIZE(iov)))
return SEC_E_INTERNAL_ERROR;

View File

@ -161,7 +161,7 @@ char** winpr_backtrace_symbols(void* buffer, size_t* used)
*msgptr = msg;
strncpy(msg, support_msg, len);
*used = 1;
return ppmsg;
return msgptr;
#endif
}

View File

@ -52,12 +52,12 @@
#include "../log.h"
#define TAG WINPR_TAG("utils.image")
static SSIZE_T winpr_convert_from_jpeg(const char* comp_data, size_t comp_data_bytes, UINT32* width,
UINT32* height, UINT32* bpp, char** ppdecomp_data);
static SSIZE_T winpr_convert_from_png(const char* comp_data, size_t comp_data_bytes, UINT32* width,
UINT32* height, UINT32* bpp, char** ppdecomp_data);
static SSIZE_T winpr_convert_from_webp(const char* comp_data, size_t comp_data_bytes, UINT32* width,
UINT32* height, UINT32* bpp, char** ppdecomp_data);
static SSIZE_T winpr_convert_from_jpeg(const BYTE* comp_data, size_t comp_data_bytes, UINT32* width,
UINT32* height, UINT32* bpp, BYTE** ppdecomp_data);
static SSIZE_T winpr_convert_from_png(const BYTE* comp_data, size_t comp_data_bytes, UINT32* width,
UINT32* height, UINT32* bpp, BYTE** ppdecomp_data);
static SSIZE_T winpr_convert_from_webp(const BYTE* comp_data, size_t comp_data_bytes, UINT32* width,
UINT32* height, UINT32* bpp, BYTE** ppdecomp_data);
static BOOL writeBitmapFileHeader(wStream* s, const WINPR_BITMAP_FILE_HEADER* bf)
{
@ -484,7 +484,7 @@ int winpr_image_read(wImage* image, const char* filename)
if (pos > 0)
{
char* buffer = malloc((size_t)pos);
BYTE* buffer = malloc((size_t)pos);
if (buffer)
{
size_t r = fread(buffer, 1, (size_t)pos, fp);
@ -518,9 +518,8 @@ int winpr_image_read_buffer(wImage* image, const BYTE* buffer, size_t size)
(sig[8] == 'W') && (sig[9] == 'E') && (sig[10] == 'B') && (sig[11] == 'P'))
{
image->type = WINPR_IMAGE_WEBP;
const SSIZE_T rc =
winpr_convert_from_webp((const char*)buffer, size, &image->width, &image->height,
&image->bitsPerPixel, ((char**)&image->data));
const SSIZE_T rc = winpr_convert_from_webp(buffer, size, &image->width, &image->height,
&image->bitsPerPixel, &image->data);
if (rc >= 0)
{
image->bytesPerPixel = (image->bitsPerPixel + 7) / 8;
@ -533,9 +532,8 @@ int winpr_image_read_buffer(wImage* image, const BYTE* buffer, size_t size)
(sig[10] == 0x00))
{
image->type = WINPR_IMAGE_JPEG;
const SSIZE_T rc =
winpr_convert_from_jpeg((const char*)buffer, size, &image->width, &image->height,
&image->bitsPerPixel, ((char**)&image->data));
const SSIZE_T rc = winpr_convert_from_jpeg(buffer, size, &image->width, &image->height,
&image->bitsPerPixel, &image->data);
if (rc >= 0)
{
image->bytesPerPixel = (image->bitsPerPixel + 7) / 8;
@ -547,9 +545,8 @@ int winpr_image_read_buffer(wImage* image, const BYTE* buffer, size_t size)
(sig[4] == '\r') && (sig[5] == '\n') && (sig[6] == 0x1A) && (sig[7] == '\n'))
{
image->type = WINPR_IMAGE_PNG;
const SSIZE_T rc =
winpr_convert_from_png((const char*)buffer, size, &image->width, &image->height,
&image->bitsPerPixel, ((char**)&image->data));
const SSIZE_T rc = winpr_convert_from_png(buffer, size, &image->width, &image->height,
&image->bitsPerPixel, &image->data);
if (rc >= 0)
{
image->bytesPerPixel = (image->bitsPerPixel + 7) / 8;
@ -625,11 +622,11 @@ void* winpr_convert_to_jpeg(const void* data, size_t size, UINT32 width, UINT32
jpeg_start_compress(&cinfo, TRUE);
const unsigned char* cdata = data;
const JSAMPLE* cdata = data;
for (size_t x = 0; x < height; x++)
{
const JDIMENSION offset = x * stride;
const JSAMPROW coffset = &cdata[offset];
const JSAMPLE* coffset = &cdata[offset];
if (jpeg_write_scanlines(&cinfo, &coffset, 1) != 1)
goto fail;
}
@ -643,8 +640,8 @@ fail:
#endif
}
SSIZE_T winpr_convert_from_jpeg(const char* comp_data, size_t comp_data_bytes, UINT32* width,
UINT32* height, UINT32* bpp, char** ppdecomp_data)
SSIZE_T winpr_convert_from_jpeg(const BYTE* comp_data, size_t comp_data_bytes, UINT32* width,
UINT32* height, UINT32* bpp, BYTE** ppdecomp_data)
{
WINPR_ASSERT(comp_data || (comp_data_bytes == 0));
WINPR_ASSERT(width);
@ -658,7 +655,7 @@ SSIZE_T winpr_convert_from_jpeg(const char* comp_data, size_t comp_data_bytes, U
struct jpeg_decompress_struct cinfo = { 0 };
struct jpeg_error_mgr jerr;
SSIZE_T size = -1;
char* decomp_data = NULL;
BYTE* decomp_data = NULL;
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_decompress(&cinfo);
@ -734,8 +731,8 @@ void* winpr_convert_to_webp(const void* data, size_t size, UINT32 width, UINT32
#endif
}
SSIZE_T winpr_convert_from_webp(const char* comp_data, size_t comp_data_bytes, UINT32* width,
UINT32* height, UINT32* bpp, char** ppdecomp_data)
SSIZE_T winpr_convert_from_webp(const BYTE* comp_data, size_t comp_data_bytes, UINT32* width,
UINT32* height, UINT32* bpp, BYTE** ppdecomp_data)
{
WINPR_ASSERT(comp_data || (comp_data_bytes == 0));
WINPR_ASSERT(width);
@ -751,13 +748,20 @@ SSIZE_T winpr_convert_from_webp(const char* comp_data, size_t comp_data_bytes, U
return -1;
#else
uint8_t* dst = WebPDecodeBGRA(comp_data, comp_data_bytes, width, height);
if (!dst)
int w = 0;
int h = 0;
uint8_t* dst = WebPDecodeBGRA(comp_data, comp_data_bytes, &w, &h);
if (!dst || (w < 0) || (h < 0))
{
free(dst);
return -1;
}
*width = w;
*height = h;
*bpp = 32;
*ppdecomp_data = dst;
return (*width) * (*height) * 4;
return 4ll * w * h;
#endif
}
@ -1006,8 +1010,8 @@ void* winpr_convert_to_png(const void* data, size_t size, UINT32 width, UINT32 h
#endif
}
SSIZE_T winpr_convert_from_png(const char* comp_data, size_t comp_data_bytes, UINT32* width,
UINT32* height, UINT32* bpp, char** ppdecomp_data)
SSIZE_T winpr_convert_from_png(const BYTE* comp_data, size_t comp_data_bytes, UINT32* width,
UINT32* height, UINT32* bpp, BYTE** ppdecomp_data)
{
#if defined(WINPR_UTILS_IMAGE_PNG)
size_t len = 0;