diff mbox

fix PATH_MAX conditional compilation

Message ID 1251928742-380-1-git-send-email-jcd@tribudubois.net
State Superseded
Headers show

Commit Message

Jean-Christophe Dubois Sept. 2, 2009, 9:59 p.m. UTC
PATH_MAX is used elsewhere in the qemu source tree without protection.

In addtion the actual code would not compile if PATH_MAX is not defined

Last the free() call is wrong as p is not malloc()ed.

Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net>
---
 vl.c |   11 ++---------
 1 files changed, 2 insertions(+), 9 deletions(-)
diff mbox

Patch

diff --git a/vl.c b/vl.c
index a894285..1bdc586 100644
--- a/vl.c
+++ b/vl.c
@@ -4703,9 +4703,7 @@  static char *find_datadir(const char *argv0)
     char *dir;
     char *p = NULL;
     char *res;
-#ifdef PATH_MAX
     char buf[PATH_MAX];
-#endif
     size_t max_len;
 
 #if defined(__linux__)
@@ -4730,10 +4728,7 @@  static char *find_datadir(const char *argv0)
     /* If we don't have any way of figuring out the actual executable
        location then try argv[0].  */
     if (!p) {
-#ifdef PATH_MAX
-        p = buf;
-#endif
-        p = realpath(argv0, p);
+        p = realpath(argv0, buf);
         if (!p) {
             return NULL;
         }
@@ -4752,9 +4747,7 @@  static char *find_datadir(const char *argv0)
             res = NULL;
         }
     }
-#ifndef PATH_MAX
-    free(p);
-#endif
+
     return res;
 }
 #undef SHARE_SUFFIX