Removed strlen use in wlog (and speed up check)
This commit is contained in:
parent
27df243a33
commit
66ad508b45
@ -167,7 +167,8 @@ BOOL WLog_SetLogAppenderType(wLog* log, DWORD logAppenderType)
|
||||
|
||||
BOOL WLog_ConfigureAppender(wLogAppender *appender, const char *setting, void *value)
|
||||
{
|
||||
if (!appender || !setting || !strlen(setting))
|
||||
/* Just check the settings string is not empty */
|
||||
if (!appender || !setting || (strnlen(setting, 2) == 0))
|
||||
return FALSE;
|
||||
|
||||
if (appender->Set)
|
||||
|
@ -124,9 +124,9 @@ static BOOL WLog_BinaryAppender_WriteMessage(wLog* log, wLogAppender* appender,
|
||||
if (!fp)
|
||||
return FALSE;
|
||||
|
||||
FileNameLength = strlen(message->FileName);
|
||||
FunctionNameLength = strlen(message->FunctionName);
|
||||
TextStringLength = strlen(message->TextString);
|
||||
FileNameLength = strnlen(message->FileName, UINT32_MAX);
|
||||
FunctionNameLength = strnlen(message->FunctionName, UINT32_MAX);
|
||||
TextStringLength = strnlen(message->TextString, UINT32_MAX);
|
||||
|
||||
MessageLength = 16 +
|
||||
(4 + FileNameLength + 1) +
|
||||
@ -180,7 +180,8 @@ static BOOL WLog_BinaryAppender_Set(wLogAppender* appender, const char *setting,
|
||||
{
|
||||
wLogBinaryAppender *binaryAppender = (wLogBinaryAppender *) appender;
|
||||
|
||||
if (!value || !strlen(value))
|
||||
/* Just check if the value string is longer than 0 */
|
||||
if (!value || (strnlen(value, 2) == 0))
|
||||
return FALSE;
|
||||
|
||||
if (!strcmp("outputfilename", setting))
|
||||
|
@ -214,7 +214,8 @@ static BOOL WLog_ConsoleAppender_Set(wLogAppender* appender, const char *setting
|
||||
{
|
||||
wLogConsoleAppender *consoleAppender = (wLogConsoleAppender *)appender;
|
||||
|
||||
if (!value || !strlen(value))
|
||||
/* Just check the value string is not empty */
|
||||
if (!value || (strnlen(value, 2) == 0))
|
||||
return FALSE;
|
||||
|
||||
if (strcmp("outputstream", setting))
|
||||
|
@ -192,7 +192,8 @@ static BOOL WLog_FileAppender_Set(wLogAppender* appender, const char* setting, v
|
||||
{
|
||||
wLogFileAppender* fileAppender = (wLogFileAppender*) appender;
|
||||
|
||||
if (!value || !strlen(value))
|
||||
/* Just check the value string is not empty */
|
||||
if (!value || (strnlen(value, 2) == 0))
|
||||
return FALSE;
|
||||
|
||||
if (!strcmp("outputfilename", setting))
|
||||
|
@ -140,7 +140,8 @@ static BOOL WLog_JournaldAppender_Set(wLogAppender* appender, const char *settin
|
||||
{
|
||||
wLogJournaldAppender* journaldAppender = (wLogJournaldAppender *)appender;
|
||||
|
||||
if (!value || !strlen(value))
|
||||
/* Just check the value string is not empty */
|
||||
if (!value || (strnlen(value, 2) == 0))
|
||||
return FALSE;
|
||||
|
||||
if (strcmp("identifier", setting))
|
||||
|
@ -104,9 +104,9 @@ static BOOL WLog_UdpAppender_WriteMessage(wLog* log, wLogAppender* appender, wLo
|
||||
udpAppender = (wLogUdpAppender*)appender;
|
||||
message->PrefixString = prefix;
|
||||
WLog_Layout_GetMessagePrefix(log, appender->Layout, message);
|
||||
_sendto(udpAppender->sock, message->PrefixString, strlen(message->PrefixString),
|
||||
_sendto(udpAppender->sock, message->PrefixString, (int)strnlen(message->PrefixString, INT_MAX),
|
||||
0, &udpAppender->targetAddr, udpAppender->targetAddrLen);
|
||||
_sendto(udpAppender->sock, message->TextString, strlen(message->TextString),
|
||||
_sendto(udpAppender->sock, message->TextString, (int)strnlen(message->TextString, INT_MAX),
|
||||
0, &udpAppender->targetAddr, udpAppender->targetAddrLen);
|
||||
_sendto(udpAppender->sock, "\n", 1, 0, &udpAppender->targetAddr, udpAppender->targetAddrLen);
|
||||
return TRUE;
|
||||
@ -132,12 +132,14 @@ static BOOL WLog_UdpAppender_WriteImageMessage(wLog* log, wLogAppender* appender
|
||||
|
||||
static BOOL WLog_UdpAppender_Set(wLogAppender* appender, const char* setting, void* value)
|
||||
{
|
||||
const char target[] = "target";
|
||||
wLogUdpAppender* udpAppender = (wLogUdpAppender*)appender;
|
||||
|
||||
if (!value || !strlen(value))
|
||||
/* Just check the value string is not empty */
|
||||
if (!value || (strnlen(value, 2) == 0))
|
||||
return FALSE;
|
||||
|
||||
if (strcmp("target", setting))
|
||||
if (strncmp(target, setting, sizeof(target)))
|
||||
return FALSE;
|
||||
|
||||
udpAppender->targetAddrLen = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user