Skip to content

Store zmq_timers_timeout() result in long, not int#681

Merged
gummif merged 1 commit intozeromq:masterfrom
alt-graph:zmq_timers_timeout_conversion_warning
Mar 13, 2026
Merged

Store zmq_timers_timeout() result in long, not int#681
gummif merged 1 commit intozeromq:masterfrom
alt-graph:zmq_timers_timeout_conversion_warning

Conversation

@alt-graph
Copy link
Contributor

[why]

When compiling with -Wconversion, gcc 13.3 issues a warning:

zmq.hpp: In member function ‘zmq::timers::timeout_result_t zmq::timers::timeout() const’: zmq.hpp:2857:41: warning: conversion from ‘long int’ to ‘int’ may change value [-Wconversion]
 2857 |         int timeout = zmq_timers_timeout(_timers);
      |                       ~~~~~~~~~~~~~~~~~~^~~~~~~~~

zmq_timers_timeout() returns long, but its return value is stored in an int variable, which may or may not be a mismatch depending on compiler and architecture.

[how]

Simply adjust the type of the variable from int to long. We could also change the literal in the following comparison from -1 to -1L, but that seems pedantic and does not match the style of the surrounding code.

[why]
When compiling with -Wconversion, gcc 13.3 issues a warning:

zmq.hpp: In member function ‘zmq::timers::timeout_result_t zmq::timers::timeout() const’:
zmq.hpp:2857:41: warning: conversion from ‘long int’ to ‘int’ may change value [-Wconversion]
 2857 |         int timeout = zmq_timers_timeout(_timers);
      |                       ~~~~~~~~~~~~~~~~~~^~~~~~~~~

zmq_timers_timeout() returns long, but its return value is stored in an
int variable, which may or may not be a mismatch depending on compiler
and architecture.

[how]
Simply adjust the type of the variable from int to long. We could also
change the literal in the following comparison from -1 to -1L, but that
seems pedantic and does not match the style of the surrounding code.

Signed-off-by: Lars Froehlich <lars.froehlich@desy.de>
@coveralls
Copy link

Pull Request Test Coverage Report for Build 23043522058

Details

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 87.896%

Totals Coverage Status
Change from base Build 22894157574: 0.0%
Covered Lines: 944
Relevant Lines: 1074

💛 - Coveralls

@gummif gummif merged commit 6a8dc38 into zeromq:master Mar 13, 2026
11 checks passed
@gummif
Copy link
Member

gummif commented Mar 13, 2026

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants