diff options
author | 2018-12-20 15:42:22 -0800 | |
---|---|---|
committer | 2019-01-02 02:38:49 +0000 | |
commit | 5ca1ea4680e2a7f4dd84e14c5a125d3413a77f64 (patch) | |
tree | e33d89edbdc2a7ed49919a8949ff5212e2299d6a | |
parent | 732dd44f5f2264a09859b97b0ca0b9abac328886 (diff) |
Fix/suppress binder google-explicit-constructor warnings
* Add explicit to conversion constructors/operators
* Use NOLINT or NOLINTNEXTLINE to suppress warnings on intended converters
* Remove redundant explicit of copy constructors
Bug: 28341362
Test: make with WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=-*,google-explicit-constructor
Change-Id: If74d738496c5787c0ec68ff808801c7ff44cf03f
-rw-r--r-- | libs/binder/Value.cpp | 2 | ||||
-rw-r--r-- | libs/binder/include/binder/BufferedTextOutput.h | 2 | ||||
-rw-r--r-- | libs/binder/include/binder/IpPrefix.h | 4 | ||||
-rw-r--r-- | libs/binder/include/binder/MemoryDealer.h | 2 | ||||
-rw-r--r-- | libs/binder/include/binder/MemoryHeapBase.h | 4 | ||||
-rw-r--r-- | libs/binder/include/binder/ParcelFileDescriptor.h | 2 | ||||
-rw-r--r-- | libs/binder/include/binder/ProcessState.h | 2 | ||||
-rw-r--r-- | libs/binder/include/binder/TextOutput.h | 4 | ||||
-rw-r--r-- | libs/binder/include/binder/Value.h | 32 | ||||
-rw-r--r-- | libs/binder/ndk/ibinder_internal.h | 6 | ||||
-rw-r--r-- | libs/binder/ndk/include_ndk/android/binder_auto_utils.h | 2 | ||||
-rw-r--r-- | libs/binder/ndk/include_ndk/android/binder_interface_utils.h | 2 | ||||
-rw-r--r-- | libs/binder/ndk/parcel_internal.h | 3 | ||||
-rw-r--r-- | libs/binder/ndk/status_internal.h | 2 | ||||
-rw-r--r-- | libs/binder/ndk/test/iface.cpp | 2 | ||||
-rw-r--r-- | libs/binder/tests/binderLibTest.cpp | 4 | ||||
-rw-r--r-- | libs/binder/tests/schd-dbg.cpp | 2 |
17 files changed, 39 insertions, 38 deletions
diff --git a/libs/binder/Value.cpp b/libs/binder/Value.cpp index a28a618939..19c57ba128 100644 --- a/libs/binder/Value.cpp +++ b/libs/binder/Value.cpp @@ -97,7 +97,7 @@ public: template<typename T> class Value::Content : public Value::ContentBase { public: Content() = default; - Content(const T & value) : mValue(value) { } + explicit Content(const T & value) : mValue(value) { } virtual ~Content() = default; diff --git a/libs/binder/include/binder/BufferedTextOutput.h b/libs/binder/include/binder/BufferedTextOutput.h index 9a7c43bb13..feae93dea1 100644 --- a/libs/binder/include/binder/BufferedTextOutput.h +++ b/libs/binder/include/binder/BufferedTextOutput.h @@ -32,7 +32,7 @@ public: MULTITHREADED = 0x0001 }; - BufferedTextOutput(uint32_t flags = 0); + explicit BufferedTextOutput(uint32_t flags = 0); virtual ~BufferedTextOutput(); virtual status_t print(const char* txt, size_t len); diff --git a/libs/binder/include/binder/IpPrefix.h b/libs/binder/include/binder/IpPrefix.h index dd5bc3aafd..c7e7a508fa 100644 --- a/libs/binder/include/binder/IpPrefix.h +++ b/libs/binder/include/binder/IpPrefix.h @@ -74,8 +74,8 @@ public: private: union InternalUnion { InternalUnion() = default; - InternalUnion(const struct in6_addr &addr):mIn6Addr(addr) { }; - InternalUnion(const struct in_addr &addr):mInAddr(addr) { }; + explicit InternalUnion(const struct in6_addr &addr):mIn6Addr(addr) { }; + explicit InternalUnion(const struct in_addr &addr):mInAddr(addr) { }; struct in6_addr mIn6Addr; struct in_addr mInAddr; } mUnion; diff --git a/libs/binder/include/binder/MemoryDealer.h b/libs/binder/include/binder/MemoryDealer.h index fe5a31d5a6..b483be0fd5 100644 --- a/libs/binder/include/binder/MemoryDealer.h +++ b/libs/binder/include/binder/MemoryDealer.h @@ -34,7 +34,7 @@ class SimpleBestFitAllocator; class MemoryDealer : public RefBase { public: - MemoryDealer(size_t size, const char* name = nullptr, + explicit MemoryDealer(size_t size, const char* name = nullptr, uint32_t flags = 0 /* or bits such as MemoryHeapBase::READ_ONLY */ ); virtual sp<IMemory> allocate(size_t size); diff --git a/libs/binder/include/binder/MemoryHeapBase.h b/libs/binder/include/binder/MemoryHeapBase.h index 5e0a382a7e..4be20a0dbd 100644 --- a/libs/binder/include/binder/MemoryHeapBase.h +++ b/libs/binder/include/binder/MemoryHeapBase.h @@ -47,12 +47,12 @@ public: /* * maps memory from the given device */ - MemoryHeapBase(const char* device, size_t size = 0, uint32_t flags = 0); + explicit MemoryHeapBase(const char* device, size_t size = 0, uint32_t flags = 0); /* * maps memory from ashmem, with the given name for debugging */ - MemoryHeapBase(size_t size, uint32_t flags = 0, char const* name = nullptr); + explicit MemoryHeapBase(size_t size, uint32_t flags = 0, char const* name = nullptr); virtual ~MemoryHeapBase(); diff --git a/libs/binder/include/binder/ParcelFileDescriptor.h b/libs/binder/include/binder/ParcelFileDescriptor.h index ad950affc5..662e56e864 100644 --- a/libs/binder/include/binder/ParcelFileDescriptor.h +++ b/libs/binder/include/binder/ParcelFileDescriptor.h @@ -31,7 +31,7 @@ class ParcelFileDescriptor : public android::Parcelable { public: ParcelFileDescriptor(); explicit ParcelFileDescriptor(android::base::unique_fd fd); - explicit ParcelFileDescriptor(ParcelFileDescriptor&& other) : mFd(std::move(other.mFd)) { } + ParcelFileDescriptor(ParcelFileDescriptor&& other) : mFd(std::move(other.mFd)) { } ~ParcelFileDescriptor() override; int get() const { return mFd.get(); } diff --git a/libs/binder/include/binder/ProcessState.h b/libs/binder/include/binder/ProcessState.h index 13f67baee1..3712c84a58 100644 --- a/libs/binder/include/binder/ProcessState.h +++ b/libs/binder/include/binder/ProcessState.h @@ -80,7 +80,7 @@ public: private: friend class IPCThreadState; - ProcessState(const char* driver); + explicit ProcessState(const char* driver); ~ProcessState(); ProcessState(const ProcessState& o); diff --git a/libs/binder/include/binder/TextOutput.h b/libs/binder/include/binder/TextOutput.h index 851e01f4b8..5b5f76688b 100644 --- a/libs/binder/include/binder/TextOutput.h +++ b/libs/binder/include/binder/TextOutput.h @@ -38,7 +38,7 @@ public: class Bundle { public: - inline Bundle(TextOutput& to) : mTO(to) { to.pushBundle(); } + inline explicit Bundle(TextOutput& to) : mTO(to) { to.pushBundle(); } inline ~Bundle() { mTO.popBundle(); } private: TextOutput& mTO; @@ -80,7 +80,7 @@ TextOutput& operator<<(TextOutput& to, TextOutputManipFunc func); class TypeCode { public: - inline TypeCode(uint32_t code); + inline explicit TypeCode(uint32_t code); inline ~TypeCode(); inline uint32_t typeCode() const; diff --git a/libs/binder/include/binder/Value.h b/libs/binder/include/binder/Value.h index 4dee3d86b0..735f40eb1f 100644 --- a/libs/binder/include/binder/Value.h +++ b/libs/binder/include/binder/Value.h @@ -74,20 +74,20 @@ public: bool operator!=(const Value& rhs) const { return !this->operator==(rhs); } Value(const Value& value); - Value(const bool& value); - Value(const int8_t& value); - Value(const int32_t& value); - Value(const int64_t& value); - Value(const double& value); - Value(const String16& value); - Value(const std::vector<bool>& value); - Value(const std::vector<uint8_t>& value); - Value(const std::vector<int32_t>& value); - Value(const std::vector<int64_t>& value); - Value(const std::vector<double>& value); - Value(const std::vector<String16>& value); - Value(const os::PersistableBundle& value); - Value(const binder::Map& value); + Value(const bool& value); // NOLINT(google-explicit-constructor) + Value(const int8_t& value); // NOLINT(google-explicit-constructor) + Value(const int32_t& value); // NOLINT(google-explicit-constructor) + Value(const int64_t& value); // NOLINT(google-explicit-constructor) + Value(const double& value); // NOLINT(google-explicit-constructor) + Value(const String16& value); // NOLINT(google-explicit-constructor) + Value(const std::vector<bool>& value); // NOLINT(google-explicit-constructor) + Value(const std::vector<uint8_t>& value); // NOLINT(google-explicit-constructor) + Value(const std::vector<int32_t>& value); // NOLINT(google-explicit-constructor) + Value(const std::vector<int64_t>& value); // NOLINT(google-explicit-constructor) + Value(const std::vector<double>& value); // NOLINT(google-explicit-constructor) + Value(const std::vector<String16>& value); // NOLINT(google-explicit-constructor) + Value(const os::PersistableBundle& value); // NOLINT(google-explicit-constructor) + Value(const binder::Map& value); // NOLINT(google-explicit-constructor) Value& operator=(const Value& rhs); Value& operator=(const int8_t& rhs); @@ -153,8 +153,8 @@ public: // String Convenience Adapters // --------------------------- - Value(const String8& value): Value(String16(value)) { } - Value(const ::std::string& value): Value(String8(value.c_str())) { } + explicit Value(const String8& value): Value(String16(value)) { } + explicit Value(const ::std::string& value): Value(String8(value.c_str())) { } void putString(const String8& value) { return putString(String16(value)); } void putString(const ::std::string& value) { return putString(String8(value.c_str())); } Value& operator=(const String8& rhs) { return *this = String16(rhs); } diff --git a/libs/binder/ndk/ibinder_internal.h b/libs/binder/ndk/ibinder_internal.h index ac592ea4f7..7852298ef9 100644 --- a/libs/binder/ndk/ibinder_internal.h +++ b/libs/binder/ndk/ibinder_internal.h @@ -34,7 +34,7 @@ struct ABBinder; struct ABpBinder; struct AIBinder : public virtual ::android::RefBase { - AIBinder(const AIBinder_Class* clazz); + explicit AIBinder(const AIBinder_Class* clazz); virtual ~AIBinder(); bool associateClass(const AIBinder_Class* clazz); @@ -97,7 +97,7 @@ struct ABpBinder : public AIBinder, public ::android::BpRefBase { ABpBinder* asABpBinder() override { return this; } private: - ABpBinder(const ::android::sp<::android::IBinder>& binder); + explicit ABpBinder(const ::android::sp<::android::IBinder>& binder); }; struct AIBinder_Class { @@ -141,7 +141,7 @@ struct AIBinder_DeathRecipient { const AIBinder_DeathRecipient_onBinderDied& mOnDied; }; - AIBinder_DeathRecipient(AIBinder_DeathRecipient_onBinderDied onDied); + explicit AIBinder_DeathRecipient(AIBinder_DeathRecipient_onBinderDied onDied); binder_status_t linkToDeath(AIBinder* binder, void* cookie); binder_status_t unlinkToDeath(AIBinder* binder, void* cookie); diff --git a/libs/binder/ndk/include_ndk/android/binder_auto_utils.h b/libs/binder/ndk/include_ndk/android/binder_auto_utils.h index ff1860e364..80773f36be 100644 --- a/libs/binder/ndk/include_ndk/android/binder_auto_utils.h +++ b/libs/binder/ndk/include_ndk/android/binder_auto_utils.h @@ -51,7 +51,7 @@ class SpAIBinder { * Convenience operator for implicitly constructing an SpAIBinder from nullptr. This is not * explicit because it is not taking ownership of anything. */ - SpAIBinder(std::nullptr_t) : SpAIBinder() {} + SpAIBinder(std::nullptr_t) : SpAIBinder() {} // NOLINT(google-explicit-constructor) /** * This will delete the underlying object if it exists. See operator=. diff --git a/libs/binder/ndk/include_ndk/android/binder_interface_utils.h b/libs/binder/ndk/include_ndk/android/binder_interface_utils.h index 153272572f..a42c60b5b2 100644 --- a/libs/binder/ndk/include_ndk/android/binder_interface_utils.h +++ b/libs/binder/ndk/include_ndk/android/binder_interface_utils.h @@ -137,7 +137,7 @@ class BnCInterface : public INTERFACE { template <typename INTERFACE> class BpCInterface : public INTERFACE { public: - BpCInterface(const SpAIBinder& binder) : mBinder(binder) {} + explicit BpCInterface(const SpAIBinder& binder) : mBinder(binder) {} virtual ~BpCInterface() {} SpAIBinder asBinder() override; diff --git a/libs/binder/ndk/parcel_internal.h b/libs/binder/ndk/parcel_internal.h index f29230905a..6b7295e4b9 100644 --- a/libs/binder/ndk/parcel_internal.h +++ b/libs/binder/ndk/parcel_internal.h @@ -27,7 +27,8 @@ struct AParcel { const ::android::Parcel* get() const { return mParcel; } ::android::Parcel* get() { return mParcel; } - AParcel(const AIBinder* binder) : AParcel(binder, new ::android::Parcel, true /*owns*/) {} + explicit AParcel(const AIBinder* binder) + : AParcel(binder, new ::android::Parcel, true /*owns*/) {} AParcel(const AIBinder* binder, ::android::Parcel* parcel, bool owns) : mBinder(binder), mParcel(parcel), mOwns(owns) {} diff --git a/libs/binder/ndk/status_internal.h b/libs/binder/ndk/status_internal.h index d39f0d887c..f6227f7d4c 100644 --- a/libs/binder/ndk/status_internal.h +++ b/libs/binder/ndk/status_internal.h @@ -23,7 +23,7 @@ struct AStatus { AStatus() {} // ok - AStatus(::android::binder::Status&& status) : mStatus(std::move(status)) {} + explicit AStatus(::android::binder::Status&& status) : mStatus(std::move(status)) {} ::android::binder::Status* get() { return &mStatus; } const ::android::binder::Status* get() const { return &mStatus; } diff --git a/libs/binder/ndk/test/iface.cpp b/libs/binder/ndk/test/iface.cpp index 6ef964e896..64832f3081 100644 --- a/libs/binder/ndk/test/iface.cpp +++ b/libs/binder/ndk/test/iface.cpp @@ -74,7 +74,7 @@ AIBinder_Class* IFoo::kClass = AIBinder_Class_define(kIFooDescriptor, IFoo_Class class BpFoo : public IFoo { public: - BpFoo(AIBinder* binder) : mBinder(binder) {} + explicit BpFoo(AIBinder* binder) : mBinder(binder) {} virtual ~BpFoo() { AIBinder_decStrong(mBinder); } virtual binder_status_t doubleNumber(int32_t in, int32_t* out) { diff --git a/libs/binder/tests/binderLibTest.cpp b/libs/binder/tests/binderLibTest.cpp index 2dd86ba7e1..99a71bd662 100644 --- a/libs/binder/tests/binderLibTest.cpp +++ b/libs/binder/tests/binderLibTest.cpp @@ -230,7 +230,7 @@ class BinderLibTestBundle : public Parcel { public: BinderLibTestBundle(void) {} - BinderLibTestBundle(const Parcel *source) : m_isValid(false) { + explicit BinderLibTestBundle(const Parcel *source) : m_isValid(false) { int32_t mark; int32_t bundleLen; size_t pos; @@ -941,7 +941,7 @@ TEST_F(BinderLibTest, OnewayQueueing) class BinderLibTestService : public BBinder { public: - BinderLibTestService(int32_t id) + explicit BinderLibTestService(int32_t id) : m_id(id) , m_nextServerId(id + 1) , m_serverStartRequested(false) diff --git a/libs/binder/tests/schd-dbg.cpp b/libs/binder/tests/schd-dbg.cpp index 6cf7f36021..ec9534abac 100644 --- a/libs/binder/tests/schd-dbg.cpp +++ b/libs/binder/tests/schd-dbg.cpp @@ -218,7 +218,7 @@ struct Results { uint64_t m_total_time = 0; uint64_t m_miss = 0; bool tracing; - Results(bool _tracing) : tracing(_tracing) { + explicit Results(bool _tracing) : tracing(_tracing) { } inline bool miss_deadline(uint64_t nano) { return nano > deadline_us * 1000; |