diff options
author | Jose A Ortega Ruiz <jao@gnu.org> | 2010-02-22 15:42:26 +0100 |
---|---|---|
committer | Jose A Ortega Ruiz <jao@gnu.org> | 2010-02-22 15:42:26 +0100 |
commit | 32dc866c396c262d3781e03bdfd1acd2b4a151ee (patch) | |
tree | bc6edd435e0e93d94c76c5849b50e56575bb6bb7 /IWlib.hsc | |
parent | fd7de94c92b5d094bd244a06f8b330237ed7e99d (diff) | |
download | xmobar-32dc866c396c262d3781e03bdfd1acd2b4a151ee.tar.gz xmobar-32dc866c396c262d3781e03bdfd1acd2b4a151ee.tar.bz2 |
Wireless monitor: better boundary checks
Ignore-this: cfb69e10b2eaff6924a2df32b1e51bf0
darcs-hash:20100222144226-748be-f28cbe827c89238074448b23da7ba606f930ceb9.gz
Diffstat (limited to 'IWlib.hsc')
-rw-r--r-- | IWlib.hsc | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -69,7 +69,8 @@ getWirelessInfo iface = qualv <- (#peek struct iw_param, value) qual :: IO CInt let qualm = (#ptr struct iw_range, max_qual) rng mv <- (#peek struct iw_param, value) qualm :: IO CInt - return $ fromIntegral qualv / fromIntegral (max 1 mv) + let mxv = if mv > 0 then fromIntegral mv else 1 + return $ fromIntegral qualv / mxv else return (-1) let qv = round (100 * (q :: Double)) - return $ WirelessInfo { wiEssid = essid, wiQuality = qv } + return $ WirelessInfo { wiEssid = essid, wiQuality = min 100 qv } |