From b81372b56bc832390f03ea2e347f794adb599212 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Fri, 8 Jun 2018 07:48:03 +0000 Subject: [PATCH] [XRay][compiler-rt] Cleanup some internal XRay utilities This change uses 'const' for the retryingWriteAll(...) API and removes unnecessary 'static' local variables in getting the temporary filename. llvm-svn: 334267 --- compiler-rt/lib/xray/xray_utils.cc | 12 ++++++------ compiler-rt/lib/xray/xray_utils.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/compiler-rt/lib/xray/xray_utils.cc b/compiler-rt/lib/xray/xray_utils.cc index 2fadad87b494..a27ac9451138 100644 --- a/compiler-rt/lib/xray/xray_utils.cc +++ b/compiler-rt/lib/xray/xray_utils.cc @@ -15,11 +15,11 @@ #include "sanitizer_common/sanitizer_common.h" #include "xray_defs.h" #include "xray_flags.h" -#include #include #include #include #include +#include #include #include #include @@ -31,7 +31,7 @@ void printToStdErr(const char *Buffer) XRAY_NEVER_INSTRUMENT { fprintf(stderr, "%s", Buffer); } -void retryingWriteAll(int Fd, char *Begin, char *End) XRAY_NEVER_INSTRUMENT { +void retryingWriteAll(int Fd, const char *Begin, const char *End) XRAY_NEVER_INSTRUMENT { if (Begin == End) return; auto TotalBytes = std::distance(Begin, End); @@ -94,10 +94,10 @@ bool readValueFromFile(const char *Filename, int getLogFD() XRAY_NEVER_INSTRUMENT { // Open a temporary file once for the log. - static char TmpFilename[256] = {}; - static char TmpWildcardPattern[] = "XXXXXX"; - auto Argv = GetArgv(); - const char *Progname = Argv[0] == nullptr ? "(unknown)" : Argv[0]; + char TmpFilename[256] = {}; + char TmpWildcardPattern[] = "XXXXXX"; + auto **Argv = GetArgv(); + const char *Progname = !Argv ? "(unknown)" : Argv[0]; const char *LastSlash = internal_strrchr(Progname, '/'); if (LastSlash != nullptr) diff --git a/compiler-rt/lib/xray/xray_utils.h b/compiler-rt/lib/xray/xray_utils.h index 1ecc74a2dce8..a06a59491daa 100644 --- a/compiler-rt/lib/xray/xray_utils.h +++ b/compiler-rt/lib/xray/xray_utils.h @@ -24,7 +24,7 @@ namespace __xray { void printToStdErr(const char *Buffer); // EINTR-safe write routine, provided a file descriptor and a character range. -void retryingWriteAll(int Fd, char *Begin, char *End); +void retryingWriteAll(int Fd, const char *Begin, const char *End); // Reads a long long value from a provided file. bool readValueFromFile(const char *Filename, long long *Value);