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

Merge pull request #229 from chipitsine/master

cppcheck issues
This commit is contained in:
Daiyuu Nobori 2016-11-27 17:25:03 +09:00 committed by GitHub
commit 5cae447c79
9 changed files with 17 additions and 17 deletions

View File

@ -11840,12 +11840,12 @@ void InRpcHubEnumCa(RPC_HUB_ENUM_CA *t, PACK *p)
void OutRpcHubEnumCa(PACK *p, RPC_HUB_ENUM_CA *t) void OutRpcHubEnumCa(PACK *p, RPC_HUB_ENUM_CA *t)
{ {
UINT i; UINT i;
PackAddStr(p, "HubName", t->HubName);
// Validate arguments // Validate arguments
if (t == NULL || p == NULL) if (t == NULL || p == NULL)
{ {
return; return;
} }
PackAddStr(p, "HubName", t->HubName);
for (i = 0;i < t->NumCa;i++) for (i = 0;i < t->NumCa;i++)
{ {
@ -12313,12 +12313,12 @@ void InRpcEnumAccessList(RPC_ENUM_ACCESS_LIST *a, PACK *p)
void OutRpcEnumAccessList(PACK *p, RPC_ENUM_ACCESS_LIST *a) void OutRpcEnumAccessList(PACK *p, RPC_ENUM_ACCESS_LIST *a)
{ {
UINT i; UINT i;
PackAddStr(p, "HubName", a->HubName);
// Validate arguments // Validate arguments
if (a == NULL || p == NULL) if (a == NULL || p == NULL)
{ {
return; return;
} }
PackAddStr(p, "HubName", a->HubName);
for (i = 0;i < a->NumAccess;i++) for (i = 0;i < a->NumAccess;i++)
{ {
@ -12573,12 +12573,12 @@ void InRpcEnumUser(RPC_ENUM_USER *t, PACK *p)
void OutRpcEnumUser(PACK *p, RPC_ENUM_USER *t) void OutRpcEnumUser(PACK *p, RPC_ENUM_USER *t)
{ {
UINT i; UINT i;
PackAddStr(p, "HubName", t->HubName);
// Validate arguments // Validate arguments
if (t == NULL || p == NULL) if (t == NULL || p == NULL)
{ {
return; return;
} }
PackAddStr(p, "HubName", t->HubName);
for (i = 0;i < t->NumUser;i++) for (i = 0;i < t->NumUser;i++)
{ {
@ -12787,12 +12787,12 @@ void InRpcEnumSession(RPC_ENUM_SESSION *t, PACK *p)
void OutRpcEnumSession(PACK *p, RPC_ENUM_SESSION *t) void OutRpcEnumSession(PACK *p, RPC_ENUM_SESSION *t)
{ {
UINT i; UINT i;
PackAddStr(p, "HubName", t->HubName);
// Validate arguments // Validate arguments
if (t == NULL || p == NULL) if (t == NULL || p == NULL)
{ {
return; return;
} }
PackAddStr(p, "HubName", t->HubName);
for (i = 0;i < t->NumSession;i++) for (i = 0;i < t->NumSession;i++)
{ {

View File

@ -2181,13 +2181,13 @@ BUF *CiAccountToCfg(RPC_CLIENT_CREATE_ACCOUNT *t)
// RPC dispatch routine // RPC dispatch routine
PACK *CiRpcDispatch(RPC *rpc, char *name, PACK *p) PACK *CiRpcDispatch(RPC *rpc, char *name, PACK *p)
{ {
CLIENT *c = rpc->Param;
PACK *ret; PACK *ret;
// Validate arguments // Validate arguments
if (rpc == NULL || name == NULL || p == NULL) if (rpc == NULL || name == NULL || p == NULL)
{ {
return NULL; return NULL;
} }
CLIENT *c = rpc->Param;
ret = NewPack(); ret = NewPack();
@ -6029,11 +6029,11 @@ L_TRY:
ReleaseSock(s); ReleaseSock(s);
ret = ZeroMalloc(sizeof(REMOTE_CLIENT)); ret = ZeroMalloc(sizeof(REMOTE_CLIENT));
ret->Rpc = rpc;
rpc->Param = ret; rpc->Param = ret;
if (ret != NULL) if (ret != NULL)
{ {
ret->Rpc = rpc;
RPC_CLIENT_VERSION t; RPC_CLIENT_VERSION t;
Zero(&t, sizeof(t)); Zero(&t, sizeof(t));
CcGetClientVersion(ret, &t); CcGetClientVersion(ret, &t);

View File

@ -1030,7 +1030,7 @@ void ConnectionSend(CONNECTION *c, UINT64 now)
UINT size; UINT size;
SESSION *s; SESSION *s;
HUB *hub = NULL; HUB *hub = NULL;
bool use_qos; bool use_qos = false;
// Validate arguments // Validate arguments
if (c == NULL) if (c == NULL)
{ {
@ -1038,11 +1038,11 @@ void ConnectionSend(CONNECTION *c, UINT64 now)
} }
s = c->Session; s = c->Session;
use_qos = s->QoS;
if (s != NULL) if (s != NULL)
{ {
hub = s->Hub; hub = s->Hub;
use_qos = s->QoS;
} }
// Protocol // Protocol

View File

@ -872,7 +872,6 @@ UINT SmDDnsDlg(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param)
// Get the ddns key from the server configuration file // Get the ddns key from the server configuration file
static UINT SmDdnsGetKey(char *key, SM_DDNS *d){ static UINT SmDdnsGetKey(char *key, SM_DDNS *d){
RPC *rpc = d->s->Rpc;
RPC_CONFIG config; RPC_CONFIG config;
UINT err; UINT err;
BUF *buf; BUF *buf;
@ -882,6 +881,7 @@ static UINT SmDdnsGetKey(char *key, SM_DDNS *d){
if(d == NULL || d->s == NULL || key == NULL){ if(d == NULL || d->s == NULL || key == NULL){
return ERR_INTERNAL_ERROR; return ERR_INTERNAL_ERROR;
} }
RPC *rpc = d->s->Rpc;
Zero(&config, sizeof(config)); Zero(&config, sizeof(config));
err = ScGetConfig(d->s->Rpc, &config); err = ScGetConfig(d->s->Rpc, &config);

View File

@ -116,7 +116,6 @@
// Polling process // Polling process
void UdpAccelPoll(UDP_ACCEL *a) void UdpAccelPoll(UDP_ACCEL *a)
{ {
UCHAR *tmp = a->TmpBuf;
IP nat_t_ip; IP nat_t_ip;
UINT num_ignore_errors = 0; UINT num_ignore_errors = 0;
// Validate arguments // Validate arguments
@ -124,6 +123,7 @@ void UdpAccelPoll(UDP_ACCEL *a)
{ {
return; return;
} }
UCHAR *tmp = a->TmpBuf;
Lock(a->NatT_Lock); Lock(a->NatT_Lock);
{ {

View File

@ -2386,7 +2386,6 @@ bool NnTestConnectivity(NATIVE_STACK *a, TUBE *halt_tube)
UINT64 next_send_tick = 0; UINT64 next_send_tick = 0;
UINT64 giveup_time; UINT64 giveup_time;
IPC *ipc; IPC *ipc;
UINT src_port = NnGenSrcPort(a->IsIpRawMode);
INTERRUPT_MANAGER *interrupt; INTERRUPT_MANAGER *interrupt;
TUBE *tubes[3]; TUBE *tubes[3];
UINT num_tubes = 0; UINT num_tubes = 0;
@ -2399,6 +2398,7 @@ bool NnTestConnectivity(NATIVE_STACK *a, TUBE *halt_tube)
{ {
return false; return false;
} }
UINT src_port = NnGenSrcPort(a->IsIpRawMode);
Copy(&using_dns, &a->DnsServerIP, sizeof(IP)); Copy(&using_dns, &a->DnsServerIP, sizeof(IP));
@ -3997,7 +3997,6 @@ bool NatTransactIcmp(VH *v, NAT_ENTRY *n)
void *buf; void *buf;
UINT recv_size; UINT recv_size;
BLOCK *block; BLOCK *block;
UINT dest_port = n->DestPort;
IP dest_ip; IP dest_ip;
UINT num_ignore_errors = 0; UINT num_ignore_errors = 0;
// Validate arguments // Validate arguments
@ -4005,6 +4004,7 @@ bool NatTransactIcmp(VH *v, NAT_ENTRY *n)
{ {
return true; return true;
} }
UINT dest_port = n->DestPort;
if (n->DisconnectNow) if (n->DisconnectNow)
{ {
@ -4200,7 +4200,6 @@ bool NatTransactUdp(VH *v, NAT_ENTRY *n)
void *buf; void *buf;
UINT recv_size; UINT recv_size;
BLOCK *block; BLOCK *block;
UINT dest_port = n->DestPort;
IP dest_ip; IP dest_ip;
UINT num_ignore_errors; UINT num_ignore_errors;
// Validate arguments // Validate arguments
@ -4208,6 +4207,7 @@ bool NatTransactUdp(VH *v, NAT_ENTRY *n)
{ {
return true; return true;
} }
UINT dest_port = n->DestPort;
if (n->DisconnectNow) if (n->DisconnectNow)
{ {

View File

@ -1725,12 +1725,12 @@ static wchar_t *WuUniReadFile(char *filename)
static void WuUniReplace(wchar_t **buf, wchar_t *from, wchar_t *to) static void WuUniReplace(wchar_t **buf, wchar_t *from, wchar_t *to)
{ {
UINT dstsize; UINT dstsize;
wchar_t *oldbuf = *buf;
if(buf == NULL || from == NULL || to == NULL) if(buf == NULL || from == NULL || to == NULL)
{ {
return; return;
} }
wchar_t *oldbuf = *buf;
dstsize = (UniCalcReplaceStrEx(*buf, from, to, true) + 1) * sizeof(wchar_t); dstsize = (UniCalcReplaceStrEx(*buf, from, to, true) + 1) * sizeof(wchar_t);
*buf = (wchar_t*)Malloc(dstsize); *buf = (wchar_t*)Malloc(dstsize);

View File

@ -380,13 +380,13 @@ void ZipAddFileStart(ZIP_PACKER *p, char *name, UINT size, UINT64 dt, UINT attri
// Add data to the file // Add data to the file
UINT ZipAddFileData(ZIP_PACKER *p, void *data, UINT pos, UINT len) UINT ZipAddFileData(ZIP_PACKER *p, void *data, UINT pos, UINT len)
{ {
UINT total_size = p->CurrentFile->CurrentSize + len;
UINT ret; UINT ret;
// Validate arguments // Validate arguments
if (p == NULL) if (p == NULL)
{ {
return 0; return 0;
} }
UINT total_size = p->CurrentFile->CurrentSize + len;
if (total_size > p->CurrentFile->Size) if (total_size > p->CurrentFile->Size)
{ {
return 0; return 0;

View File

@ -1834,9 +1834,9 @@ PKT *ParsePacketEx4(UCHAR *buf, UINT size, bool no_l3, UINT vlan_type_id, bool b
if ((p->TypeL3 == L3_IPV4 || p->TypeL3 == L3_IPV6) && p->TypeL4 == L4_TCP) if ((p->TypeL3 == L3_IPV4 || p->TypeL3 == L3_IPV6) && p->TypeL4 == L4_TCP)
{ {
TCP_HEADER *tcp = p->L4.TCPHeader; TCP_HEADER *tcp = p->L4.TCPHeader;
if (tcp->DstPort == port_raw || tcp->DstPort == port_raw2) if (tcp != NULL && (!((tcp->Flag & TCP_SYN) || (tcp->Flag & TCP_RST) || (tcp->Flag & TCP_FIN))))
{ {
if (tcp != NULL && (!((tcp->Flag & TCP_SYN) || (tcp->Flag & TCP_RST) || (tcp->Flag & TCP_FIN)))) if (tcp->DstPort == port_raw || tcp->DstPort == port_raw2)
{ {
if (p->PayloadSize >= 1) if (p->PayloadSize >= 1)
{ {