1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-12-24 17:19:52 +03:00

resolve several issues found by cppcheck (#483)

[src/Cedar/Connection.c:1090] -> [src/Cedar/Connection.c:1086]:
(warning) Either the condition 's!=NULL' is redundant or there is possible null pointer dereference: s.

macros IS_SEND_TCP_SOCK expands into "s" dereferencing, so check for NULL should go before that macros

[src/Cedar/Protocol.c:2951] -> [src/Cedar/Protocol.c:2892]:
(warning) Either the condition 'policy!=NULL' is redundant or there is possible null pointer dereference: policy.
[src/Cedar/Protocol.c:2951] -> [src/Cedar/Protocol.c:2901]:
(warning) Either the condition 'policy!=NULL' is redundant or there is possible null pointer dereference: policy.
[src/Cedar/Protocol.c:3151] -> [src/Cedar/Protocol.c:3082]:
(warning) Either the condition 'policy!=NULL' is redundant or there is possible null pointer dereference: policy.
[src/Cedar/Protocol.c:3151] -> [src/Cedar/Protocol.c:3083]:
(warning) Either the condition 'policy!=NULL' is redundant or there is possible null pointer dereference: policy.

as we already have a check

			if (policy == NULL)
			{
				// Use the default policy
				policy = ClonePolicy(GetDefaultPolicy());
                        }

no need to compare policy with NULL anymore
This commit is contained in:
Ilya Shipitsin 2018-05-14 13:00:25 +05:00 committed by Moataz Elmasry
parent 6cdeb69a86
commit f5645fe3fd
2 changed files with 5 additions and 13 deletions

View File

@ -1082,12 +1082,12 @@ void ConnectionSend(CONNECTION *c, UINT64 now)
for (i = 0;i < num;i++)
{
TCPSOCK *tcpsock = tcpsocks[i];
if (tcpsock->Sock->Connected && tcpsock->Sock->AsyncMode &&
if (s != NULL && tcpsock->Sock->Connected && tcpsock->Sock->AsyncMode &&
IS_SEND_TCP_SOCK(tcpsock))
{
// Processing of KeepAlive
if (now >= tcpsock->NextKeepAliveTime || tcpsock->NextKeepAliveTime == 0 ||
(s != NULL && s->UseUdpAcceleration && s->UdpAccel != NULL && s->UdpAccel->MyPortByNatTServerChanged))
(s->UseUdpAcceleration && s->UdpAccel != NULL && s->UdpAccel->MyPortByNatTServerChanged))
{
// Send the KeepAlive
SendKeepAlive(c, tcpsock);

View File

@ -2948,12 +2948,9 @@ bool ServerAccept(CONNECTION *c)
// VLAN ID
if (assigned_vlan_id != 0)
{
if (policy != NULL)
if (policy->VLanId == 0)
{
if (policy->VLanId == 0)
{
policy->VLanId = assigned_vlan_id;
}
policy->VLanId = assigned_vlan_id;
}
}
@ -3146,12 +3143,7 @@ bool ServerAccept(CONNECTION *c)
s->Timeout = timeout;
s->QoS = qos;
s->NoReconnectToSession = no_reconnect_to_session;
if (policy != NULL)
{
s->VLanId = policy->VLanId;
}
s->VLanId = policy->VLanId;
// User name
s->Username = CopyStr(username);