Commit 2da6629e authored by Simon Giesecke's avatar Simon Giesecke

Problem: Magic numbers "1" and "100" in signaler.cpp

Solution: introduced constants, use std::min/std::max instead of control structures
parent a6060674
...@@ -99,11 +99,10 @@ static int sleep_ms (unsigned int ms_) ...@@ -99,11 +99,10 @@ static int sleep_ms (unsigned int ms_)
static int close_wait_ms (int fd_, unsigned int max_ms_ = 2000) static int close_wait_ms (int fd_, unsigned int max_ms_ = 2000)
{ {
unsigned int ms_so_far = 0; unsigned int ms_so_far = 0;
unsigned int step_ms = max_ms_ / 10; const unsigned int min_step_ms = 1;
if (step_ms < 1) const unsigned int max_step_ms = 100;
step_ms = 1; const unsigned int step_ms =
if (step_ms > 100) std::min (std::max (min_step_ms, max_ms_ / 10), max_step_ms);
step_ms = 100;
int rc = 0; // do not sleep on first attempt int rc = 0; // do not sleep on first attempt
do { do {
......
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