Skip to content

Commit 156f524

Browse files
pks-tdscho
authored andcommitted
object-file: rename variables in check_collision()
Rename variables used in `check_collision()` to clearly identify which file is the source and which is the destination. This will make the next step easier to reason about when we start to treat those files different from one another. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e18be56 commit 156f524

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

object-file.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,56 +1970,56 @@ static void write_object_file_prepare_literally(const struct git_hash_algo *algo
19701970
hash_object_body(algo, &c, buf, len, oid, hdr, hdrlen);
19711971
}
19721972

1973-
static int check_collision(const char *filename_a, const char *filename_b)
1973+
static int check_collision(const char *source, const char *dest)
19741974
{
1975-
char buf_a[4096], buf_b[4096];
1976-
int fd_a = -1, fd_b = -1;
1975+
char buf_source[4096], buf_dest[4096];
1976+
int fd_source = -1, fd_dest = -1;
19771977
int ret = 0;
19781978

1979-
fd_a = open(filename_a, O_RDONLY);
1980-
if (fd_a < 0) {
1979+
fd_source = open(source, O_RDONLY);
1980+
if (fd_source < 0) {
19811981
if (errno != ENOENT)
1982-
ret = error_errno(_("unable to open %s"), filename_a);
1982+
ret = error_errno(_("unable to open %s"), source);
19831983
goto out;
19841984
}
19851985

1986-
fd_b = open(filename_b, O_RDONLY);
1987-
if (fd_b < 0) {
1986+
fd_dest = open(dest, O_RDONLY);
1987+
if (fd_dest < 0) {
19881988
if (errno != ENOENT)
1989-
ret = error_errno(_("unable to open %s"), filename_b);
1989+
ret = error_errno(_("unable to open %s"), dest);
19901990
goto out;
19911991
}
19921992

19931993
while (1) {
19941994
ssize_t sz_a, sz_b;
19951995

1996-
sz_a = read_in_full(fd_a, buf_a, sizeof(buf_a));
1996+
sz_a = read_in_full(fd_source, buf_source, sizeof(buf_source));
19971997
if (sz_a < 0) {
1998-
ret = error_errno(_("unable to read %s"), filename_a);
1998+
ret = error_errno(_("unable to read %s"), source);
19991999
goto out;
20002000
}
20012001

2002-
sz_b = read_in_full(fd_b, buf_b, sizeof(buf_b));
2002+
sz_b = read_in_full(fd_dest, buf_dest, sizeof(buf_dest));
20032003
if (sz_b < 0) {
2004-
ret = error_errno(_("unable to read %s"), filename_b);
2004+
ret = error_errno(_("unable to read %s"), dest);
20052005
goto out;
20062006
}
20072007

2008-
if (sz_a != sz_b || memcmp(buf_a, buf_b, sz_a)) {
2008+
if (sz_a != sz_b || memcmp(buf_source, buf_dest, sz_a)) {
20092009
ret = error(_("files '%s' and '%s' differ in contents"),
2010-
filename_a, filename_b);
2010+
source, dest);
20112011
goto out;
20122012
}
20132013

2014-
if (sz_a < sizeof(buf_a))
2014+
if (sz_a < sizeof(buf_source))
20152015
break;
20162016
}
20172017

20182018
out:
2019-
if (fd_a > -1)
2020-
close(fd_a);
2021-
if (fd_b > -1)
2022-
close(fd_b);
2019+
if (fd_source > -1)
2020+
close(fd_source);
2021+
if (fd_dest > -1)
2022+
close(fd_dest);
20232023
return ret;
20242024
}
20252025

0 commit comments

Comments
 (0)