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>
Alex Riesen committed
Jun 12, 2007 at 22:52 UTC
7cbf2f24ee8430fbf48a2c6f106f22adf9df62e1
1 file changed
+2
-4
connect.c
+2
-4
@@ -224,11 +224,10 @@ static int git_tcp_connect_sock(char *host, int flags)
224
}
225
if (connect(sockfd, ai->ai_addr, ai->ai_addrlen) < 0) {
226
saved_errno = errno;
227
- fprintf(stderr, "%s[%d: %s]: net=%s, errno=%s\n",
227
+ fprintf(stderr, "%s[%d: %s]: errno=%s\n",
228
host,
229
cnt,
230
ai_name(ai),
231
- hstrerror(h_errno),
231
strerror(saved_errno));
232
close(sockfd);
233
sockfd = -1;
@@ -315,11 +314,10 @@ static int git_tcp_connect_sock(char *host, int flags)
314
315
if (connect(sockfd, (struct sockaddr *)&sa, sizeof sa) < 0) {
316
saved_errno = errno;
318
- fprintf(stderr, "%s[%d: %s]: net=%s, errno=%s\n",
317
+ fprintf(stderr, "%s[%d: %s]: errno=%s\n",
318
host,
319
cnt,
320
inet_ntoa(*(struct in_addr *)&sa.sin_addr),
322
- hstrerror(h_errno),
321
strerror(saved_errno));
322
close(sockfd);
323
sockfd = -1;