diff options
| author | Vasileios Kalintiris <Vasileios.Kalintiris@imgtec.com> | 2015-02-25 13:50:18 +0000 |
|---|---|---|
| committer | Vasileios Kalintiris <Vasileios.Kalintiris@imgtec.com> | 2015-02-25 13:50:18 +0000 |
| commit | c9c7a3e4e563696b0dd40accdc7be1bcbdc97ccf (patch) | |
| tree | 5c3b125cb3b45dc7b2173730b7448d15d638a359 /compiler-rt | |
| parent | 765b5e5bfe675cfaca24a1ab4e6706ce383c00ff (diff) | |
| download | bcm5719-llvm-c9c7a3e4e563696b0dd40accdc7be1bcbdc97ccf.tar.gz bcm5719-llvm-c9c7a3e4e563696b0dd40accdc7be1bcbdc97ccf.zip | |
InstrProf: Fix warnings for mixed declarations and code. NFC.
llvm-svn: 230494
Diffstat (limited to 'compiler-rt')
| -rw-r--r-- | compiler-rt/lib/profile/InstrProfilingFile.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/compiler-rt/lib/profile/InstrProfilingFile.c b/compiler-rt/lib/profile/InstrProfilingFile.c index 346665fd5b3..daa309427d1 100644 --- a/compiler-rt/lib/profile/InstrProfilingFile.c +++ b/compiler-rt/lib/profile/InstrProfilingFile.c @@ -85,12 +85,15 @@ static void setFilename(const char *Filename, int OwnsFilename) { } static void truncateCurrentFile(void) { - const char *Filename = __llvm_profile_CurrentFilename; + const char *Filename; + FILE *File; + + Filename = __llvm_profile_CurrentFilename; if (!Filename || !Filename[0]) return; /* Truncate the file. Later we'll reopen and append. */ - FILE *File = fopen(Filename, "w"); + File = fopen(Filename, "w"); if (!File) return; fclose(File); @@ -101,15 +104,16 @@ static void setDefaultFilename(void) { setFilename("default.profraw", 0); } int getpid(void); static int setFilenameFromEnvironment(void) { const char *Filename = getenv("LLVM_PROFILE_FILE"); +#define MAX_PID_SIZE 16 + char PidChars[MAX_PID_SIZE] = {0}; + int NumPids = 0, PidLength = 0; + char *Allocated; + int I, J; + if (!Filename || !Filename[0]) return -1; /* Check the filename for "%p", which indicates a pid-substitution. */ -#define MAX_PID_SIZE 16 - char PidChars[MAX_PID_SIZE] = {0}; - int NumPids = 0; - int PidLength = 0; - int I; for (I = 0; Filename[I]; ++I) if (Filename[I] == '%' && Filename[++I] == 'p') if (!NumPids++) { @@ -123,12 +127,11 @@ static int setFilenameFromEnvironment(void) { } /* Allocate enough space for the substituted filename. */ - char *Allocated = (char*)malloc(I + NumPids*(PidLength - 2) + 1); + Allocated = malloc(I + NumPids*(PidLength - 2) + 1); if (!Allocated) return -1; /* Construct the new filename. */ - int J; for (I = 0, J = 0; Filename[I]; ++I) if (Filename[I] == '%') { if (Filename[++I] == 'p') { @@ -171,12 +174,14 @@ void __llvm_profile_set_filename(const char *Filename) { __attribute__((visibility("hidden"))) int __llvm_profile_write_file(void) { + int rc; + /* Check the filename. */ if (!__llvm_profile_CurrentFilename) return -1; /* Write the file. */ - int rc = writeFileWithName(__llvm_profile_CurrentFilename); + rc = writeFileWithName(__llvm_profile_CurrentFilename); if (rc && getenv("LLVM_PROFILE_VERBOSE_ERRORS")) fprintf(stderr, "LLVM Profile: Failed to write file \"%s\": %s\n", __llvm_profile_CurrentFilename, strerror(errno)); |

