summaryrefslogtreecommitdiff
path: root/src/unittest
diff options
context:
space:
mode:
authorSmallJoker <SmallJoker@users.noreply.github.com>2020-10-05 09:07:33 +0200
committerGitHub <noreply@github.com>2020-10-05 09:07:33 +0200
commitf46509d5e2c681b6da2abdeb27779be3c36a6916 (patch)
treedf654ae11cb73825e071e8222f37a73a1a604707 /src/unittest
parent81c66d6efb9fb0ab8a03b40e2bc22aa49eff9a04 (diff)
downloadminetest-f46509d5e2c681b6da2abdeb27779be3c36a6916.tar.gz
minetest-f46509d5e2c681b6da2abdeb27779be3c36a6916.tar.bz2
minetest-f46509d5e2c681b6da2abdeb27779be3c36a6916.zip
Remove unused functions reported by cppcheck (#10463)
Run unused functions reported by cppcheck This change removes a few (but not all) unused functions. Some unused helper functions were not removed due to their complexity and potential of future use.
Diffstat (limited to 'src/unittest')
-rw-r--r--src/unittest/test_map_settings_manager.cpp28
1 files changed, 2 insertions, 26 deletions
diff --git a/src/unittest/test_map_settings_manager.cpp b/src/unittest/test_map_settings_manager.cpp
index 0a5c971b9..3d642a9b4 100644
--- a/src/unittest/test_map_settings_manager.cpp
+++ b/src/unittest/test_map_settings_manager.cpp
@@ -65,31 +65,6 @@ void check_noise_params(const NoiseParams *np1, const NoiseParams *np2)
}
-std::string read_file_to_string(const std::string &filepath)
-{
- std::string buf;
- FILE *f = fopen(filepath.c_str(), "rb");
- if (!f)
- return "";
-
- fseek(f, 0, SEEK_END);
-
- long filesize = ftell(f);
- if (filesize == -1) {
- fclose(f);
- return "";
- }
- rewind(f);
-
- buf.resize(filesize);
-
- UASSERTEQ(size_t, fread(&buf[0], 1, filesize, f), 1);
-
- fclose(f);
- return buf;
-}
-
-
void TestMapSettingsManager::makeUserConfig(Settings *conf)
{
conf->set("mg_name", "v7");
@@ -199,7 +174,8 @@ void TestMapSettingsManager::testMapSettingsManager()
};
SHA1 ctx;
- std::string metafile_contents = read_file_to_string(test_mapmeta_path);
+ std::string metafile_contents;
+ UASSERT(fs::ReadFile(test_mapmeta_path, metafile_contents));
ctx.addBytes(&metafile_contents[0], metafile_contents.size());
unsigned char *sha1_result = ctx.getDigest();
int resultdiff = memcmp(sha1_result, expected_contents_hash, 20);