From 2c532e8b79b6c61d0b5490e4bbc15230ea4c6759 Mon Sep 17 00:00:00 2001 From: Takeshi Nakatani Date: Mon, 27 May 2024 14:31:28 +0000 Subject: [PATCH] Fixed error reports of failure in cppcheck 2.14.0 --- Makefile.am | 1 + src/curl.h | 10 +++++----- src/test_curl_util.cpp | 2 +- src/test_page_list.cpp | 2 +- src/test_string_util.cpp | 2 +- test/truncate_read_file.cc | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Makefile.am b/Makefile.am index 84b782a9bc..508c9aa7ef 100644 --- a/Makefile.am +++ b/Makefile.am @@ -46,6 +46,7 @@ cppcheck: --suppress=unmatchedSuppression \ --suppress=useStlAlgorithm \ --suppress=checkLevelNormal \ + --suppress=normalCheckLevelMaxBranches \ src/ test/ # diff --git a/src/curl.h b/src/curl.h index 74d6958d2d..9b4ecdbef6 100644 --- a/src/curl.h +++ b/src/curl.h @@ -385,11 +385,11 @@ class S3fsCurl // methods(variables) CURL* GetCurlHandle() const { return hCurl; } - std::string GetPath() const { return path; } - std::string GetBasePath() const { return base_path; } - std::string GetSpecialSavedPath() const { return saved_path; } - std::string GetUrl() const { return url; } - std::string GetOp() const { return op; } + const std::string& GetPath() const { return path; } + const std::string& GetBasePath() const { return base_path; } + const std::string& GetSpecialSavedPath() const { return saved_path; } + const std::string& GetUrl() const { return url; } + const std::string& GetOp() const { return op; } const headers_t* GetResponseHeaders() const { return &responseHeaders; } const std::string* GetBodyData() const { return &bodydata; } const std::string* GetHeadData() const { return &headdata; } diff --git a/src/test_curl_util.cpp b/src/test_curl_util.cpp index 126172837e..2e0ea9cb92 100644 --- a/src/test_curl_util.cpp +++ b/src/test_curl_util.cpp @@ -150,7 +150,7 @@ void test_slist_remove() curl_slist_free_all(list); } -int main(int argc, char *argv[]) +int main(int argc, const char *argv[]) { test_sort_insert(); test_slist_remove(); diff --git a/src/test_page_list.cpp b/src/test_page_list.cpp index 1edf2278ab..63a0642d36 100644 --- a/src/test_page_list.cpp +++ b/src/test_page_list.cpp @@ -72,7 +72,7 @@ void test_compress() ASSERT_EQUALS(off_t(36), size); } -int main(int argc, char *argv[]) +int main(int argc, const char *argv[]) { test_compress(); return 0; diff --git a/src/test_string_util.cpp b/src/test_string_util.cpp index 3dcc34d4ce..20f49f1b8e 100644 --- a/src/test_string_util.cpp +++ b/src/test_string_util.cpp @@ -197,7 +197,7 @@ void test_cr_encoding() ASSERT_EQUALS(get_decoded_cr_code(get_encoded_cr_code(base_mid_crper2.c_str()).c_str()), base_mid_crper2); } -int main(int argc, char *argv[]) +int main(int argc, const char *argv[]) { S3fsLog singletonLog; diff --git a/test/truncate_read_file.cc b/test/truncate_read_file.cc index 9228a15e27..0dd890e3bb 100644 --- a/test/truncate_read_file.cc +++ b/test/truncate_read_file.cc @@ -31,7 +31,7 @@ // This program truncates the file and reads the file in another process // between truncate and flush(close file). // -int main(int argc, char *argv[]) +int main(int argc, const char *argv[]) { if(argc != 3){ fprintf(stderr, "[ERROR] Wrong paraemters\n");