Skip to contentSkip to conversation

Use PATH_MAX instead of MAXPATHLEN

PATCH New Jonas Fonseca 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Use PATH_MAX instead of MAXPATHLEN

According to sys/paramh.h it's a "BSD name" for values defined in <limits.h>. Besides PATH_MAX seems to be more commonly used.

---
 builtin-checkout-index.c |    2 +-
 dir.c                    |    2 +-
 entry.c                  |    4 +---
 git-compat-util.h        |    3 ---
 4 files changed, 3 insertions(+), 8 deletions(-)
builtin-checkout-index.c +1 -1
index 6b55f93..b097c88 100644
@@ -45,7 +45,7 @@ #define CHECKOUT_ALL 4
 static int line_termination = '\n';
 static int checkout_stage; /* default to checkout stage0 */
 static int to_tempfile;
-static char topath[4][MAXPATHLEN+1];
+static char topath[4][PATH_MAX + 1];
 
 static struct checkout state;
 
dir.c +1 -1
index 092d077..a686de6 100644
@@ -293,7 +293,7 @@ static int read_directory_recursive(stru
 	if (fdir) {
 		int exclude_stk;
 		struct dirent *de;
-		char fullname[MAXPATHLEN + 1];
+		char fullname[PATH_MAX + 1];
 		memcpy(fullname, base, baselen);
 
 		exclude_stk = push_exclude_per_directory(dir, base, baselen);
entry.c +1 -3
index 793724f..b2ea0ef 100644
@@ -135,7 +135,7 @@ static int write_entry(struct cache_entr
 
 int checkout_entry(struct cache_entry *ce, struct checkout *state, char *topath)
 {
-	static char path[MAXPATHLEN+1];
+	static char path[PATH_MAX + 1];
 	struct stat st;
 	int len = state->base_dir_len;
 
@@ -172,5 +172,3 @@ int checkout_entry(struct cache_entry *c
 	create_directories(path, state);
 	return write_entry(ce, path, state, 0);
 }
-
-
git-compat-util.h +0 -3
index b2e1895..91f2b0d 100644
@@ -172,7 +172,4 @@ static inline int sane_case(int x, int h
 	return x;
 }
 
-#ifndef MAXPATHLEN
-#define MAXPATHLEN 256
-#endif
 #endif
Signature · 4 lines
1.4.2.GIT

-- 
Jonas Fonseca