From a6ec96e8102693c417f44bf69c7805615f06b917 Mon Sep 17 00:00:00 2001 From: Nicholas Nezis Date: Sat, 29 Feb 2020 05:49:20 -0500 Subject: [PATCH] Patch to fix cppcheck with newer glibc (#3471) --- WORKSPACE | 8 +++++--- third_party/cppcheck/cppcheck-readdir-fix.patch | 12 ++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 third_party/cppcheck/cppcheck-readdir-fix.patch diff --git a/WORKSPACE b/WORKSPACE index ac4393fa601..065d85b25f5 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -930,10 +930,12 @@ http_archive( http_archive( name = "com_github_danmar_cppcheck", - urls = ["https://github.com/danmar/cppcheck/archive/1.87.zip"], - strip_prefix = "cppcheck-1.87", build_file = "@//:third_party/cppcheck/cppcheck.BUILD", - sha256 = "b3de7fbdc1a23d7341b55f7f88877e106a76847bd5a07fa721c07310b625318b", + patch_args = ["-p2"], + patches = ["//third_party/cppcheck:cppcheck-readdir-fix.patch"], + sha256 = "cb0e66cbe2d6b655fce430cfaaa74b83ad11c91f221e3926f1ca3211bb7c906b", + strip_prefix = "cppcheck-1.90", + urls = ["https://github.com/danmar/cppcheck/archive/1.90.zip"], ) http_archive( diff --git a/third_party/cppcheck/cppcheck-readdir-fix.patch b/third_party/cppcheck/cppcheck-readdir-fix.patch new file mode 100644 index 00000000000..bde961a3e26 --- /dev/null +++ b/third_party/cppcheck/cppcheck-readdir-fix.patch @@ -0,0 +1,12 @@ +diff -Naur cppcheck/cppcheck-1.90/cli/filelister.cpp cppcheck-fixed/cppcheck-1.90/cli/filelister.cpp +--- cppcheck/cppcheck-1.90/cli/filelister.cpp 2020-02-20 22:42:28.000000000 -0500 ++++ cppcheck-fixed/cppcheck-1.90/cli/filelister.cpp 2020-02-20 22:44:48.000000000 -0500 +@@ -194,7 +194,7 @@ + std::string new_path; + new_path.reserve(path.length() + 100);// prealloc some memory to avoid constant new/deletes in loop + +- while ((readdir_r(dir, &entry, &dir_result) == 0) && (dir_result != nullptr)) { ++ while ((dir_result = readdir(dir)) != NULL) { + + if ((std::strcmp(dir_result->d_name, ".") == 0) || + (std::strcmp(dir_result->d_name, "..") == 0))