aboutsummaryrefslogtreecommitdiffstats
path: root/testing/motion/get_current_dir_name.patch
blob: d7e3816c2f8347fcb3f4b3cd23507ab63a13b2c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
The check for get_current_dir_name appears to be broken. you need
set _GNU_SOURCE for it.

But that triggered other issue with broken ifdefs so we simply avoid
using get_current_dir_name alltogether.

--- ./conf.c.orig
+++ ./conf.c
@@ -32,16 +32,6 @@
 #include "video.h"
 #endif /* BSD */
 
-#ifndef HAVE_GET_CURRENT_DIR_NAME
-char *get_current_dir_name(void)
-{
-    char *buf = malloc(MAXPATHLEN);
-    getwd(buf);
-    return buf;
-}
-#endif
-
-
 #define stripnewline(x) {if ((x)[strlen(x)-1]=='\n') (x)[strlen(x) - 1] = 0;}
 
 
@@ -1645,18 +1635,17 @@
     }
 
     if (!fp) {      /* Commandline didn't work, try current dir */
-        char *path = NULL;
+        char path[PATH_MAX];
         if (cnt[0]->conf_filename[0])
             motion_log(-1, 1, "Configfile %s not found - trying defaults.", filename);
         
-        if ((path = get_current_dir_name()) == NULL) {
+        if (getcwd(path, PATH_MAX) == NULL) {
             motion_log(LOG_ERR, 1, "Error get_current_dir_name");
             exit(-1);
         }
 
         snprintf(filename, PATH_MAX, "%s/motion.conf", path);
         fp = fopen (filename, "r");
-        free(path);
     }
 
     if (!fp) {     /* specified file does not exist... try default file */