mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-27 07:31:03 +08:00
Problem: resolution of int optval_ was made more verbose
There's no value in this as the same pattern is repeated in several places and it's fair to expect people to understand it. Solution: revert to the old, one-liner style.
This commit is contained in:
parent
c8318912f5
commit
27a8961c37
@ -70,8 +70,7 @@ int zmq::dealer_t::xsetsockopt (int option_, const void *optval_,
|
||||
size_t optvallen_)
|
||||
{
|
||||
bool is_int = (optvallen_ == sizeof (int));
|
||||
int value = 0;
|
||||
if (is_int) memcpy(&value, optval_, sizeof (int));
|
||||
int value = is_int? *((int *) optval_): 0;
|
||||
|
||||
switch (option_) {
|
||||
case ZMQ_PROBE_ROUTER:
|
||||
|
@ -92,8 +92,7 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
|
||||
size_t optvallen_)
|
||||
{
|
||||
bool is_int = (optvallen_ == sizeof (int));
|
||||
int value = 0;
|
||||
if (is_int) memcpy(&value, optval_, sizeof (int));
|
||||
int value = is_int? *((int *) optval_): 0;
|
||||
#if defined (ZMQ_ACT_MILITANT)
|
||||
bool malformed = true; // Did caller pass a bad option value?
|
||||
#endif
|
||||
|
@ -204,8 +204,8 @@ bool zmq::req_t::xhas_out ()
|
||||
int zmq::req_t::xsetsockopt (int option_, const void *optval_, size_t optvallen_)
|
||||
{
|
||||
bool is_int = (optvallen_ == sizeof (int));
|
||||
int value = 0;
|
||||
if (is_int) memcpy(&value, optval_, sizeof (int));
|
||||
int value = is_int? *((int *) optval_): 0;
|
||||
|
||||
switch (option_) {
|
||||
case ZMQ_REQ_CORRELATE:
|
||||
if (is_int && value >= 0) {
|
||||
|
@ -97,8 +97,7 @@ int zmq::router_t::xsetsockopt (int option_, const void *optval_,
|
||||
size_t optvallen_)
|
||||
{
|
||||
bool is_int = (optvallen_ == sizeof (int));
|
||||
int value = 0;
|
||||
if (is_int) memcpy(&value, optval_, sizeof (int));
|
||||
int value = is_int? *((int *) optval_): 0;
|
||||
|
||||
switch (option_) {
|
||||
case ZMQ_CONNECT_RID:
|
||||
|
@ -178,8 +178,8 @@ int zmq::stream_t::xsetsockopt (int option_, const void *optval_,
|
||||
size_t optvallen_)
|
||||
{
|
||||
bool is_int = (optvallen_ == sizeof (int));
|
||||
int value = 0;
|
||||
if (is_int) memcpy(&value, optval_, sizeof (int));
|
||||
int value = is_int? *((int *) optval_): 0;
|
||||
|
||||
switch (option_) {
|
||||
case ZMQ_CONNECT_RID:
|
||||
if (optval_ && optvallen_) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user