Commit 27a8961c authored by Pieter Hintjens's avatar Pieter Hintjens

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.
parent c8318912
......@@ -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_) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment