Revision
928
Author
wsiegrist@apple.com
Date
2011-02-08 11:58:24 -0800 (Tue, 08 Feb 2011)

Log Message

Return sooner from redirection is redirect is not set

Modified Paths

Diff

Modified: branches/PR-8817822/darwintrace/darwintrace.c (927 => 928)


--- branches/PR-8817822/darwintrace/darwintrace.c	2011-02-08 19:38:26 UTC (rev 927)
+++ branches/PR-8817822/darwintrace/darwintrace.c	2011-02-08 19:58:24 UTC (rev 928)
@@ -101,17 +101,19 @@
 }
 
 /* apply redirection heuristic to path */
-static inline char* darwintrace_redirect_path(const char* path) {	
+static inline char* darwintrace_redirect_path(const char* path) {
+  if (!darwintrace_redirect) return (char*)path;
+
   char *redirpath;
   redirpath = (char *)path;
-  if (darwintrace_redirect
-      && path[0] == '/'
+  if (path[0] == '/'
       && !darwintrace_except(path)
       && strncmp(darwintrace_buildroot, path, strlen(darwintrace_buildroot))!=0
       && strncmp(darwintrace_redirect, path, strlen(darwintrace_redirect))!=0 ) {
     asprintf(&redirpath, "%s%s%s", darwintrace_redirect, (*path == '/' ? "" : "/"), path);
     dprintf("darwintrace: redirect %s -> %s\n", path, redirpath);
   }
+
   return redirpath;
 }
 
@@ -228,7 +230,7 @@
 	mode = va_arg(args, int);
 	va_end(args);
 	result = open(redirpath, flags, mode);
-	if (result >= 0 && (flags & (O_CREAT | O_WRONLY /*O_RDWR*/)) == 0 ) {
+	if (result >= 0 && (flags & (O_CREAT | O_WRONLY)) == 0 ) {
 	  darwintrace_setup();
 	  if (darwintrace_fd >= 0) {
 	    char realpath[MAXPATHLEN];