From: Daniel Stenberg Date: Tue, 23 Mar 2004 14:43:42 +0000 (+0000) Subject: If localbind fails, provide a more portable error message. X-Git-Tag: upstream/7.37.1~13115 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1f61e7f8f4df121ca2695870d800f726db4dbb31;p=platform%2Fupstream%2Fcurl.git If localbind fails, provide a more portable error message. --- diff --git a/lib/connect.c b/lib/connect.c index 1b57e3f..adeadb5 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -295,10 +295,10 @@ static CURLcode bindlocal(struct connectdata *conn, if (setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE, data->set.device, strlen(data->set.device)+1) != 0) { /* printf("Failed to BINDTODEVICE, socket: %d device: %s error: %s\n", - sockfd, data->set.device, strerror(errno)); */ + sockfd, data->set.device, strerror(Curl_ourerrno())); */ infof(data, "SO_BINDTODEVICE %s failed\n", data->set.device); - /* This is typiclally "errno 1, error: Operation not permitted" if + /* This is typically "errno 1, error: Operation not permitted" if you're not running as root or another suitable privileged user */ } } @@ -353,34 +353,35 @@ static CURLcode bindlocal(struct connectdata *conn, } #endif if(!bindworked) { + int err = Curl_ourerrno(); switch(errno) { case EBADF: - failf(data, "Invalid descriptor: %d", errno); + failf(data, "Invalid descriptor: %d", err); break; case EINVAL: - failf(data, "Invalid request: %d", errno); + failf(data, "Invalid request: %d", err); break; case EACCES: - failf(data, "Address is protected, user not superuser: %d", errno); + failf(data, "Address is protected, user not superuser: %d", err); break; case ENOTSOCK: failf(data, "Argument is a descriptor for a file, not a socket: %d", - errno); + err); break; case EFAULT: - failf(data, "Inaccessable memory error: %d", errno); + failf(data, "Inaccessable memory error: %d", err); break; case ENAMETOOLONG: - failf(data, "Address too long: %d", errno); + failf(data, "Address too long: %d", err); break; case ENOMEM: - failf(data, "Insufficient kernel memory was available: %d", errno); + failf(data, "Insufficient kernel memory was available: %d", err); break; default: - failf(data, "errno %d", errno); + failf(data, "errno %d", err); break; - } /* end of switch(errno) */ + } /* end of switch(err) */ return CURLE_HTTP_PORT_FAILED; } /* end of else */