From b0ebd1f1d5241e87c8118bd153830bf3a6ada2a7 Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Sat, 18 Aug 2018 19:24:12 +0500 Subject: [PATCH] src/Cedar/Client: remove dead code, unused functions, variables found by coverity, cppcheck [src/Cedar/Client.c:10486]: (style) The function 'CiFreeInnerVPNServer' is never used. [src/Cedar/Client.c:10877]: (style) The function 'CiGetNumActiveSessions' is never used. [src/Cedar/Client.c:2042]: (style) The function 'CiHasAccountSensitiveInformationFile' is never used. [src/Cedar/Client.c:10469]: (style) The function 'CiNewInnerVPNServer' is never used. [src/Cedar/Client.c:1128]: (style) The function 'CncGetSessionId' is never used. [src/Cedar/Client.c:767]: (style) The function 'CncPasswordDlgHaltThread' is never used. [src/Cedar/Client.c:10681]: (style) The function 'CompareInternetSetting' is never used. [src/Cedar/Client.c:11060]: (style) The function 'CtGetClient' is never used. [src/Cedar/Client.c:5128]: (style) The function 'InRpcClientNotify' is never used. [src/Cedar/Client.c:4340]: (style) The function 'InRpcEnumObjectInSecure' is never used. [src/Cedar/Client.c:5140]: (style) The function 'OutRpcClientNotify' is never used. [src/Cedar/Client.c:5657]: (style) Condition 'reg_port!=0' is always false [src/Cedar/Client.c:683]: (style) Variable 'ret' is assigned a value that is never used. [src/Cedar/Client.c:725]: (style) Variable 'ret' is assigned a value that is never used. [src/Cedar/Client.c:1013]: (style) Variable 'param' is assigned a value that is never used. --- src/Cedar/Client.c | 244 +-------------------------------------------- src/Cedar/Client.h | 13 --- 2 files changed, 4 insertions(+), 253 deletions(-) diff --git a/src/Cedar/Client.c b/src/Cedar/Client.c index 9008b0fd..1c8812b8 100644 --- a/src/Cedar/Client.c +++ b/src/Cedar/Client.c @@ -680,7 +680,6 @@ SOCK *CncNicInfo(UI_NICINFO *info) { SOCK *s; PACK *p; - bool ret = false; // Validate arguments if (info == NULL) { @@ -722,7 +721,6 @@ SOCK *CncMsgDlg(UI_MSG_DLG *dlg) { SOCK *s; PACK *p; - bool ret = false; char *utf; // Validate arguments if (dlg == NULL) @@ -763,29 +761,6 @@ void CndMsgDlgFree(SOCK *s) ReleaseSock(s); } -// The thread to stop the password input dialog client forcibly -void CncPasswordDlgHaltThread(THREAD *thread, void *param) -{ - CNC_CONNECT_ERROR_DLG_THREAD_PARAM *dp = (CNC_CONNECT_ERROR_DLG_THREAD_PARAM *)param; - // Validate arguments - if (thread == NULL || param == NULL) - { - return; - } - - while (true) - { - if (dp->Session->Halt || dp->HaltThread) - { - break; - } - - Wait(dp->Event, 100); - } - - Disconnect(dp->Sock); -} - // Show the password input dialog bool CncPasswordDlg(SESSION *session, UI_PASSWORD_DLG *dlg) { @@ -1025,7 +1000,6 @@ SOCK *CncStatusPrinterWindowStart(SESSION *s) // Send a string to the status indicator void CncStatusPrinterWindowPrint(SOCK *s, wchar_t *str) { - CNC_STATUS_PRINTER_WINDOW_PARAM *param; PACK *p; // Validate arguments if (s == NULL || str == NULL) @@ -1033,8 +1007,6 @@ void CncStatusPrinterWindowPrint(SOCK *s, wchar_t *str) return; } - param = (CNC_STATUS_PRINTER_WINDOW_PARAM *)s->Param; - p = NewPack(); PackAddUniStr(p, "string", str); SendPack(s, p); @@ -1124,41 +1096,6 @@ void CncReleaseSocket() ReleaseSock(s); } -// Get the Session ID of the client notification service -UINT CncGetSessionId() -{ - SOCK *s = CncConnect(); - PACK *p; - UINT ret; - if (s == NULL) - { - return INFINITE; - } - - p = NewPack(); - PackAddStr(p, "function", "get_session_id"); - - SendPack(s, p); - FreePack(p); - - p = RecvPack(s); - if (p == NULL) - { - Disconnect(s); - ReleaseSock(s); - return INFINITE; - } - - ret = PackGetInt(p, "session_id"); - - FreePack(p); - - Disconnect(s); - ReleaseSock(s); - - return ret; -} - // Terminate the process of the client notification service void CncExit() { @@ -2039,28 +1976,6 @@ bool CiHasAccountSensitiveInformation(BUF *b) return ret; } -bool CiHasAccountSensitiveInformationFile(wchar_t *name) -{ - bool ret = false; - BUF *b; - // Validate arguments - if (name == NULL) - { - return false; - } - - b = ReadDumpW(name); - if (b == NULL) - { - return false; - } - - ret = CiHasAccountSensitiveInformation(b); - - FreeBuf(b); - - return ret; -} // Delete the sensitive information in the account information bool CiEraseSensitiveInAccount(BUF *b) @@ -4337,33 +4252,6 @@ void CiFreeEnumObjectInSecure(RPC_ENUM_OBJECT_IN_SECURE *a) } // RPC_ENUM_OBJECT_IN_SECURE -void InRpcEnumObjectInSecure(RPC_ENUM_OBJECT_IN_SECURE *e, PACK *p) -{ - UINT i; - // Validate arguments - if (e == NULL || p == NULL) - { - return; - } - - Zero(e, sizeof(RPC_ENUM_OBJECT_IN_SECURE)); - - e->NumItem = PackGetNum(p, "NumItem"); - e->hWnd = PackGetInt(p, "hWnd"); - e->ItemName = ZeroMalloc(sizeof(char *) * e->NumItem); - e->ItemType = ZeroMalloc(sizeof(bool) * e->NumItem); - - for (i = 0;i < e->NumItem;i++) - { - char name[MAX_SIZE]; - - Zero(name, sizeof(name)); - PackGetStrEx(p, "ItemName", name, sizeof(name), i); - e->ItemName[i] = CopyStr(name); - - e->ItemType[i] = PackGetIntEx(p, "ItemType", i) ? true : false; - } -} void OutRpcEnumObjectInSecure(PACK *p, RPC_ENUM_OBJECT_IN_SECURE *e) { UINT i; @@ -5125,29 +5013,6 @@ void OutRpcClientGetConnectionStatus(PACK *p, RPC_CLIENT_GET_CONNECTION_STATUS * } } -void InRpcClientNotify(RPC_CLIENT_NOTIFY *n, PACK *p) -{ - // Validate arguments - if (n == NULL || p == NULL) - { - return; - } - - Zero(n, sizeof(RPC_CLIENT_NOTIFY)); - - n->NotifyCode = PackGetInt(p, "NotifyCode"); -} -void OutRpcClientNotify(PACK *p, RPC_CLIENT_NOTIFY *n) -{ - // Validate arguments - if (n == NULL || p == NULL) - { - return; - } - - PackAddInt(p, "NotifyCode", n->NotifyCode); -} - // Notification main void CiNotifyMain(CLIENT *c, SOCK *s) { @@ -5781,9 +5646,7 @@ REMOTE_CLIENT *CcConnectRpcEx(char *server_name, char *password, bool *bad_pass, reg_port = 0; } } -#endif // OS_WIN32 - port_start = CLIENT_CONFIG_PORT - 1; if (reg_port != 0) { s = Connect(server_name, reg_port); @@ -5794,6 +5657,10 @@ REMOTE_CLIENT *CcConnectRpcEx(char *server_name, char *password, bool *bad_pass, } } +#endif // OS_WIN32 + + port_start = CLIENT_CONFIG_PORT - 1; + RETRY: port_start++; @@ -6351,11 +6218,6 @@ bool CiCheckCertProc(SESSION *s, CONNECTION *c, X *server_x, bool *expired) } } - if (old_x != NULL) - { - FreeX(old_x); - } - return false; #endif // OS_WIN32 } @@ -10470,35 +10332,6 @@ void CiWriteSettingToCfg(CLIENT *c, FOLDER *root) } } -// Create the inner VPN Server -SERVER *CiNewInnerVPNServer(CLIENT *c, bool relay_server) -{ - SERVER *s = NULL; - // Validate arguments - if (c == NULL) - { - return NULL; - } - - SetNatTLowPriority(); - - s = SiNewServerEx(false, true, relay_server); - - return s; -} - -// Stop the inner VPN Server -void CiFreeInnerVPNServer(CLIENT *c, SERVER *s) -{ - // Validate arguments - if (c == NULL || s == NULL) - { - return; - } - - SiReleaseServer(s); -} - // Apply settings of Inner VPN Server void CiApplyInnerVPNServerConfig(CLIENT *c) { @@ -10682,48 +10515,6 @@ CLIENT *CiNewClient() return c; } -// Examine whether two proxy server settings equal -bool CompareInternetSetting(INTERNET_SETTING *s1, INTERNET_SETTING *s2) -{ - // Validate arguments - if (s1 == NULL || s2 == NULL) - { - return false; - } - - if (s1->ProxyType != s2->ProxyType) - { - return false; - } - - if (s1->ProxyType == PROXY_DIRECT) - { - return true; - } - - if (s1->ProxyPort != s2->ProxyPort) - { - return false; - } - - if (StrCmp(s1->ProxyHostName, s2->ProxyHostName) != 0) - { - return false; - } - - if (StrCmp(s1->ProxyUsername, s2->ProxyUsername) != 0) - { - return false; - } - - if (StrCmp(s1->ProxyPassword, s2->ProxyPassword) != 0) - { - return false; - } - - return true; -} - // Send a global pulse void CiSendGlobalPulse(CLIENT *c) { @@ -10878,20 +10669,6 @@ void CiDecrementNumActiveSessions() Unlock(ci_active_sessions_lock); } -// Get the number of active sessions -UINT CiGetNumActiveSessions() -{ - UINT ret; - - Lock(ci_active_sessions_lock); - { - ret = ci_num_active_sessions; - } - Unlock(ci_active_sessions_lock); - - return ret; -} - // Release the client void CtReleaseClient(CLIENT *c) { @@ -11061,19 +10838,6 @@ void CiCheckOs() } } -// Get the client object -CLIENT *CtGetClient() -{ - if (client == NULL) - { - return NULL; - } - - AddRef(client->ref); - - return client; -} - // Client status indicator void CiClientStatusPrinter(SESSION *s, wchar_t *status) { diff --git a/src/Cedar/Client.h b/src/Cedar/Client.h index 75718089..540a18f9 100644 --- a/src/Cedar/Client.h +++ b/src/Cedar/Client.h @@ -602,9 +602,6 @@ void CcSetServiceToForegroundProcess(REMOTE_CLIENT *r); char *CiGetFirstVLan(CLIENT *c); void CiNormalizeAccountVLan(CLIENT *c); -bool CompareInternetSetting(INTERNET_SETTING *s1, INTERNET_SETTING *s2); - - void CnStart(); void CnListenerProc(THREAD *thread, void *param); @@ -646,7 +643,6 @@ SOCK *CncConnect(); SOCK *CncConnectEx(UINT timeout); void CncReleaseSocket(); void CncExit(); -UINT CncGetSessionId(); bool CncExecDriverInstaller(char *arg); SOCK *CncStatusPrinterWindowStart(SESSION *s); void CncStatusPrinterWindowPrint(SOCK *s, wchar_t *str); @@ -655,7 +651,6 @@ void CncStatusPrinterWindowThreadProc(THREAD *thread, void *param); bool CncConnectErrorDlg(SESSION *session, UI_CONNECTERROR_DLG *dlg); void CncConnectErrorDlgHaltThread(THREAD *thread, void *param); bool CncPasswordDlg(SESSION *session, UI_PASSWORD_DLG *dlg); -void CncPasswordDlgHaltThread(THREAD *thread, void *param); void CncCheckCert(SESSION *session, UI_CHECKCERT *dlg); void CncCheckCertHaltThread(THREAD *thread, void *param); bool CncSecureSignDlg(SECURE_SIGN *sign); @@ -666,7 +661,6 @@ void CncNicInfoFree(SOCK *s); void CtStartClient(); void CtStopClient(); -CLIENT *CtGetClient(); void CtReleaseClient(CLIENT *c); bool CtGetClientVersion(CLIENT *c, RPC_CLIENT_VERSION *ver); bool CtGetCmSetting(CLIENT *c, CM_SETTING *s); @@ -797,13 +791,9 @@ bool CiTryToParseAccount(BUF *b); bool CiTryToParseAccountFile(wchar_t *name); bool CiEraseSensitiveInAccount(BUF *b); bool CiHasAccountSensitiveInformation(BUF *b); -bool CiHasAccountSensitiveInformationFile(wchar_t *name); void CiApplyInnerVPNServerConfig(CLIENT *c); -SERVER *CiNewInnerVPNServer(CLIENT *c, bool relay_server); -void CiFreeInnerVPNServer(CLIENT *c, SERVER *s); void CiIncrementNumActiveSessions(); void CiDecrementNumActiveSessions(); -UINT CiGetNumActiveSessions(); BUF *EncryptPassword(char *password); BUF *EncryptPassword2(char *password); @@ -828,7 +818,6 @@ void InRpcClientEnumSecure(RPC_CLIENT_ENUM_SECURE *e, PACK *p); void OutRpcClientEnumSecure(PACK *p, RPC_CLIENT_ENUM_SECURE *e); void InRpcUseSecure(RPC_USE_SECURE *u, PACK *p); void OutRpcUseSecure(PACK *p, RPC_USE_SECURE *u); -void InRpcEnumObjectInSecure(RPC_ENUM_OBJECT_IN_SECURE *e, PACK *p); void OutRpcEnumObjectInSecure(PACK *p, RPC_ENUM_OBJECT_IN_SECURE *e); void InRpcCreateVLan(RPC_CLIENT_CREATE_VLAN *v, PACK *p); void OutRpcCreateVLan(PACK *p, RPC_CLIENT_CREATE_VLAN *v); @@ -858,8 +847,6 @@ void InRpcPolicy(POLICY *o, PACK *p); void OutRpcPolicy(PACK *p, POLICY *o); void InRpcClientGetConnectionStatus(RPC_CLIENT_GET_CONNECTION_STATUS *s, PACK *p); void OutRpcClientGetConnectionStatus(PACK *p, RPC_CLIENT_GET_CONNECTION_STATUS *c); -void InRpcClientNotify(RPC_CLIENT_NOTIFY *n, PACK *p); -void OutRpcClientNotify(PACK *p, RPC_CLIENT_NOTIFY *n); void InRpcClientConfig(CLIENT_CONFIG *c, PACK *p); void OutRpcClientConfig(PACK *p, CLIENT_CONFIG *c); void InRpcClientPasswordSetting(RPC_CLIENT_PASSWORD_SETTING *a, PACK *p);