Fix google-explicit-constructor warnings in libhardware
Bug: 28341362
Change-Id: I29a56734e54740e4b15fe2f6cacbbd867163ae79
Test: build with clang-tidy
diff --git a/modules/camera/Camera.h b/modules/camera/Camera.h
index 0ceaf25..072de35 100644
--- a/modules/camera/Camera.h
+++ b/modules/camera/Camera.h
@@ -34,7 +34,7 @@
public:
// id is used to distinguish cameras. 0 <= id < NUM_CAMERAS.
// module is a handle to the HAL module, used when the device is opened.
- Camera(int id);
+ explicit Camera(int id);
virtual ~Camera();
// Common Camera Device Operations (see <hardware/camera_common.h>)
diff --git a/modules/camera/CameraHAL.h b/modules/camera/CameraHAL.h
index 00c74e5..74a70a6 100644
--- a/modules/camera/CameraHAL.h
+++ b/modules/camera/CameraHAL.h
@@ -29,7 +29,7 @@
// camera device.
class CameraHAL {
public:
- CameraHAL(int num_cameras);
+ explicit CameraHAL(int num_cameras);
~CameraHAL();
// Camera Module Interface (see <hardware/camera_common.h>)
diff --git a/modules/camera/ExampleCamera.h b/modules/camera/ExampleCamera.h
index 45c4a94..44eac76 100644
--- a/modules/camera/ExampleCamera.h
+++ b/modules/camera/ExampleCamera.h
@@ -27,7 +27,7 @@
// metadata and logic about that device.
class ExampleCamera : public Camera {
public:
- ExampleCamera(int id);
+ explicit ExampleCamera(int id);
~ExampleCamera();
private:
diff --git a/modules/gralloc/gr.h b/modules/gralloc/gr.h
index 732b6bc..ac7e967 100644
--- a/modules/gralloc/gr.h
+++ b/modules/gralloc/gr.h
@@ -48,7 +48,7 @@
class Autolock {
Locker& locker;
public:
- inline Autolock(Locker& locker) : locker(locker) { locker.lock(); }
+ inline explicit Autolock(Locker& locker) : locker(locker) { locker.lock(); }
inline ~Autolock() { locker.unlock(); }
};
inline Locker() { pthread_mutex_init(&mutex, 0); }
diff --git a/modules/sensors/SensorEventQueue.h b/modules/sensors/SensorEventQueue.h
index 11e1f41..9778e93 100644
--- a/modules/sensors/SensorEventQueue.h
+++ b/modules/sensors/SensorEventQueue.h
@@ -38,7 +38,7 @@
pthread_cond_t mSpaceAvailableCondition;
public:
- SensorEventQueue(int capacity);
+ explicit SensorEventQueue(int capacity);
~SensorEventQueue();
// Returns length of region, between zero and min(capacity, requestedLength). If there is any
diff --git a/modules/usbcamera/Camera.h b/modules/usbcamera/Camera.h
index 6419c7d..4051345 100644
--- a/modules/usbcamera/Camera.h
+++ b/modules/usbcamera/Camera.h
@@ -38,7 +38,7 @@
public:
// id is used to distinguish cameras. 0 <= id < NUM_CAMERAS.
// module is a handle to the HAL module, used when the device is opened.
- Camera(int id);
+ explicit Camera(int id);
virtual ~Camera();
// Common Camera Device Operations (see <hardware/camera_common.h>)
diff --git a/modules/usbcamera/HotplugThread.h b/modules/usbcamera/HotplugThread.h
index a13adb7..625dcb4 100644
--- a/modules/usbcamera/HotplugThread.h
+++ b/modules/usbcamera/HotplugThread.h
@@ -36,7 +36,7 @@
class HotplugThread : public android::Thread {
public:
- HotplugThread(CameraHAL *hal);
+ explicit HotplugThread(CameraHAL *hal);
~HotplugThread();
// Override below two methods for proper cleanup.
diff --git a/modules/usbcamera/UsbCamera.h b/modules/usbcamera/UsbCamera.h
index fe52ade..57017fe 100644
--- a/modules/usbcamera/UsbCamera.h
+++ b/modules/usbcamera/UsbCamera.h
@@ -28,7 +28,7 @@
*/
class UsbCamera : public Camera {
public:
- UsbCamera(int id);
+ explicit UsbCamera(int id);
~UsbCamera();
private:
diff --git a/tests/camera2/CameraModuleFixture.h b/tests/camera2/CameraModuleFixture.h
index 3a2df69..102fa6d 100644
--- a/tests/camera2/CameraModuleFixture.h
+++ b/tests/camera2/CameraModuleFixture.h
@@ -36,7 +36,7 @@
template <bool InfoQuirk = false>
struct CameraModuleFixture {
- CameraModuleFixture(int CameraID = -1) {
+ explicit CameraModuleFixture(int CameraID = -1) {
TEST_EXTENSION_FORKING_CONSTRUCTOR;
mCameraID = CameraID;
diff --git a/tests/camera2/CameraStreamFixture.h b/tests/camera2/CameraStreamFixture.h
index bf7fb42..92ff05b 100644
--- a/tests/camera2/CameraStreamFixture.h
+++ b/tests/camera2/CameraStreamFixture.h
@@ -71,7 +71,7 @@
: public CameraModuleFixture</*InfoQuirk*/true> {
public:
- CameraStreamFixture(CameraStreamParams p)
+ explicit CameraStreamFixture(CameraStreamParams p)
: CameraModuleFixture(TestSettings::DeviceId()) {
TEST_EXTENSION_FORKING_CONSTRUCTOR;
diff --git a/tests/camera2/camera2_utils.h b/tests/camera2/camera2_utils.h
index ab1fcfb..a01bae2 100644
--- a/tests/camera2/camera2_utils.h
+++ b/tests/camera2/camera2_utils.h
@@ -166,7 +166,7 @@
*/
class StreamAdapter: public camera2_stream_ops {
public:
- StreamAdapter(sp<IGraphicBufferProducer> consumer);
+ explicit StreamAdapter(sp<IGraphicBufferProducer> consumer);
~StreamAdapter();
diff --git a/tests/input/evdev/TestHelpers.h b/tests/input/evdev/TestHelpers.h
index 461db04..d26adfb 100644
--- a/tests/input/evdev/TestHelpers.h
+++ b/tests/input/evdev/TestHelpers.h
@@ -42,7 +42,7 @@
*/
class TempFile {
public:
- TempFile(const char* path);
+ explicit TempFile(const char* path);
~TempFile();
// No copy or assign