diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-04-26 15:36:13 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-04-26 19:13:59 -0700 |
| commit | fd06aba05381055ab56e1ec81d56055b66462f0b (patch) | |
| tree | 99633af36e1c393bffeda213c0ac85e83fc4a6ee /tests/bufsz.c | |
| parent | 3de2b56557c80b310341c423492bd8ba895c1abe (diff) | |
| download | nng-fd06aba05381055ab56e1ec81d56055b66462f0b.tar.gz nng-fd06aba05381055ab56e1ec81d56055b66462f0b.tar.bz2 nng-fd06aba05381055ab56e1ec81d56055b66462f0b.zip | |
fixes #375 integer types are error prone
This change converts the various integer types like nng_socket
in the public API to opaque structures that are passed by value.
Basically we just wrap the integer ID. This "hack" give us strong
type checks by the compiler (yay!), at the expense of not being able
to directly use these as numbers (so comparisions for example don't
work, and neither does initialization to zero using the normal
method.
Comparison of disassembly output shows that at least with the optimizer
enabled there is no difference in the compiler output between using
a structure or an integral value.
Diffstat (limited to 'tests/bufsz.c')
| -rw-r--r-- | tests/bufsz.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/bufsz.c b/tests/bufsz.c index 4686a4e5..b7128ed4 100644 --- a/tests/bufsz.c +++ b/tests/bufsz.c @@ -61,7 +61,7 @@ TestMain("Buffer Options", { // MUST NOT assume this. We only do so for testing. Convey("Legacy Recv Buf Option", { int cnt; - int os = (int) s1; + int os = (int) s1.id; size_t sz = sizeof(cnt); So(nng_setopt_int(s1, NNG_OPT_RECVBUF, 10) == 0); So(nn_getsockopt( @@ -82,7 +82,7 @@ TestMain("Buffer Options", { }); Convey("Legacy Send Buf Option", { int cnt; - int os = (int) s1; + int os = (int) s1.id; size_t sz = sizeof(cnt); So(nng_setopt_int(s1, NNG_OPT_SENDBUF, 10) == 0); So(nn_getsockopt( |
