From 08538280d01017e417e5101cb41949f6f8cf1473 Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Tue, 22 Dec 2015 23:21:14 +0500 Subject: [PATCH] cppcheck cleanup: [openvpn_config.c:194]: (style) The function 'ConfigFileOptionExist' is never used. [localization.c:299]: (style) The function 'LocalizedDialogBox' is never used. [main.c:549]: (style) The function 'PrintErrorDebug' is never used. [main.c:583]: (style) The function 'init_security_attributes_allow_all' is never used. [misc.c:180]: (style) The function 'wcseq' is never used. --- localization.c | 7 ------- localization.h | 1 - main.c | 47 ----------------------------------------------- main.h | 2 -- misc.c | 7 ------- misc.h | 1 - openvpn_config.c | 37 ------------------------------------- 7 files changed, 102 deletions(-) diff --git a/localization.c b/localization.c index ef60cd9..e2facd6 100644 --- a/localization.c +++ b/localization.c @@ -295,13 +295,6 @@ LocalizedDialogBoxParam(const UINT dialogId, DLGPROC dialogFunc, const LPARAM pa } -INT_PTR -LocalizedDialogBox(const UINT dialogId, DLGPROC dialogFunc) -{ - return LocalizedDialogBoxParam(dialogId, dialogFunc, 0); -} - - HWND CreateLocalizedDialogParam(const UINT dialogId, DLGPROC dialogFunc, const LPARAM param) { diff --git a/localization.h b/localization.h index 7a58db3..39eacd6 100644 --- a/localization.h +++ b/localization.h @@ -30,7 +30,6 @@ int ShowLocalizedMsgEx(const UINT, LPCTSTR, const UINT, ...); HICON LoadLocalizedIcon(const UINT); LPCDLGTEMPLATE LocalizedDialogResource(const UINT); INT_PTR LocalizedDialogBoxParam(const UINT, DLGPROC, const LPARAM); -INT_PTR LocalizedDialogBox(const UINT, DLGPROC); HWND CreateLocalizedDialogParam(const UINT, DLGPROC, const LPARAM); HWND CreateLocalizedDialog(const UINT, DLGPROC); INT_PTR CALLBACK LanguageSettingsDlgProc(HWND, UINT, WPARAM, LPARAM); diff --git a/main.c b/main.c index 08c5663..20e81ab 100644 --- a/main.c +++ b/main.c @@ -545,55 +545,8 @@ void PrintDebugMsg(TCHAR *msg) _ftprintf(o.debug_fp, _T("%s %s\n"), date, msg); fflush(o.debug_fp); } - -void PrintErrorDebug(TCHAR *msg) -{ - LPVOID lpMsgBuf; - TCHAR *buf; - - /* Get last error message */ - if (!FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR) &lpMsgBuf, - 0, - NULL )) - { - /* FormatMessage failed! */ - PrintDebug(_T("FormatMessage() failed. %s "), msg); - return; - } - - /* Cut of CR/LFs */ - buf = (TCHAR *)lpMsgBuf; - buf[_tcslen(buf) - 3] = '\0'; - - PrintDebug(_T("%s %s"), msg, (LPCTSTR)lpMsgBuf); - - LocalFree(lpMsgBuf); - -} #endif -bool -init_security_attributes_allow_all (struct security_attributes *obj) -{ - CLEAR (*obj); - - obj->sa.nLength = sizeof (SECURITY_ATTRIBUTES); - obj->sa.lpSecurityDescriptor = &obj->sd; - obj->sa.bInheritHandle = FALSE; - if (!InitializeSecurityDescriptor (&obj->sd, SECURITY_DESCRIPTOR_REVISION)) - return false; - if (!SetSecurityDescriptorDacl (&obj->sd, TRUE, NULL, FALSE)) - return false; - return true; -} - #define PACKVERSION(major,minor) MAKELONG(minor,major) DWORD GetDllVersion(LPCTSTR lpszDllName) { diff --git a/main.h b/main.h index 7c5f08d..091e563 100644 --- a/main.h +++ b/main.h @@ -110,8 +110,6 @@ __snprintf_0(char *buf, size_t size, char *format, ...) } void PrintDebugMsg(TCHAR *msg); -void PrintErrorDebug(TCHAR *msg); -bool init_security_attributes_allow_all (struct security_attributes *obj); #endif DWORD GetDllVersion(LPCTSTR lpszDllName); diff --git a/misc.c b/misc.c index d22a23f..e21dd93 100644 --- a/misc.c +++ b/misc.c @@ -176,13 +176,6 @@ wcsbegins(LPCWSTR str, LPCWSTR begin) return (wcsncmp(str, begin, wcslen(begin)) == 0); } -BOOL -wcseq(LPCWSTR str1, LPCWSTR str2) -{ - return (wcscmp(str1, str2) == 0); -} - - /* * Force setting window as foreground window by simulating an ALT keypress */ diff --git a/misc.h b/misc.h index d513591..615ba73 100644 --- a/misc.h +++ b/misc.h @@ -28,7 +28,6 @@ BOOL EnsureDirExists(LPTSTR); BOOL streq(LPCSTR, LPCSTR); BOOL wcsbegins(LPCWSTR, LPCWSTR); -BOOL wcseq(LPCWSTR, LPCWSTR); BOOL ForceForegroundWindow(HWND); #endif diff --git a/openvpn_config.c b/openvpn_config.c index 95e1d1f..f40a110 100644 --- a/openvpn_config.c +++ b/openvpn_config.c @@ -185,40 +185,3 @@ BuildFileList() FindClose(find_handle); } } - - -/* - * Returns TRUE if option exist in config file. - */ -bool -ConfigFileOptionExist(int config, const char *option) -{ - FILE *fp; - char line[256]; - TCHAR path[MAX_PATH]; - - _tcsncpy(path, o.conn[config].config_dir, _countof(path)); - if (path[_tcslen(path) - 1] != _T('\\')) - _tcscat(path, _T("\\")); - _tcsncat(path, o.conn[config].config_file, _countof(path) - _tcslen(path) - 1); - - fp = _tfopen(path, _T("r")); - if (fp == NULL) - { - ShowLocalizedMsg(IDS_ERR_OPEN_CONFIG, path); - return false; - } - - while (fgets(line, sizeof(line), fp)) - { - if (strncmp(line, option, strlen(option)) == 0) - { - fclose(fp); - return true; - } - } - - fclose(fp); - return false; -} -