From 8b979454d891b84da727a329906c4293fadc5f3c Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 18 Mar 2018 12:46:31 -0700 Subject: fixes #295 boolean options should use C99 bool type fixes #275 nng_pipe_getopt_ptr() missing? fixes #285 nng_setopt_ptr MIS fixes #297 nng_listener/dialer_close does not validate mode This change adds some missing APIs, and changes others. In particular, certain options are now of type bool, with size of just one. This is a *breaking* change for code that uses those options -- NNG_OPT_RAW, NNG_OPT_PAIR1_POLY, NNG_OPT_TLS_VERIFIED. --- src/compat/nanomsg/nn.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/compat') diff --git a/src/compat/nanomsg/nn.c b/src/compat/nanomsg/nn.c index 01b51503..fc29083e 100644 --- a/src/compat/nanomsg/nn.c +++ b/src/compat/nanomsg/nn.c @@ -164,7 +164,7 @@ nn_socket(int domain, int protocol) return (-1); } if (domain == AF_SP_RAW) { - if ((rv = nng_setopt_int(sock, NNG_OPT_RAW, 1)) != 0) { + if ((rv = nng_setopt_bool(sock, NNG_OPT_RAW, true)) != 0) { nn_seterror(rv); nng_close(sock); return (-1); @@ -624,14 +624,15 @@ static const struct { static int nn_getdomain(int s, void *valp, size_t *szp) { - int i; - int rv; + int i; + bool b; + int rv; - if ((rv = nng_getopt_int((nng_socket) s, NNG_OPT_RAW, &i)) != 0) { + if ((rv = nng_getopt_bool((nng_socket) s, NNG_OPT_RAW, &b)) != 0) { nn_seterror(rv); return (-1); } - i = i ? AF_SP_RAW : AF_SP; + i = b ? AF_SP_RAW : AF_SP; memcpy(valp, &i, *szp < sizeof(int) ? *szp : sizeof(int)); *szp = sizeof(int); return (0); -- cgit v1.2.3-70-g09d2