Skip to content

Commit bc16da9

Browse files
committed
compat.h: include the compatible definition for PATH_MAX
This moves the definition of PATH_MAX, including completions where PATH_MAX is undefined, to "compat.h" so that it does not have to be defined in multiple places. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
1 parent fdf9d4e commit bc16da9

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

include/compat.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@
136136
#endif /* __BYTE_ORDER */
137137

138138

139+
#if HAVE_LIMITS_H
140+
#include <limits.h> /* PATH_MAX */
141+
#endif /* HAVE_LIMITS_H */
142+
143+
#ifndef PATH_MAX
144+
#define PATH_MAX 8192
145+
#endif
146+
139147
#if HAVE_SYS_SYSMACROS_H
140148
#include <sys/sysmacros.h> /* major(), minor() */
141149
#else

lib/nilfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
#include <errno.h>
7575
#include <assert.h>
7676
#include "nilfs.h"
77-
#include "compat.h"
77+
#include "compat.h" /* PATH_MAX, etc */
7878
#include "util.h"
7979
#include "pathnames.h"
8080
#include "realpath.h"

lib/realpath.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,6 @@
2727
* since the libc version has some security flaws.
2828
*/
2929

30-
#if HAVE_LIMITS_H
31-
#include <limits.h> /* for PATH_MAX */
32-
#endif /* HAVE_LIMITS_H */
33-
34-
#ifndef PATH_MAX
35-
#define PATH_MAX 8192
36-
#endif
37-
3830
#if HAVE_STDLIB_H
3931
#include <stdlib.h> /* free() */
4032
#endif /* HAVE_STDLIB_H */
@@ -48,6 +40,7 @@
4840
#endif /* HAVE_STRINGS_H */
4941

5042
#include <errno.h>
43+
#include "compat.h" /* PATH_MAX */
5144
#include "realpath.h"
5245

5346
#define MAX_READLINKS 32

0 commit comments

Comments
 (0)