summaryrefslogtreecommitdiff
path: root/abspath.c
diff options
context:
space:
mode:
authorBrandon Casey <drafnel@gmail.com>2009-08-27 11:16:33 -0500
committerJunio C Hamano <gitster@pobox.com>2009-08-27 16:20:53 -0700
commit1630726e849b8b0f1802ad0681b94a64d4851a30 (patch)
tree270b4d7ca086a71c6146f1da32182847dcaecead /abspath.c
parentb42c9af2cd3dcc56c8aae9a7d73ed1fc342e1f02 (diff)
downloadgit-1630726e849b8b0f1802ad0681b94a64d4851a30.tar.gz
abspath.c: move declaration of 'len' into inner block and use appropriate type
The 'len' variable was declared at the beginning of the make_absolute_path function and also in an inner 'if' block which masked the outer declaration. It is only used in two 'if' blocks, so remove the outer declaration and make a new declaration inside the other 'if' block that uses 'len'. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'abspath.c')
-rw-r--r--abspath.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/abspath.c b/abspath.c
index 4bee0ba1ec..b88122cbe7 100644
--- a/abspath.c
+++ b/abspath.c
@@ -18,7 +18,7 @@ const char *make_absolute_path(const char *path)
{
static char bufs[2][PATH_MAX + 1], *buf = bufs[0], *next_buf = bufs[1];
char cwd[1024] = "";
- int buf_index = 1, len;
+ int buf_index = 1;
int depth = MAXDEPTH;
char *last_elem = NULL;
@@ -50,7 +50,7 @@ const char *make_absolute_path(const char *path)
die_errno ("Could not get current working directory");
if (last_elem) {
- int len = strlen(buf);
+ size_t len = strlen(buf);
if (len + strlen(last_elem) + 2 > PATH_MAX)
die ("Too long path name: '%s/%s'",
buf, last_elem);
@@ -61,7 +61,7 @@ const char *make_absolute_path(const char *path)
}
if (!lstat(buf, &st) && S_ISLNK(st.st_mode)) {
- len = readlink(buf, next_buf, PATH_MAX);
+ ssize_t len = readlink(buf, next_buf, PATH_MAX);
if (len < 0)
die_errno ("Invalid symlink '%s'", buf);
if (PATH_MAX <= len)