diff options
| author | Garrett D'Amore <garrett@damore.org> | 2025-04-27 23:35:25 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2025-04-27 23:35:25 -0700 |
| commit | 7bb5ab9c4f70c9fa0a67a22c4aee83b0109318c4 (patch) | |
| tree | 5a3036d609404ee5218b6189a89799e70f4623df /src/platform | |
| parent | 70ae513e4dda50864f7d45b6676549ed5246144d (diff) | |
| download | nng-7bb5ab9c4f70c9fa0a67a22c4aee83b0109318c4.tar.gz nng-7bb5ab9c4f70c9fa0a67a22c4aee83b0109318c4.tar.bz2 nng-7bb5ab9c4f70c9fa0a67a22c4aee83b0109318c4.zip | |
Converted property functions to use nng_err.
Diffstat (limited to 'src/platform')
| -rw-r--r-- | src/platform/posix/posix_ipcconn.c | 28 | ||||
| -rw-r--r-- | src/platform/posix/posix_ipcdial.c | 8 | ||||
| -rw-r--r-- | src/platform/posix/posix_ipclisten.c | 28 | ||||
| -rw-r--r-- | src/platform/posix/posix_sockfd.c | 30 | ||||
| -rw-r--r-- | src/platform/posix/posix_tcpconn.c | 18 | ||||
| -rw-r--r-- | src/platform/posix/posix_tcpdial.c | 28 | ||||
| -rw-r--r-- | src/platform/posix/posix_tcplisten.c | 42 | ||||
| -rw-r--r-- | src/platform/windows/win_ipcconn.c | 8 | ||||
| -rw-r--r-- | src/platform/windows/win_ipcdial.c | 6 | ||||
| -rw-r--r-- | src/platform/windows/win_ipclisten.c | 4 | ||||
| -rw-r--r-- | src/platform/windows/win_tcpconn.c | 8 | ||||
| -rw-r--r-- | src/platform/windows/win_tcpdial.c | 28 | ||||
| -rw-r--r-- | src/platform/windows/win_tcplisten.c | 41 |
13 files changed, 142 insertions, 135 deletions
diff --git a/src/platform/posix/posix_ipcconn.c b/src/platform/posix/posix_ipcconn.c index a585bafd..fd3cdbd8 100644 --- a/src/platform/posix/posix_ipcconn.c +++ b/src/platform/posix/posix_ipcconn.c @@ -299,26 +299,26 @@ ipc_recv(void *arg, nni_aio *aio) nni_mtx_unlock(&c->mtx); } -static int +static nng_err ipc_get_peer_uid(void *arg, void *buf, size_t *szp, nni_type t) { ipc_conn *c = arg; - int rv; + nng_err rv; int ignore; int id = 0; if ((rv = nni_posix_peerid(nni_posix_pfd_fd(&c->pfd), &id, &ignore, - &ignore, &ignore)) != 0) { + &ignore, &ignore)) != NNG_OK) { return (rv); } return (nni_copyout_int(id, buf, szp, t)); } -static int +static nng_err ipc_get_peer_gid(void *arg, void *buf, size_t *szp, nni_type t) { ipc_conn *c = arg; - int rv; + nng_err rv; int ignore; int id = 0; @@ -329,16 +329,16 @@ ipc_get_peer_gid(void *arg, void *buf, size_t *szp, nni_type t) return (nni_copyout_int(id, buf, szp, t)); } -static int +static nng_err ipc_get_peer_zoneid(void *arg, void *buf, size_t *szp, nni_type t) { ipc_conn *c = arg; - int rv; + nng_err rv; int ignore; int id = 0; if ((rv = nni_posix_peerid(nni_posix_pfd_fd(&c->pfd), &ignore, &ignore, - &ignore, &id)) != 0) { + &ignore, &id)) != NNG_OK) { return (rv); } if (id == -1) { @@ -348,16 +348,16 @@ ipc_get_peer_zoneid(void *arg, void *buf, size_t *szp, nni_type t) return (nni_copyout_int(id, buf, szp, t)); } -static int +static nng_err ipc_get_peer_pid(void *arg, void *buf, size_t *szp, nni_type t) { ipc_conn *c = arg; - int rv; + nng_err rv; int ignore; int id = 0; if ((rv = nni_posix_peerid(nni_posix_pfd_fd(&c->pfd), &ignore, &ignore, - &id, &ignore)) != 0) { + &id, &ignore)) != NNG_OK) { return (rv); } if (id == -1) { @@ -367,7 +367,7 @@ ipc_get_peer_pid(void *arg, void *buf, size_t *szp, nni_type t) return (nni_copyout_int(id, buf, szp, t)); } -static int +static nng_err ipc_get_addr(void *arg, void *buf, size_t *szp, nni_type t) { ipc_conn *c = arg; @@ -441,14 +441,14 @@ static const nni_option ipc_options[] = { }, }; -static int +static nng_err ipc_get(void *arg, const char *name, void *val, size_t *szp, nni_type t) { ipc_conn *c = arg; return (nni_getopt(ipc_options, name, c, val, szp, t)); } -static int +static nng_err ipc_set(void *arg, const char *name, const void *val, size_t sz, nni_type t) { ipc_conn *c = arg; diff --git a/src/platform/posix/posix_ipcdial.c b/src/platform/posix/posix_ipcdial.c index f9e87b72..a570bc4f 100644 --- a/src/platform/posix/posix_ipcdial.c +++ b/src/platform/posix/posix_ipcdial.c @@ -249,7 +249,7 @@ error: nni_aio_finish_error(aio, rv); } -static int +static nng_err ipc_dialer_get_remaddr(void *arg, void *buf, size_t *szp, nni_type t) { ipc_dialer *d = arg; @@ -258,7 +258,7 @@ ipc_dialer_get_remaddr(void *arg, void *buf, size_t *szp, nni_type t) } #ifdef NNG_TEST_LIB -static int +static nng_err ipc_dialer_set_test_no_connect( void *arg, const void *buf, size_t sz, nni_type t) { @@ -289,14 +289,14 @@ static const nni_option ipc_dialer_options[] = { }, }; -static int +static nng_err ipc_dialer_get(void *arg, const char *nm, void *buf, size_t *szp, nni_type t) { ipc_dialer *d = arg; return (nni_getopt(ipc_dialer_options, nm, d, buf, szp, t)); } -static int +static nng_err ipc_dialer_set( void *arg, const char *nm, const void *buf, size_t sz, nni_type t) { diff --git a/src/platform/posix/posix_ipclisten.c b/src/platform/posix/posix_ipclisten.c index c651b9ab..6254bf81 100644 --- a/src/platform/posix/posix_ipclisten.c +++ b/src/platform/posix/posix_ipclisten.c @@ -179,7 +179,7 @@ ipc_listener_cancel(nni_aio *aio, void *arg, nng_err rv) nni_mtx_unlock(&l->mtx); } -static int +static nng_err ipc_remove_stale(const char *path) { int fd; @@ -213,24 +213,24 @@ ipc_remove_stale(const char *path) } } (void) close(fd); - return (0); + return (NNG_OK); } -static int +static nng_err ipc_listener_get_addr(void *arg, void *buf, size_t *szp, nni_type t) { ipc_listener *l = arg; return (nni_copyout_sockaddr(&l->sa, buf, szp, t)); } -static int +static nng_err ipc_listener_set_perms(void *arg, const void *buf, size_t sz, nni_type t) { ipc_listener *l = arg; int mode; - int rv; + nng_err rv; - if ((rv = nni_copyin_int(&mode, buf, sz, 0, S_IFMT, t)) != 0) { + if ((rv = nni_copyin_int(&mode, buf, sz, 0, S_IFMT, t)) != NNG_OK) { return (rv); } if (l->sa.s_family == NNG_AF_ABSTRACT) { @@ -249,10 +249,10 @@ ipc_listener_set_perms(void *arg, const void *buf, size_t sz, nni_type t) } l->perms = mode; nni_mtx_unlock(&l->mtx); - return (0); + return (NNG_OK); } -static int +static nng_err ipc_listener_set_listen_fd(void *arg, const void *buf, size_t sz, nni_type t) { ipc_listener *l = arg; @@ -261,7 +261,7 @@ ipc_listener_set_listen_fd(void *arg, const void *buf, size_t sz, nni_type t) socklen_t len = sizeof(ss); int rv; - if ((rv = nni_copyin_int(&fd, buf, sz, 0, NNI_MAXINT, t)) != 0) { + if ((rv = nni_copyin_int(&fd, buf, sz, 0, NNI_MAXINT, t)) != NNG_OK) { return (rv); } @@ -286,15 +286,15 @@ ipc_listener_set_listen_fd(void *arg, const void *buf, size_t sz, nni_type t) nni_posix_pfd_init(&l->pfd, fd, ipc_listener_cb, l); l->started = true; nni_mtx_unlock(&l->mtx); - return (0); + return (NNG_OK); } #ifdef NNG_TEST_LIB // this is readable only for test code -- user code should never rely on this -static int +static nng_err ipc_listener_get_listen_fd(void *arg, void *buf, size_t *szp, nni_type t) { - int rv; + nng_err rv; ipc_listener *l = arg; nni_mtx_lock(&l->mtx); @@ -327,7 +327,7 @@ static const nni_option ipc_listener_options[] = { }, }; -static int +static nng_err ipc_listener_get( void *arg, const char *name, void *buf, size_t *szp, nni_type t) { @@ -335,7 +335,7 @@ ipc_listener_get( return (nni_getopt(ipc_listener_options, name, l, buf, szp, t)); } -static int +static nng_err ipc_listener_set( void *arg, const char *name, const void *buf, size_t sz, nni_type t) { diff --git a/src/platform/posix/posix_sockfd.c b/src/platform/posix/posix_sockfd.c index a76ef85f..6762987b 100644 --- a/src/platform/posix/posix_sockfd.c +++ b/src/platform/posix/posix_sockfd.c @@ -327,7 +327,7 @@ sfd_recv(void *arg, nni_aio *aio) nni_mtx_unlock(&c->mtx); } -static int +static nng_err sfd_get_addr(void *arg, void *buf, size_t *szp, nni_type t) { NNI_ARG_UNUSED(arg); @@ -336,46 +336,46 @@ sfd_get_addr(void *arg, void *buf, size_t *szp, nni_type t) return (nni_copyout_sockaddr(&sa, buf, szp, t)); } -static int +static nng_err sfd_get_peer_uid(void *arg, void *buf, size_t *szp, nni_type t) { nni_sfd_conn *c = arg; - int rv; + nng_err rv; int ignore; int id = 0; rv = nni_posix_peerid(c->fd, &id, &ignore, &ignore, &ignore); - if (rv != 0) { + if (rv != NNG_OK) { return (rv); } return (nni_copyout_int(id, buf, szp, t)); } -static int +static nng_err sfd_get_peer_gid(void *arg, void *buf, size_t *szp, nni_type t) { nni_sfd_conn *c = arg; - int rv; + nng_err rv; int ignore; int id = 0; rv = nni_posix_peerid(c->fd, &ignore, &id, &ignore, &ignore); - if (rv != 0) { + if (rv != NNG_OK) { return (rv); } return (nni_copyout_int(id, buf, szp, t)); } -static int +static nng_err sfd_get_peer_zoneid(void *arg, void *buf, size_t *szp, nni_type t) { nni_sfd_conn *c = arg; - int rv; + nng_err rv; int ignore; int id = 0; rv = nni_posix_peerid(c->fd, &ignore, &ignore, &ignore, &id); - if (rv != 0) { + if (rv != NNG_OK) { return (rv); } if (id == -1) { @@ -385,16 +385,16 @@ sfd_get_peer_zoneid(void *arg, void *buf, size_t *szp, nni_type t) return (nni_copyout_int(id, buf, szp, t)); } -static int +static nng_err sfd_get_peer_pid(void *arg, void *buf, size_t *szp, nni_type t) { nni_sfd_conn *c = arg; - int rv; + nng_err rv; int ignore; int id = 0; rv = nni_posix_peerid(c->fd, &ignore, &ignore, &id, &ignore); - if (rv != 0) { + if (rv != NNG_OK) { return (rv); } if (id == -1) { @@ -434,14 +434,14 @@ static const nni_option sfd_options[] = { }, }; -static int +static nng_err sfd_get(void *arg, const char *name, void *buf, size_t *szp, nni_type t) { nni_sfd_conn *c = arg; return (nni_getopt(sfd_options, name, c, buf, szp, t)); } -static int +static nng_err sfd_set(void *arg, const char *name, const void *buf, size_t sz, nni_type t) { nni_sfd_conn *c = arg; diff --git a/src/platform/posix/posix_tcpconn.c b/src/platform/posix/posix_tcpconn.c index 9b61a68e..674e3f46 100644 --- a/src/platform/posix/posix_tcpconn.c +++ b/src/platform/posix/posix_tcpconn.c @@ -332,26 +332,26 @@ tcp_recv(void *arg, nni_aio *aio) nni_mtx_unlock(&c->mtx); } -static int +static nng_err tcp_get_peername(void *arg, void *buf, size_t *szp, nni_type t) { nni_tcp_conn *c = arg; struct sockaddr_storage ss; socklen_t len = sizeof(ss); int fd = nni_posix_pfd_fd(&c->pfd); - int rv; + nng_err rv; nng_sockaddr sa; if (getpeername(fd, (void *) &ss, &len) != 0) { return (nni_plat_errno(errno)); } - if ((rv = nni_posix_sockaddr2nn(&sa, &ss, len)) == 0) { + if ((rv = nni_posix_sockaddr2nn(&sa, &ss, len)) == NNG_OK) { rv = nni_copyout_sockaddr(&sa, buf, szp, t); } return (rv); } -static int +static nng_err tcp_get_sockname(void *arg, void *buf, size_t *szp, nni_type t) { nni_tcp_conn *c = arg; @@ -364,13 +364,13 @@ tcp_get_sockname(void *arg, void *buf, size_t *szp, nni_type t) if (getsockname(fd, (void *) &ss, &len) != 0) { return (nni_plat_errno(errno)); } - if ((rv = nni_posix_sockaddr2nn(&sa, &ss, len)) == 0) { + if ((rv = nni_posix_sockaddr2nn(&sa, &ss, len)) == NNG_OK) { rv = nni_copyout_sockaddr(&sa, buf, szp, t); } return (rv); } -static int +static nng_err tcp_get_nodelay(void *arg, void *buf, size_t *szp, nni_type t) { nni_tcp_conn *c = arg; @@ -385,7 +385,7 @@ tcp_get_nodelay(void *arg, void *buf, size_t *szp, nni_type t) return (nni_copyout_bool(val, buf, szp, t)); } -static int +static nng_err tcp_get_keepalive(void *arg, void *buf, size_t *szp, nni_type t) { nni_tcp_conn *c = arg; @@ -422,14 +422,14 @@ static const nni_option tcp_options[] = { }, }; -static int +static nng_err tcp_get(void *arg, const char *name, void *buf, size_t *szp, nni_type t) { nni_tcp_conn *c = arg; return (nni_getopt(tcp_options, name, c, buf, szp, t)); } -static int +static nng_err tcp_set(void *arg, const char *name, const void *buf, size_t sz, nni_type t) { nni_tcp_conn *c = arg; diff --git a/src/platform/posix/posix_tcpdial.c b/src/platform/posix/posix_tcpdial.c index 52807892..181a667f 100644 --- a/src/platform/posix/posix_tcpdial.c +++ b/src/platform/posix/posix_tcpdial.c @@ -280,14 +280,15 @@ error: nni_aio_finish_error(aio, rv); } -static int +static nng_err tcp_dialer_set_nodelay(void *arg, const void *buf, size_t sz, nni_type t) { nni_tcp_dialer *d = arg; - int rv; + nng_err rv; bool b; - if (((rv = nni_copyin_bool(&b, buf, sz, t)) != 0) || (d == NULL)) { + if (((rv = nni_copyin_bool(&b, buf, sz, t)) != NNG_OK) || + (d == NULL)) { return (rv); } nni_mtx_lock(&d->mtx); @@ -296,7 +297,7 @@ tcp_dialer_set_nodelay(void *arg, const void *buf, size_t sz, nni_type t) return (0); } -static int +static nng_err tcp_dialer_get_nodelay(void *arg, void *buf, size_t *szp, nni_type t) { bool b; @@ -307,14 +308,15 @@ tcp_dialer_get_nodelay(void *arg, void *buf, size_t *szp, nni_type t) return (nni_copyout_bool(b, buf, szp, t)); } -static int +static nng_err tcp_dialer_set_keepalive(void *arg, const void *buf, size_t sz, nni_type t) { nni_tcp_dialer *d = arg; - int rv; + nng_err rv; bool b; - if (((rv = nni_copyin_bool(&b, buf, sz, t)) != 0) || (d == NULL)) { + if (((rv = nni_copyin_bool(&b, buf, sz, t)) != NNG_OK) || + (d == NULL)) { return (rv); } nni_mtx_lock(&d->mtx); @@ -323,7 +325,7 @@ tcp_dialer_set_keepalive(void *arg, const void *buf, size_t sz, nni_type t) return (0); } -static int +static nng_err tcp_dialer_get_keepalive(void *arg, void *buf, size_t *szp, nni_type t) { bool b; @@ -334,7 +336,7 @@ tcp_dialer_get_keepalive(void *arg, void *buf, size_t *szp, nni_type t) return (nni_copyout_bool(b, buf, szp, t)); } -static int +static nng_err tcp_dialer_get_locaddr(void *arg, void *buf, size_t *szp, nni_type t) { nni_tcp_dialer *d = arg; @@ -348,7 +350,7 @@ tcp_dialer_get_locaddr(void *arg, void *buf, size_t *szp, nni_type t) return (nni_copyout_sockaddr(&sa, buf, szp, t)); } -static int +static nng_err tcp_dialer_set_locaddr(void *arg, const void *buf, size_t sz, nni_type t) { nni_tcp_dialer *d = arg; @@ -356,13 +358,13 @@ tcp_dialer_set_locaddr(void *arg, const void *buf, size_t sz, nni_type t) struct sockaddr_storage ss; struct sockaddr_in *sin; size_t len; - int rv; + nng_err rv; #ifdef NNG_ENABLE_IPV6 struct sockaddr_in6 *sin6; #endif NNI_ARG_UNUSED(sz); - if ((rv = nni_copyin_sockaddr(&sa, buf, t)) != 0) { + if ((rv = nni_copyin_sockaddr(&sa, buf, t)) != NNG_OK) { return (rv); } if ((len = nni_posix_nn2sockaddr(&ss, &sa)) == 0) { @@ -400,7 +402,7 @@ tcp_dialer_set_locaddr(void *arg, const void *buf, size_t sz, nni_type t) d->srclen = len; nni_mtx_unlock(&d->mtx); } - return (0); + return (NNG_OK); } static const nni_option tcp_dialer_options[] = { diff --git a/src/platform/posix/posix_tcplisten.c b/src/platform/posix/posix_tcplisten.c index 29255df2..508f4d1e 100644 --- a/src/platform/posix/posix_tcplisten.c +++ b/src/platform/posix/posix_tcplisten.c @@ -301,7 +301,7 @@ tcp_listener_accept(void *arg, nni_aio *aio) nni_mtx_unlock(&l->mtx); } -static int +static nng_err tcp_listener_get_locaddr(void *arg, void *buf, size_t *szp, nni_type t) { tcp_listener *l = arg; @@ -320,23 +320,24 @@ tcp_listener_get_locaddr(void *arg, void *buf, size_t *szp, nni_type t) return (nni_copyout_sockaddr(&sa, buf, szp, t)); } -static int +static nng_err tcp_listener_set_nodelay(void *arg, const void *buf, size_t sz, nni_type t) { tcp_listener *l = arg; - int rv; + nng_err rv; bool b; - if (((rv = nni_copyin_bool(&b, buf, sz, t)) != 0) || (l == NULL)) { + if (((rv = nni_copyin_bool(&b, buf, sz, t)) != NNG_OK) || + (l == NULL)) { return (rv); } nni_mtx_lock(&l->mtx); l->nodelay = b; nni_mtx_unlock(&l->mtx); - return (0); + return (NNG_OK); } -static int +static nng_err tcp_listener_get_nodelay(void *arg, void *buf, size_t *szp, nni_type t) { bool b; @@ -347,23 +348,24 @@ tcp_listener_get_nodelay(void *arg, void *buf, size_t *szp, nni_type t) return (nni_copyout_bool(b, buf, szp, t)); } -static int +static nng_err tcp_listener_set_keepalive(void *arg, const void *buf, size_t sz, nni_type t) { tcp_listener *l = arg; - int rv; + nng_err rv; bool b; - if (((rv = nni_copyin_bool(&b, buf, sz, t)) != 0) || (l == NULL)) { + if (((rv = nni_copyin_bool(&b, buf, sz, t)) != NNG_OK) || + (l == NULL)) { return (rv); } nni_mtx_lock(&l->mtx); l->keepalive = b; nni_mtx_unlock(&l->mtx); - return (0); + return (NNG_OK); } -static int +static nng_err tcp_listener_get_keepalive(void *arg, void *buf, size_t *szp, nni_type t) { bool b; @@ -374,7 +376,7 @@ tcp_listener_get_keepalive(void *arg, void *buf, size_t *szp, nni_type t) return (nni_copyout_bool(b, buf, szp, t)); } -static int +static nng_err tcp_listener_get_port(void *arg, void *buf, size_t *szp, nni_type t) { tcp_listener *l = arg; @@ -403,16 +405,16 @@ tcp_listener_get_port(void *arg, void *buf, size_t *szp, nni_type t) return (nni_copyout_int(port, buf, szp, t)); } -static int +static nng_err tcp_listener_set_listen_fd(void *arg, const void *buf, size_t sz, nni_type t) { tcp_listener *l = arg; int fd; struct sockaddr_storage ss; socklen_t len = sizeof(ss); - int rv; + nng_err rv; - if ((rv = nni_copyin_int(&fd, buf, sz, 0, NNI_MAXINT, t)) != 0) { + if ((rv = nni_copyin_int(&fd, buf, sz, 0, NNI_MAXINT, t)) != NNG_OK) { return (rv); } @@ -442,15 +444,15 @@ tcp_listener_set_listen_fd(void *arg, const void *buf, size_t sz, nni_type t) nni_posix_pfd_init(&l->pfd, fd, tcp_listener_cb, l); l->started = true; nni_mtx_unlock(&l->mtx); - return (0); + return (NNG_OK); } #ifdef NNG_TEST_LIB // this is readable only for test code -- user code should never rely on this -static int +static nng_err tcp_listener_get_listen_fd(void *arg, void *buf, size_t *szp, nni_type t) { - int rv; + nng_err rv; tcp_listener *l = arg; nni_mtx_lock(&l->mtx); NNI_ASSERT(l->started); @@ -492,14 +494,14 @@ static const nni_option tcp_listener_options[] = { }, }; -static int +static nng_err tcp_listener_get( void *arg, const char *name, void *buf, size_t *szp, nni_type t) { return (nni_getopt(tcp_listener_options, name, arg, buf, szp, t)); } -static int +static nng_err tcp_listener_set( void *arg, const char *name, const void *buf, size_t sz, nni_type t) { diff --git a/src/platform/windows/win_ipcconn.c b/src/platform/windows/win_ipcconn.c index 5493d32f..45235387 100644 --- a/src/platform/windows/win_ipcconn.c +++ b/src/platform/windows/win_ipcconn.c @@ -387,13 +387,13 @@ ipc_free(void *arg) NNI_FREE_STRUCT(c); } -static int +static nng_err ipc_conn_get_addr(void *c, void *buf, size_t *szp, nni_opt_type t) { return (nni_copyout_sockaddr(&(CONN(c))->sa, buf, szp, t)); } -static int +static nng_err ipc_conn_get_peer_pid(void *c, void *buf, size_t *szp, nni_opt_type t) { ULONG id; @@ -431,14 +431,14 @@ static const nni_option ipc_conn_options[] = { }, }; -static int +static nng_err ipc_set(void *arg, const char *nm, const void *val, size_t sz, nni_opt_type t) { ipc_conn *c = arg; return (nni_setopt(ipc_conn_options, nm, c, val, sz, t)); } -static int +static nng_err ipc_get(void *arg, const char *nm, void *val, size_t *szp, nni_opt_type t) { ipc_conn *c = arg; diff --git a/src/platform/windows/win_ipcdial.c b/src/platform/windows/win_ipcdial.c index ae42837c..04ee5829 100644 --- a/src/platform/windows/win_ipcdial.c +++ b/src/platform/windows/win_ipcdial.c @@ -205,7 +205,7 @@ ipc_dialer_free(void *arg) NNI_FREE_STRUCT(d); } -static int +static nng_err ipc_dialer_get_remaddr(void *arg, void *buf, size_t *szp, nni_type t) { ipc_dialer *d = arg; @@ -223,7 +223,7 @@ static const nni_option ipc_dialer_options[] = { }, }; -static int +static nng_err ipc_dialer_set( void *arg, const char *nm, const void *buf, size_t sz, nni_type t) { @@ -231,7 +231,7 @@ ipc_dialer_set( return (nni_setopt(ipc_dialer_options, nm, d, buf, sz, t)); } -static int +static nng_err ipc_dialer_get(void *arg, const char *nm, void *buf, size_t *szp, nni_type t) { ipc_dialer *d = arg; diff --git a/src/platform/windows/win_ipclisten.c b/src/platform/windows/win_ipclisten.c index e8670afe..3bb71c7d 100644 --- a/src/platform/windows/win_ipclisten.c +++ b/src/platform/windows/win_ipclisten.c @@ -139,7 +139,7 @@ ipc_accept_cb(nni_win_io *io, int rv, size_t cnt) nni_mtx_unlock(&l->mtx); } -static int +static nng_err ipc_listener_set_sec_desc(void *arg, void *desc) { ipc_listener *l = arg; @@ -155,7 +155,7 @@ ipc_listener_set_sec_desc(void *arg, void *desc) } l->sec_attr.lpSecurityDescriptor = desc; nni_mtx_unlock(&l->mtx); - return (0); + return (NNG_OK); } static int diff --git a/src/platform/windows/win_tcpconn.c b/src/platform/windows/win_tcpconn.c index e6d30b7a..102700ec 100644 --- a/src/platform/windows/win_tcpconn.c +++ b/src/platform/windows/win_tcpconn.c @@ -262,7 +262,7 @@ tcp_close(void *arg) nni_mtx_unlock(&c->mtx); } -static int +static nng_err tcp_get_peername(void *arg, void *buf, size_t *szp, nni_type t) { nni_tcp_conn *c = arg; @@ -274,7 +274,7 @@ tcp_get_peername(void *arg, void *buf, size_t *szp, nni_type t) return (nni_copyout_sockaddr(&sa, buf, szp, t)); } -static int +static nng_err tcp_get_sockname(void *arg, void *buf, size_t *szp, nni_type t) { nni_tcp_conn *c = arg; @@ -286,7 +286,7 @@ tcp_get_sockname(void *arg, void *buf, size_t *szp, nni_type t) return (nni_copyout_sockaddr(&sa, buf, szp, t)); } -static int +static nng_err tcp_get_nodelay(void *arg, void *buf, size_t *szp, nni_type t) { nni_tcp_conn *c = arg; @@ -300,7 +300,7 @@ tcp_get_nodelay(void *arg, void *buf, size_t *szp, nni_type t) return (nni_copyout_bool(b, buf, szp, t)); } -static int +static nng_err tcp_get_keepalive(void *arg, void *buf, size_t *szp, nni_type t) { nni_tcp_conn *c = arg; diff --git a/src/platform/windows/win_tcpdial.c b/src/platform/windows/win_tcpdial.c index 4d3771f2..72e4f8a7 100644 --- a/src/platform/windows/win_tcpdial.c +++ b/src/platform/windows/win_tcpdial.c @@ -246,14 +246,15 @@ nni_tcp_dial(nni_tcp_dialer *d, const nni_sockaddr *sa, nni_aio *aio) nni_mtx_unlock(&d->mtx); } -static int +static nng_err tcp_dialer_set_nodelay(void *arg, const void *buf, size_t sz, nni_type t) { nni_tcp_dialer *d = arg; - int rv; + nng_err rv; bool b; - if (((rv = nni_copyin_bool(&b, buf, sz, t)) != 0) || (d == NULL)) { + if (((rv = nni_copyin_bool(&b, buf, sz, t)) != NNG_OK) || + (d == NULL)) { return (rv); } nni_mtx_lock(&d->mtx); @@ -262,7 +263,7 @@ tcp_dialer_set_nodelay(void *arg, const void *buf, size_t sz, nni_type t) return (0); } -static int +static nng_err tcp_dialer_get_nodelay(void *arg, void *buf, size_t *szp, nni_type t) { bool b; @@ -273,14 +274,15 @@ tcp_dialer_get_nodelay(void *arg, void *buf, size_t *szp, nni_type t) return (nni_copyout_bool(b, buf, szp, t)); } -static int +static nng_err tcp_dialer_set_keepalive(void *arg, const void *buf, size_t sz, nni_type t) { nni_tcp_dialer *d = arg; - int rv; + nng_err rv; bool b; - if (((rv = nni_copyin_bool(&b, buf, sz, t)) != 0) || (d == NULL)) { + if (((rv = nni_copyin_bool(&b, buf, sz, t)) != NNG_OK) || + (d == NULL)) { return (rv); } nni_mtx_lock(&d->mtx); @@ -289,7 +291,7 @@ tcp_dialer_set_keepalive(void *arg, const void *buf, size_t sz, nni_type t) return (0); } -static int +static nng_err tcp_dialer_get_keepalive(void *arg, void *buf, size_t *szp, nni_type t) { bool b; @@ -300,7 +302,7 @@ tcp_dialer_get_keepalive(void *arg, void *buf, size_t *szp, nni_type t) return (nni_copyout_bool(b, buf, szp, t)); } -static int +static nng_err tcp_dialer_get_locaddr(void *arg, void *buf, size_t *szp, nni_type t) { nni_tcp_dialer *d = arg; @@ -314,7 +316,7 @@ tcp_dialer_get_locaddr(void *arg, void *buf, size_t *szp, nni_type t) return (nni_copyout_sockaddr(&sa, buf, szp, t)); } -static int +static nng_err tcp_dialer_set_locaddr(void *arg, const void *buf, size_t sz, nni_type t) { nni_tcp_dialer *d = arg; @@ -322,13 +324,13 @@ tcp_dialer_set_locaddr(void *arg, const void *buf, size_t sz, nni_type t) SOCKADDR_STORAGE ss; struct sockaddr_in *sin; size_t sslen; - int rv; + nng_err rv; #ifdef NNG_ENABLE_IPV6 struct sockaddr_in6 *sin6; #endif NNI_ARG_UNUSED(sz); - if ((rv = nni_copyin_sockaddr(&sa, buf, t)) != 0) { + if ((rv = nni_copyin_sockaddr(&sa, buf, t)) != NNG_OK) { return (rv); } if ((sslen = nni_win_nn2sockaddr(&ss, &sa)) == 0) { @@ -364,7 +366,7 @@ tcp_dialer_set_locaddr(void *arg, const void *buf, size_t sz, nni_type t) d->srclen = sslen; nni_mtx_unlock(&d->mtx); } - return (0); + return (NNG_OK); } static const nni_option tcp_dialer_options[] = { diff --git a/src/platform/windows/win_tcplisten.c b/src/platform/windows/win_tcplisten.c index b92470ca..563cbcf0 100644 --- a/src/platform/windows/win_tcplisten.c +++ b/src/platform/windows/win_tcplisten.c @@ -330,7 +330,7 @@ tcp_listener_accept(void *arg, nni_aio *aio) nni_mtx_unlock(&l->mtx); } -static int +static nng_err tcp_listener_get_locaddr(void *arg, void *buf, size_t *szp, nni_type t) { tcp_listener *l = arg; @@ -345,14 +345,15 @@ tcp_listener_get_locaddr(void *arg, void *buf, size_t *szp, nni_type t) return (nni_copyout_sockaddr(&sa, buf, szp, t)); } -static int +static nng_err tcp_listener_set_nodelay(void *arg, const void *buf, size_t sz, nni_type t) { tcp_listener *l = arg; - int rv; + nng_err rv; bool b; - if (((rv = nni_copyin_bool(&b, buf, sz, t)) != 0) || (l == NULL)) { + if (((rv = nni_copyin_bool(&b, buf, sz, t)) != NNG_OK) || + (l == NULL)) { return (rv); } nni_mtx_lock(&l->mtx); @@ -361,7 +362,7 @@ tcp_listener_set_nodelay(void *arg, const void *buf, size_t sz, nni_type t) return (0); } -static int +static nng_err tcp_listener_get_nodelay(void *arg, void *buf, size_t *szp, nni_type t) { bool b; @@ -372,14 +373,15 @@ tcp_listener_get_nodelay(void *arg, void *buf, size_t *szp, nni_type t) return (nni_copyout_bool(b, buf, szp, t)); } -static int +static nng_err tcp_listener_set_keepalive(void *arg, const void *buf, size_t sz, nni_type t) { tcp_listener *l = arg; - int rv; + nng_err rv; bool b; - if (((rv = nni_copyin_bool(&b, buf, sz, t)) != 0) || (l == NULL)) { + if (((rv = nni_copyin_bool(&b, buf, sz, t)) != NNG_OK) || + (l == NULL)) { return (rv); } nni_mtx_lock(&l->mtx); @@ -388,7 +390,7 @@ tcp_listener_set_keepalive(void *arg, const void *buf, size_t sz, nni_type t) return (0); } -static int +static nng_err tcp_listener_get_keepalive(void *arg, void *buf, size_t *szp, nni_type t) { bool b; @@ -399,11 +401,10 @@ tcp_listener_get_keepalive(void *arg, void *buf, size_t *szp, nni_type t) return (nni_copyout_bool(b, buf, szp, t)); } -static int +static nng_err tcp_listener_get_port(void *arg, void *buf, size_t *szp, nni_type t) { tcp_listener *l = arg; - int rv; nng_sockaddr sa; size_t sz; int port; @@ -429,16 +430,16 @@ tcp_listener_get_port(void *arg, void *buf, size_t *szp, nni_type t) return (nni_copyout_int(port, buf, szp, t)); } -static int +static nng_err tcp_listener_set_listen_fd(void *arg, const void *buf, size_t sz, nni_type t) { tcp_listener *l = arg; int fd; SOCKADDR_STORAGE ss; int len = sizeof(ss); - int rv; + nng_err rv; - if ((rv = nni_copyin_int(&fd, buf, sz, 0, NNI_MAXINT, t)) != 0) { + if ((rv = nni_copyin_int(&fd, buf, sz, 0, NNI_MAXINT, t)) != NNG_OK) { return (rv); } @@ -472,22 +473,22 @@ tcp_listener_set_listen_fd(void *arg, const void *buf, size_t sz, nni_type t) l->ss = ss; l->s = (SOCKET) fd; - if ((rv = nni_win_io_register((HANDLE) l->s)) != 0) { + if ((rv = nni_win_io_register((HANDLE) l->s)) != NNG_OK) { l->s = INVALID_SOCKET; nni_mtx_unlock(&l->mtx); return (rv); } l->started = true; nni_mtx_unlock(&l->mtx); - return (0); + return (NNG_OK); } #ifdef NNG_TEST_LIB // this is readable only for test code -- user code should never rely on this -static int +static nng_err tcp_listener_get_listen_fd(void *arg, void *buf, size_t *szp, nni_type t) { - int rv; + nng_err rv; tcp_listener *l = arg; nni_mtx_lock(&l->mtx); NNI_ASSERT(l->started); @@ -529,14 +530,14 @@ static const nni_option tcp_listener_options[] = { }, }; -static int +static nng_err tcp_listener_get( void *arg, const char *name, void *buf, size_t *szp, nni_type t) { return (nni_getopt(tcp_listener_options, name, arg, buf, szp, t)); } -static int +static nng_err tcp_listener_set( void *arg, const char *name, const void *buf, size_t sz, nni_type t) { |
