diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2014-07-08 09:06:50 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2014-07-08 09:06:50 +0000 |
commit | dc2325cc3c81b5bc878c04b29167cd950987680c (patch) | |
tree | 18f0dcd5db8e37e944962a3dd234320606d95632 | |
parent | 9378cf17a73a63295153b75813e3d017fe1a6def (diff) |
Simplify various BIO_sock_* fuctions - less code, better variable names,
correct types and fewer casts.
ok deraadt@ miod@
-rw-r--r-- | lib/libssl/src/crypto/bio/b_sock.c | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/lib/libssl/src/crypto/bio/b_sock.c b/lib/libssl/src/crypto/bio/b_sock.c index 5f8b1e052fe..447f0febcee 100644 --- a/lib/libssl/src/crypto/bio/b_sock.c +++ b/lib/libssl/src/crypto/bio/b_sock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: b_sock.c,v 1.43 2014/06/24 17:42:54 jsing Exp $ */ +/* $OpenBSD: b_sock.c,v 1.44 2014/07/08 09:06:49 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -173,20 +173,13 @@ BIO_get_port(const char *str, unsigned short *port_ptr) int BIO_sock_error(int sock) { - int j, i; - int size; - - size = sizeof(int); - /* Note: under Windows the third parameter is of type (char *) - * whereas under other systems it is (void *) if you don't have - * a cast it will choke the compiler: if you do have a cast then - * you can either go for (char *) or (void *). - */ - i = getsockopt(sock, SOL_SOCKET, SO_ERROR, (void *)&j, (void *)&size); - if (i < 0) + socklen_t len; + int err; + + len = sizeof(err); + if (getsockopt(sock, SOL_SOCKET, SO_ERROR, &err, &len) != 0) return (1); - else - return (j); + return (err); } struct hostent * @@ -209,14 +202,12 @@ BIO_sock_cleanup(void) int BIO_socket_ioctl(int fd, long type, void *arg) { - int i; - -# define ARG arg + int ret; - i = ioctl(fd, type, ARG); - if (i < 0) + ret = ioctl(fd, type, arg); + if (ret < 0) SYSerr(SYS_F_IOCTLSOCKET, errno); - return (i); + return (ret); } int @@ -471,11 +462,5 @@ BIO_set_tcp_ndelay(int s, int on) int BIO_socket_nbio(int s, int mode) { - int ret = -1; - int l; - - l = mode; - ret = BIO_socket_ioctl(s, FIONBIO, &l); - - return (ret == 0); + return (BIO_socket_ioctl(s, FIONBIO, &mode) == 0); } |