Navigation Menu

Skip to content

Commit

Permalink
Fixed coverity defects
Browse files Browse the repository at this point in the history
  • Loading branch information
Lihan Guo committed Feb 16, 2011
1 parent e16d329 commit 6e8eee9
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 3 deletions.
3 changes: 3 additions & 0 deletions adaptors/alsadaptor-ascii/alsadaptor-ascii.cpp
Expand Up @@ -12,6 +12,7 @@
@author Matias Muhonen <ext-matias.muhonen@nokia.com>
@author Tapio Rantala <ext-tapio.rantala@nokia.com>
@author Antti Virtanen <antti.i.virtanen@nokia.com>
@author Lihan Guo <ext-lihan.4.guo@nokia.com>
This file is part of Sensord.
Expand All @@ -32,6 +33,7 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <errno.h>
#include <string.h>
#include <QFile>

#include "logging.h"
Expand All @@ -43,6 +45,7 @@

ALSAdaptorAscii::ALSAdaptorAscii(const QString& id) : SysfsAdaptor(id, SysfsAdaptor::IntervalMode)
{
memset(buf, 0x0, 16);
alsBuffer_ = new DeviceAdaptorRingBuffer<TimedUnsigned>(16);
setAdaptedSensor("als", "Internal ambient light sensor lux values", alsBuffer_);
setDescription("Ambient light");
Expand Down
Expand Up @@ -12,6 +12,8 @@
@author Matias Muhonen <ext-matias.muhonen@nokia.com>
@author Tapio Rantala <ext-tapio.rantala@nokia.com>
@author Antti Virtanen <antti.i.virtanen@nokia.com>
@author Lihan Guo <ext-lihan.4.guo@nokia.com>
This file is part of Sensord.
Expand All @@ -30,6 +32,7 @@
*/

#include <errno.h>
#include <string.h>
#include "logging.h"
#include "config.h"
#include "magnetometeradaptor-ascii.h"
Expand All @@ -38,6 +41,7 @@
MagnetometerAdaptorAscii::MagnetometerAdaptorAscii(const QString& id) :
SysfsAdaptor(id, SysfsAdaptor::IntervalMode)
{
memset(buf, ' ', 32);
magnetBuffer_ = new DeviceAdaptorRingBuffer<TimedXyzData>(16);
setAdaptedSensor("magnetometer", "ak8974 ascii", magnetBuffer_);
}
Expand Down
3 changes: 3 additions & 0 deletions adaptors/proximityadaptor-ascii/proximityadaptor-ascii.cpp
Expand Up @@ -12,6 +12,7 @@
@author Matias Muhonen <ext-matias.muhonen@nokia.com>
@author Tapio Rantala <ext-tapio.rantala@nokia.com>
@author Antti Virtanen <antti.i.virtanen@nokia.com>
@author Lihan Guo <ext-lihan.4.guo@nokia.com>
This file is part of Sensord.
Expand All @@ -30,6 +31,7 @@
*/

#include <errno.h>
#include <string.h>
#include "logging.h"
#include "config.h"
#include "proximityadaptor-ascii.h"
Expand All @@ -38,6 +40,7 @@
ProximityAdaptorAscii::ProximityAdaptorAscii(const QString& id) :
SysfsAdaptor(id, SysfsAdaptor::IntervalMode)
{
memset(buf, ' ', 16);
proximityBuffer_ = new DeviceAdaptorRingBuffer<TimedUnsigned>(16);
setAdaptedSensor("proximity", "apds9802ps ascii", proximityBuffer_);
}
Expand Down
8 changes: 6 additions & 2 deletions chains/orientationchain/orientationchain.h
Expand Up @@ -6,6 +6,7 @@
Copyright (C) 2009-2010 Nokia Corporation
@author Ustun Ergenoglu <ext-ustun.ergenoglu@nokia.com>
@author Lihan Guo <ext-lihan.4.guo@nokia.com>
This file is part of Sensord.
Expand Down Expand Up @@ -71,8 +72,11 @@ class OrientationChain : public AbstractChain
TimedUnsigned orientation() const
{
QObject *filter = dynamic_cast<QObject*>(orientationInterpreterFilter_);
PoseData pose = qvariant_cast< PoseData >(filter->property("orientation"));
return TimedUnsigned(pose.timestamp_, pose.orientation_);
if (filter != NULL) {
PoseData pose = qvariant_cast< PoseData >(filter->property("orientation"));
return TimedUnsigned(pose.timestamp_, pose.orientation_);
}
return TimedUnsigned();
}


Expand Down
5 changes: 5 additions & 0 deletions core/inputdevadaptor.cpp
Expand Up @@ -9,6 +9,7 @@
@author Ustun Ergenoglu <ext-ustun.ergenoglu@nokia.com>
@author Matias Muhonen <ext-matias.muhonen@nokia.com>
@author Antti Virtanen <antti.i.virtanen@nokia.com>
@author Lihan Guo <ext-lihan.4.guo@nokia.com>
This file is part of Sensord.
Expand Down Expand Up @@ -48,6 +49,10 @@ InputDevAdaptor::InputDevAdaptor(const QString& id, int maxDeviceCount) :
{
deviceSysPathString_ = Config::configuration()->value("global/device_sys_path").toString();
devicePollFilePath_ = Config::configuration()->value("global/device_poll_file_path").toString();

for (int i = 0; i < 64; i++) {
evlist_[i] = {{0, 0}, 0, 0, 0};
}
}

InputDevAdaptor::~InputDevAdaptor()
Expand Down
3 changes: 3 additions & 0 deletions debian/changelog
@@ -1,5 +1,8 @@
sensord (0.7.0) unstable; urgency=low

[Lihan Guo]
* Fixed coverity defects

[Antti Virtanen]
* Removed possibility of having multiple sensors inside single DeviceAdaptor. This feature was never used.
* DeviceAdaptor::init() added. Subclasses can implement this to initialize themselves.
Expand Down
3 changes: 3 additions & 0 deletions qt-api/abstractsensor_i.cpp
Expand Up @@ -8,6 +8,7 @@
@author Joep van Gassel <joep.van.gassel@nokia.com>
@author Timo Rongas <ext-timo.2.rongas@nokia.com>
@author Antti Virtanen <antti.i.virtanen@nokia.com>
@author Lihan Guo <ext-lihan.4.guo@nokia.com>
This file is part of Sensord.
Expand Down Expand Up @@ -44,6 +45,8 @@ struct AbstractSensorChannelInterface::AbstractSensorChannelInterfaceImpl
};

AbstractSensorChannelInterface::AbstractSensorChannelInterfaceImpl::AbstractSensorChannelInterfaceImpl(QObject* parent, int sessionId) :
errorCode_(SNoError),
errorString_(""),
sessionId_(sessionId),
interval_(0),
bufferInterval_(0),
Expand Down
5 changes: 4 additions & 1 deletion tests/dataflow/dataflowtests.cpp
Expand Up @@ -6,6 +6,7 @@
@author Timo Rongas <ext-timo.2.rongas@nokia.com>
@author Pia Niemela <pia.s.niemela@nokia.com>
@author Lihan Guo <ext-lihan.4.guo@nokia.com>
This file is part of Sensord.
Expand Down Expand Up @@ -85,14 +86,16 @@ void DataFlowTest::testAdaptorSharing()

// Check that A runs, is not running unless sensor is started
SysfsAdaptor* sysfsAdaptorA = dynamic_cast<SysfsAdaptor*>(adaptorA);
QVERIFY(sysfsAdaptorA);
QVERIFY2(sysfsAdaptorA->isRunning(), "AdaptorA is not running after start");

// start B
QVERIFY(adaptorB->startSensor());

// Check that B runs, is not running unless sensor is started

SysfsAdaptor* sysfsAdaptorB = dynamic_cast<SysfsAdaptor*>(adaptorB);
QVERIFY(sysfsAdaptorB);
QVERIFY2(sysfsAdaptorB->isRunning(), "AdaptorB is not running after start");

// Stop B
Expand Down
1 change: 1 addition & 0 deletions tests/filters/filtertests.cpp
Expand Up @@ -495,6 +495,7 @@ void FilterApiTest::testDeclinationFilter()
};

FilterBase* declinationFilter = DeclinationFilter::factoryMethod();
QVERIFY(declinationFilter);
int key = qvariant_cast<int>(dynamic_cast<DeclinationFilter*>(declinationFilter)->property("declinationCorrection"));

// Expected output data
Expand Down

0 comments on commit 6e8eee9

Please sign in to comment.