Skip to content

Commit

Permalink
compat.h: include the compatible definition for PATH_MAX
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
konis committed Feb 19, 2024
1 parent 8f2521a commit 919ac39
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
8 changes: 8 additions & 0 deletions include/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@
#endif /* __BYTE_ORDER */


#if HAVE_LIMITS_H
#include <limits.h> /* PATH_MAX */
#endif /* HAVE_LIMITS_H */

#ifndef PATH_MAX
#define PATH_MAX 8192
#endif

#if HAVE_SYS_SYSMACROS_H
#include <sys/sysmacros.h> /* major(), minor() */
#else
Expand Down
2 changes: 1 addition & 1 deletion lib/nilfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
#include <errno.h>
#include <assert.h>
#include "nilfs.h"
#include "compat.h"
#include "compat.h" /* PATH_MAX, etc */
#include "util.h"
#include "pathnames.h"
#include "realpath.h"
Expand Down
9 changes: 1 addition & 8 deletions lib/realpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@
* since the libc version has some security flaws.
*/

#if HAVE_LIMITS_H
#include <limits.h> /* for PATH_MAX */
#endif /* HAVE_LIMITS_H */

#ifndef PATH_MAX
#define PATH_MAX 8192
#endif

#if HAVE_STDLIB_H
#include <stdlib.h> /* free() */
#endif /* HAVE_STDLIB_H */
Expand All @@ -48,6 +40,7 @@
#endif /* HAVE_STRINGS_H */

#include <errno.h>
#include "compat.h" /* PATH_MAX */
#include "realpath.h"

#define MAX_READLINKS 32
Expand Down

0 comments on commit 919ac39

Please sign in to comment.