[Lldb-commits] [lldb] r237371 - Avoid Linux-specific header in platform-independent tests

Ed Maste emaste at freebsd.org
Thu May 14 09:39:03 PDT 2015


Author: emaste
Date: Thu May 14 11:39:02 2015
New Revision: 237371

URL: http://llvm.org/viewvc/llvm-project?rev=237371&view=rev
Log:
Avoid Linux-specific header in platform-independent tests


Modified:
    lldb/trunk/test/functionalities/process_attach/attach_denied/main.cpp

Modified: lldb/trunk/test/functionalities/process_attach/attach_denied/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/process_attach/attach_denied/main.cpp?rev=237371&r1=237370&r2=237371&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/process_attach/attach_denied/main.cpp (original)
+++ lldb/trunk/test/functionalities/process_attach/attach_denied/main.cpp Thu May 14 11:39:02 2015
@@ -2,11 +2,10 @@
 #include <fcntl.h>
 #include <signal.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 
-#include <linux/limits.h>
-
 #include <sys/types.h>
 #include <sys/ptrace.h>
 #include <sys/stat.h>
@@ -24,13 +23,14 @@
 
 bool writePid (const char* file_name, const pid_t pid)
 {
-    char tmp_file_name[PATH_MAX];
+    char *tmp_file_name = (char *)malloc(strlen(file_name) + 16);
     strcpy(tmp_file_name, file_name);
     strcat(tmp_file_name, "_tmp");
     int fd = open (tmp_file_name, O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR | S_IWUSR);
     if (fd == -1)
     {
         fprintf (stderr, "open(%s) failed: %s\n", tmp_file_name, strerror (errno));
+        free(tmp_file_name);
         return false;
     }
     char buffer[64];
@@ -49,6 +49,7 @@ bool writePid (const char* file_name, co
         fprintf (stderr, "rename(%s, %s) failed: %s\n", tmp_file_name, file_name, strerror (errno));
         res = false;
     }
+    free(tmp_file_name);
 
     return res;
 }





More information about the lldb-commits mailing list