Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
24b79c7e
Commit
24b79c7e
authored
May 28, 2012
by
Martin Hurton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prefer errno_assert/alloc_assert to zmq_assert
parent
01396768
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
39 additions
and
38 deletions
+39
-38
ctx.cpp
src/ctx.cpp
+1
-1
dealer.cpp
src/dealer.cpp
+1
-1
dist.cpp
src/dist.cpp
+1
-1
lb.cpp
src/lb.cpp
+1
-1
mtrie.cpp
src/mtrie.cpp
+8
-8
pgm_sender.cpp
src/pgm_sender.cpp
+1
-1
session_base.cpp
src/session_base.cpp
+4
-3
signaler.cpp
src/signaler.cpp
+2
-2
socket_base.cpp
src/socket_base.cpp
+5
-5
tcp_address.cpp
src/tcp_address.cpp
+6
-6
trie.cpp
src/trie.cpp
+5
-5
xsub.cpp
src/xsub.cpp
+4
-4
No files found.
src/ctx.cpp
View file @
24b79c7e
...
...
@@ -113,7 +113,7 @@ int zmq::ctx_t::terminate ()
int
rc
=
term_mailbox
.
recv
(
&
cmd
,
-
1
);
if
(
rc
==
-
1
&&
errno
==
EINTR
)
return
-
1
;
zmq
_assert
(
rc
==
0
);
errno
_assert
(
rc
==
0
);
zmq_assert
(
cmd
.
type
==
command_t
::
done
);
slot_sync
.
lock
();
zmq_assert
(
sockets
.
empty
());
...
...
src/dealer.cpp
View file @
24b79c7e
...
...
@@ -89,7 +89,7 @@ bool zmq::dealer_t::xhas_in ()
int
rc
=
dealer_t
::
xrecv
(
&
prefetched_msg
,
ZMQ_DONTWAIT
);
if
(
rc
!=
0
&&
errno
==
EAGAIN
)
return
false
;
zmq
_assert
(
rc
==
0
);
errno
_assert
(
rc
==
0
);
prefetched
=
true
;
return
true
;
}
...
...
src/dist.cpp
View file @
24b79c7e
...
...
@@ -133,7 +133,7 @@ void zmq::dist_t::distribute (msg_t *msg_, int flags_)
int
rc
=
msg_
->
close
();
errno_assert
(
rc
==
0
);
rc
=
msg_
->
init
();
zmq
_assert
(
rc
==
0
);
errno
_assert
(
rc
==
0
);
return
;
}
...
...
src/lb.cpp
View file @
24b79c7e
...
...
@@ -84,7 +84,7 @@ int zmq::lb_t::send (msg_t *msg_, int flags_)
int
rc
=
msg_
->
close
();
errno_assert
(
rc
==
0
);
rc
=
msg_
->
init
();
zmq
_assert
(
rc
==
0
);
errno
_assert
(
rc
==
0
);
return
0
;
}
...
...
src/mtrie.cpp
View file @
24b79c7e
...
...
@@ -94,7 +94,7 @@ bool zmq::mtrie_t::add_helper (unsigned char *prefix_, size_t size_,
count
=
(
min
<
c
?
c
-
min
:
min
-
c
)
+
1
;
next
.
table
=
(
mtrie_t
**
)
malloc
(
sizeof
(
mtrie_t
*
)
*
count
);
zmq
_assert
(
next
.
table
);
alloc
_assert
(
next
.
table
);
for
(
unsigned
short
i
=
0
;
i
!=
count
;
++
i
)
next
.
table
[
i
]
=
0
;
min
=
std
::
min
(
min
,
c
);
...
...
@@ -107,7 +107,7 @@ bool zmq::mtrie_t::add_helper (unsigned char *prefix_, size_t size_,
count
=
c
-
min
+
1
;
next
.
table
=
(
mtrie_t
**
)
realloc
((
void
*
)
next
.
table
,
sizeof
(
mtrie_t
*
)
*
count
);
zmq
_assert
(
next
.
table
);
alloc
_assert
(
next
.
table
);
for
(
unsigned
short
i
=
old_count
;
i
!=
count
;
i
++
)
next
.
table
[
i
]
=
NULL
;
}
...
...
@@ -118,7 +118,7 @@ bool zmq::mtrie_t::add_helper (unsigned char *prefix_, size_t size_,
count
=
(
min
+
old_count
)
-
c
;
next
.
table
=
(
mtrie_t
**
)
realloc
((
void
*
)
next
.
table
,
sizeof
(
mtrie_t
*
)
*
count
);
zmq
_assert
(
next
.
table
);
alloc
_assert
(
next
.
table
);
memmove
(
next
.
table
+
min
-
c
,
next
.
table
,
old_count
*
sizeof
(
mtrie_t
*
));
for
(
unsigned
short
i
=
0
;
i
!=
min
-
c
;
i
++
)
...
...
@@ -132,7 +132,7 @@ bool zmq::mtrie_t::add_helper (unsigned char *prefix_, size_t size_,
if
(
!
next
.
node
)
{
next
.
node
=
new
(
std
::
nothrow
)
mtrie_t
;
++
live_nodes
;
zmq
_assert
(
next
.
node
);
alloc
_assert
(
next
.
node
);
}
return
next
.
node
->
add_helper
(
prefix_
+
1
,
size_
-
1
,
pipe_
);
}
...
...
@@ -140,7 +140,7 @@ bool zmq::mtrie_t::add_helper (unsigned char *prefix_, size_t size_,
if
(
!
next
.
table
[
c
-
min
])
{
next
.
table
[
c
-
min
]
=
new
(
std
::
nothrow
)
mtrie_t
;
++
live_nodes
;
zmq
_assert
(
next
.
table
[
c
-
min
]);
alloc
_assert
(
next
.
table
[
c
-
min
]);
}
return
next
.
table
[
c
-
min
]
->
add_helper
(
prefix_
+
1
,
size_
-
1
,
pipe_
);
}
...
...
@@ -260,7 +260,7 @@ void zmq::mtrie_t::rm_helper (pipe_t *pipe_, unsigned char **buff_,
count
=
new_max
-
new_min
+
1
;
next
.
table
=
(
mtrie_t
**
)
malloc
(
sizeof
(
mtrie_t
*
)
*
count
);
zmq
_assert
(
next
.
table
);
alloc
_assert
(
next
.
table
);
memmove
(
next
.
table
,
old_table
+
(
new_min
-
min
),
sizeof
(
mtrie_t
*
)
*
count
);
...
...
@@ -353,7 +353,7 @@ bool zmq::mtrie_t::rm_helper (unsigned char *prefix_, size_t size_,
count
=
count
-
(
new_min
-
min
);
next
.
table
=
(
mtrie_t
**
)
malloc
(
sizeof
(
mtrie_t
*
)
*
count
);
zmq
_assert
(
next
.
table
);
alloc
_assert
(
next
.
table
);
memmove
(
next
.
table
,
old_table
+
(
new_min
-
min
),
sizeof
(
mtrie_t
*
)
*
count
);
...
...
@@ -375,7 +375,7 @@ bool zmq::mtrie_t::rm_helper (unsigned char *prefix_, size_t size_,
mtrie_t
**
old_table
=
next
.
table
;
next
.
table
=
(
mtrie_t
**
)
malloc
(
sizeof
(
mtrie_t
*
)
*
count
);
zmq
_assert
(
next
.
table
);
alloc
_assert
(
next
.
table
);
memmove
(
next
.
table
,
old_table
,
sizeof
(
mtrie_t
*
)
*
count
);
free
(
old_table
);
...
...
src/pgm_sender.cpp
View file @
24b79c7e
...
...
@@ -197,7 +197,7 @@ void zmq::pgm_sender_t::out_event ()
add_timer
(
timeout
,
tx_timer_id
);
has_tx_timer
=
true
;
}
else
zmq
_assert
(
errno
==
EBUSY
);
errno
_assert
(
errno
==
EBUSY
);
}
}
...
...
src/session_base.cpp
View file @
24b79c7e
...
...
@@ -155,7 +155,8 @@ int zmq::session_base_t::read (msg_t *msg_)
// First message to send is identity (if required).
if
(
send_identity
)
{
zmq_assert
(
!
(
msg_
->
flags
()
&
msg_t
::
more
));
msg_
->
init_size
(
options
.
identity_size
);
int
rc
=
msg_
->
init_size
(
options
.
identity_size
);
errno_assert
(
rc
==
0
);
memcpy
(
msg_
->
data
(),
options
.
identity
,
options
.
identity_size
);
send_identity
=
false
;
incomplete_in
=
false
;
...
...
@@ -449,7 +450,7 @@ void zmq::session_base_t::start_connecting (bool wait_)
alloc_assert
(
pgm_sender
);
int
rc
=
pgm_sender
->
init
(
udp_encapsulation
,
addr
->
address
.
c_str
());
zmq
_assert
(
rc
==
0
);
errno
_assert
(
rc
==
0
);
send_attach
(
this
,
pgm_sender
);
}
...
...
@@ -461,7 +462,7 @@ void zmq::session_base_t::start_connecting (bool wait_)
alloc_assert
(
pgm_receiver
);
int
rc
=
pgm_receiver
->
init
(
udp_encapsulation
,
addr
->
address
.
c_str
());
zmq
_assert
(
rc
==
0
);
errno
_assert
(
rc
==
0
);
send_attach
(
this
,
pgm_receiver
);
}
...
...
src/signaler.cpp
View file @
24b79c7e
...
...
@@ -144,7 +144,7 @@ int zmq::signaler_t::wait (int timeout_)
pfd
.
events
=
POLLIN
;
int
rc
=
poll
(
&
pfd
,
1
,
timeout_
);
if
(
unlikely
(
rc
<
0
))
{
zmq
_assert
(
errno
==
EINTR
);
errno
_assert
(
errno
==
EINTR
);
return
-
1
;
}
else
if
(
unlikely
(
rc
==
0
))
{
...
...
@@ -173,7 +173,7 @@ int zmq::signaler_t::wait (int timeout_)
int
rc
=
select
(
r
+
1
,
&
fds
,
NULL
,
NULL
,
timeout_
>=
0
?
&
timeout
:
NULL
);
if
(
unlikely
(
rc
<
0
))
{
zmq
_assert
(
errno
==
EINTR
);
errno
_assert
(
errno
==
EINTR
);
return
-
1
;
}
#endif
...
...
src/socket_base.cpp
View file @
24b79c7e
...
...
@@ -448,7 +448,7 @@ int zmq::socket_base_t::connect (const char *addr_)
if
(
options
.
send_identity
)
{
msg_t
id
;
rc
=
id
.
init_size
(
options
.
identity_size
);
zmq
_assert
(
rc
==
0
);
errno
_assert
(
rc
==
0
);
memcpy
(
id
.
data
(),
options
.
identity
,
options
.
identity_size
);
id
.
set_flags
(
msg_t
::
identity
);
bool
written
=
pipes
[
0
]
->
write
(
&
id
);
...
...
@@ -460,7 +460,7 @@ int zmq::socket_base_t::connect (const char *addr_)
if
(
peer
.
options
.
send_identity
)
{
msg_t
id
;
rc
=
id
.
init_size
(
peer
.
options
.
identity_size
);
zmq
_assert
(
rc
==
0
);
errno
_assert
(
rc
==
0
);
memcpy
(
id
.
data
(),
peer
.
options
.
identity
,
peer
.
options
.
identity_size
);
id
.
set_flags
(
msg_t
::
identity
);
bool
written
=
pipes
[
1
]
->
write
(
&
id
);
...
...
@@ -487,12 +487,12 @@ int zmq::socket_base_t::connect (const char *addr_)
}
address_t
*
paddr
=
new
(
std
::
nothrow
)
address_t
(
protocol
,
address
);
zmq
_assert
(
paddr
);
alloc
_assert
(
paddr
);
// Resolve address (if needed by the protocol)
if
(
protocol
==
"tcp"
)
{
paddr
->
resolved
.
tcp_addr
=
new
(
std
::
nothrow
)
tcp_address_t
();
zmq
_assert
(
paddr
->
resolved
.
tcp_addr
);
alloc
_assert
(
paddr
->
resolved
.
tcp_addr
);
int
rc
=
paddr
->
resolved
.
tcp_addr
->
resolve
(
address
.
c_str
(),
false
,
options
.
ipv4only
?
true
:
false
);
if
(
rc
!=
0
)
{
...
...
@@ -503,7 +503,7 @@ int zmq::socket_base_t::connect (const char *addr_)
#if !defined ZMQ_HAVE_WINDOWS && !defined ZMQ_HAVE_OPENVMS
else
if
(
protocol
==
"ipc"
)
{
paddr
->
resolved
.
ipc_addr
=
new
(
std
::
nothrow
)
ipc_address_t
();
zmq
_assert
(
paddr
->
resolved
.
ipc_addr
);
alloc
_assert
(
paddr
->
resolved
.
ipc_addr
);
int
rc
=
paddr
->
resolved
.
ipc_addr
->
resolve
(
address
.
c_str
());
if
(
rc
!=
0
)
{
delete
paddr
;
...
...
src/tcp_address.cpp
View file @
24b79c7e
...
...
@@ -59,14 +59,14 @@ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv4only_)
// Create a socket.
int
fd
=
open_socket
(
AF_INET
,
SOCK_DGRAM
,
0
);
zmq
_assert
(
fd
!=
-
1
);
errno
_assert
(
fd
!=
-
1
);
// Retrieve number of interfaces.
lifnum
ifn
;
ifn
.
lifn_family
=
AF_INET
;
ifn
.
lifn_flags
=
0
;
int
rc
=
ioctl
(
fd
,
SIOCGLIFNUM
,
(
char
*
)
&
ifn
);
zmq
_assert
(
rc
!=
-
1
);
errno
_assert
(
rc
!=
-
1
);
// Allocate memory to get interface names.
size_t
ifr_size
=
sizeof
(
struct
lifreq
)
*
ifn
.
lifn_count
;
...
...
@@ -80,7 +80,7 @@ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv4only_)
ifc
.
lifc_len
=
ifr_size
;
ifc
.
lifc_buf
=
ifr
;
rc
=
ioctl
(
fd
,
SIOCGLIFCONF
,
(
char
*
)
&
ifc
);
zmq
_assert
(
rc
!=
-
1
);
errno
_assert
(
rc
!=
-
1
);
// Find the interface with the specified name and AF_INET family.
bool
found
=
false
;
...
...
@@ -89,7 +89,7 @@ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv4only_)
n
++
,
ifrp
++
)
{
if
(
!
strcmp
(
nic_
,
ifrp
->
lifr_name
))
{
rc
=
ioctl
(
fd
,
SIOCGLIFADDR
,
(
char
*
)
ifrp
);
zmq
_assert
(
rc
!=
-
1
);
errno
_assert
(
rc
!=
-
1
);
if
(
ifrp
->
lifr_addr
.
ss_family
==
AF_INET
)
{
address
.
ipv4
=
*
(
sockaddr_in
*
)
&
ifrp
->
lifr_addr
;
found
=
true
;
...
...
@@ -124,7 +124,7 @@ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv4only_)
// Create a socket.
int
sd
=
open_socket
(
AF_INET
,
SOCK_DGRAM
,
0
);
zmq
_assert
(
sd
!=
-
1
);
errno
_assert
(
sd
!=
-
1
);
struct
ifreq
ifr
;
...
...
@@ -162,7 +162,7 @@ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv4only_)
// Get the addresses.
ifaddrs
*
ifa
=
NULL
;
int
rc
=
getifaddrs
(
&
ifa
);
zmq
_assert
(
rc
==
0
);
errno
_assert
(
rc
==
0
);
zmq_assert
(
ifa
!=
NULL
);
// Find the corresponding network interface.
...
...
src/trie.cpp
View file @
24b79c7e
...
...
@@ -80,7 +80,7 @@ bool zmq::trie_t::add (unsigned char *prefix_, size_t size_)
count
=
(
min
<
c
?
c
-
min
:
min
-
c
)
+
1
;
next
.
table
=
(
trie_t
**
)
malloc
(
sizeof
(
trie_t
*
)
*
count
);
zmq
_assert
(
next
.
table
);
alloc
_assert
(
next
.
table
);
for
(
unsigned
short
i
=
0
;
i
!=
count
;
++
i
)
next
.
table
[
i
]
=
0
;
min
=
std
::
min
(
min
,
c
);
...
...
@@ -117,7 +117,7 @@ bool zmq::trie_t::add (unsigned char *prefix_, size_t size_)
if
(
count
==
1
)
{
if
(
!
next
.
node
)
{
next
.
node
=
new
(
std
::
nothrow
)
trie_t
;
zmq
_assert
(
next
.
node
);
alloc
_assert
(
next
.
node
);
++
live_nodes
;
zmq_assert
(
live_nodes
==
1
);
}
...
...
@@ -126,7 +126,7 @@ bool zmq::trie_t::add (unsigned char *prefix_, size_t size_)
else
{
if
(
!
next
.
table
[
c
-
min
])
{
next
.
table
[
c
-
min
]
=
new
(
std
::
nothrow
)
trie_t
;
zmq
_assert
(
next
.
table
[
c
-
min
]);
alloc
_assert
(
next
.
table
[
c
-
min
]);
++
live_nodes
;
zmq_assert
(
live_nodes
>
1
);
}
...
...
@@ -218,7 +218,7 @@ bool zmq::trie_t::rm (unsigned char *prefix_, size_t size_)
count
=
count
-
(
new_min
-
min
);
next
.
table
=
(
trie_t
**
)
malloc
(
sizeof
(
trie_t
*
)
*
count
);
zmq
_assert
(
next
.
table
);
alloc
_assert
(
next
.
table
);
memmove
(
next
.
table
,
old_table
+
(
new_min
-
min
),
sizeof
(
trie_t
*
)
*
count
);
...
...
@@ -242,7 +242,7 @@ bool zmq::trie_t::rm (unsigned char *prefix_, size_t size_)
trie_t
**
old_table
=
next
.
table
;
next
.
table
=
(
trie_t
**
)
malloc
(
sizeof
(
trie_t
*
)
*
count
);
zmq
_assert
(
next
.
table
);
alloc
_assert
(
next
.
table
);
memmove
(
next
.
table
,
old_table
,
sizeof
(
trie_t
*
)
*
count
);
free
(
old_table
);
...
...
src/xsub.cpp
View file @
24b79c7e
...
...
@@ -150,7 +150,7 @@ int zmq::xsub_t::xrecv (msg_t *msg_, int flags_)
// from the pipe.
while
(
msg_
->
flags
()
&
msg_t
::
more
)
{
rc
=
fq
.
recv
(
msg_
);
zmq
_assert
(
rc
==
0
);
errno
_assert
(
rc
==
0
);
}
}
}
...
...
@@ -176,7 +176,7 @@ bool zmq::xsub_t::xhas_in ()
// If there's no message available, return immediately.
// The same when error occurs.
if
(
rc
!=
0
)
{
zmq
_assert
(
errno
==
EAGAIN
);
errno
_assert
(
errno
==
EAGAIN
);
return
false
;
}
...
...
@@ -190,7 +190,7 @@ bool zmq::xsub_t::xhas_in ()
// from the pipe.
while
(
message
.
flags
()
&
msg_t
::
more
)
{
rc
=
fq
.
recv
(
&
message
);
zmq
_assert
(
rc
==
0
);
errno
_assert
(
rc
==
0
);
}
}
}
...
...
@@ -208,7 +208,7 @@ void zmq::xsub_t::send_subscription (unsigned char *data_, size_t size_,
// Create the subsctription message.
msg_t
msg
;
int
rc
=
msg
.
init_size
(
size_
+
1
);
zmq
_assert
(
rc
==
0
);
errno
_assert
(
rc
==
0
);
unsigned
char
*
data
=
(
unsigned
char
*
)
msg
.
data
();
data
[
0
]
=
1
;
memcpy
(
data
+
1
,
data_
,
size_
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment