diff options
| author | Garrett D'Amore <garrett@damore.org> | 2024-10-20 17:01:10 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2024-10-20 17:01:10 -0700 |
| commit | 693773195dcd877164314d6b4c37cbd980cbb6ab (patch) | |
| tree | 3c6014205fb75d1e39227ac505dab8964e57a815 /src | |
| parent | 5830408d11fb19aaf78cb47016ea1692e8f6d2ed (diff) | |
| download | nng-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')
| -rw-r--r-- | src/core/list.h | 7 | ||||
| -rw-r--r-- | src/core/stats.c | 62 | ||||
| -rw-r--r-- | src/core/stats_test.c | 24 | ||||
| -rw-r--r-- | src/sp/protocol/bus0/bus_test.c | 12 | ||||
| -rw-r--r-- | src/sp/protocol/pair0/pair0_test.c | 28 | ||||
| -rw-r--r-- | src/sp/protocol/pair1/pair1_poly_test.c | 24 | ||||
| -rw-r--r-- | src/sp/protocol/pair1/pair1_test.c | 38 | ||||
| -rw-r--r-- | src/sp/protocol/pipeline0/pull_test.c | 22 | ||||
| -rw-r--r-- | src/sp/protocol/pipeline0/push_test.c | 46 | ||||
| -rw-r--r-- | src/sp/protocol/pubsub0/pub_test.c | 22 | ||||
| -rw-r--r-- | src/sp/protocol/pubsub0/sub_test.c | 42 | ||||
| -rw-r--r-- | src/sp/protocol/pubsub0/xsub_test.c | 24 | ||||
| -rw-r--r-- | src/sp/protocol/reqrep0/rep_test.c | 10 | ||||
| -rw-r--r-- | src/sp/protocol/reqrep0/req_test.c | 14 | ||||
| -rw-r--r-- | src/sp/protocol/reqrep0/xrep_test.c | 32 | ||||
| -rw-r--r-- | src/sp/protocol/reqrep0/xreq_test.c | 26 | ||||
| -rw-r--r-- | src/sp/protocol/survey0/respond_test.c | 46 | ||||
| -rw-r--r-- | src/sp/protocol/survey0/survey_test.c | 10 | ||||
| -rw-r--r-- | src/sp/protocol/survey0/xrespond_test.c | 32 | ||||
| -rw-r--r-- | src/sp/protocol/survey0/xsurvey_test.c | 36 |
20 files changed, 281 insertions, 276 deletions
diff --git a/src/core/list.h b/src/core/list.h index d3c703bb..28720564 100644 --- a/src/core/list.h +++ b/src/core/list.h @@ -1,5 +1,5 @@ // -// Copyright 2017 Garrett D'Amore <garrett@damore.org> +// Copyright 2024 Garrett D'Amore <garrett@damore.org> // // This software is supplied under the terms of the MIT License, a // copy of which should be located in the distribution where this @@ -58,7 +58,8 @@ extern int nni_list_empty(nni_list *); extern int nni_list_node_active(nni_list_node *); extern void nni_list_node_remove(nni_list_node *); -#define NNI_LIST_FOREACH(l, it) \ - for (it = nni_list_first(l); it != NULL; it = nni_list_next(l, it)) +#define NNI_LIST_FOREACH(l, it) \ + for (it = nni_list_first(l); it != NULL; \ + it = nni_list_next(l, (void *) it)) #endif // CORE_LIST_H diff --git a/src/core/stats.c b/src/core/stats.c index 5fa9ca41..c049d611 100644 --- a/src/core/stats.c +++ b/src/core/stats.c @@ -1,5 +1,5 @@ // -// Copyright 2022 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 @@ -396,28 +396,28 @@ nng_stats_get(nng_stat **statp) #endif } -nng_stat * -nng_stat_parent(nng_stat *stat) +const nng_stat * +nng_stat_parent(const nng_stat *stat) { return (stat->s_parent); } -nng_stat * -nng_stat_next(nng_stat *stat) +const nng_stat * +nng_stat_next(const nng_stat *stat) { #if NNG_ENABLE_STATS if (stat->s_parent == NULL) { return (NULL); // Root node, no siblings. } - return (nni_list_next(&stat->s_parent->s_children, stat)); + return (nni_list_next(&stat->s_parent->s_children, (void *) stat)); #else NNI_ARG_UNUSED(stat); return (NULL); #endif } -nng_stat * -nng_stat_child(nng_stat *stat) +const nng_stat * +nng_stat_child(const nng_stat *stat) { #if NNG_ENABLE_STATS return (nni_list_first(&stat->s_children)); @@ -428,7 +428,7 @@ nng_stat_child(nng_stat *stat) } const char * -nng_stat_name(nni_stat *stat) +nng_stat_name(const nng_stat *stat) { #if NNG_ENABLE_STATS return (stat->s_info->si_name); @@ -439,7 +439,7 @@ nng_stat_name(nni_stat *stat) } uint64_t -nng_stat_value(nni_stat *stat) +nng_stat_value(const nng_stat *stat) { #if NNG_ENABLE_STATS return (stat->s_val.sv_value); @@ -450,7 +450,7 @@ nng_stat_value(nni_stat *stat) } bool -nng_stat_bool(nni_stat *stat) +nng_stat_bool(const nng_stat *stat) { #if NNG_ENABLE_STATS return (stat->s_val.sv_bool); @@ -461,7 +461,7 @@ nng_stat_bool(nni_stat *stat) } const char * -nng_stat_string(nng_stat *stat) +nng_stat_string(const nng_stat *stat) { #if NNG_ENABLE_STATS if (stat->s_info->si_type != NNG_STAT_STRING) { @@ -475,7 +475,7 @@ nng_stat_string(nng_stat *stat) } uint64_t -nng_stat_timestamp(nng_stat *stat) +nng_stat_timestamp(const nng_stat *stat) { #if NNG_ENABLE_STATS return ((uint64_t) stat->s_timestamp); @@ -486,7 +486,7 @@ nng_stat_timestamp(nng_stat *stat) } int -nng_stat_type(nng_stat *stat) +nng_stat_type(const nng_stat *stat) { #if NNG_ENABLE_STATS return (stat->s_info->si_type); @@ -497,7 +497,7 @@ nng_stat_type(nng_stat *stat) } int -nng_stat_unit(nng_stat *stat) +nng_stat_unit(const nng_stat *stat) { #if NNG_ENABLE_STATS return (stat->s_info->si_unit); @@ -508,7 +508,7 @@ nng_stat_unit(nng_stat *stat) } const char * -nng_stat_desc(nng_stat *stat) +nng_stat_desc(const nng_stat *stat) { #if NNG_ENABLE_STATS return (stat->s_info->si_desc); @@ -518,11 +518,11 @@ nng_stat_desc(nng_stat *stat) #endif } -nng_stat * -nng_stat_find(nng_stat *stat, const char *name) +const nng_stat * +nng_stat_find(const nng_stat *stat, const char *name) { #if NNG_ENABLE_STATS - nng_stat *child; + const nng_stat *child; if (stat == NULL) { return (NULL); } @@ -530,7 +530,7 @@ nng_stat_find(nng_stat *stat, const char *name) return (stat); } NNI_LIST_FOREACH (&stat->s_children, child) { - nng_stat *result; + const nng_stat *result; if ((result = nng_stat_find(child, name)) != NULL) { return (result); } @@ -542,8 +542,8 @@ nng_stat_find(nng_stat *stat, const char *name) return (NULL); } -nng_stat * -nng_stat_find_scope(nng_stat *stat, const char *name, int id) +const nng_stat * +nng_stat_find_scope(const nng_stat *stat, const char *name, int id) { #if NNG_ENABLE_STATS nng_stat *child; @@ -556,7 +556,7 @@ nng_stat_find_scope(nng_stat *stat, const char *name, int id) return (stat); } NNI_LIST_FOREACH (&stat->s_children, child) { - nng_stat *result; + const nng_stat *result; if ((result = nng_stat_find_scope(child, name, id)) != NULL) { return (result); } @@ -569,27 +569,27 @@ nng_stat_find_scope(nng_stat *stat, const char *name, int id) return (NULL); } -nng_stat * -nng_stat_find_socket(nng_stat *stat, nng_socket s) +const nng_stat * +nng_stat_find_socket(const nng_stat *stat, nng_socket s) { return (nng_stat_find_scope(stat, "socket", nng_socket_id(s))); } -nng_stat * -nng_stat_find_dialer(nng_stat *stat, nng_dialer d) +const nng_stat * +nng_stat_find_dialer(const nng_stat *stat, nng_dialer d) { return (nng_stat_find_scope(stat, "dialer", nng_dialer_id(d))); } -nng_stat * -nng_stat_find_listener(nng_stat *stat, nng_listener l) +const nng_stat * +nng_stat_find_listener(const nng_stat *stat, nng_listener l) { return (nng_stat_find_scope(stat, "listener", nng_listener_id(l))); } #ifdef NNG_ENABLE_STATS void -stat_sprint_scope(nni_stat *stat, char **scope, int *lenp) +stat_sprint_scope(const nni_stat *stat, char **scope, int *lenp) { if (stat->s_parent != NULL) { stat_sprint_scope(stat->s_parent, scope, lenp); @@ -606,7 +606,7 @@ stat_sprint_scope(nni_stat *stat, char **scope, int *lenp) #endif void -nng_stats_dump(nng_stat *stat) +nng_stats_dump(const nng_stat *stat) { #ifdef NNG_ENABLE_STATS static char buf[128]; // to minimize recursion, not thread safe diff --git a/src/core/stats_test.c b/src/core/stats_test.c index ba4198ab..e15b4001 100644 --- a/src/core/stats_test.c +++ b/src/core/stats_test.c @@ -1,5 +1,5 @@ // -// Copyright 2022 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 @@ -16,12 +16,12 @@ void test_stats_socket(void) { #ifdef NNG_ENABLE_STATS - nng_socket s1; - nng_socket s2; - nng_stat *st1; - nng_stat *st2; - nng_stat *item; - nng_stat *stats; + nng_socket s1; + nng_socket s2; + const nng_stat *st1; + const nng_stat *st2; + const nng_stat *item; + nng_stat *stats; NUTS_OPEN(s1); NUTS_OPEN(s2); @@ -63,11 +63,11 @@ void test_stats_dump(void) { #ifdef NNG_ENABLE_STATS - nng_socket s1; - nng_socket s2; - nng_stat *st1; - nng_stat *st2; - nng_stat *stats; + nng_socket s1; + nng_socket s2; + const nng_stat *st1; + const nng_stat *st2; + nng_stat *stats; NUTS_OPEN(s1); NUTS_OPEN(s2); diff --git a/src/sp/protocol/bus0/bus_test.c b/src/sp/protocol/bus0/bus_test.c index 6a214972..a832d9dd 100644 --- a/src/sp/protocol/bus0/bus_test.c +++ b/src/sp/protocol/bus0/bus_test.c @@ -1,5 +1,5 @@ // -// Copyright 2021 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 @@ -70,7 +70,7 @@ test_bus_device(void) { nng_socket s1, s2, s3; nng_socket none = NNG_SOCKET_INITIALIZER; - nng_aio *aio; + nng_aio *aio; NUTS_PASS(nng_bus0_open_raw(&s1)); NUTS_PASS(nng_bus0_open(&s2)); @@ -101,10 +101,10 @@ test_bus_device(void) static void test_bus_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_bus0_open(&s1)); diff --git a/src/sp/protocol/pair0/pair0_test.c b/src/sp/protocol/pair0/pair0_test.c index 0bce1bb7..83d72c0c 100644 --- a/src/sp/protocol/pair0/pair0_test.c +++ b/src/sp/protocol/pair0/pair0_test.c @@ -22,7 +22,7 @@ test_identity(void) { nng_socket s; int p; - char * n; + char *n; NUTS_PASS(nng_pair0_open(&s)); NUTS_PASS(nng_socket_get_int(s, NNG_OPT_PROTO, &p)); @@ -43,7 +43,7 @@ test_cooked(void) { nng_socket s1; nng_socket c1; - nng_msg * msg; + nng_msg *msg; NUTS_PASS(nng_pair0_open(&s1)); NUTS_PASS(nng_pair0_open(&c1)); @@ -75,7 +75,7 @@ test_faithful(void) nng_socket s1; nng_socket c1; nng_socket c2; - nng_msg * msg; + nng_msg *msg; const char *addr = "inproc://pair0_mono_faithful"; NUTS_PASS(nng_pair0_open(&s1)); @@ -116,7 +116,7 @@ test_back_pressure(void) nng_socket c1; int i; int rv; - nng_msg * msg; + nng_msg *msg; nng_duration to = 100; NUTS_PASS(nng_pair0_open(&s1)); @@ -147,7 +147,7 @@ void test_send_no_peer(void) { nng_socket s1; - nng_msg * msg; + nng_msg *msg; nng_duration to = 100; NUTS_PASS(nng_pair0_open(&s1)); @@ -203,8 +203,8 @@ void test_pair0_send_closed_aio(void) { nng_socket s1; - nng_aio * aio; - nng_msg * msg; + nng_aio *aio; + nng_msg *msg; NUTS_PASS(nng_aio_alloc(&aio, NULL, NULL)); NUTS_PASS(nng_msg_alloc(&msg, 0)); @@ -241,10 +241,10 @@ test_pair0_raw(void) void test_pair0_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_pair0_open(&s1)); @@ -295,7 +295,8 @@ test_pair0_send_buffer(void) NUTS_FAIL(nng_socket_get(s, NNG_OPT_SENDBUF, &b, &sz), NNG_EINVAL); NUTS_FAIL(nng_socket_set_int(s, NNG_OPT_SENDBUF, -1), NNG_EINVAL); NUTS_FAIL(nng_socket_set_int(s, NNG_OPT_SENDBUF, 100000), NNG_EINVAL); - NUTS_FAIL(nng_socket_set_bool(s, NNG_OPT_SENDBUF, false), NNG_EBADTYPE); + NUTS_FAIL( + nng_socket_set_bool(s, NNG_OPT_SENDBUF, false), NNG_EBADTYPE); NUTS_FAIL(nng_socket_set(s, NNG_OPT_SENDBUF, &b, 1), NNG_EINVAL); NUTS_PASS(nng_socket_set_int(s, NNG_OPT_SENDBUF, 100)); NUTS_PASS(nng_socket_get_int(s, NNG_OPT_SENDBUF, &v)); @@ -319,7 +320,8 @@ test_pair0_recv_buffer(void) NUTS_FAIL(nng_socket_get(s, NNG_OPT_RECVBUF, &b, &sz), NNG_EINVAL); NUTS_FAIL(nng_socket_set_int(s, NNG_OPT_RECVBUF, -1), NNG_EINVAL); NUTS_FAIL(nng_socket_set_int(s, NNG_OPT_RECVBUF, 100000), NNG_EINVAL); - NUTS_FAIL(nng_socket_set_bool(s, NNG_OPT_RECVBUF, false), NNG_EBADTYPE); + NUTS_FAIL( + nng_socket_set_bool(s, NNG_OPT_RECVBUF, false), NNG_EBADTYPE); NUTS_FAIL(nng_socket_set(s, NNG_OPT_RECVBUF, &b, 1), NNG_EINVAL); NUTS_PASS(nng_socket_set_int(s, NNG_OPT_RECVBUF, 100)); NUTS_PASS(nng_socket_get_int(s, NNG_OPT_RECVBUF, &v)); diff --git a/src/sp/protocol/pair1/pair1_poly_test.c b/src/sp/protocol/pair1/pair1_poly_test.c index 3aabb248..895dd935 100644 --- a/src/sp/protocol/pair1/pair1_poly_test.c +++ b/src/sp/protocol/pair1/pair1_poly_test.c @@ -1,5 +1,5 @@ // -// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2017 Capitar IT Group BV <info@capitar.com> // // This software is supplied under the terms of the MIT License, a @@ -22,7 +22,7 @@ test_poly_identity(void) { nng_socket s; int p; - char * n; + char *n; NUTS_PASS(nng_pair1_open_poly(&s)); NUTS_PASS(nng_socket_get_int(s, NNG_OPT_PROTO, &p)); @@ -43,7 +43,7 @@ test_poly_best_effort(void) { nng_socket s1; nng_socket c1; - nng_msg * msg; + nng_msg *msg; NUTS_PASS(nng_pair1_open_poly(&s1)); NUTS_PASS(nng_pair1_open(&c1)); @@ -70,7 +70,7 @@ test_poly_cooked(void) nng_socket s1; nng_socket c1; nng_socket c2; - nng_msg * msg; + nng_msg *msg; bool v; nng_pipe p1; nng_pipe p2; @@ -146,7 +146,7 @@ test_poly_default(void) nng_socket s1; nng_socket c1; nng_socket c2; - nng_msg * msg; + nng_msg *msg; NUTS_PASS(nng_pair1_open_poly(&s1)); NUTS_PASS(nng_pair1_open(&c1)); @@ -211,7 +211,7 @@ test_poly_recv_no_header(void) { nng_socket s; nng_socket c; - nng_msg * m; + nng_msg *m; NUTS_PASS(nng_pair1_open_poly(&s)); NUTS_PASS(nng_pair1_open(&c)); @@ -234,7 +234,7 @@ test_poly_recv_garbage(void) { nng_socket s; nng_socket c; - nng_msg * m; + nng_msg *m; NUTS_PASS(nng_pair1_open_poly(&s)); NUTS_PASS(nng_pair1_open(&c)); @@ -259,7 +259,7 @@ test_poly_ttl(void) { nng_socket s1; nng_socket c1; - nng_msg * msg; + nng_msg *msg; uint32_t val; int ttl; @@ -327,10 +327,10 @@ test_poly_ttl(void) void test_poly_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"); diff --git a/src/sp/protocol/pair1/pair1_test.c b/src/sp/protocol/pair1/pair1_test.c index 83c96478..ea80d80c 100644 --- a/src/sp/protocol/pair1/pair1_test.c +++ b/src/sp/protocol/pair1/pair1_test.c @@ -1,5 +1,5 @@ // -// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2017 Capitar IT Group BV <info@capitar.com> // // This software is supplied under the terms of the MIT License, a @@ -22,7 +22,7 @@ test_mono_identity(void) { nng_socket s; int p; - char * n; + char *n; NUTS_PASS(nng_pair1_open(&s)); NUTS_PASS(nng_socket_get_int(s, NNG_OPT_PROTO, &p)); @@ -43,7 +43,7 @@ test_mono_cooked(void) { nng_socket s1; nng_socket c1; - nng_msg * msg; + nng_msg *msg; NUTS_PASS(nng_pair1_open(&s1)); NUTS_PASS(nng_pair1_open(&c1)); @@ -75,7 +75,7 @@ test_mono_faithful(void) nng_socket s1; nng_socket c1; nng_socket c2; - nng_msg * msg; + nng_msg *msg; const char *addr = "inproc://pair1_mono_faithful"; NUTS_PASS(nng_pair1_open(&s1)); @@ -116,7 +116,7 @@ test_mono_back_pressure(void) nng_socket c1; int i; int rv; - nng_msg * msg; + nng_msg *msg; nng_duration to = 100; NUTS_PASS(nng_pair1_open(&s1)); @@ -147,7 +147,7 @@ void test_send_no_peer(void) { nng_socket s1; - nng_msg * msg; + nng_msg *msg; nng_duration to = 100; NUTS_PASS(nng_pair1_open(&s1)); @@ -214,7 +214,7 @@ test_mono_raw_header(void) { nng_socket s1; nng_socket c1; - nng_msg * msg; + nng_msg *msg; uint32_t v; NUTS_PASS(nng_pair1_open_raw(&s1)); @@ -269,8 +269,8 @@ void test_pair1_send_closed_aio(void) { nng_socket s1; - nng_aio * aio; - nng_msg * msg; + nng_aio *aio; + nng_msg *msg; NUTS_PASS(nng_aio_alloc(&aio, NULL, NULL)); NUTS_PASS(nng_msg_alloc(&msg, 0)); @@ -309,7 +309,7 @@ test_pair1_ttl(void) { nng_socket s1; nng_socket c1; - nng_msg * msg; + nng_msg *msg; uint32_t val; int ttl; @@ -377,10 +377,10 @@ test_pair1_ttl(void) void test_pair1_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_pair1_open(&s1)); @@ -409,7 +409,7 @@ test_pair1_recv_no_header(void) { nng_socket s; nng_socket c; - nng_msg * m; + nng_msg *m; NUTS_PASS(nng_pair1_open(&s)); NUTS_PASS(nng_pair1_open(&c)); @@ -432,7 +432,7 @@ test_pair1_recv_garbage(void) { nng_socket s; nng_socket c; - nng_msg * m; + nng_msg *m; NUTS_PASS(nng_pair1_open(&s)); NUTS_PASS(nng_pair1_open(&c)); @@ -479,7 +479,8 @@ test_pair1_send_buffer(void) NUTS_FAIL(nng_socket_get(s, NNG_OPT_SENDBUF, &b, &sz), NNG_EINVAL); NUTS_FAIL(nng_socket_set_int(s, NNG_OPT_SENDBUF, -1), NNG_EINVAL); NUTS_FAIL(nng_socket_set_int(s, NNG_OPT_SENDBUF, 100000), NNG_EINVAL); - NUTS_FAIL(nng_socket_set_bool(s, NNG_OPT_SENDBUF, false), NNG_EBADTYPE); + NUTS_FAIL( + nng_socket_set_bool(s, NNG_OPT_SENDBUF, false), NNG_EBADTYPE); NUTS_FAIL(nng_socket_set(s, NNG_OPT_SENDBUF, &b, 1), NNG_EINVAL); NUTS_PASS(nng_socket_set_int(s, NNG_OPT_SENDBUF, 100)); NUTS_PASS(nng_socket_get_int(s, NNG_OPT_SENDBUF, &v)); @@ -503,7 +504,8 @@ test_pair1_recv_buffer(void) NUTS_FAIL(nng_socket_get(s, NNG_OPT_RECVBUF, &b, &sz), NNG_EINVAL); NUTS_FAIL(nng_socket_set_int(s, NNG_OPT_RECVBUF, -1), NNG_EINVAL); NUTS_FAIL(nng_socket_set_int(s, NNG_OPT_RECVBUF, 100000), NNG_EINVAL); - NUTS_FAIL(nng_socket_set_bool(s, NNG_OPT_RECVBUF, false), NNG_EBADTYPE); + NUTS_FAIL( + nng_socket_set_bool(s, NNG_OPT_RECVBUF, false), NNG_EBADTYPE); NUTS_FAIL(nng_socket_set(s, NNG_OPT_RECVBUF, &b, 1), NNG_EINVAL); NUTS_PASS(nng_socket_set_int(s, NNG_OPT_RECVBUF, 100)); NUTS_PASS(nng_socket_get_int(s, NNG_OPT_RECVBUF, &v)); diff --git a/src/sp/protocol/pipeline0/pull_test.c b/src/sp/protocol/pipeline0/pull_test.c index 25066093..be11a42d 100644 --- a/src/sp/protocol/pipeline0/pull_test.c +++ b/src/sp/protocol/pipeline0/pull_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_pull_identity(void) { nng_socket s; int p; - char * n; + char *n; NUTS_PASS(nng_pull0_open(&s)); NUTS_PASS(nng_socket_get_int(s, NNG_OPT_PROTO, &p)); @@ -104,7 +104,7 @@ test_pull_close_pending(void) nng_socket pull; nng_socket push; nng_pipe p1, p2; - char * addr; + char *addr; NUTS_ADDR(addr, "inproc"); @@ -136,10 +136,10 @@ test_pull_close_pending(void) void test_pull_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"); @@ -168,7 +168,7 @@ static void test_pull_recv_aio_stopped(void) { nng_socket s; - nng_aio * aio; + nng_aio *aio; NUTS_PASS(nng_pull0_open(&s)); NUTS_PASS(nng_aio_alloc(&aio, NULL, NULL)); @@ -185,7 +185,7 @@ static void test_pull_close_recv(void) { nng_socket s; - nng_aio * aio; + nng_aio *aio; NUTS_PASS(nng_pull0_open(&s)); NUTS_PASS(nng_aio_alloc(&aio, NULL, NULL)); @@ -202,7 +202,7 @@ static void test_pull_recv_nonblock(void) { nng_socket s; - nng_aio * aio; + nng_aio *aio; NUTS_PASS(nng_pull0_open(&s)); NUTS_PASS(nng_aio_alloc(&aio, NULL, NULL)); @@ -220,7 +220,7 @@ static void test_pull_recv_cancel(void) { nng_socket s; - nng_aio * aio; + nng_aio *aio; NUTS_PASS(nng_pull0_open(&s)); NUTS_PASS(nng_aio_alloc(&aio, NULL, NULL)); diff --git a/src/sp/protocol/pipeline0/push_test.c b/src/sp/protocol/pipeline0/push_test.c index 9bdd9635..15574732 100644 --- a/src/sp/protocol/pipeline0/push_test.c +++ b/src/sp/protocol/pipeline0/push_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_push_identity(void) { nng_socket s; int p; - char * n; + char *n; NUTS_PASS(nng_push0_open(&s)); NUTS_PASS(nng_socket_get_int(s, NNG_OPT_PROTO, &p)); @@ -34,7 +34,7 @@ static void test_push_cannot_recv(void) { nng_socket s; - nng_msg * m = NULL; + nng_msg *m = NULL; NUTS_PASS(nng_push0_open(&s)); NUTS_FAIL(nng_recvmsg(s, &m, 0), NNG_ENOTSUP); @@ -210,10 +210,10 @@ test_push_poll_truncate(void) void test_push_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"); @@ -242,8 +242,8 @@ static void test_push_send_aio_stopped(void) { nng_socket s; - nng_aio * aio; - nng_msg * m; + nng_aio *aio; + nng_msg *m; NUTS_PASS(nng_push0_open(&s)); NUTS_PASS(nng_aio_alloc(&aio, NULL, NULL)); @@ -263,8 +263,8 @@ static void test_push_close_send(void) { nng_socket s; - nng_aio * aio; - nng_msg * m; + nng_aio *aio; + nng_msg *m; NUTS_PASS(nng_push0_open(&s)); NUTS_PASS(nng_aio_alloc(&aio, NULL, NULL)); @@ -284,8 +284,8 @@ static void test_push_send_nonblock(void) { nng_socket s; - nng_aio * aio; - nng_msg * m; + nng_aio *aio; + nng_msg *m; NUTS_PASS(nng_push0_open(&s)); NUTS_PASS(nng_aio_alloc(&aio, NULL, NULL)); @@ -306,8 +306,8 @@ static void test_push_send_timeout(void) { nng_socket s; - nng_aio * aio; - nng_msg * m; + nng_aio *aio; + nng_msg *m; NUTS_PASS(nng_push0_open(&s)); NUTS_PASS(nng_aio_alloc(&aio, NULL, NULL)); @@ -328,8 +328,8 @@ static void test_push_send_cancel(void) { nng_socket s; - nng_aio * aio; - nng_msg * m; + nng_aio *aio; + nng_msg *m; NUTS_PASS(nng_push0_open(&s)); NUTS_PASS(nng_aio_alloc(&aio, NULL, NULL)); @@ -352,8 +352,8 @@ test_push_send_late_unbuffered(void) { nng_socket s; nng_socket pull; - nng_aio * aio; - nng_msg * m; + nng_aio *aio; + nng_msg *m; NUTS_PASS(nng_push0_open(&s)); NUTS_PASS(nng_pull0_open(&pull)); @@ -375,14 +375,13 @@ test_push_send_late_unbuffered(void) nng_aio_free(aio); } - static void test_push_send_late_buffered(void) { nng_socket s; nng_socket pull; - nng_aio * aio; - nng_msg * m; + nng_aio *aio; + nng_msg *m; NUTS_PASS(nng_push0_open(&s)); NUTS_PASS(nng_pull0_open(&pull)); @@ -493,7 +492,8 @@ test_push_send_buffer(void) NUTS_FAIL(nng_socket_get(s, NNG_OPT_SENDBUF, &b, &sz), NNG_EINVAL); NUTS_FAIL(nng_socket_set_int(s, NNG_OPT_SENDBUF, -1), NNG_EINVAL); NUTS_FAIL(nng_socket_set_int(s, NNG_OPT_SENDBUF, 100000), NNG_EINVAL); - NUTS_FAIL(nng_socket_set_bool(s, NNG_OPT_SENDBUF, false), NNG_EBADTYPE); + NUTS_FAIL( + nng_socket_set_bool(s, NNG_OPT_SENDBUF, false), NNG_EBADTYPE); NUTS_FAIL(nng_socket_set(s, NNG_OPT_SENDBUF, &b, 1), NNG_EINVAL); NUTS_PASS(nng_socket_set_int(s, NNG_OPT_SENDBUF, 100)); NUTS_PASS(nng_socket_get_int(s, NNG_OPT_SENDBUF, &v)); diff --git a/src/sp/protocol/pubsub0/pub_test.c b/src/sp/protocol/pubsub0/pub_test.c index a430b610..462decd2 100644 --- a/src/sp/protocol/pubsub0/pub_test.c +++ b/src/sp/protocol/pubsub0/pub_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_pub_identity(void) { nng_socket s; int p; - char * n; + char *n; NUTS_PASS(nng_pub0_open(&s)); NUTS_PASS(nng_socket_get_int(s, NNG_OPT_PROTO, &p)); @@ -103,10 +103,10 @@ test_pub_send_no_pipes(void) void test_pub_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"); @@ -166,7 +166,7 @@ test_sub_recv_ctx_closed(void) { nng_socket sub; nng_ctx ctx; - nng_aio * aio; + nng_aio *aio; NUTS_PASS(nng_sub0_open(&sub)); NUTS_PASS(nng_ctx_open(&ctx, sub)); NUTS_PASS(nng_aio_alloc(&aio, NULL, NULL)); @@ -183,7 +183,7 @@ test_sub_ctx_recv_aio_stopped(void) { nng_socket sub; nng_ctx ctx; - nng_aio * aio; + nng_aio *aio; NUTS_PASS(nng_sub0_open(&sub)); NUTS_PASS(nng_aio_alloc(&aio, NULL, NULL)); @@ -203,7 +203,7 @@ test_sub_close_context_recv(void) { nng_socket sub; nng_ctx ctx; - nng_aio * aio; + nng_aio *aio; NUTS_PASS(nng_sub0_open(&sub)); NUTS_PASS(nng_ctx_open(&ctx, sub)); @@ -223,7 +223,7 @@ test_sub_ctx_recv_nonblock(void) { nng_socket sub; nng_ctx ctx; - nng_aio * aio; + nng_aio *aio; NUTS_PASS(nng_sub0_open(&sub)); NUTS_PASS(nng_ctx_open(&ctx, sub)); @@ -243,7 +243,7 @@ test_sub_ctx_recv_cancel(void) { nng_socket sub; nng_ctx ctx; - nng_aio * aio; + nng_aio *aio; NUTS_PASS(nng_sub0_open(&sub)); NUTS_PASS(nng_ctx_open(&ctx, sub)); diff --git a/src/sp/protocol/pubsub0/sub_test.c b/src/sp/protocol/pubsub0/sub_test.c index b830ae80..a332a0a7 100644 --- a/src/sp/protocol/pubsub0/sub_test.c +++ b/src/sp/protocol/pubsub0/sub_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_sub_identity(void) { nng_socket s; int p; - char * n; + char *n; NUTS_PASS(nng_sub0_open(&s)); NUTS_PASS(nng_socket_get_int(s, NNG_OPT_PROTO, &p)); @@ -45,8 +45,8 @@ test_sub_context_cannot_send(void) { nng_socket sub; nng_ctx ctx; - nng_msg * m; - nng_aio * aio; + nng_msg *m; + nng_aio *aio; NUTS_PASS(nng_sub0_open(&sub)); NUTS_PASS(nng_ctx_open(&ctx, sub)); @@ -121,8 +121,8 @@ test_sub_recv_late(void) int fd; nng_socket pub; nng_socket sub; - nng_aio * aio; - nng_msg * msg; + nng_aio *aio; + nng_msg *msg; NUTS_PASS(nng_sub0_open(&sub)); NUTS_PASS(nng_pub0_open(&pub)); @@ -179,10 +179,10 @@ test_sub_context_no_poll(void) void test_sub_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"); @@ -212,7 +212,7 @@ test_sub_recv_ctx_closed(void) { nng_socket sub; nng_ctx ctx; - nng_aio * aio; + nng_aio *aio; NUTS_PASS(nng_sub0_open(&sub)); NUTS_PASS(nng_ctx_open(&ctx, sub)); NUTS_PASS(nng_aio_alloc(&aio, NULL, NULL)); @@ -229,7 +229,7 @@ test_sub_ctx_recv_aio_stopped(void) { nng_socket sub; nng_ctx ctx; - nng_aio * aio; + nng_aio *aio; NUTS_PASS(nng_sub0_open(&sub)); NUTS_PASS(nng_aio_alloc(&aio, NULL, NULL)); @@ -249,7 +249,7 @@ test_sub_close_context_recv(void) { nng_socket sub; nng_ctx ctx; - nng_aio * aio; + nng_aio *aio; NUTS_PASS(nng_sub0_open(&sub)); NUTS_PASS(nng_ctx_open(&ctx, sub)); @@ -269,7 +269,7 @@ test_sub_ctx_recv_nonblock(void) { nng_socket sub; nng_ctx ctx; - nng_aio * aio; + nng_aio *aio; NUTS_PASS(nng_sub0_open(&sub)); NUTS_PASS(nng_ctx_open(&ctx, sub)); @@ -289,7 +289,7 @@ test_sub_ctx_recv_cancel(void) { nng_socket sub; nng_ctx ctx; - nng_aio * aio; + nng_aio *aio; NUTS_PASS(nng_sub0_open(&sub)); NUTS_PASS(nng_ctx_open(&ctx, sub)); @@ -413,7 +413,7 @@ test_sub_drop_new(void) { nng_socket sub; nng_socket pub; - nng_msg * msg; + nng_msg *msg; NUTS_PASS(nng_sub0_open(&sub)); NUTS_PASS(nng_pub0_open(&pub)); @@ -439,7 +439,7 @@ test_sub_drop_old(void) { nng_socket sub; nng_socket pub; - nng_msg * msg; + nng_msg *msg; NUTS_PASS(nng_sub0_open(&sub)); NUTS_PASS(nng_pub0_open(&pub)); @@ -485,7 +485,7 @@ test_sub_filter(void) NUTS_PASS(nng_send(pub, "def", 3, 0)); NUTS_PASS(nng_send(pub, "de", 2, 0)); // will not go through NUTS_PASS(nng_send(pub, "abc123", 6, 0)); - NUTS_PASS(nng_send(pub, "xzy", 3, 0)); // does not match + NUTS_PASS(nng_send(pub, "xzy", 3, 0)); // does not match NUTS_PASS(nng_send(pub, "ghi-drop", 7, 0)); // dropped by unsub NUTS_PASS(nng_send(pub, "jkl-mno", 6, 0)); @@ -517,9 +517,9 @@ test_sub_multi_context(void) nng_socket pub; nng_ctx c1; nng_ctx c2; - nng_aio * aio1; - nng_aio * aio2; - nng_msg * m; + nng_aio *aio1; + nng_aio *aio2; + nng_msg *m; NUTS_PASS(nng_sub0_open(&sub)); NUTS_PASS(nng_pub0_open(&pub)); diff --git a/src/sp/protocol/pubsub0/xsub_test.c b/src/sp/protocol/pubsub0/xsub_test.c index 19815661..9f2be2be 100644 --- a/src/sp/protocol/pubsub0/xsub_test.c +++ b/src/sp/protocol/pubsub0/xsub_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_xsub_identity(void) { nng_socket s; int p; - char * n; + char *n; NUTS_PASS(nng_sub0_open_raw(&s)); NUTS_PASS(nng_socket_get_int(s, NNG_OPT_PROTO, &p)); @@ -93,8 +93,8 @@ test_xsub_recv_late(void) int fd; nng_socket pub; nng_socket sub; - nng_aio * aio; - nng_msg * msg; + nng_aio *aio; + nng_msg *msg; NUTS_PASS(nng_sub0_open_raw(&sub)); NUTS_PASS(nng_pub0_open(&pub)); @@ -146,10 +146,10 @@ test_xsub_no_context(void) void test_xsub_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"); @@ -178,7 +178,7 @@ static void test_xsub_recv_closed(void) { nng_socket sub; - nng_aio * aio; + nng_aio *aio; NUTS_PASS(nng_sub0_open_raw(&sub)); NUTS_PASS(nng_aio_alloc(&aio, NULL, NULL)); NUTS_CLOSE(sub); @@ -192,7 +192,7 @@ static void test_xsub_close_recv(void) { nng_socket sub; - nng_aio * aio; + nng_aio *aio; NUTS_PASS(nng_sub0_open_raw(&sub)); NUTS_PASS(nng_aio_alloc(&aio, NULL, NULL)); @@ -209,7 +209,7 @@ static void test_xsub_recv_nonblock(void) { nng_socket sub; - nng_aio * aio; + nng_aio *aio; NUTS_PASS(nng_sub0_open_raw(&sub)); NUTS_PASS(nng_aio_alloc(&aio, NULL, NULL)); @@ -341,7 +341,7 @@ static void test_xsub_recv_aio_stopped(void) { nng_socket sub; - nng_aio * aio; + nng_aio *aio; NUTS_PASS(nng_sub0_open_raw(&sub)); NUTS_PASS(nng_aio_alloc(&aio, NULL, NULL)); diff --git a/src/sp/protocol/reqrep0/rep_test.c b/src/sp/protocol/reqrep0/rep_test.c index 57da9cac..1a535998 100644 --- a/src/sp/protocol/reqrep0/rep_test.c +++ b/src/sp/protocol/reqrep0/rep_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 @@ -137,10 +137,10 @@ test_rep_context_no_poll(void) void test_rep_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_rep0_open(&s1)); diff --git a/src/sp/protocol/reqrep0/req_test.c b/src/sp/protocol/reqrep0/req_test.c index c115c8e7..31175cfd 100644 --- a/src/sp/protocol/reqrep0/req_test.c +++ b/src/sp/protocol/reqrep0/req_test.c @@ -1,5 +1,5 @@ // -// Copyright 2023 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 @@ -233,7 +233,7 @@ test_req_resend_reconnect(void) // the retry from loss of our original peer. NUTS_PASS(nng_socket_set_ms(req, NNG_OPT_REQ_RESENDTIME, 60 * SECOND)); // And make sure the tick runs faster than our timeout! - NUTS_PASS(nng_socket_set_ms(req, NNG_OPT_REQ_RESENDTICK, SECOND/10)); + NUTS_PASS(nng_socket_set_ms(req, NNG_OPT_REQ_RESENDTICK, SECOND / 10)); NUTS_MARRY(rep1, req); @@ -272,7 +272,7 @@ test_req_resend_disconnect(void) // the retry from loss of our original peer. NUTS_PASS(nng_socket_set_ms(req, NNG_OPT_REQ_RESENDTIME, 60 * SECOND)); // And make sure the tick runs faster than our timeout! - NUTS_PASS(nng_socket_set_ms(req, NNG_OPT_REQ_RESENDTICK, SECOND/10)); + NUTS_PASS(nng_socket_set_ms(req, NNG_OPT_REQ_RESENDTICK, SECOND / 10)); NUTS_MARRY(rep1, req); NUTS_SEND(req, "ping"); @@ -974,10 +974,10 @@ test_req_ctx_recv_close_socket(void) static void test_req_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"); diff --git a/src/sp/protocol/reqrep0/xrep_test.c b/src/sp/protocol/reqrep0/xrep_test.c index 6f1564eb..cee5952f 100644 --- a/src/sp/protocol/reqrep0/xrep_test.c +++ b/src/sp/protocol/reqrep0/xrep_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_xrep_identity(void) { nng_socket s; int p1, p2; - char * n1; - char * n2; + char *n1; + char *n2; NUTS_PASS(nng_rep0_open_raw(&s)); NUTS_PASS(nng_socket_get_int(s, NNG_OPT_PROTO, &p1)); @@ -87,7 +87,7 @@ test_xrep_poll_readable(void) int fd; nng_socket req; nng_socket rep; - nng_msg * msg; + nng_msg *msg; NUTS_PASS(nng_req0_open(&req)); NUTS_PASS(nng_rep0_open_raw(&rep)); @@ -120,10 +120,10 @@ test_xrep_poll_readable(void) static void test_xrep_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_xrep_close_pipe_before_send(void) nng_socket rep; nng_socket req; nng_pipe p; - nng_aio * aio1; - nng_msg * m; + nng_aio *aio1; + nng_msg *m; NUTS_PASS(nng_rep0_open_raw(&rep)); NUTS_PASS(nng_req0_open(&req)); @@ -186,7 +186,7 @@ test_xrep_close_pipe_during_send(void) nng_socket rep; nng_socket req; nng_pipe p; - nng_msg * m; + nng_msg *m; NUTS_PASS(nng_rep0_open_raw(&rep)); NUTS_PASS(nng_req0_open_raw(&req)); @@ -226,7 +226,7 @@ test_xrep_close_during_recv(void) { nng_socket rep; nng_socket req; - nng_msg * m; + nng_msg *m; NUTS_PASS(nng_rep0_open_raw(&rep)); NUTS_PASS(nng_req0_open_raw(&req)); @@ -255,7 +255,7 @@ static void test_xrep_recv_aio_stopped(void) { nng_socket rep; - nng_aio * aio; + nng_aio *aio; NUTS_PASS(nng_rep0_open_raw(&rep)); NUTS_PASS(nng_aio_alloc(&aio, NULL, NULL)); @@ -273,7 +273,7 @@ test_xrep_send_no_header(void) { nng_socket rep; nng_socket req; - nng_msg * m; + nng_msg *m; NUTS_PASS(nng_req0_open_raw(&req)); NUTS_PASS(nng_rep0_open_raw(&rep)); @@ -297,7 +297,7 @@ test_xrep_recv_garbage(void) { nng_socket rep; nng_socket req; - nng_msg * m; + nng_msg *m; NUTS_PASS(nng_rep0_open_raw(&rep)); NUTS_PASS(nng_req0_open_raw(&req)); @@ -355,7 +355,7 @@ test_xrep_ttl_drop(void) { nng_socket rep; nng_socket req; - nng_msg * m; + nng_msg *m; NUTS_PASS(nng_rep0_open_raw(&rep)); NUTS_PASS(nng_req0_open_raw(&req)); diff --git a/src/sp/protocol/reqrep0/xreq_test.c b/src/sp/protocol/reqrep0/xreq_test.c index 8c850cba..c2d6c9ed 100644 --- a/src/sp/protocol/reqrep0/xreq_test.c +++ b/src/sp/protocol/reqrep0/xreq_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_xreq_identity(void) { nng_socket s; int p1, p2; - char * n1; - char * n2; + char *n1; + char *n2; NUTS_PASS(nng_req0_open_raw(&s)); NUTS_PASS(nng_socket_get_int(s, NNG_OPT_PROTO, &p1)); @@ -84,7 +84,7 @@ test_xreq_poll_readable(void) int fd; nng_socket req; nng_socket rep; - nng_msg * msg; + nng_msg *msg; NUTS_PASS(nng_req0_open_raw(&req)); NUTS_PASS(nng_rep0_open(&rep)); @@ -129,10 +129,10 @@ test_xreq_poll_readable(void) static void test_xreq_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"); @@ -161,7 +161,7 @@ static void test_xreq_recv_aio_stopped(void) { nng_socket req; - nng_aio * aio; + nng_aio *aio; NUTS_PASS(nng_req0_open_raw(&req)); NUTS_PASS(nng_aio_alloc(&aio, NULL, NULL)); @@ -179,7 +179,7 @@ test_xreq_recv_garbage(void) { nng_socket rep; nng_socket req; - nng_msg * m; + nng_msg *m; uint32_t req_id; NUTS_PASS(nng_rep0_open_raw(&rep)); @@ -216,7 +216,7 @@ test_xreq_recv_header(void) { nng_socket rep; nng_socket req; - nng_msg * m; + nng_msg *m; nng_pipe p1, p2; uint32_t id; @@ -258,7 +258,7 @@ test_xreq_close_during_recv(void) { nng_socket rep; nng_socket req; - nng_msg * m; + nng_msg *m; nng_pipe p1; nng_pipe p2; @@ -289,7 +289,7 @@ test_xreq_close_pipe_during_send(void) { nng_socket rep; nng_socket req; - nng_msg * m; + nng_msg *m; nng_pipe p1; nng_pipe p2; 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)); |
