aboutsummaryrefslogtreecommitdiff
path: root/src/sp/protocol/survey0
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-10-20 17:01:10 -0700
committerGarrett D'Amore <garrett@damore.org>2024-10-20 17:01:10 -0700
commit693773195dcd877164314d6b4c37cbd980cbb6ab (patch)
tree3c6014205fb75d1e39227ac505dab8964e57a815 /src/sp/protocol/survey0
parent5830408d11fb19aaf78cb47016ea1692e8f6d2ed (diff)
downloadnng-693773195dcd877164314d6b4c37cbd980cbb6ab.tar.gz
nng-693773195dcd877164314d6b4c37cbd980cbb6ab.tar.bz2
nng-693773195dcd877164314d6b4c37cbd980cbb6ab.zip
Use `const` for nng_stat when possible.
This should help the compiler enforce checks, and may result in better optimizations.
Diffstat (limited to 'src/sp/protocol/survey0')
-rw-r--r--src/sp/protocol/survey0/respond_test.c46
-rw-r--r--src/sp/protocol/survey0/survey_test.c10
-rw-r--r--src/sp/protocol/survey0/xrespond_test.c32
-rw-r--r--src/sp/protocol/survey0/xsurvey_test.c36
4 files changed, 62 insertions, 62 deletions
diff --git a/src/sp/protocol/survey0/respond_test.c b/src/sp/protocol/survey0/respond_test.c
index 15762f05..92e9bf81 100644
--- a/src/sp/protocol/survey0/respond_test.c
+++ b/src/sp/protocol/survey0/respond_test.c
@@ -1,5 +1,5 @@
//
-// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
@@ -14,7 +14,7 @@ test_resp_identity(void)
{
nng_socket s;
int p;
- char * n;
+ char *n;
NUTS_PASS(nng_respondent0_open(&s));
NUTS_PASS(nng_socket_get_int(s, NNG_OPT_PROTO, &p));
@@ -34,7 +34,7 @@ void
test_resp_send_bad_state(void)
{
nng_socket resp;
- nng_msg * msg = NULL;
+ nng_msg *msg = NULL;
NUTS_PASS(nng_respondent0_open(&resp));
NUTS_PASS(nng_msg_alloc(&msg, 0));
@@ -85,7 +85,7 @@ test_resp_poll_readable(void)
int fd;
nng_socket surv;
nng_socket resp;
- nng_msg * msg;
+ nng_msg *msg;
NUTS_PASS(nng_surveyor0_open(&surv));
NUTS_PASS(nng_respondent0_open(&resp));
@@ -135,10 +135,10 @@ test_resp_context_no_poll(void)
void
test_resp_validate_peer(void)
{
- nng_socket s1, s2;
- nng_stat * stats;
- nng_stat * reject;
- char * addr;
+ nng_socket s1, s2;
+ nng_stat *stats;
+ const nng_stat *reject;
+ char *addr;
NUTS_ADDR(addr, "inproc");
@@ -167,8 +167,8 @@ void
test_resp_double_recv(void)
{
nng_socket s1;
- nng_aio * aio1;
- nng_aio * aio2;
+ nng_aio *aio1;
+ nng_aio *aio2;
NUTS_PASS(nng_respondent0_open(&s1));
NUTS_PASS(nng_aio_alloc(&aio1, NULL, NULL));
@@ -191,8 +191,8 @@ test_resp_close_pipe_before_send(void)
nng_socket resp;
nng_socket surv;
nng_pipe p;
- nng_aio * aio1;
- nng_msg * m;
+ nng_aio *aio1;
+ nng_msg *m;
NUTS_PASS(nng_respondent0_open(&resp));
NUTS_PASS(nng_surveyor0_open(&surv));
@@ -223,7 +223,7 @@ test_resp_close_pipe_during_send(void)
nng_socket resp;
nng_socket surv;
nng_pipe p = NNG_PIPE_INITIALIZER;
- nng_msg * m;
+ nng_msg *m;
NUTS_PASS(nng_respondent0_open(&resp));
NUTS_PASS(nng_surveyor0_open_raw(&surv));
@@ -263,7 +263,7 @@ test_resp_ctx_recv_aio_stopped(void)
{
nng_socket resp;
nng_ctx ctx;
- nng_aio * aio;
+ nng_aio *aio;
NUTS_PASS(nng_respondent0_open(&resp));
NUTS_PASS(nng_aio_alloc(&aio, NULL, NULL));
@@ -284,9 +284,9 @@ test_resp_close_pipe_context_send(void)
nng_socket resp;
nng_socket surv;
nng_pipe p = NNG_PIPE_INITIALIZER;
- nng_msg * m;
+ nng_msg *m;
nng_ctx ctx[10];
- nng_aio * aio[10];
+ nng_aio *aio[10];
int i;
NUTS_PASS(nng_respondent0_open(&resp));
@@ -343,9 +343,9 @@ test_resp_close_context_send(void)
{
nng_socket resp;
nng_socket surv;
- nng_msg * m;
+ nng_msg *m;
nng_ctx ctx[10];
- nng_aio * aio[10];
+ nng_aio *aio[10];
int i;
NUTS_PASS(nng_respondent0_open(&resp));
@@ -399,7 +399,7 @@ test_resp_ctx_recv_nonblock(void)
{
nng_socket resp;
nng_ctx ctx;
- nng_aio * aio;
+ nng_aio *aio;
NUTS_PASS(nng_respondent0_open(&resp));
NUTS_PASS(nng_ctx_open(&ctx, resp));
@@ -420,8 +420,8 @@ test_resp_ctx_send_nonblock(void)
nng_socket resp;
nng_socket surv;
nng_ctx ctx;
- nng_aio * aio;
- nng_msg * msg;
+ nng_aio *aio;
+ nng_msg *msg;
NUTS_PASS(nng_surveyor0_open(&surv));
NUTS_PASS(nng_respondent0_open(&resp));
@@ -455,7 +455,7 @@ test_resp_recv_garbage(void)
{
nng_socket resp;
nng_socket surv;
- nng_msg * m;
+ nng_msg *m;
NUTS_PASS(nng_respondent0_open(&resp));
NUTS_PASS(nng_surveyor0_open_raw(&surv));
@@ -513,7 +513,7 @@ test_resp_ttl_drop(void)
{
nng_socket resp;
nng_socket surv;
- nng_msg * m;
+ nng_msg *m;
NUTS_PASS(nng_respondent0_open(&resp));
NUTS_PASS(nng_surveyor0_open_raw(&surv));
diff --git a/src/sp/protocol/survey0/survey_test.c b/src/sp/protocol/survey0/survey_test.c
index 94a7922a..c5f699da 100644
--- a/src/sp/protocol/survey0/survey_test.c
+++ b/src/sp/protocol/survey0/survey_test.c
@@ -1,5 +1,5 @@
//
-// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
@@ -600,10 +600,10 @@ test_surv_context_multi(void)
static void
test_surv_validate_peer(void)
{
- nng_socket s1, s2;
- nng_stat *stats;
- nng_stat *reject;
- char *addr;
+ nng_socket s1, s2;
+ nng_stat *stats;
+ const nng_stat *reject;
+ char *addr;
NUTS_ADDR(addr, "inproc");
NUTS_PASS(nng_surveyor0_open(&s1));
diff --git a/src/sp/protocol/survey0/xrespond_test.c b/src/sp/protocol/survey0/xrespond_test.c
index ec5e99a3..b8d29b9a 100644
--- a/src/sp/protocol/survey0/xrespond_test.c
+++ b/src/sp/protocol/survey0/xrespond_test.c
@@ -1,5 +1,5 @@
//
-// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
@@ -14,8 +14,8 @@ test_xresp_identity(void)
{
nng_socket s;
int p1, p2;
- char * n1;
- char * n2;
+ char *n1;
+ char *n2;
NUTS_PASS(nng_respondent0_open_raw(&s));
NUTS_PASS(nng_socket_get_int(s, NNG_OPT_PROTO, &p1));
@@ -87,7 +87,7 @@ test_xresp_poll_readable(void)
int fd;
nng_socket surv;
nng_socket resp;
- nng_msg * msg;
+ nng_msg *msg;
NUTS_PASS(nng_surveyor0_open(&surv));
NUTS_PASS(nng_respondent0_open_raw(&resp));
@@ -120,10 +120,10 @@ test_xresp_poll_readable(void)
static void
test_xresp_validate_peer(void)
{
- nng_socket s1, s2;
- nng_stat * stats;
- nng_stat * reject;
- char * addr;
+ nng_socket s1, s2;
+ nng_stat *stats;
+ const nng_stat *reject;
+ char *addr;
NUTS_ADDR(addr, "inproc");
@@ -154,8 +154,8 @@ test_xresp_close_pipe_before_send(void)
nng_socket resp;
nng_socket surv;
nng_pipe p;
- nng_aio * aio1;
- nng_msg * m;
+ nng_aio *aio1;
+ nng_msg *m;
NUTS_PASS(nng_respondent0_open_raw(&resp));
NUTS_PASS(nng_surveyor0_open(&surv));
@@ -186,7 +186,7 @@ test_xresp_close_pipe_during_send(void)
nng_socket resp;
nng_socket surv;
nng_pipe p;
- nng_msg * m;
+ nng_msg *m;
NUTS_PASS(nng_respondent_open_raw(&resp));
NUTS_PASS(nng_surveyor0_open_raw(&surv));
@@ -226,7 +226,7 @@ test_xresp_close_during_recv(void)
{
nng_socket resp;
nng_socket surv;
- nng_msg * m;
+ nng_msg *m;
NUTS_PASS(nng_respondent0_open_raw(&resp));
NUTS_PASS(nng_surveyor0_open_raw(&surv));
@@ -255,7 +255,7 @@ static void
test_xresp_recv_aio_stopped(void)
{
nng_socket resp;
- nng_aio * aio;
+ nng_aio *aio;
NUTS_PASS(nng_respondent0_open_raw(&resp));
NUTS_PASS(nng_aio_alloc(&aio, NULL, NULL));
@@ -273,7 +273,7 @@ test_xresp_send_no_header(void)
{
nng_socket resp;
nng_socket surv;
- nng_msg * m;
+ nng_msg *m;
NUTS_PASS(nng_surveyor0_open_raw(&surv));
NUTS_PASS(nng_respondent0_open_raw(&resp));
@@ -297,7 +297,7 @@ test_xresp_recv_garbage(void)
{
nng_socket resp;
nng_socket surv;
- nng_msg * m;
+ nng_msg *m;
NUTS_PASS(nng_respondent0_open_raw(&resp));
NUTS_PASS(nng_surveyor0_open_raw(&surv));
@@ -355,7 +355,7 @@ test_xresp_ttl_drop(void)
{
nng_socket resp;
nng_socket surv;
- nng_msg * m;
+ nng_msg *m;
NUTS_PASS(nng_respondent0_open_raw(&resp));
NUTS_PASS(nng_surveyor0_open_raw(&surv));
diff --git a/src/sp/protocol/survey0/xsurvey_test.c b/src/sp/protocol/survey0/xsurvey_test.c
index f8e9d401..3b874afe 100644
--- a/src/sp/protocol/survey0/xsurvey_test.c
+++ b/src/sp/protocol/survey0/xsurvey_test.c
@@ -1,5 +1,5 @@
//
-// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
@@ -14,7 +14,7 @@ test_xsurveyor_identity(void)
{
nng_socket s;
int p;
- char * n;
+ char *n;
NUTS_PASS(nng_surveyor0_open_raw(&s));
NUTS_PASS(nng_socket_get_int(s, NNG_OPT_PROTO, &p));
@@ -83,7 +83,7 @@ test_xsurvey_poll_readable(void)
int fd;
nng_socket surv;
nng_socket resp;
- nng_msg * msg;
+ nng_msg *msg;
NUTS_PASS(nng_surveyor0_open_raw(&surv));
NUTS_PASS(nng_respondent0_open(&resp));
@@ -114,7 +114,7 @@ test_xsurvey_poll_readable(void)
NUTS_SLEEP(100);
- NUTS_TRUE(nuts_poll_fd(fd) );
+ NUTS_TRUE(nuts_poll_fd(fd));
// and receiving makes it no longer ready
NUTS_PASS(nng_recvmsg(surv, &msg, 0));
@@ -128,10 +128,10 @@ test_xsurvey_poll_readable(void)
static void
test_xsurvey_validate_peer(void)
{
- nng_socket s1, s2;
- nng_stat * stats;
- nng_stat * reject;
- char *addr;
+ nng_socket s1, s2;
+ nng_stat *stats;
+ const nng_stat *reject;
+ char *addr;
NUTS_ADDR(addr, "inproc");
@@ -160,7 +160,7 @@ static void
test_xsurvey_recv_aio_stopped(void)
{
nng_socket surv;
- nng_aio * aio;
+ nng_aio *aio;
NUTS_PASS(nng_surveyor0_open_raw(&surv));
NUTS_PASS(nng_aio_alloc(&aio, NULL, NULL));
@@ -178,7 +178,7 @@ test_xsurvey_recv_garbage(void)
{
nng_socket resp;
nng_socket surv;
- nng_msg * m;
+ nng_msg *m;
uint32_t req_id;
NUTS_PASS(nng_respondent0_open_raw(&resp));
@@ -215,7 +215,7 @@ test_xsurvey_recv_header(void)
{
nng_socket resp;
nng_socket surv;
- nng_msg * m;
+ nng_msg *m;
nng_pipe p;
uint32_t id;
@@ -257,7 +257,7 @@ test_xsurvey_close_during_recv(void)
{
nng_socket resp;
nng_socket surv;
- nng_msg * m;
+ nng_msg *m;
nng_pipe p1;
nng_pipe p2;
@@ -288,7 +288,7 @@ test_xsurvey_close_pipe_during_send(void)
{
nng_socket resp;
nng_socket surv;
- nng_msg * m;
+ nng_msg *m;
nng_pipe p1;
nng_pipe p2;
@@ -340,11 +340,11 @@ test_xsurvey_ttl_option(void)
NUTS_TRUE(v == 3);
NUTS_TRUE(sz == sizeof(v));
- NUTS_FAIL(nng_socket_set(s, opt, "", 1) , NNG_EINVAL);
+ NUTS_FAIL(nng_socket_set(s, opt, "", 1), NNG_EINVAL);
sz = 1;
- NUTS_FAIL(nng_socket_get(s, opt, &v, &sz) , NNG_EINVAL);
- NUTS_FAIL(nng_socket_set_bool(s, opt, true) , NNG_EBADTYPE);
- NUTS_FAIL(nng_socket_get_bool(s, opt, &b) , NNG_EBADTYPE);
+ NUTS_FAIL(nng_socket_get(s, opt, &v, &sz), NNG_EINVAL);
+ NUTS_FAIL(nng_socket_set_bool(s, opt, true), NNG_EBADTYPE);
+ NUTS_FAIL(nng_socket_get_bool(s, opt, &b), NNG_EBADTYPE);
NUTS_CLOSE(s);
}
@@ -355,7 +355,7 @@ test_xsurvey_broadcast(void)
nng_socket resp1;
nng_socket resp2;
nng_socket surv;
- nng_msg * m;
+ nng_msg *m;
NUTS_PASS(nng_respondent0_open(&resp1));
NUTS_PASS(nng_respondent0_open(&resp2));