0
0
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:
Pieter Hintjens 2016-02-06 13:32:23 +01:00
parent c8318912f5
commit 27a8961c37
5 changed files with 7 additions and 10 deletions

View File

@ -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:

View File

@ -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

View File

@ -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) {

View File

@ -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:

View File

@ -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_) {