From d2f24411b28eb5fe3a9d83243247156237409d37 Mon Sep 17 00:00:00 2001 From: Thomas McGuire Date: Thu, 23 Aug 2012 15:15:48 +0200 Subject: Blackberry: Fix potential division by zero. Some users reported a division by zero problem when connecting to the backend, I suspect this is the reason for it. The sensor service seems to report either the min or the max delay as zero. Change-Id: I8b7e8f7c3243d7016c0c4472713c4c116471015d Reviewed-by: Tobias Koenig Reviewed-by: Kevin Ottens Reviewed-by: Adam Parco Reviewed-by: Lorn Potter --- src/plugins/sensors/blackberry/bbsensorbackend.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/plugins/sensors/blackberry') diff --git a/src/plugins/sensors/blackberry/bbsensorbackend.cpp b/src/plugins/sensors/blackberry/bbsensorbackend.cpp index 1b880a0e..77570655 100644 --- a/src/plugins/sensors/blackberry/bbsensorbackend.cpp +++ b/src/plugins/sensors/blackberry/bbsensorbackend.cpp @@ -125,9 +125,11 @@ void BbSensorBackendBase::initSensorInfo() convertValue(deviceInfo.rx.info.resolution)); } - // Min and max intentionally swapped here, as the minimum delay is the maximum rate - addDataRate(microSecondsToHertz(deviceInfo.rx.info.delay_max), - microSecondsToHertz(deviceInfo.rx.info.delay_min)); + if (deviceInfo.rx.info.delay_max > 0 && deviceInfo.rx.info.delay_min > 0) { + // Min and max intentionally swapped here, as the minimum delay is the maximum rate + addDataRate(microSecondsToHertz(deviceInfo.rx.info.delay_max), + microSecondsToHertz(deviceInfo.rx.info.delay_min)); + } } additionalDeviceInit(); m_deviceFile.close(); -- cgit v1.2.3