1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-11-22 17:39:53 +03:00

src/Cedar/Session: modify code to avoid "Identical code for different branches", remove unused functions.

found by coverity, cppcheck

[src/Cedar/Session.c:1856]: (style) The function 'CompareSession' is never used.
[src/Cedar/Session.c:2384]: (style) The function 'DebugPrintSessionKey' is never used.
[src/Cedar/Session.c:2102]: (style) The function 'GetSessionFromKey32' is never used.
This commit is contained in:
Ilya Shipitsin 2018-08-29 12:36:09 +05:00
parent eb0edeb1db
commit c81dfc0e58
2 changed files with 3 additions and 94 deletions

View File

@ -1261,22 +1261,11 @@ void StopSessionEx(SESSION *s, bool no_wait)
// Event
Set(s->HaltEvent);
if (s->ServerMode == false)
{
// Client mode
// Server and client mode
if (s->Connection)
{
StopConnection(s->Connection, no_wait);
}
}
else
{
// Server mode
if (s->Connection)
{
StopConnection(s->Connection, no_wait);
}
}
// Wait until the stop
if (no_wait == false)
@ -1863,23 +1852,6 @@ SKIP:
}
}
// Name comparison of sessions
int CompareSession(void *p1, void *p2)
{
SESSION *s1, *s2;
if (p1 == NULL || p2 == NULL)
{
return 0;
}
s1 = *(SESSION **)p1;
s2 = *(SESSION **)p2;
if (s1 == NULL || s2 == NULL)
{
return 0;
}
return StrCmpi(s1->Name, s2->Name);
}
// Create an RPC session
SESSION *NewRpcSession(CEDAR *cedar, CLIENT_OPTION *option)
{
@ -2109,52 +2081,6 @@ SESSION *NewClientSession(CEDAR *cedar, CLIENT_OPTION *option, CLIENT_AUTH *auth
return NewClientSessionEx(cedar, option, auth, pa, NULL, NicDownOnDisconnect);
}
// Get the session from the 32bit session key
SESSION *GetSessionFromKey32(CEDAR *cedar, UINT key32)
{
HUB *h;
UINT i, j;
// Validate arguments
if (cedar == NULL)
{
return NULL;
}
LockList(cedar->HubList);
{
for (i = 0;i < LIST_NUM(cedar->HubList);i++)
{
h = LIST_DATA(cedar->HubList, i);
LockList(h->SessionList);
{
for (j = 0;j < LIST_NUM(h->SessionList);j++)
{
SESSION *s = LIST_DATA(h->SessionList, j);
Lock(s->lock);
{
if (s->SessionKey32 == key32)
{
// Session found
AddRef(s->ref);
// Unlock
Unlock(s->lock);
UnlockList(h->SessionList);
UnlockList(cedar->HubList);
return s;
}
}
Unlock(s->lock);
}
}
UnlockList(h->SessionList);
}
}
UnlockList(cedar->HubList);
return NULL;
}
// Get the session from the session key
SESSION *GetSessionFromKey(CEDAR *cedar, UCHAR *session_key)
{
@ -2391,20 +2317,6 @@ bool IsIpcMacAddress(UCHAR *mac)
return false;
}
// Display the session key for debugging
void DebugPrintSessionKey(UCHAR *session_key)
{
char tmp[MAX_SIZE];
// Validate arguments
if (session_key == NULL)
{
return;
}
Bit160ToStr(tmp, session_key);
Debug("SessionKey: %s\n", tmp);
}
// Display the status on the client
void PrintStatus(SESSION *s, wchar_t *str)
{

View File

@ -413,15 +413,12 @@ void StopSession(SESSION *s);
void StopSessionEx(SESSION *s, bool no_wait);
bool SessionConnect(SESSION *s);
bool ClientConnect(CONNECTION *c);
int CompareSession(void *p1, void *p2);
PACKET_ADAPTER *NewPacketAdapter(PA_INIT *init, PA_GETCANCEL *getcancel, PA_GETNEXTPACKET *getnext,
PA_PUTPACKET *put, PA_FREE *free);
void FreePacketAdapter(PACKET_ADAPTER *pa);
void SessionMain(SESSION *s);
void NewSessionKey(CEDAR *cedar, UCHAR *session_key, UINT *session_key_32);
SESSION *GetSessionFromKey(CEDAR *cedar, UCHAR *session_key);
SESSION *GetSessionFromKey32(CEDAR *cedar, UINT key32);
void DebugPrintSessionKey(UCHAR *session_key);
bool IsIpcMacAddress(UCHAR *mac);
void ClientAdditionalConnectChance(SESSION *s);
void SessionAdditionalConnect(SESSION *s);