Fix google-explicit-constructor warnings in sensorservice.
* Add explicit keyword to conversion constructors,
or use NOLINT for implicit converters.
Bug: 28341362
Test: build with WITH_TIDY=1
Change-Id: Ie7c4dfcdbd069809e103f0dd008ae2fb4b0502f4
diff --git a/services/sensorservice/RecentEventLogger.h b/services/sensorservice/RecentEventLogger.h
index 4f9bc4a..973a247 100644
--- a/services/sensorservice/RecentEventLogger.h
+++ b/services/sensorservice/RecentEventLogger.h
@@ -35,7 +35,7 @@
// behavior.
class RecentEventLogger : public Dumpable {
public:
- RecentEventLogger(int sensorType);
+ explicit RecentEventLogger(int sensorType);
void addEvent(const sensors_event_t& event);
bool populateLastEvent(sensors_event_t *event) const;
bool isEmpty() const;
@@ -46,7 +46,7 @@
protected:
struct SensorEventLog {
- SensorEventLog(const sensors_event_t& e);
+ explicit SensorEventLog(const sensors_event_t& e);
timespec mWallTime;
sensors_event_t mEvent;
};
diff --git a/services/sensorservice/RingBuffer.h b/services/sensorservice/RingBuffer.h
index ec98a01..a60eb90 100644
--- a/services/sensorservice/RingBuffer.h
+++ b/services/sensorservice/RingBuffer.h
@@ -39,7 +39,7 @@
/**
* Construct a RingBuffer that can grow up to the given length.
*/
- RingBuffer(size_t length);
+ explicit RingBuffer(size_t length);
/**
* Forward iterator to this class. Implements an std:forward_iterator.
diff --git a/services/sensorservice/RotationVectorSensor.h b/services/sensorservice/RotationVectorSensor.h
index 3cc2248..265b4c4 100644
--- a/services/sensorservice/RotationVectorSensor.h
+++ b/services/sensorservice/RotationVectorSensor.h
@@ -34,7 +34,7 @@
class RotationVectorSensor : public VirtualSensor {
public:
- RotationVectorSensor(int mode = FUSION_9AXIS);
+ explicit RotationVectorSensor(int mode = FUSION_9AXIS);
virtual bool process(sensors_event_t* outEvent, const sensors_event_t& event) override;
virtual status_t activate(void* ident, bool enabled) override;
virtual status_t setDelay(void* ident, int handle, int64_t ns) override;
diff --git a/services/sensorservice/SensorEventAckReceiver.h b/services/sensorservice/SensorEventAckReceiver.h
index 998597a..20fa4c7 100644
--- a/services/sensorservice/SensorEventAckReceiver.h
+++ b/services/sensorservice/SensorEventAckReceiver.h
@@ -27,7 +27,7 @@
sp<SensorService> const mService;
public:
virtual bool threadLoop();
- SensorEventAckReceiver(const sp<SensorService>& service)
+ explicit SensorEventAckReceiver(const sp<SensorService>& service)
: mService(service) {
}
};
diff --git a/services/sensorservice/SensorInterface.h b/services/sensorservice/SensorInterface.h
index dafcf2d..0867dc2 100644
--- a/services/sensorservice/SensorInterface.h
+++ b/services/sensorservice/SensorInterface.h
@@ -47,7 +47,7 @@
class BaseSensor : public SensorInterface {
public:
- BaseSensor(const sensor_t& sensor);
+ explicit BaseSensor(const sensor_t& sensor);
BaseSensor(const sensor_t& sensor, const uint8_t (&uuid)[16]);
// Not all sensors need to support batching.
@@ -74,7 +74,7 @@
class HardwareSensor : public BaseSensor {
public:
- HardwareSensor(const sensor_t& sensor);
+ explicit HardwareSensor(const sensor_t& sensor);
HardwareSensor(const sensor_t& sensor, const uint8_t (&uuid)[16]);
virtual ~HardwareSensor();
diff --git a/services/sensorservice/mat.h b/services/sensorservice/mat.h
index a76fc91..495c14e 100644
--- a/services/sensorservice/mat.h
+++ b/services/sensorservice/mat.h
@@ -139,13 +139,13 @@
mat() { }
mat(const mat& rhs) : base(rhs) { }
- mat(const base& rhs) : base(rhs) { }
+ mat(const base& rhs) : base(rhs) { } // NOLINT(implicit)
// -----------------------------------------------------------------------
// conversion constructors
// sets the diagonal to the value, off-diagonal to zero
- mat(pTYPE rhs) {
+ mat(pTYPE rhs) { // NOLINT(implicit)
helpers::doAssign(*this, rhs);
}
@@ -220,7 +220,7 @@
template<size_t PREV_COLUMN>
struct column_builder {
mat& matrix;
- column_builder(mat& matrix) : matrix(matrix) { }
+ explicit column_builder(mat& matrix) : matrix(matrix) { }
};
// operator << is not a method of column_builder<> so we can
@@ -265,9 +265,9 @@
enum { ROWS = R, COLS = 1 };
mat() { }
- mat(const base& rhs) : base(rhs) { }
+ explicit mat(const base& rhs) : base(rhs) { }
mat(const mat& rhs) : base(rhs) { }
- mat(const TYPE& rhs) { helpers::doAssign(*this, rhs); }
+ explicit mat(const TYPE& rhs) { helpers::doAssign(*this, rhs); }
mat& operator=(const mat& rhs) { base::operator=(rhs); return *this; }
mat& operator=(const base& rhs) { base::operator=(rhs); return *this; }
mat& operator=(const TYPE& rhs) { return helpers::doAssign(*this, rhs); }
diff --git a/services/sensorservice/vec.h b/services/sensorservice/vec.h
index a142bad..9e5d280 100644
--- a/services/sensorservice/vec.h
+++ b/services/sensorservice/vec.h
@@ -322,12 +322,12 @@
vec() { }
vec(const vec& rhs) : base(rhs) { }
- vec(const base& rhs) : base(rhs) { }
+ vec(const base& rhs) : base(rhs) { } // NOLINT(implicit)
// -----------------------------------------------------------------------
// conversion constructors
- vec(pTYPE rhs) {
+ vec(pTYPE rhs) { // NOLINT(implicit)
for (size_t i=0 ; i<SIZE ; i++)
base::operator[](i) = rhs;
}