Fixed integer warnings, fixed data types

This commit is contained in:
Armin Novak 2021-06-16 18:09:14 +02:00 committed by akallabeth
parent 299c962b28
commit 2e0d1cc33c
19 changed files with 97 additions and 67 deletions

View File

@ -122,7 +122,7 @@ static BOOL audin_alsa_set_params(AudinALSADevice* alsa, snd_pcm_t* capture_hand
static DWORD WINAPI audin_alsa_thread_func(LPVOID arg)
{
long error;
int error;
BYTE* buffer;
snd_pcm_t* capture_handle = NULL;
AudinALSADevice* alsa = (AudinALSADevice*)arg;

View File

@ -357,7 +357,7 @@ BOOL wlf_keyboard_modifiers(freerdp* instance, const UwacKeyboardModifiersEvent*
BOOL wlf_handle_touch_up(freerdp* instance, const UwacTouchUp* ev)
{
uint32_t x, y;
uint32_t x = 0, y = 0;
int i;
int touchId;
int contactId;

View File

@ -282,7 +282,7 @@ static INLINE BOOL BitBlt_write(HGDI_DC hdcDest, HGDI_DC hdcSrc, INT32 nXDest, I
if (!dstp)
{
WLog_ERR(TAG, "dstp=%p", (void*)dstp);
WLog_ERR(TAG, "dstp=%p", (const void*)dstp);
return FALSE;
}
@ -294,7 +294,7 @@ static INLINE BOOL BitBlt_write(HGDI_DC hdcDest, HGDI_DC hdcSrc, INT32 nXDest, I
if (!srcp)
{
WLog_ERR(TAG, "srcp=%p", (void*)srcp);
WLog_ERR(TAG, "srcp=%p", (const void*)srcp);
return FALSE;
}
@ -317,7 +317,7 @@ static INLINE BOOL BitBlt_write(HGDI_DC hdcDest, HGDI_DC hdcSrc, INT32 nXDest, I
if (!patp)
{
WLog_ERR(TAG, "patp=%p", (void*)patp);
WLog_ERR(TAG, "patp=%p", (const void*)patp);
return FALSE;
}

View File

@ -73,28 +73,28 @@ extern "C"
LPSTR PrefixString;
LPCSTR FormatString;
LPSTR TextString;
LPCSTR TextString;
DWORD LineNumber; /* __LINE__ */
size_t LineNumber; /* __LINE__ */
LPCSTR FileName; /* __FILE__ */
LPCSTR FunctionName; /* __FUNCTION__ */
/* Data Message */
void* Data;
int Length;
size_t Length;
/* Image Message */
void* ImageData;
int ImageWidth;
int ImageHeight;
int ImageBpp;
size_t ImageWidth;
size_t ImageHeight;
size_t ImageBpp;
/* Packet Message */
void* PacketData;
int PacketLength;
size_t PacketLength;
DWORD PacketFlags;
};
typedef struct _wLogMessage wLogMessage;
@ -105,9 +105,9 @@ extern "C"
#define WLOG_PACKET_INBOUND 1
#define WLOG_PACKET_OUTBOUND 2
WINPR_API BOOL WLog_PrintMessage(wLog* log, DWORD type, DWORD level, DWORD line,
WINPR_API BOOL WLog_PrintMessage(wLog* log, DWORD type, DWORD level, size_t line,
const char* file, const char* function, ...);
WINPR_API BOOL WLog_PrintMessageVA(wLog* log, DWORD type, DWORD level, DWORD line,
WINPR_API BOOL WLog_PrintMessageVA(wLog* log, DWORD type, DWORD level, size_t line,
const char* file, const char* function, va_list args);
WINPR_API wLog* WLog_GetRoot(void);

View File

@ -9,15 +9,19 @@ static const char* SECRET_PASSWORD_TEST = "MySecretPassword123!";
int TestCryptoProtectMemory(int argc, char* argv[])
{
int cbPlainText;
int cbCipherText;
UINT32 cbPlainText;
UINT32 cbCipherText;
const char* pPlainText;
BYTE* pCipherText;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
pPlainText = SECRET_PASSWORD_TEST;
cbPlainText = strlen(pPlainText) + 1;
cbCipherText = cbPlainText +
(CRYPTPROTECTMEMORY_BLOCK_SIZE - (cbPlainText % CRYPTPROTECTMEMORY_BLOCK_SIZE));
printf("cbPlainText: %d cbCipherText: %d\n", cbPlainText, cbCipherText);
printf("cbPlainText: %" PRIu32 " cbCipherText: %" PRIu32 "\n", cbPlainText, cbCipherText);
pCipherText = (BYTE*)malloc(cbCipherText);
if (!pCipherText)
{
@ -34,8 +38,8 @@ int TestCryptoProtectMemory(int argc, char* argv[])
return -1;
}
printf("PlainText: %s (cbPlainText = %d, cbCipherText = %d)\n", pPlainText, cbPlainText,
cbCipherText);
printf("PlainText: %s (cbPlainText = %" PRIu32 ", cbCipherText = %" PRIu32 ")\n", pPlainText,
cbPlainText, cbCipherText);
winpr_HexDump("crypto.test", WLOG_DEBUG, pCipherText, cbCipherText);
if (!CryptUnprotectMemory(pCipherText, cbCipherText, CRYPTPROTECTMEMORY_SAME_PROCESS))

View File

@ -15,6 +15,9 @@ int TestWLog(int argc, char* argv[])
char* wlog_file = NULL;
int result = 1;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
if (!(tmp_path = GetKnownPath(KNOWN_PATH_TEMP)))
{
fprintf(stderr, "Failed to get temporary directory!\n");

View File

@ -50,25 +50,25 @@ static BOOL check(const wLogMessage* msg)
return rc;
}
BOOL CallbackAppenderMessage(const wLogMessage* msg)
static BOOL CallbackAppenderMessage(const wLogMessage* msg)
{
check(msg);
return TRUE;
}
BOOL CallbackAppenderData(const wLogMessage* msg)
static BOOL CallbackAppenderData(const wLogMessage* msg)
{
fprintf(stdout, "%s\n", __FUNCTION__);
return TRUE;
}
BOOL CallbackAppenderImage(const wLogMessage* msg)
static BOOL CallbackAppenderImage(const wLogMessage* msg)
{
fprintf(stdout, "%s\n", __FUNCTION__);
return TRUE;
}
BOOL CallbackAppenderPackage(const wLogMessage* msg)
static BOOL CallbackAppenderPackage(const wLogMessage* msg)
{
fprintf(stdout, "%s\n", __FUNCTION__);
return TRUE;
@ -83,6 +83,9 @@ int TestWLogCallback(int argc, char* argv[])
wLogAppender* appender;
wLogCallbacks callbacks;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
function = __FUNCTION__;
root = WLog_GetRoot();

View File

@ -25,6 +25,7 @@
#include "BinaryAppender.h"
#include <winpr/crt.h>
#include <winpr/assert.h>
#include <winpr/file.h>
#include <winpr/path.h>
#include <winpr/stream.h>
@ -145,7 +146,8 @@ static BOOL WLog_BinaryAppender_WriteMessage(wLog* log, wLogAppender* appender,
Stream_Write_UINT32(s, message->Type);
Stream_Write_UINT32(s, message->Level);
Stream_Write_UINT32(s, message->LineNumber);
WINPR_ASSERT(message->LineNumber <= UINT32_MAX);
Stream_Write_UINT32(s, (UINT32)message->LineNumber);
Stream_Write_UINT32(s, (UINT32)FileNameLength);
Stream_Write(s, message->FileName, FileNameLength + 1);

View File

@ -30,7 +30,7 @@
#include "../../log.h"
#define TAG WINPR_TAG("utils.wlog")
BOOL WLog_DataMessage_Write(char* filename, void* data, int length)
BOOL WLog_DataMessage_Write(const char* filename, const void* data, size_t length)
{
FILE* fp;
BOOL ret = TRUE;

View File

@ -20,6 +20,6 @@
#ifndef WINPR_WLOG_DATA_MESSAGE_PRIVATE_H
#define WINPR_WLOG_DATA_MESSAGE_PRIVATE_H
BOOL WLog_DataMessage_Write(char* filename, void* data, int length);
BOOL WLog_DataMessage_Write(const char* filename, const void* data, size_t length);
#endif /* WINPR_WLOG_DATA_MESSAGE_PRIVATE_H */

View File

@ -26,7 +26,7 @@
#include "wlog/ImageMessage.h"
BOOL WLog_ImageMessage_Write(char* filename, void* data, int width, int height, int bpp)
BOOL WLog_ImageMessage_Write(char* filename, void* data, size_t width, size_t height, size_t bpp)
{
int status;

View File

@ -20,6 +20,6 @@
#ifndef WINPR_WLOG_IMAGE_MESSAGE_PRIVATE_H
#define WINPR_WLOG_IMAGE_MESSAGE_PRIVATE_H
BOOL WLog_ImageMessage_Write(char* filename, void* data, int width, int height, int bpp);
BOOL WLog_ImageMessage_Write(char* filename, void* data, size_t width, size_t height, size_t bpp);
#endif /* WINPR_WLOG_IMAGE_MESSAGE_PRIVATE_H */

View File

@ -26,6 +26,7 @@
#include <stdarg.h>
#include <winpr/crt.h>
#include <winpr/assert.h>
#include <winpr/print.h>
#include <winpr/sysinfo.h>
#include <winpr/environment.h>
@ -48,6 +49,7 @@ extern const char* WLOG_LEVELS[7];
static void WLog_PrintMessagePrefixVA(wLog* log, wLogMessage* message, const char* format,
va_list args)
{
WINPR_ASSERT(message);
if (!strchr(format, '%'))
sprintf_s(message->PrefixString, WLOG_MAX_PREFIX_SIZE - 1, "%s", format);
else
@ -70,6 +72,10 @@ BOOL WLog_Layout_GetMessagePrefix(wLog* log, wLogLayout* layout, wLogMessage* me
void* args[32];
char format[256];
SYSTEMTIME localTime;
WINPR_ASSERT(layout);
WINPR_ASSERT(message);
GetLocalTime(&localTime);
index = 0;
p = (char*)layout->FormatString;
@ -84,7 +90,7 @@ BOOL WLog_Layout_GetMessagePrefix(wLog* log, wLogLayout* layout, wLogMessage* me
{
if ((p[0] == 'l') && (p[1] == 'v')) /* log level */
{
args[argc++] = (void*)WLOG_LEVELS[message->Level];
args[argc++] = (const void*)WLOG_LEVELS[message->Level];
format[index++] = '%';
format[index++] = 's';
p++;
@ -98,7 +104,7 @@ BOOL WLog_Layout_GetMessagePrefix(wLog* log, wLogLayout* layout, wLogMessage* me
}
else if ((p[0] == 'f') && (p[1] == 'l')) /* file */
{
char* file;
const char* file;
file = strrchr(message->FileName, '/');
if (!file)
@ -107,7 +113,7 @@ BOOL WLog_Layout_GetMessagePrefix(wLog* log, wLogLayout* layout, wLogMessage* me
if (file)
file++;
else
file = (char*)message->FileName;
file = (const char*)message->FileName;
args[argc++] = (void*)file;
format[index++] = '%';
@ -116,7 +122,7 @@ BOOL WLog_Layout_GetMessagePrefix(wLog* log, wLogLayout* layout, wLogMessage* me
}
else if ((p[0] == 'f') && (p[1] == 'n')) /* function */
{
args[argc++] = (void*)message->FunctionName;
args[argc++] = (const void*)message->FunctionName;
format[index++] = '%';
format[index++] = 's';
p++;

View File

@ -375,7 +375,7 @@ static BOOL WLog_PacketMessage_Write_TcpHeader(wPcap* pcap, wTcpHeader* tcp)
static UINT32 g_InboundSequenceNumber = 0;
static UINT32 g_OutboundSequenceNumber = 0;
BOOL WLog_PacketMessage_Write(wPcap* pcap, void* data, DWORD length, DWORD flags)
BOOL WLog_PacketMessage_Write(wPcap* pcap, void* data, size_t length, DWORD flags)
{
wTcpHeader tcp;
wIPv4Header ipv4;

View File

@ -51,7 +51,7 @@ struct _wPcapRecord
{
wPcapRecordHeader header;
void* data;
UINT32 length;
size_t length;
wPcapRecord* next;
};
@ -114,6 +114,6 @@ struct _wTcpHeader
};
typedef struct _wTcpHeader wTcpHeader;
BOOL WLog_PacketMessage_Write(wPcap* pcap, void* data, DWORD length, DWORD flags);
BOOL WLog_PacketMessage_Write(wPcap* pcap, void* data, size_t length, DWORD flags);
#endif /* WINPR_WLOG_PACKET_MESSAGE_PRIVATE_H */

View File

@ -93,7 +93,7 @@ static BOOL WLog_SyslogAppender_WriteDataMessage(wLog* log, wLogAppender* append
syslogLevel = getSyslogLevel(message->Level);
if (syslogLevel >= 0)
syslog(syslogLevel, "skipped data message of %d bytes", message->Length);
syslog(syslogLevel, "skipped data message of %" PRIuz " bytes", message->Length);
return TRUE;
}
@ -108,8 +108,8 @@ static BOOL WLog_SyslogAppender_WriteImageMessage(wLog* log, wLogAppender* appen
syslogLevel = getSyslogLevel(message->Level);
if (syslogLevel >= 0)
syslog(syslogLevel, "skipped image (%dx%dx%d)", message->ImageWidth, message->ImageHeight,
message->ImageBpp);
syslog(syslogLevel, "skipped image (%" PRIuz "x%" PRIuz "x%" PRIuz ")", message->ImageWidth,
message->ImageHeight, message->ImageBpp);
return TRUE;
}

View File

@ -44,7 +44,8 @@ static BOOL WLog_UdpAppender_Open(wLog* log, wLogAppender* appender)
char addressString[256];
struct addrinfo hints;
struct addrinfo* result;
int status, addrLen;
int status;
size_t addrLen;
char* colonPos;
if (!appender)
@ -60,7 +61,7 @@ static BOOL WLog_UdpAppender_Open(wLog* log, wLogAppender* appender)
if (!colonPos)
return FALSE;
addrLen = (int)(colonPos - udpAppender->host);
addrLen = (colonPos - udpAppender->host);
memcpy(addressString, udpAppender->host, addrLen);
addressString[addrLen] = '\0';
ZeroMemory(&hints, sizeof(hints));

View File

@ -25,6 +25,7 @@
#include <string.h>
#include <winpr/crt.h>
#include <winpr/assert.h>
#include <winpr/print.h>
#include <winpr/debug.h>
#include <winpr/environment.h>
@ -41,7 +42,7 @@ struct _wLogFilter
{
DWORD Level;
LPSTR* Names;
DWORD NameCount;
size_t NameCount;
};
typedef struct _wLogFilter wLogFilter;
@ -95,13 +96,15 @@ static void WLog_Uninit_(void)
g_RootLog = NULL;
}
void WLog_Lock(wLog* log)
static void WLog_Lock(wLog* log)
{
WINPR_ASSERT(log);
EnterCriticalSection(&log->lock);
}
void WLog_Unlock(wLog* log)
static void WLog_Unlock(wLog* log)
{
WINPR_ASSERT(log);
LeaveCriticalSection(&log->lock);
}
@ -112,6 +115,10 @@ static BOOL CALLBACK WLog_InitializeRoot(PINIT_ONCE InitOnce, PVOID Parameter, P
DWORD logAppenderType;
LPCSTR appender = "WLOG_APPENDER";
WINPR_UNUSED(InitOnce);
WINPR_UNUSED(Parameter);
WINPR_UNUSED(Context);
if (!(g_RootLog = WLog_New("", NULL)))
return FALSE;
@ -171,7 +178,7 @@ fail:
return FALSE;
}
static BOOL log_recursion(LPCSTR file, LPCSTR fkt, int line)
static BOOL log_recursion(LPCSTR file, LPCSTR fkt, size_t line)
{
BOOL status = FALSE;
char** msg = NULL;
@ -206,7 +213,7 @@ static BOOL log_recursion(LPCSTR file, LPCSTR fkt, int line)
if (fprintf(stderr, "[%s]: Recursion detected!\n", fkt) < 0)
goto out;
if (fprintf(stderr, "[%s]: Check %s:%d\n", fkt, file, line) < 0)
if (fprintf(stderr, "[%s]: Check %s:%" PRIuz "\n", fkt, file, line) < 0)
goto out;
for (i = 0; i < used; i++)
@ -345,7 +352,7 @@ static BOOL WLog_WritePacket(wLog* log, wLogMessage* message)
return status;
}
BOOL WLog_PrintMessageVA(wLog* log, DWORD type, DWORD level, DWORD line, const char* file,
BOOL WLog_PrintMessageVA(wLog* log, DWORD type, DWORD level, size_t line, const char* file,
const char* function, va_list args)
{
BOOL status = FALSE;
@ -363,7 +370,7 @@ BOOL WLog_PrintMessageVA(wLog* log, DWORD type, DWORD level, DWORD line, const c
if (!strchr(message.FormatString, '%'))
{
message.TextString = (LPSTR)message.FormatString;
message.TextString = (LPCSTR)message.FormatString;
status = WLog_Write(log, &message);
}
else
@ -382,22 +389,22 @@ BOOL WLog_PrintMessageVA(wLog* log, DWORD type, DWORD level, DWORD line, const c
case WLOG_MESSAGE_DATA:
message.Data = va_arg(args, void*);
message.Length = va_arg(args, int);
message.Length = va_arg(args, size_t);
status = WLog_WriteData(log, &message);
break;
case WLOG_MESSAGE_IMAGE:
message.ImageData = va_arg(args, void*);
message.ImageWidth = va_arg(args, int);
message.ImageHeight = va_arg(args, int);
message.ImageBpp = va_arg(args, int);
message.ImageWidth = va_arg(args, size_t);
message.ImageHeight = va_arg(args, size_t);
message.ImageBpp = va_arg(args, size_t);
status = WLog_WriteImage(log, &message);
break;
case WLOG_MESSAGE_PACKET:
message.PacketData = va_arg(args, void*);
message.PacketLength = va_arg(args, int);
message.PacketFlags = va_arg(args, int);
message.PacketLength = va_arg(args, size_t);
message.PacketFlags = va_arg(args, unsigned);
status = WLog_WritePacket(log, &message);
break;
@ -408,7 +415,7 @@ BOOL WLog_PrintMessageVA(wLog* log, DWORD type, DWORD level, DWORD line, const c
return status;
}
BOOL WLog_PrintMessage(wLog* log, DWORD type, DWORD level, DWORD line, const char* file,
BOOL WLog_PrintMessage(wLog* log, DWORD type, DWORD level, size_t line, const char* file,
const char* function, ...)
{
BOOL status;
@ -490,8 +497,9 @@ static BOOL WLog_AddStringLogFilters_int(wLog* root, LPCSTR filter)
DWORD pos;
DWORD size;
DWORD count;
LPCSTR cpp;
LPSTR p;
LPSTR filterStr;
LPCSTR filterStr;
LPSTR cp;
wLogFilter* tmp;
@ -499,12 +507,12 @@ static BOOL WLog_AddStringLogFilters_int(wLog* root, LPCSTR filter)
return FALSE;
count = 1;
p = (LPSTR)filter;
cpp = filter;
while ((p = strchr(p, ',')) != NULL)
while ((cpp = strchr(cpp, ',')) != NULL)
{
count++;
p++;
cpp++;
}
pos = g_FilterCount;
@ -633,24 +641,27 @@ int WLog_ParseLogLevel(LPCSTR level)
BOOL WLog_ParseFilter(wLog* root, wLogFilter* filter, LPCSTR name)
{
const char* pc;
char* p;
char* q;
int count;
size_t count;
LPSTR names;
int iLevel;
count = 1;
WINPR_UNUSED(root);
if (!name)
return FALSE;
p = (char*)name;
pc = name;
if (p)
if (pc)
{
while ((p = strchr(p, '.')) != NULL)
while ((pc = strchr(pc, '.')) != NULL)
{
count++;
p++;
pc++;
}
}
@ -701,7 +712,7 @@ BOOL WLog_ParseFilter(wLog* root, wLogFilter* filter, LPCSTR name)
while ((p = strchr(p, '.')) != NULL)
{
if (count < (int)filter->NameCount)
if (count < filter->NameCount)
filter->Names[count++] = p + 1;
*p = '\0';
@ -783,7 +794,7 @@ LONG WLog_GetFilterLogLevel(wLog* log)
static BOOL WLog_ParseName(wLog* log, LPCSTR name)
{
char* p;
int count;
size_t count;
LPSTR names;
count = 1;
p = (char*)name;
@ -815,7 +826,7 @@ static BOOL WLog_ParseName(wLog* log, LPCSTR name)
while ((p = strchr(p, '.')) != NULL)
{
if (count < (int)log->NameCount)
if (count < log->NameCount)
log->Names[count++] = p + 1;
*p = '\0';

View File

@ -71,7 +71,7 @@ struct _wLog
BOOL IsRoot;
BOOL inherit;
LPSTR* Names;
DWORD NameCount;
size_t NameCount;
wLogAppender* Appender;
wLog* Parent;