From 87702f0f7d3fb08bb6d8c22da63ebdb8b04ceaf7 Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Sun, 4 Nov 2018 00:41:12 +0500 Subject: [PATCH 1/3] src/Mayaqua/OS: remove unused functions found by cppcheck [src/Mayaqua/OS.c:493]: (style) The function 'OSDec32' is never used. [src/Mayaqua/OS.c:373]: (style) The function 'OSDeleteDir' is never used. [src/Mayaqua/OS.c:393]: (style) The function 'OSFileCreate' is never used. [src/Mayaqua/OS.c:353]: (style) The function 'OSFileDelete' is never used. [src/Mayaqua/OS.c:383]: (style) The function 'OSFileOpen' is never used. [src/Mayaqua/OS.c:331]: (style) The function 'OSFileRename' is never used. [src/Mayaqua/OS.c:487]: (style) The function 'OSInc32' is never used. [src/Mayaqua/OS.c:363]: (style) The function 'OSMakeDir' is never used. [src/Mayaqua/OS.c:541]: (style) The function 'OSResetEvent' is never used. --- src/Mayaqua/OS.c | 42 ------------------------------------------ src/Mayaqua/OS.h | 9 --------- 2 files changed, 51 deletions(-) diff --git a/src/Mayaqua/OS.c b/src/Mayaqua/OS.c index bbb0f4e8..774b88d1 100644 --- a/src/Mayaqua/OS.c +++ b/src/Mayaqua/OS.c @@ -328,10 +328,6 @@ UINT OSThreadId() } // Rename -bool OSFileRename(char *old_name, char *new_name) -{ - return os->FileRename(old_name, new_name); -} bool OSFileRenameW(wchar_t *old_name, wchar_t *new_name) { return os->FileRenameW(old_name, new_name); @@ -350,50 +346,30 @@ bool OSFileSeek(void *pData, UINT mode, int offset) } // Delete the file -bool OSFileDelete(char *name) -{ - return os->FileDelete(name); -} bool OSFileDeleteW(wchar_t *name) { return os->FileDeleteW(name); } // Create a directory -bool OSMakeDir(char *name) -{ - return os->MakeDir(name); -} bool OSMakeDirW(wchar_t *name) { return os->MakeDirW(name); } // Delete the directory -bool OSDeleteDir(char *name) -{ - return os->DeleteDir(name); -} bool OSDeleteDirW(wchar_t *name) { return os->DeleteDirW(name); } // Open the file -void *OSFileOpen(char *name, bool write_mode, bool read_lock) -{ - return os->FileOpen(name, write_mode, read_lock); -} void *OSFileOpenW(wchar_t *name, bool write_mode, bool read_lock) { return os->FileOpenW(name, write_mode, read_lock); } // Create a file -void *OSFileCreate(char *name) -{ - return os->FileCreate(name); -} void *OSFileCreateW(wchar_t *name) { return os->FileCreateW(name); @@ -483,18 +459,6 @@ void OSGetSystemTime(SYSTEMTIME *system_time) os->GetSystemTime(system_time); } -// 32bit increment -void OSInc32(UINT *value) -{ - os->Inc32(value); -} - -// 32bit decrement -void OSDec32(UINT *value) -{ - os->Dec32(value); -} - // Sleep the thread void OSSleep(UINT time) { @@ -537,12 +501,6 @@ void OSSetEvent(EVENT *event) os->SetEvent(event); } -// Reset event -void OSResetEvent(EVENT *event) -{ - os->ResetEvent(event); -} - // Wait for event bool OSWaitEvent(EVENT *event, UINT timeout) { diff --git a/src/Mayaqua/OS.h b/src/Mayaqua/OS.h index 71691639..a569357b 100644 --- a/src/Mayaqua/OS.h +++ b/src/Mayaqua/OS.h @@ -124,8 +124,6 @@ void *OSMemoryReAlloc(void *addr, UINT size); void OSMemoryFree(void *addr); UINT OSGetTick(); void OSGetSystemTime(SYSTEMTIME *system_time); -void OSInc32(UINT *value); -void OSDec32(UINT *value); void OSSleep(UINT time); LOCK *OSNewLock(); bool OSLock(LOCK *lock); @@ -133,15 +131,12 @@ void OSUnlock(LOCK *lock); void OSDeleteLock(LOCK *lock); void OSInitEvent(EVENT *event); void OSSetEvent(EVENT *event); -void OSResetEvent(EVENT *event); bool OSWaitEvent(EVENT *event, UINT timeout); void OSFreeEvent(EVENT *event); bool OSWaitThread(THREAD *t); void OSFreeThread(THREAD *t); bool OSInitThread(THREAD *t); -void *OSFileOpen(char *name, bool write_mode, bool read_lock); void *OSFileOpenW(wchar_t *name, bool write_mode, bool read_lock); -void *OSFileCreate(char *name); void *OSFileCreateW(wchar_t *name); bool OSFileWrite(void *pData, void *buf, UINT size); bool OSFileRead(void *pData, void *buf, UINT size); @@ -149,15 +144,11 @@ void OSFileClose(void *pData, bool no_flush); void OSFileFlush(void *pData); UINT64 OSFileSize(void *pData); bool OSFileSeek(void *pData, UINT mode, int offset); -bool OSFileDelete(char *name); bool OSFileDeleteW(wchar_t *name); -bool OSMakeDir(char *name); bool OSMakeDirW(wchar_t *name); -bool OSDeleteDir(char *name); bool OSDeleteDirW(wchar_t *name); CALLSTACK_DATA *OSGetCallStack(); bool OSGetCallStackSymbolInfo(CALLSTACK_DATA *s); -bool OSFileRename(char *old_name, char *new_name); bool OSFileRenameW(wchar_t *old_name, wchar_t *new_name); UINT OSThreadId(); bool OSRun(char *filename, char *arg, bool hide, bool wait); From dcc684ea285e7a10734d66444b14c3d20433326e Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Sun, 4 Nov 2018 01:02:51 +0500 Subject: [PATCH 2/3] src/Cedar/Admin.c: remove reccuring check found by PVS analyzer src/Cedar/Admin.c 5583 err V571 Recurring check. The 'if (no_include)' condition was already verified in line 5581. --- src/Cedar/Admin.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/Cedar/Admin.c b/src/Cedar/Admin.c index 1d837d9c..76e226b5 100644 --- a/src/Cedar/Admin.c +++ b/src/Cedar/Admin.c @@ -5580,19 +5580,16 @@ UINT StAddAccess(ADMIN *a, RPC_ADD_ACCESS *t) if (no_include) { - if (no_include) + if (StartWith(t->Access.SrcUsername, ACCESS_LIST_INCLUDED_PREFIX) || + StartWith(t->Access.SrcUsername, ACCESS_LIST_EXCLUDED_PREFIX)) { - if (StartWith(t->Access.SrcUsername, ACCESS_LIST_INCLUDED_PREFIX) || - StartWith(t->Access.SrcUsername, ACCESS_LIST_EXCLUDED_PREFIX)) - { - ClearStr(t->Access.SrcUsername, sizeof(t->Access.SrcUsername)); - } + ClearStr(t->Access.SrcUsername, sizeof(t->Access.SrcUsername)); + } - if (StartWith(t->Access.DestUsername, ACCESS_LIST_INCLUDED_PREFIX) || - StartWith(t->Access.DestUsername, ACCESS_LIST_EXCLUDED_PREFIX)) - { - ClearStr(t->Access.DestUsername, sizeof(t->Access.DestUsername)); - } + if (StartWith(t->Access.DestUsername, ACCESS_LIST_INCLUDED_PREFIX) || + StartWith(t->Access.DestUsername, ACCESS_LIST_EXCLUDED_PREFIX)) + { + ClearStr(t->Access.DestUsername, sizeof(t->Access.DestUsername)); } } From 6440521f8103f929c6deabc75a7122616b5ee377 Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Sun, 4 Nov 2018 01:04:58 +0500 Subject: [PATCH 3/3] src/Mayaqua/Network.c: remove reccuring check found by PVS analyzer src/Mayaqua/Network.c 18715 err V571 Recurring check. The 'if (u->GetNatTIpThread == NULL)' condition was already verified in line 18712. --- src/Mayaqua/Network.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/Mayaqua/Network.c b/src/Mayaqua/Network.c index 9556ce26..0f31ab15 100644 --- a/src/Mayaqua/Network.c +++ b/src/Mayaqua/Network.c @@ -18711,16 +18711,9 @@ LABEL_RESTART: // Create a thread to get a NAT-T IP address if necessary if (u->GetNatTIpThread == NULL) { - // Create a thread to get a NAT-T IP address if necessary - if (u->GetNatTIpThread == NULL) - { - char natt_hostname[MAX_SIZE]; - - RUDPGetRegisterHostNameByIP(natt_hostname, sizeof(natt_hostname), NULL); - - u->GetNatTIpThread = NewQueryIpThread(natt_hostname, QUERYIPTHREAD_INTERVAL_LAST_OK, QUERYIPTHREAD_INTERVAL_LAST_NG); - } - + char natt_hostname[MAX_SIZE]; + RUDPGetRegisterHostNameByIP(natt_hostname, sizeof(natt_hostname), NULL); + u->GetNatTIpThread = NewQueryIpThread(natt_hostname, QUERYIPTHREAD_INTERVAL_LAST_OK, QUERYIPTHREAD_INTERVAL_LAST_NG); GetQueryIpThreadResult(u->GetNatTIpThread, &nat_t_ip); } }