Skip to content

Commit 7cbf2f2

Browse files
raalkmlgitster
authored andcommitted
Do not use h_errno after connect(2): the function does not set it
Randal L. Schwartz noticed compilation problems on SunOS, which made me look at the code again. The thing is, h_errno is not used by connect(2), it is only for functions from netdb.h, like gethostbyname. Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 3e48af3 commit 7cbf2f2

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

connect.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,10 @@ static int git_tcp_connect_sock(char *host, int flags)
224224
}
225225
if (connect(sockfd, ai->ai_addr, ai->ai_addrlen) < 0) {
226226
saved_errno = errno;
227-
fprintf(stderr, "%s[%d: %s]: net=%s, errno=%s\n",
227+
fprintf(stderr, "%s[%d: %s]: errno=%s\n",
228228
host,
229229
cnt,
230230
ai_name(ai),
231-
hstrerror(h_errno),
232231
strerror(saved_errno));
233232
close(sockfd);
234233
sockfd = -1;
@@ -315,11 +314,10 @@ static int git_tcp_connect_sock(char *host, int flags)
315314

316315
if (connect(sockfd, (struct sockaddr *)&sa, sizeof sa) < 0) {
317316
saved_errno = errno;
318-
fprintf(stderr, "%s[%d: %s]: net=%s, errno=%s\n",
317+
fprintf(stderr, "%s[%d: %s]: errno=%s\n",
319318
host,
320319
cnt,
321320
inet_ntoa(*(struct in_addr *)&sa.sin_addr),
322-
hstrerror(h_errno),
323321
strerror(saved_errno));
324322
close(sockfd);
325323
sockfd = -1;

0 commit comments

Comments
 (0)