path: root/cache.h
diff options
authorNguyễn Thái Ngọc Duy <>2014-11-30 08:24:27 (GMT)
committerJunio C Hamano <>2014-12-01 19:00:10 (GMT)
commitdcf692625ac569fefbe52269061230f4fde10e47 (patch)
treea56beac7a3de4c6bd8557288f802fc28738b52a4 /cache.h
parent4ef9caf5431dbbd23f240a25b69a989aeb9840a4 (diff)
path.c: make get_pathname() call sites return const char *
Before the previous commit, get_pathname returns an array of PATH_MAX length. Even if git_path() and similar functions does not use the whole array, git_path() caller can, in theory. After the commit, get_pathname() may return a buffer that has just enough room for the returned string and git_path() caller should never write beyond that. Make git_path(), mkpath() and git_path_submodule() return a const buffer to make sure callers do not write in it at all. This could have been part of the previous commit, but the "const" conversion is too much distraction from the core changes in path.c. Signed-off-by: Nguyễn Thái Ngọc Duy <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'cache.h')
1 files changed, 3 insertions, 3 deletions
diff --git a/cache.h b/cache.h
index 99ed096..dbee0a3 100644
--- a/cache.h
+++ b/cache.h
@@ -687,9 +687,9 @@ extern char *mkpathdup(const char *fmt, ...)
__attribute__((format (printf, 1, 2)));
/* Return a statically allocated filename matching the sha1 signature */
-extern char *mkpath(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
-extern char *git_path(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
-extern char *git_path_submodule(const char *path, const char *fmt, ...)
+extern const char *mkpath(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
+extern const char *git_path(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
+extern const char *git_path_submodule(const char *path, const char *fmt, ...)
__attribute__((format (printf, 2, 3)));