Skip to content

Commit 7dce06b

Browse files
committed
api: pipes should use nng_err
1 parent 6dc7573 commit 7dce06b

File tree

12 files changed

+42
-42
lines changed

12 files changed

+42
-42
lines changed

include/nng/nng.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -740,14 +740,14 @@ NNG_DECL nng_pipe nng_msg_get_pipe(const nng_msg *);
740740
// we do permit an application to close a pipe. This can be useful, for
741741
// example during a connection notification, to disconnect a pipe that
742742
// is associated with an invalid or untrusted remote peer.
743-
NNG_DECL int nng_pipe_get_bool(nng_pipe, const char *, bool *);
744-
NNG_DECL int nng_pipe_get_int(nng_pipe, const char *, int *);
745-
NNG_DECL int nng_pipe_get_ms(nng_pipe, const char *, nng_duration *);
746-
NNG_DECL int nng_pipe_get_size(nng_pipe, const char *, size_t *);
747-
NNG_DECL int nng_pipe_get_string(nng_pipe, const char *, char **);
748-
NNG_DECL int nng_pipe_get_addr(nng_pipe, const char *, nng_sockaddr *);
749-
750-
NNG_DECL int nng_pipe_close(nng_pipe);
743+
NNG_DECL nng_err nng_pipe_get_bool(nng_pipe, const char *, bool *);
744+
NNG_DECL nng_err nng_pipe_get_int(nng_pipe, const char *, int *);
745+
NNG_DECL nng_err nng_pipe_get_ms(nng_pipe, const char *, nng_duration *);
746+
NNG_DECL nng_err nng_pipe_get_size(nng_pipe, const char *, size_t *);
747+
NNG_DECL nng_err nng_pipe_get_string(nng_pipe, const char *, char **);
748+
NNG_DECL nng_err nng_pipe_get_addr(nng_pipe, const char *, nng_sockaddr *);
749+
750+
NNG_DECL nng_err nng_pipe_close(nng_pipe);
751751
NNG_DECL int nng_pipe_id(nng_pipe);
752752
NNG_DECL nng_socket nng_pipe_socket(nng_pipe);
753753
NNG_DECL nng_dialer nng_pipe_dialer(nng_pipe);

src/core/pipe.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
2+
// Copyright 2025 Staysail Systems, Inc. <info@staysail.tech>
33
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
44
// Copyright 2018 Devolutions <info@devolutions.net>
55
//
@@ -75,7 +75,7 @@ pipe_reap(void *arg)
7575
nni_pipe_rele(p);
7676
}
7777

78-
int
78+
nng_err
7979
nni_pipe_find(nni_pipe **pp, uint32_t id)
8080
{
8181
nni_pipe *p;
@@ -90,7 +90,7 @@ nni_pipe_find(nni_pipe **pp, uint32_t id)
9090
*pp = p;
9191
}
9292
nni_mtx_unlock(&pipes_lk);
93-
return (p == NULL ? NNG_ENOENT : 0);
93+
return (p == NULL ? NNG_ENOENT : NNG_OK);
9494
}
9595

9696
void
@@ -330,11 +330,11 @@ nni_pipe_alloc_listener(void **datap, nni_listener *l)
330330
return (0);
331331
}
332332

333-
int
333+
nng_err
334334
nni_pipe_getopt(
335335
nni_pipe *p, const char *name, void *val, size_t *szp, nni_opt_type t)
336336
{
337-
int rv;
337+
nng_err rv;
338338

339339
rv = p->p_tran_ops.p_getopt(p->p_tran_data, name, val, szp, t);
340340
if (rv != NNG_ENOTSUP) {

src/core/pipe.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ extern void nni_pipe_close(nni_pipe *);
3636
extern uint16_t nni_pipe_peer(nni_pipe *);
3737

3838
// nni_pipe_getopt looks up the option.
39-
extern int nni_pipe_getopt(
39+
extern nng_err nni_pipe_getopt(
4040
nni_pipe *, const char *, void *, size_t *, nni_opt_type);
4141

4242
// nni_pipe_find finds a pipe given its ID. It places a hold on the
4343
// pipe, which must be released by the caller when it is done.
44-
extern int nni_pipe_find(nni_pipe **, uint32_t);
44+
extern nng_err nni_pipe_find(nni_pipe **, uint32_t);
4545

4646
// nni_pipe_sock_id returns the socket id for the pipe (used by public API).
4747
extern uint32_t nni_pipe_sock_id(nni_pipe *);

src/nng.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
2+
// Copyright 2025 Staysail Systems, Inc. <info@staysail.tech>
33
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
44
//
55
// This software is supplied under the terms of the MIT License, a
@@ -1301,51 +1301,51 @@ nng_strerror(nng_err num)
13011301
return (unknownerrbuf);
13021302
}
13031303

1304-
static int
1304+
static nng_err
13051305
pipe_get(nng_pipe p, const char *name, void *val, size_t *szp, nni_type t)
13061306
{
1307-
int rv;
1307+
nng_err rv;
13081308
nni_pipe *pipe;
13091309

13101310
if ((rv = nni_pipe_find(&pipe, p.id)) != 0) {
13111311
return (rv);
13121312
}
13131313
rv = nni_pipe_getopt(pipe, name, val, szp, t);
13141314
nni_pipe_rele(pipe);
1315-
return (rv);
1315+
return (NNG_OK);
13161316
}
13171317

1318-
int
1318+
nng_err
13191319
nng_pipe_get_int(nng_pipe id, const char *n, int *v)
13201320
{
13211321
return (pipe_get(id, n, v, NULL, NNI_TYPE_INT32));
13221322
}
13231323

1324-
int
1324+
nng_err
13251325
nng_pipe_get_bool(nng_pipe id, const char *n, bool *v)
13261326
{
13271327
return (pipe_get(id, n, v, NULL, NNI_TYPE_BOOL));
13281328
}
13291329

1330-
int
1330+
nng_err
13311331
nng_pipe_get_size(nng_pipe id, const char *n, size_t *v)
13321332
{
13331333
return (pipe_get(id, n, v, NULL, NNI_TYPE_SIZE));
13341334
}
13351335

1336-
int
1336+
nng_err
13371337
nng_pipe_get_string(nng_pipe id, const char *n, char **v)
13381338
{
13391339
return (pipe_get(id, n, v, NULL, NNI_TYPE_STRING));
13401340
}
13411341

1342-
int
1342+
nng_err
13431343
nng_pipe_get_ms(nng_pipe id, const char *n, nng_duration *v)
13441344
{
13451345
return (pipe_get(id, n, v, NULL, NNI_TYPE_DURATION));
13461346
}
13471347

1348-
int
1348+
nng_err
13491349
nng_pipe_get_addr(nng_pipe id, const char *n, nng_sockaddr *v)
13501350
{
13511351
return (pipe_get(id, n, v, NULL, NNI_TYPE_SOCKADDR));
@@ -1388,18 +1388,18 @@ nng_pipe_listener(nng_pipe p)
13881388
return (l);
13891389
}
13901390

1391-
int
1391+
nng_err
13921392
nng_pipe_close(nng_pipe p)
13931393
{
1394-
int rv;
1394+
nng_err rv;
13951395
nni_pipe *pipe;
13961396

13971397
if ((rv = nni_pipe_find(&pipe, p.id)) != 0) {
13981398
return (rv);
13991399
}
14001400
nni_pipe_close(pipe);
14011401
nni_pipe_rele(pipe);
1402-
return (0);
1402+
return (NNG_OK);
14031403
}
14041404

14051405
int

src/sp/transport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ struct nni_sp_pipe_ops {
180180

181181
// p_getopt is used to obtain an option. Pipes don't implement
182182
// option setting.
183-
int (*p_getopt)(void *, const char *, void *, size_t *, nni_type);
183+
nng_err (*p_getopt)(void *, const char *, void *, size_t *, nni_type);
184184
};
185185

186186
// Transport implementation details. Transports must implement the

src/sp/transport/inproc/inproc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
2+
// Copyright 2025 Staysail Systems, Inc. <info@staysail.tech>
33
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
44
// Copyright 2018 Devolutions <info@devolutions.net>
55
//
@@ -577,7 +577,7 @@ static const nni_option inproc_pipe_options[] = {
577577
},
578578
};
579579

580-
static int
580+
static nng_err
581581
inproc_pipe_getopt(
582582
void *arg, const char *name, void *v, size_t *szp, nni_type t)
583583
{

src/sp/transport/ipc/ipc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ ipc_ep_accept(void *arg, nni_aio *aio)
947947
nni_mtx_unlock(&ep->mtx);
948948
}
949949

950-
static int
950+
static nng_err
951951
ipc_pipe_get(void *arg, const char *name, void *buf, size_t *szp, nni_type t)
952952
{
953953
ipc_pipe *p = arg;

src/sp/transport/socket/sockfd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
2+
// Copyright 2025 Staysail Systems, Inc. <info@staysail.tech>
33
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
44
// Copyright 2019 Devolutions <info@devolutions.net>
55
//
@@ -546,7 +546,7 @@ sfd_tran_pipe_peer(void *arg)
546546
return (p->peer);
547547
}
548548

549-
static int
549+
static nng_err
550550
sfd_tran_pipe_getopt(
551551
void *arg, const char *name, void *buf, size_t *szp, nni_type t)
552552
{

src/sp/transport/tcp/tcp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ tcptran_pipe_peer(void *arg)
567567
return (p->peer);
568568
}
569569

570-
static int
570+
static nng_err
571571
tcptran_pipe_getopt(
572572
void *arg, const char *name, void *buf, size_t *szp, nni_type t)
573573
{

src/sp/transport/tls/tls.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
2+
// Copyright 2025 Staysail Systems, Inc. <info@staysail.tech>
33
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
44
// Copyright 2019 Devolutions <info@devolutions.net>
55
//
@@ -938,12 +938,12 @@ static const nni_option tlstran_pipe_opts[] = {
938938
},
939939
};
940940

941-
static int
941+
static nng_err
942942
tlstran_pipe_getopt(
943943
void *arg, const char *name, void *buf, size_t *szp, nni_type t)
944944
{
945945
tlstran_pipe *p = arg;
946-
int rv;
946+
nng_err rv;
947947

948948
if ((rv = nni_stream_get(p->tls, name, buf, szp, t)) == NNG_ENOTSUP) {
949949
rv = nni_getopt(tlstran_pipe_opts, name, p, buf, szp, t);

src/sp/transport/udp/udp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
1+
// Copyright 2025 Staysail Systems, Inc. <info@staysail.tech>
22
//
33
// This software is supplied under the terms of the MIT License, a
44
// copy of which should be located in the distribution where this
@@ -1082,7 +1082,7 @@ static nni_option udp_pipe_options[] = {
10821082
},
10831083
};
10841084

1085-
static int
1085+
static nng_err
10861086
udp_pipe_getopt(
10871087
void *arg, const char *name, void *buf, size_t *szp, nni_type t)
10881088
{

src/sp/transport/ws/websocket.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,12 +315,12 @@ static const nni_option ws_pipe_options[] = {
315315
}
316316
};
317317

318-
static int
318+
static nng_err
319319
wstran_pipe_getopt(
320320
void *arg, const char *name, void *buf, size_t *szp, nni_type t)
321321
{
322322
ws_pipe *p = arg;
323-
int rv;
323+
nng_err rv;
324324

325325
if ((rv = nni_stream_get(p->ws, name, buf, szp, t)) == NNG_ENOTSUP) {
326326
rv = nni_getopt(ws_pipe_options, name, p, buf, szp, t);

0 commit comments

Comments
 (0)