Skip to content

Commit 1630726

Browse files
drafnelgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b42c9af commit 1630726

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

abspath.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const char *make_absolute_path(const char *path)
1818
{
1919
static char bufs[2][PATH_MAX + 1], *buf = bufs[0], *next_buf = bufs[1];
2020
char cwd[1024] = "";
21-
int buf_index = 1, len;
21+
int buf_index = 1;
2222

2323
int depth = MAXDEPTH;
2424
char *last_elem = NULL;
@@ -50,7 +50,7 @@ const char *make_absolute_path(const char *path)
5050
die_errno ("Could not get current working directory");
5151

5252
if (last_elem) {
53-
int len = strlen(buf);
53+
size_t len = strlen(buf);
5454
if (len + strlen(last_elem) + 2 > PATH_MAX)
5555
die ("Too long path name: '%s/%s'",
5656
buf, last_elem);
@@ -61,7 +61,7 @@ const char *make_absolute_path(const char *path)
6161
}
6262

6363
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);
6565
if (len < 0)
6666
die_errno ("Invalid symlink '%s'", buf);
6767
if (PATH_MAX <= len)

0 commit comments

Comments
 (0)