Skip to content

Commit 53e1a76

Browse files
author
Junio C Hamano
committed
finish_connect(): thinkofix
All but one callers have ignore the return value from this function, but the only caller, builtin-tar-tree.c::remote_tar(), assumed it returns non-zero on failure and zero on success. The implementation however was returning either the waited pid (which must be the same as its input) or -1 (an error). Fix this thinko, while getting rid of an assignment of return value from waitpid() into a variable of type int. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1d6249e commit 53e1a76

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

connect.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -737,14 +737,9 @@ int git_connect(int fd[2], char *url, const char *prog)
737737

738738
int finish_connect(pid_t pid)
739739
{
740-
int ret;
741-
742-
for (;;) {
743-
ret = waitpid(pid, NULL, 0);
744-
if (!ret)
745-
break;
740+
while (waitpid(pid, NULL, 0) < 0) {
746741
if (errno != EINTR)
747-
break;
742+
return -1;
748743
}
749-
return ret;
744+
return 0;
750745
}

0 commit comments

Comments
 (0)