From: Michael Haggerty Date: Sat, 18 Jan 2014 22:48:46 GMT Subject: [PATCH v3 02/17] safe_create_leading_directories(): reduce scope of local variable Message-ID: <1390085341-2553-3-git-send-email-mhagger@alum.mit.edu> In-Reply-To: <1390085341-2553-1-git-send-email-mhagger@alum.mit.edu> This makes it more obvious that values of "st" don't persist across loop iterations. Signed-off-by: Michael Haggerty --- sha1_file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sha1_file.c b/sha1_file.c index 8031d51..d8647c7 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -108,9 +108,10 @@ int mkdir_in_gitdir(const char *path) int safe_create_leading_directories(char *path) { char *pos = path + offset_1st_component(path); - struct stat st; while (pos) { + struct stat st; + pos = strchr(pos, '/'); if (!pos) break; -- 1.8.5.2