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

src/Cedar/Cedar.c: resolve "Identical code for different branches", remove unused functions

found by coverity, cppcheck

[src/Cedar/Cedar.c:1605]: (style) The function 'EnableDebugLog' is never used.
[src/Cedar/Cedar.c:858]: (style) The function 'GetUnestablishedConnections' is never used.
[src/Cedar/Cedar.c:652]: (style) The function 'InitHiddenPassword' is never used.
[src/Cedar/Cedar.c:633]: (style) The function 'IsHiddenPasswordChanged' is never used.
[src/Cedar/Cedar.c:393]: (style) The function 'IsInNoSsl' is never used.
[src/Cedar/Cedar.c:1785]: (style) The function 'IsLaterBuild' is never used.
This commit is contained in:
Ilya Shipitsin 2018-08-24 15:23:45 +05:00
parent e530932df6
commit 2f7d71a567
2 changed files with 4 additions and 168 deletions

View File

@ -265,23 +265,11 @@ bool IsSupportedWinVer(RPC_WINVER *v)
if ((v->VerMajor == 6 && v->VerMinor == 4) || (v->VerMajor == 10 && v->VerMinor == 0)) if ((v->VerMajor == 6 && v->VerMinor == 4) || (v->VerMajor == 10 && v->VerMinor == 0))
{ {
if (v->IsServer == false) // Windows 10 or Windows Server 2016
if (v->ServicePack <= 0)
{ {
// Windows 10 (not Windows Server 2016) // SP0 only
if (v->ServicePack <= 0) return true;
{
// SP0 only
return true;
}
}
else
{
// Windows Server 2016
if (v->ServicePack <= 0)
{
// SP0 only
return true;
}
} }
} }
@ -389,34 +377,6 @@ int CompareNoSslList(void *p1, void *p2)
return CmpIpAddr(&n1->IpAddress, &n2->IpAddress); return CmpIpAddr(&n1->IpAddress, &n2->IpAddress);
} }
// Check whether the specified IP address is in Non-SSL connection list
bool IsInNoSsl(CEDAR *c, IP *ip)
{
bool ret = false;
// Validate arguments
if (c == NULL || ip == NULL)
{
return false;
}
LockList(c->NonSslList);
{
NON_SSL *n = SearchNoSslList(c, ip);
if (n != NULL)
{
if (n->EntryExpires > Tick64() && n->Count > NON_SSL_MIN_COUNT)
{
n->EntryExpires = Tick64() + (UINT64)NON_SSL_ENTRY_EXPIRES;
ret = true;
}
}
}
UnlockList(c->NonSslList);
return ret;
}
// Decrement connection count of Non-SSL connection list entry // Decrement connection count of Non-SSL connection list entry
void DecrementNoSsl(CEDAR *c, IP *ip, UINT num_dec) void DecrementNoSsl(CEDAR *c, IP *ip, UINT num_dec)
{ {
@ -629,37 +589,6 @@ UINT64 GetTrafficPacketNum(TRAFFIC *t)
t->Send.BroadcastCount + t->Send.UnicastCount; t->Send.BroadcastCount + t->Send.UnicastCount;
} }
// Get whether hidden password is changed in UI
bool IsHiddenPasswordChanged(char *str)
{
// Validate arguments
if (str == NULL)
{
return true;
}
if (StrCmpi(str, HIDDEN_PASSWORD) == 0)
{
return true;
}
else
{
return false;
}
}
// Initialize hidden password in UI
void InitHiddenPassword(char *str, UINT size)
{
// Validate arguments
if (str == NULL)
{
return;
}
StrCpy(str, size, HIDDEN_PASSWORD);
}
// Check whether the certificate is signed by CA which is trusted by the hub // Check whether the certificate is signed by CA which is trusted by the hub
bool CheckSignatureByCaLinkMode(SESSION *s, X *x) bool CheckSignatureByCaLinkMode(SESSION *s, X *x)
{ {
@ -854,47 +783,6 @@ void DelConnection(CEDAR *cedar, CONNECTION *c)
UnlockList(cedar->ConnectionList); UnlockList(cedar->ConnectionList);
} }
// Get the number of unestablished connections
UINT GetUnestablishedConnections(CEDAR *cedar)
{
UINT i, ret;
// Validate arguments
if (cedar == NULL)
{
return 0;
}
ret = 0;
LockList(cedar->ConnectionList);
{
for (i = 0;i < LIST_NUM(cedar->ConnectionList);i++)
{
CONNECTION *c = LIST_DATA(cedar->ConnectionList, i);
switch (c->Type)
{
case CONNECTION_TYPE_CLIENT:
case CONNECTION_TYPE_INIT:
case CONNECTION_TYPE_LOGIN:
case CONNECTION_TYPE_ADDITIONAL:
switch (c->Status)
{
case CONNECTION_STATUS_ACCEPTED:
case CONNECTION_STATUS_NEGOTIATION:
case CONNECTION_STATUS_USERAUTH:
ret++;
break;
}
break;
}
}
}
UnlockList(cedar->ConnectionList);
return ret + Count(cedar->AcceptingSockets);
}
// Add connection to Cedar // Add connection to Cedar
void AddConnection(CEDAR *cedar, CONNECTION *c) void AddConnection(CEDAR *cedar, CONNECTION *c)
{ {
@ -1601,18 +1489,6 @@ void SetCedarCert(CEDAR *c, X *server_x, K *server_k)
Unlock(c->lock); Unlock(c->lock);
} }
// Enable debug log
void EnableDebugLog(CEDAR *c)
{
// Validate arguments
if (c == NULL || c->DebugLog != NULL)
{
return;
}
c->DebugLog = NewLog("cedar_debug_log", "cedar", LOG_SWITCH_NO);
}
// Set the Cedar into VPN Bridge mode // Set the Cedar into VPN Bridge mode
void SetCedarVpnBridge(CEDAR *c) void SetCedarVpnBridge(CEDAR *c)
{ {
@ -1781,40 +1657,6 @@ CEDAR *NewCedar(X *server_x, K *server_k)
return c; return c;
} }
// Check whether the Cedar was build after the specified date
bool IsLaterBuild(CEDAR *c, UINT64 t)
{
SYSTEMTIME sb, st;
UINT64 b;
// Validate arguments
if (c == NULL)
{
return false;
}
Zero(&sb, sizeof(sb));
Zero(&st, sizeof(st));
UINT64ToSystem(&sb, c->BuiltDate);
UINT64ToSystem(&st, t);
// Ignore time of the day
sb.wHour = sb.wMinute = sb.wSecond = sb.wMilliseconds = 0;
st.wHour = st.wMinute = st.wSecond = st.wMilliseconds = 0;
b = SystemToUINT64(&sb);
t = SystemToUINT64(&st);
if (b > t)
{
return true;
}
else
{
return false;
}
}
// Cumulate traffic size // Cumulate traffic size
void AddTraffic(TRAFFIC *dst, TRAFFIC *diff) void AddTraffic(TRAFFIC *dst, TRAFFIC *diff)
{ {

View File

@ -1211,7 +1211,6 @@ void DelHubEx(CEDAR *c, HUB *h, bool no_lock);
void StopAllHub(CEDAR *c); void StopAllHub(CEDAR *c);
void StopAllConnection(CEDAR *c); void StopAllConnection(CEDAR *c);
void AddConnection(CEDAR *cedar, CONNECTION *c); void AddConnection(CEDAR *cedar, CONNECTION *c);
UINT GetUnestablishedConnections(CEDAR *cedar);
void DelConnection(CEDAR *cedar, CONNECTION *c); void DelConnection(CEDAR *cedar, CONNECTION *c);
void SetCedarCipherList(CEDAR *cedar, char *name); void SetCedarCipherList(CEDAR *cedar, char *name);
void InitCedar(); void InitCedar();
@ -1225,11 +1224,8 @@ void InitNetSvcList(CEDAR *cedar);
void FreeNetSvcList(CEDAR *cedar); void FreeNetSvcList(CEDAR *cedar);
int CompareNetSvc(void *p1, void *p2); int CompareNetSvc(void *p1, void *p2);
char *GetSvcName(CEDAR *cedar, bool udp, UINT port); char *GetSvcName(CEDAR *cedar, bool udp, UINT port);
void InitHiddenPassword(char *str, UINT size);
bool IsHiddenPasswordChanged(char *str);
UINT64 GetTrafficPacketSize(TRAFFIC *t); UINT64 GetTrafficPacketSize(TRAFFIC *t);
UINT64 GetTrafficPacketNum(TRAFFIC *t); UINT64 GetTrafficPacketNum(TRAFFIC *t);
void EnableDebugLog(CEDAR *c);
void StartCedarLog(); void StartCedarLog();
void StopCedarLog(); void StopCedarLog();
int CompareNoSslList(void *p1, void *p2); int CompareNoSslList(void *p1, void *p2);
@ -1239,13 +1235,11 @@ bool AddNoSsl(CEDAR *c, IP *ip);
void DecrementNoSsl(CEDAR *c, IP *ip, UINT num_dec); void DecrementNoSsl(CEDAR *c, IP *ip, UINT num_dec);
void DeleteOldNoSsl(CEDAR *c); void DeleteOldNoSsl(CEDAR *c);
NON_SSL *SearchNoSslList(CEDAR *c, IP *ip); NON_SSL *SearchNoSslList(CEDAR *c, IP *ip);
bool IsInNoSsl(CEDAR *c, IP *ip);
void FreeTinyLog(TINY_LOG *t); void FreeTinyLog(TINY_LOG *t);
void WriteTinyLog(TINY_LOG *t, char *str); void WriteTinyLog(TINY_LOG *t, char *str);
TINY_LOG *NewTinyLog(); TINY_LOG *NewTinyLog();
void GetWinVer(RPC_WINVER *v); void GetWinVer(RPC_WINVER *v);
bool IsSupportedWinVer(RPC_WINVER *v); bool IsSupportedWinVer(RPC_WINVER *v);
bool IsLaterBuild(CEDAR *c, UINT64 t);
SOCK *GetInProcListeningSock(CEDAR *c); SOCK *GetInProcListeningSock(CEDAR *c);
SOCK *GetReverseListeningSock(CEDAR *c); SOCK *GetReverseListeningSock(CEDAR *c);
void GetCedarVersion(char *tmp, UINT size); void GetCedarVersion(char *tmp, UINT size);