From d72329c007269babaa179617806db03a8dd7eb1e Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Tue, 27 Nov 2018 01:52:27 +0500 Subject: [PATCH] src/Mayaqua/Cfg: remove unused functions, variables found by cppcheck [src/Mayaqua/Cfg.c:669]: (style) Variable 'invalid_file' is assigned a value that is never used. [src/Mayaqua/Cfg.c:2111]: (style) Variable 'v' is assigned a value that is never used. [src/Mayaqua/Cfg.c:1114]: (style) The function 'CfgFolderToBufText' is never used. [src/Mayaqua/Cfg.c:539]: (style) The function 'CfgRead' is never used. [src/Mayaqua/Cfg.c:418]: (style) The function 'CfgSave' is never used. [src/Mayaqua/Cfg.c:1425]: (style) The function 'CfgStrToType' is never used. [src/Mayaqua/Cfg.c:708]: (style) The function 'CfgTest' is never used. [src/Mayaqua/Cfg.c:704]: (style) The function 'CfgTest2' is never used. [src/Mayaqua/Cfg.c:247]: (style) The function 'NewCfgRwW' is never used. --- src/Mayaqua/Cfg.c | 68 ----------------------------------------------- src/Mayaqua/Cfg.h | 5 ---- 2 files changed, 73 deletions(-) diff --git a/src/Mayaqua/Cfg.c b/src/Mayaqua/Cfg.c index 8dd2f1d2..588f3a6f 100644 --- a/src/Mayaqua/Cfg.c +++ b/src/Mayaqua/Cfg.c @@ -244,10 +244,6 @@ CFG_RW *NewCfgRw(FOLDER **root, char *cfg_name) { return NewCfgRwEx(root, cfg_name, false); } -CFG_RW *NewCfgRwW(FOLDER **root, wchar_t *cfg_name) -{ - return NewCfgRwExW(root, cfg_name, false); -} CFG_RW *NewCfgRwEx(FOLDER **root, char *cfg_name, bool dont_backup) { wchar_t *cfg_name_w = CopyStrToUni(cfg_name); @@ -556,7 +552,6 @@ FOLDER *CfgReadW(wchar_t *name) FOLDER *f; bool delete_new = false; bool binary_file = false; - bool invalid_file = false; UCHAR header[8]; bool has_eof = false; // Validate arguments @@ -613,11 +608,6 @@ FOLDER *CfgReadW(wchar_t *name) { // Read the original file too if the size of temporary file is 0 if (FileSize(o) == 0) - { - invalid_file = true; - } - - if (invalid_file) { FileClose(o); o = FileOpenW(name, false); @@ -666,7 +656,6 @@ FOLDER *CfgReadW(wchar_t *name) if (Cmp(hash1, hash2, SHA1_SIZE) != 0) { // Corrupted file - invalid_file = true; FreeBuf(b); return NULL; } @@ -700,46 +689,6 @@ FOLDER *CfgReadW(wchar_t *name) return f; } -// Test of Cfg -void CfgTest2(FOLDER *f, UINT n) -{ -} - -void CfgTest() -{ -#if 0 - FOLDER *root; - BUF *b; - Debug("\nCFG Test Begin\n"); - - root = CfgCreateFolder(NULL, TAG_ROOT); - CfgTest2(root, 5); - - b = CfgFolderToBufText(root); - //Print("%s\n", b->Buf); - SeekBuf(b, 0, 0); - - CfgDeleteFolder(root); - - DumpBuf(b, "test1.config"); - - root = CfgBufTextToFolder(b); - - FreeBuf(b); - - b = CfgFolderToBufText(root); -// Print("%s\n", b->Buf); - DumpBuf(b, "test2.config"); - FreeBuf(b); - - CfgSave(root, "test.txt"); - - CfgDeleteFolder(root); - - Debug("\nCFG Test End\n"); -#endif -} - // Read one line char *CfgReadNextLine(BUF *b) { @@ -1111,10 +1060,6 @@ BUF *CfgFolderToBufBin(FOLDER *f) } // Convert the folder to a stream text -BUF *CfgFolderToBufText(FOLDER *f) -{ - return CfgFolderToBufTextEx(f, false); -} BUF *CfgFolderToBufTextEx(FOLDER *f, bool no_banner) { BUF *b; @@ -1421,17 +1366,6 @@ void CfgAddData(BUF *b, UINT type, char *name, char *data, char *sub, UINT depth Free(tmp); } -// Convert the data type string to an integer value -UINT CfgStrToType(char *str) -{ - if (!StrCmpi(str, TAG_INT)) return ITEM_TYPE_INT; - if (!StrCmpi(str, TAG_INT64)) return ITEM_TYPE_INT64; - if (!StrCmpi(str, TAG_BYTE)) return ITEM_TYPE_BYTE; - if (!StrCmpi(str, TAG_STRING)) return ITEM_TYPE_STRING; - if (!StrCmpi(str, TAG_BOOL)) return ITEM_TYPE_BOOL; - return 0; -} - // Convert the type of data to a string char *CfgTypeToStr(UINT type) { @@ -2101,14 +2035,12 @@ ITEM *CfgAddInt(FOLDER *f, char *name, UINT i) // Adding a bool type ITEM *CfgAddBool(FOLDER *f, char *name, bool b) { - bool v; // Validate arguments if (f == NULL || name == NULL) { return NULL; } - v = b ? 1 : 0; return CfgCreateItem(f, name, ITEM_TYPE_BOOL, &b, sizeof(bool)); } diff --git a/src/Mayaqua/Cfg.h b/src/Mayaqua/Cfg.h index 2ffe4fb5..c1d5a8ee 100644 --- a/src/Mayaqua/Cfg.h +++ b/src/Mayaqua/Cfg.h @@ -210,14 +210,11 @@ BUF *CfgGetBuf(FOLDER *f, char *name); bool CfgGetStr(FOLDER *f, char *name, char *str, UINT size); bool CfgGetUniStr(FOLDER *f, char *name, wchar_t *str, UINT size); bool CfgIsItem(FOLDER *f, char *name); -void CfgTest(); -void CfgTest2(FOLDER *f, UINT n); char *CfgEscape(char *name); bool CfgCheckCharForName(char c); char *CfgUnescape(char *str); BUF *CfgFolderToBuf(FOLDER *f, bool textmode); BUF *CfgFolderToBufEx(FOLDER *f, bool textmode, bool no_banner); -BUF *CfgFolderToBufText(FOLDER *f); BUF *CfgFolderToBufTextEx(FOLDER *f, bool no_banner); BUF *CfgFolderToBufBin(FOLDER *f); void CfgOutputFolderText(BUF *b, FOLDER *f, UINT depth); @@ -226,7 +223,6 @@ void CfgAddLine(BUF *b, char *str, UINT depth); void CfgAddDeclare(BUF *b, char *name, UINT depth); void CfgAddEnd(BUF *b, UINT depth); void CfgAddData(BUF *b, UINT type, char *name, char *data, char *sub, UINT depth); -UINT CfgStrToType(char *str); char *CfgTypeToStr(UINT type); void CfgAddItemText(BUF *b, ITEM *t, UINT depth); bool CfgEnumFolderProc(FOLDER *f, void *param); @@ -248,7 +244,6 @@ FOLDER *CfgCreateRoot(); void CfgTest(); void CfgTest2(FOLDER *f, UINT n); CFG_RW *NewCfgRw(FOLDER **root, char *cfg_name); -CFG_RW *NewCfgRwW(FOLDER **root, wchar_t *cfg_name); CFG_RW *NewCfgRwEx(FOLDER **root, char *cfg_name, bool dont_backup); CFG_RW *NewCfgRwExW(FOLDER **root, wchar_t *cfg_name, bool dont_backup); CFG_RW *NewCfgRwEx2W(FOLDER **root, wchar_t *cfg_name, bool dont_backup, wchar_t *template_name);