[PATCH 2/5] Consolidate all the PATH_MAX handling into misc.h

Christopher James Halse Rogers christopher.halse.rogers at canonical.com
Tue Mar 8 16:17:27 PST 2011


Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers at canonical.com>
---
 hw/xfree86/common/xf86Configure.c  |    5 +----
 hw/xfree86/os-support/xf86_OSlib.h |   11 +++--------
 hw/xfree86/parser/scan.c           |   11 +++--------
 include/misc.h                     |   11 +++++++++++
 os/access.c                        |   19 -------------------
 os/osinit.c                        |    9 +--------
 os/utils.c                         |   11 -----------
 7 files changed, 19 insertions(+), 58 deletions(-)

diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c
index 883c48c..c712df7 100644
--- a/hw/xfree86/common/xf86Configure.c
+++ b/hw/xfree86/common/xf86Configure.c
@@ -39,6 +39,7 @@
 #include "xf86Bus.h"
 #include "xf86Sbus.h"
 #endif
+#include "misc.h"
 
 typedef struct _DevToConfig {
     GDevRec GDev;
@@ -514,10 +515,6 @@ configureDDCMonitorSection (int screennum)
     return ptr;
 }
 
-#if !defined(PATH_MAX)
-# define PATH_MAX 1024
-#endif
-
 void
 DoConfigure(void)
 {
diff --git a/hw/xfree86/os-support/xf86_OSlib.h b/hw/xfree86/os-support/xf86_OSlib.h
index 147a201..24c92fb 100644
--- a/hw/xfree86/os-support/xf86_OSlib.h
+++ b/hw/xfree86/os-support/xf86_OSlib.h
@@ -370,6 +370,9 @@
 
 #include <sys/wait.h>	/* May need to adjust this for other OSs */
 
+/* For PATH_MAX */
+#include "misc.h"
+
 /* 
  * Hack originally for ISC 2.2 POSIX headers, but may apply elsewhere,
  * and it's safe, so just do it.
@@ -390,14 +393,6 @@
 # undef _POSIX_SOURCE
 #endif /* _POSIX_SOURCE */
 
-#if !defined(PATH_MAX)
-# if defined(MAXPATHLEN)
-#  define PATH_MAX MAXPATHLEN
-# else
-#  define PATH_MAX 1024
-# endif /* MAXPATHLEN */
-#endif /* !PATH_MAX */
-
 
 #ifndef DEV_MEM
 #define DEV_MEM "/dev/mem"
diff --git a/hw/xfree86/parser/scan.c b/hw/xfree86/parser/scan.c
index e4fce30..1cff3bc 100644
--- a/hw/xfree86/parser/scan.c
+++ b/hw/xfree86/parser/scan.c
@@ -77,18 +77,13 @@
 #undef _POSIX_SOURCE
 #endif /* _POSIX_SOURCE */
 
-#if !defined(PATH_MAX)
-#if defined(MAXPATHLEN)
-#define PATH_MAX MAXPATHLEN
-#else
-#define PATH_MAX 1024
-#endif /* MAXPATHLEN */
-#endif /* !PATH_MAX */
-
 #if !defined(MAXHOSTNAMELEN)
 #define MAXHOSTNAMELEN 32
 #endif /* !MAXHOSTNAMELEN */
 
+/* For PATH_MAX */
+#include "misc.h"
+
 #include "Configint.h"
 #include "xf86tokens.h"
 
diff --git a/include/misc.h b/include/misc.h
index 62d813e..9ab96ac 100644
--- a/include/misc.h
+++ b/include/misc.h
@@ -180,6 +180,17 @@ typedef struct _xReq *xReqPtr;
 
 #endif
 
+#ifndef PATH_MAX
+#include <sys/param.h>
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif
+#endif
+#endif 
+
 /**
  * Calculate the number of bytes needed to hold bits.
  * @param bits The minimum number of bits needed.
diff --git a/os/access.c b/os/access.c
index eb1a21d..3856e60 100644
--- a/os/access.c
+++ b/os/access.c
@@ -165,17 +165,6 @@ SOFTWARE.
 
 #endif /* WIN32 */
 
-#ifndef PATH_MAX
-#include <sys/param.h>
-#ifndef PATH_MAX
-#ifdef MAXPATHLEN
-#define PATH_MAX MAXPATHLEN
-#else
-#define PATH_MAX 1024
-#endif
-#endif
-#endif 
-
 
 #define X_INCLUDE_NETDB_H
 #include <X11/Xos_r.h>
@@ -185,14 +174,6 @@ SOFTWARE.
 
 #include "xace.h"
 
-#ifndef PATH_MAX
-#ifdef MAXPATHLEN
-#define PATH_MAX MAXPATHLEN
-#else
-#define PATH_MAX 1024
-#endif
-#endif
-
 Bool defeatAccessControl = FALSE;
 
 #define acmp(a1, a2, len) memcmp((char *)(a1), (char *)(a2), len)
diff --git a/os/osinit.c b/os/osinit.c
index 018e404..45d202d 100644
--- a/os/osinit.c
+++ b/os/osinit.c
@@ -63,17 +63,10 @@ SOFTWARE.
 #include <execinfo.h>
 #endif
 
+#include "misc.h"
 
 #include "dixstruct.h"
 
-#ifndef PATH_MAX
-#ifdef MAXPATHLEN
-#define PATH_MAX MAXPATHLEN
-#else
-#define PATH_MAX 1024
-#endif
-#endif
-
 
 #if !defined(SYSV) && !defined(WIN32) 
 #include <sys/resource.h>
diff --git a/os/utils.c b/os/utils.c
index 18fd911..a365aca 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -231,17 +231,6 @@ OsSignal(int sig, OsSigHandlerPtr handler)
 #define LOCK_PREFIX "/.X"
 #define LOCK_SUFFIX "-lock"
 
-#ifndef PATH_MAX
-#include <sys/param.h>
-#ifndef PATH_MAX
-#ifdef MAXPATHLEN
-#define PATH_MAX MAXPATHLEN
-#else
-#define PATH_MAX 1024
-#endif
-#endif
-#endif
-
 static Bool StillLocking = FALSE;
 static char LockFile[PATH_MAX];
 static Bool nolock = FALSE;
-- 
1.7.4.1



More information about the xorg-devel mailing list