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>
Brandon Casey committed
Aug 27, 2009 at 11:16 UTC
1630726e849b8b0f1802ad0681b94a64d4851a30
1 file changed
+3
-3
abspath.c
+3
-3
@@ -18,7 +18,7 @@ const char *make_absolute_path(const char *path)
18
{
19
static char bufs[2][PATH_MAX + 1], *buf = bufs[0], *next_buf = bufs[1];
20
char cwd[1024] = "";
21
- int buf_index = 1, len;
21
+ int buf_index = 1;
22
23
int depth = MAXDEPTH;
24
char *last_elem = NULL;
@@ -50,7 +50,7 @@ const char *make_absolute_path(const char *path)
50
die_errno ("Could not get current working directory");
51
52
if (last_elem) {
53
- int len = strlen(buf);
53
+ size_t len = strlen(buf);
54
if (len + strlen(last_elem) + 2 > PATH_MAX)
55
die ("Too long path name: '%s/%s'",
56
buf, last_elem);
@@ -61,7 +61,7 @@ const char *make_absolute_path(const char *path)
61
}
62
63
if (!lstat(buf, &st) && S_ISLNK(st.st_mode)) {
64
- len = readlink(buf, next_buf, PATH_MAX);
64
+ ssize_t len = readlink(buf, next_buf, PATH_MAX);
65
if (len < 0)
66
die_errno ("Invalid symlink '%s'", buf);
67
if (PATH_MAX <= len)