From 8395de69278a883317b75347b00f4aa39db05419 Mon Sep 17 00:00:00 2001 From: Stephen Hines Date: Mon, 24 Sep 2018 13:03:25 -0700 Subject: [PATCH] Fix two clang-tidy issues in crasher.cpp. TEMP_FAILURE_RETRY's result was unused for the call to read(), so now mark it as such to silence a possible unused result warning. For __read_chk(), this function is an internal implementation detail of FORTIFY in Bionic. Under clang-tidy, FORTIFY checks are actually removed, so this now results in an unknown function being called. The code should not be explicitly depending on an implementation detail, but we can just suppress the failing case to retain test coverage of the actual implementation. Bug: http://b/110779387 Test: Build using WITH_TIDY=1 Change-Id: If83ac1d6f3b6dc32c0d0fb56d8e675e53b586f78 --- debuggerd/crasher/crasher.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/debuggerd/crasher/crasher.cpp b/debuggerd/crasher/crasher.cpp index f0fe1d0d9..f0bdfbfde 100644 --- a/debuggerd/crasher/crasher.cpp +++ b/debuggerd/crasher/crasher.cpp @@ -224,7 +224,7 @@ noinline int do_action(const char* arg) { // Prefixes. if (!strncmp(arg, "wait-", strlen("wait-"))) { char buf[1]; - TEMP_FAILURE_RETRY(read(STDIN_FILENO, buf, sizeof(buf))); + UNUSED(TEMP_FAILURE_RETRY(read(STDIN_FILENO, buf, sizeof(buf)))); return do_action(arg + strlen("wait-")); } else if (!strncmp(arg, "exhaustfd-", strlen("exhaustfd-"))) { errno = 0; @@ -258,10 +258,14 @@ noinline int do_action(const char* arg) { __assert("some_file.c", 123, "false"); } else if (!strcasecmp(arg, "assert2")) { __assert2("some_file.c", 123, "some_function", "false"); +#if !defined(__clang_analyzer__) } else if (!strcasecmp(arg, "fortify")) { + // FORTIFY is disabled when running clang-tidy and other tools, so this + // shouldn't depend on internal implementation details of it. char buf[10]; __read_chk(-1, buf, 32, 10); while (true) pause(); +#endif } else if (!strcasecmp(arg, "fdsan_file")) { FILE* f = fopen("/dev/null", "r"); close(fileno(f));