fix: static_cast clamp

pull/471/head
Alex 2019-09-19 22:07:38 +01:00
parent 52db1e8e68
commit bae83ee4e3
1 changed files with 3 additions and 2 deletions

View File

@ -717,8 +717,9 @@ void waybar::modules::Network::parseSignal(struct nlattr **bss) {
// WiFi-hardware usually operates in the range -90 to -20dBm. // WiFi-hardware usually operates in the range -90 to -20dBm.
const int hardwareMax = -20; const int hardwareMax = -20;
const int hardwareMin = -90; const int hardwareMin = -90;
signal_strength_ = const int strength =
std::clamp(((signal_strength_dbm_ - hardwareMin) / double{hardwareMax - hardwareMin}) * 100, 0, 100); ((signal_strength_dbm_ - hardwareMin) / double{hardwareMax - hardwareMin}) * 100;
signal_strength_ = std::clamp(strength, 0, 100);
} }
if (bss[NL80211_BSS_SIGNAL_UNSPEC] != nullptr) { if (bss[NL80211_BSS_SIGNAL_UNSPEC] != nullptr) {
signal_strength_ = nla_get_u8(bss[NL80211_BSS_SIGNAL_UNSPEC]); signal_strength_ = nla_get_u8(bss[NL80211_BSS_SIGNAL_UNSPEC]);