Skip to content

Commit

Permalink
Consolidate all the PATH_MAX handling into misc.h
Browse files Browse the repository at this point in the history
Reviewed-by: Adam Jackson <[email protected]>
Signed-off-by: Christopher James Halse Rogers <[email protected]>
  • Loading branch information
RAOF authored and nwnk committed Mar 14, 2011
1 parent 021393d commit d17a9fb
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 58 deletions.
5 changes: 1 addition & 4 deletions hw/xfree86/common/xf86Configure.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "xf86Bus.h"
#include "xf86Sbus.h"
#endif
#include "misc.h"

typedef struct _DevToConfig {
GDevRec GDev;
Expand Down Expand Up @@ -514,10 +515,6 @@ configureDDCMonitorSection (int screennum)
return ptr;
}

#if !defined(PATH_MAX)
# define PATH_MAX 1024
#endif

void
DoConfigure(void)
{
Expand Down
11 changes: 3 additions & 8 deletions hw/xfree86/os-support/xf86_OSlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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"
Expand Down
11 changes: 3 additions & 8 deletions hw/xfree86/parser/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
11 changes: 11 additions & 0 deletions include/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,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.
Expand Down
19 changes: 0 additions & 19 deletions os/access.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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)
Expand Down
9 changes: 1 addition & 8 deletions os/osinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
11 changes: 0 additions & 11 deletions os/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d17a9fb

Please sign in to comment.