Simplify the logic that tries to open the GCDA file at all costs. Basically, if
authorBill Wendling <isanbard@gmail.com>
Mon, 28 May 2012 09:46:43 +0000 (09:46 +0000)
committerBill Wendling <isanbard@gmail.com>
Mon, 28 May 2012 09:46:43 +0000 (09:46 +0000)
we can't open the file even after creating all of the directories to it, then
just give up.

llvm-svn: 157572

compiler-rt/lib/profile/GCDAProfiling.c

index 1126787..4d0c41b 100644 (file)
@@ -113,21 +113,10 @@ void llvm_gcda_start_file(const char *orig_filename) {
   output_file = fopen(filename, "w+b");
 
   if (!output_file) {
-    int len = strlen(orig_filename) - 1;
     recursive_mkdir(filename);
-
-    for (; len >= 0 && orig_filename[len] != '/'; --len)
-      /* empty */;
-
-    if (len < 0)
-      len = 0;
-    else if (orig_filename[len] == '/')
-      ++len;
-
-    output_file = fopen(&orig_filename[len], "w+b");
-
+    output_file = fopen(filename, "w+b");
     if (!output_file) {
-      fprintf(stderr, "profiling:%s: cannot open\n", &orig_filename[len]);
+      fprintf(stderr, "profiling:%s: cannot open\n", filename);
       return;
     }
   }