[compiler-rt] r230494 - InstrProf: Fix warnings for mixed declarations and code. NFC.
Vasileios Kalintiris
Vasileios.Kalintiris at imgtec.com
Wed Feb 25 05:50:18 PST 2015
Author: vkalintiris
Date: Wed Feb 25 07:50:18 2015
New Revision: 230494
URL: http://llvm.org/viewvc/llvm-project?rev=230494&view=rev
Log:
InstrProf: Fix warnings for mixed declarations and code. NFC.
Modified:
compiler-rt/trunk/lib/profile/InstrProfilingFile.c
Modified: compiler-rt/trunk/lib/profile/InstrProfilingFile.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingFile.c?rev=230494&r1=230493&r2=230494&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingFile.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingFile.c Wed Feb 25 07:50:18 2015
@@ -85,12 +85,15 @@ static void setFilename(const char *File
}
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) { s
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(vo
}
/* 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 c
__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));
More information about the llvm-commits
mailing list