diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2016-01-29 09:59:57 +0100 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2016-01-29 20:18:22 +0100 |
commit | 503b714f15dd7c9369ed13dfb324739a386ceb03 (patch) | |
tree | b656f10beb7c97c16d280a75f7673caf41705b1e /src | |
parent | 9b8517984018434b12cd6bd390b3659529db28fc (diff) | |
download | NetworkManager-503b714f15dd7c9369ed13dfb324739a386ceb03.tar.gz |
wext: avoid division by zero
Coverity is angry:
CID 59367 (#1-3 of 3): Division or modulo by float zero (DIVIDE_BY_ZERO)
30. divide_by_zero: In expression
((double)max_level - (double)level) /
((double)max_level - (double)noise),
division by expression (double)max_level - (double)noise which may be zero has
undefined behavior.
Diffstat (limited to 'src')
-rw-r--r-- | src/platform/wifi/wifi-utils-wext.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/platform/wifi/wifi-utils-wext.c b/src/platform/wifi/wifi-utils-wext.c index 96bcf53d26..85a387fae2 100644 --- a/src/platform/wifi/wifi-utils-wext.c +++ b/src/platform/wifi/wifi-utils-wext.c @@ -315,7 +315,7 @@ wext_qual_to_percent (const struct iw_quality *qual, noise = qual->noise - 0x100; else if ((max_qual->noise > 0) && !(max_qual->updated & IW_QUAL_NOISE_INVALID)) noise = max_qual->noise - 0x100; - noise = CLAMP (noise, FALLBACK_NOISE_FLOOR_DBM, FALLBACK_SIGNAL_MAX_DBM); + noise = CLAMP (noise, FALLBACK_NOISE_FLOOR_DBM, FALLBACK_SIGNAL_MAX_DBM - 1); /* A sort of signal-to-noise ratio calculation */ level_percent = (int) (100 - 70 * (((double)max_level - (double)level) / |