From 8e138d4419bcaeb29f1a77dff66a01288c6643e7 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Sun, 31 Aug 2014 21:12:55 -0400 Subject: [PATCH] Bug 1060997 - Fix more bad implicit constructors in IPC; r=smaug --- ipc/chromium/src/base/debug_util.h | 2 +- ipc/chromium/src/base/stl_util-inl.h | 16 ++++++++-------- ipc/chromium/src/base/thread_local_storage.h | 2 +- ipc/chromium/src/chrome/common/child_process.h | 2 +- .../src/chrome/common/child_process_host.cc | 4 ++-- ipc/chromium/src/chrome/common/child_thread.h | 2 +- ipc/chromium/src/chrome/common/mach_ipc_mac.h | 12 ++++++------ .../src/chrome/common/notification_details.h | 6 +++--- .../src/chrome/common/notification_source.h | 6 +++--- .../src/chrome/common/notification_type.h | 2 +- ipc/glue/BackgroundChildImpl.cpp | 2 +- ipc/glue/BackgroundImpl.cpp | 10 +++++----- ipc/glue/GeckoChildProcessHost.cpp | 4 ++-- ipc/glue/MessageChannel.cpp | 4 ++-- ipc/glue/MessagePump.cpp | 2 +- ipc/glue/ProcessChild.h | 2 +- toolkit/xre/nsEmbedFunctions.cpp | 4 ++-- 17 files changed, 41 insertions(+), 41 deletions(-) diff --git a/ipc/chromium/src/base/debug_util.h b/ipc/chromium/src/base/debug_util.h index 2b7fad7c64bc..7ae9d6822e0a 100644 --- a/ipc/chromium/src/base/debug_util.h +++ b/ipc/chromium/src/base/debug_util.h @@ -72,7 +72,7 @@ namespace mozilla { class EnvironmentLog { public: - EnvironmentLog(const char* varname); + explicit EnvironmentLog(const char* varname); ~EnvironmentLog(); void print(const char* format, ...); diff --git a/ipc/chromium/src/base/stl_util-inl.h b/ipc/chromium/src/base/stl_util-inl.h index a403544cbf4b..ffa1628b2844 100644 --- a/ipc/chromium/src/base/stl_util-inl.h +++ b/ipc/chromium/src/base/stl_util-inl.h @@ -267,7 +267,7 @@ void STLDeleteValues(T *v) { template class STLElementDeleter { public: - STLElementDeleter(STLContainer *ptr) : container_ptr_(ptr) {} + explicit STLElementDeleter(STLContainer *ptr) : container_ptr_(ptr) {} ~STLElementDeleter() { STLDeleteElements(container_ptr_); } private: STLContainer *container_ptr_; @@ -278,7 +278,7 @@ template class STLElementDeleter { template class STLValueDeleter { public: - STLValueDeleter(STLContainer *ptr) : container_ptr_(ptr) {} + explicit STLValueDeleter(STLContainer *ptr) : container_ptr_(ptr) {} ~STLValueDeleter() { STLDeleteValues(container_ptr_); } private: STLContainer *container_ptr_; @@ -301,7 +301,7 @@ class STLBinaryFunction : public std::binary_function { public: typedef ResultCallback2 Callback; - STLBinaryFunction(Callback* callback) + explicit STLBinaryFunction(Callback* callback) : callback_(callback) { assert(callback_); } @@ -325,7 +325,7 @@ template class STLBinaryPredicate : public STLBinaryFunction { public: typedef typename STLBinaryPredicate::Callback Callback; - STLBinaryPredicate(Callback* callback) + explicit STLBinaryPredicate(Callback* callback) : STLBinaryFunction(callback) { } }; @@ -351,7 +351,7 @@ class UnaryOperateOnFirst UnaryOperateOnFirst() { } - UnaryOperateOnFirst(const UnaryOp& f) : f_(f) { + explicit UnaryOperateOnFirst(const UnaryOp& f) : f_(f) { } typename UnaryOp::result_type operator()(const Pair& p) const { @@ -374,7 +374,7 @@ class UnaryOperateOnSecond UnaryOperateOnSecond() { } - UnaryOperateOnSecond(const UnaryOp& f) : f_(f) { + explicit UnaryOperateOnSecond(const UnaryOp& f) : f_(f) { } typename UnaryOp::result_type operator()(const Pair& p) const { @@ -397,7 +397,7 @@ class BinaryOperateOnFirst BinaryOperateOnFirst() { } - BinaryOperateOnFirst(const BinaryOp& f) : f_(f) { + explicit BinaryOperateOnFirst(const BinaryOp& f) : f_(f) { } typename BinaryOp::result_type operator()(const Pair& p1, @@ -421,7 +421,7 @@ class BinaryOperateOnSecond BinaryOperateOnSecond() { } - BinaryOperateOnSecond(const BinaryOp& f) : f_(f) { + explicit BinaryOperateOnSecond(const BinaryOp& f) : f_(f) { } typename BinaryOp::result_type operator()(const Pair& p1, diff --git a/ipc/chromium/src/base/thread_local_storage.h b/ipc/chromium/src/base/thread_local_storage.h index 646ded51cb02..6e693a05c68c 100644 --- a/ipc/chromium/src/base/thread_local_storage.h +++ b/ipc/chromium/src/base/thread_local_storage.h @@ -24,7 +24,7 @@ class ThreadLocalStorage { // A key representing one value stored in TLS. class Slot { public: - Slot(TLSDestructorFunc destructor = NULL); + explicit Slot(TLSDestructorFunc destructor = NULL); // This constructor should be used for statics. // It returns an uninitialized Slot. diff --git a/ipc/chromium/src/chrome/common/child_process.h b/ipc/chromium/src/chrome/common/child_process.h index 23bfad8acff2..e7570325b22b 100644 --- a/ipc/chromium/src/chrome/common/child_process.h +++ b/ipc/chromium/src/chrome/common/child_process.h @@ -21,7 +21,7 @@ class ChildProcess { public: // Child processes should have an object that derives from this class. The // constructor will return once ChildThread has started. - ChildProcess(ChildThread* child_thread); + explicit ChildProcess(ChildThread* child_thread); virtual ~ChildProcess(); // Getter for this process' main thread. diff --git a/ipc/chromium/src/chrome/common/child_process_host.cc b/ipc/chromium/src/chrome/common/child_process_host.cc index 3d590e5a2f87..2162ab215d65 100644 --- a/ipc/chromium/src/chrome/common/child_process_host.cc +++ b/ipc/chromium/src/chrome/common/child_process_host.cc @@ -113,7 +113,7 @@ void ChildProcessHost::SetHandle(base::ProcessHandle process) { } void ChildProcessHost::InstanceCreated() { - Notify(NotificationType::CHILD_INSTANCE_CREATED); + Notify(NotificationType(NotificationType::CHILD_INSTANCE_CREATED)); } bool ChildProcessHost::Send(IPC::Message* msg) { @@ -188,7 +188,7 @@ void ChildProcessHost::ListenerHook::OnChannelConnected(int32_t peer_pid) { host_->OnChannelConnected(peer_pid); // Notify in the main loop of the connection. - host_->Notify(NotificationType::CHILD_PROCESS_HOST_CONNECTED); + host_->Notify(NotificationType(NotificationType::CHILD_PROCESS_HOST_CONNECTED)); } void ChildProcessHost::ListenerHook::OnChannelError() { diff --git a/ipc/chromium/src/chrome/common/child_thread.h b/ipc/chromium/src/chrome/common/child_thread.h index ac7ed0670130..c75ddfdabc7f 100644 --- a/ipc/chromium/src/chrome/common/child_thread.h +++ b/ipc/chromium/src/chrome/common/child_thread.h @@ -17,7 +17,7 @@ class ChildThread : public IPC::Channel::Listener, public base::Thread { public: // Creates the thread. - ChildThread(Thread::Options options); + explicit ChildThread(Thread::Options options); virtual ~ChildThread(); // IPC::Message::Sender implementation: diff --git a/ipc/chromium/src/chrome/common/mach_ipc_mac.h b/ipc/chromium/src/chrome/common/mach_ipc_mac.h index 5d9b2893043d..46466245edb7 100644 --- a/ipc/chromium/src/chrome/common/mach_ipc_mac.h +++ b/ipc/chromium/src/chrome/common/mach_ipc_mac.h @@ -86,7 +86,7 @@ class MachMsgPortDescriptor : public mach_msg_port_descriptor_t { } // For passing send rights to a port - MachMsgPortDescriptor(mach_port_t in_name) { + explicit MachMsgPortDescriptor(mach_port_t in_name) { name = in_name; pad1 = 0; pad2 = 0; @@ -251,7 +251,7 @@ class MachReceiveMessage : public MachMessage { //============================================================================== class MachSendMessage : public MachMessage { public: - MachSendMessage(int32_t message_id); + explicit MachSendMessage(int32_t message_id); MachSendMessage(void *storage, size_t storage_length, int32_t message_id); private: @@ -265,11 +265,11 @@ class MachSendMessage : public MachMessage { class ReceivePort { public: // Creates a new mach port for receiving messages and registers a name for it - ReceivePort(const char *receive_port_name); + explicit ReceivePort(const char *receive_port_name); // Given an already existing mach port, use it. We take ownership of the // port and deallocate it in our destructor. - ReceivePort(mach_port_t receive_port); + explicit ReceivePort(mach_port_t receive_port); // Create a new mach port for receiving messages ReceivePort(); @@ -295,11 +295,11 @@ class ReceivePort { class MachPortSender { public: // get a port with send rights corresponding to a named registered service - MachPortSender(const char *receive_port_name); + explicit MachPortSender(const char *receive_port_name); // Given an already existing mach port, use it. - MachPortSender(mach_port_t send_port); + explicit MachPortSender(mach_port_t send_port); kern_return_t SendMessage(MachSendMessage &message, mach_msg_timeout_t timeout); diff --git a/ipc/chromium/src/chrome/common/notification_details.h b/ipc/chromium/src/chrome/common/notification_details.h index c9385425f57f..f4dffcdb15f7 100644 --- a/ipc/chromium/src/chrome/common/notification_details.h +++ b/ipc/chromium/src/chrome/common/notification_details.h @@ -33,7 +33,7 @@ class NotificationDetails { } protected: - NotificationDetails(void* ptr) : ptr_(ptr) {} + explicit NotificationDetails(void* ptr) : ptr_(ptr) {} void* ptr_; }; @@ -41,8 +41,8 @@ class NotificationDetails { template class Details : public NotificationDetails { public: - Details(T* ptr) : NotificationDetails(ptr) {} - Details(const NotificationDetails& other) + explicit Details(T* ptr) : NotificationDetails(ptr) {} + explicit Details(const NotificationDetails& other) : NotificationDetails(other) {} T* operator->() const { return ptr(); } diff --git a/ipc/chromium/src/chrome/common/notification_source.h b/ipc/chromium/src/chrome/common/notification_source.h index 93b20ba15955..c3db15320b2c 100644 --- a/ipc/chromium/src/chrome/common/notification_source.h +++ b/ipc/chromium/src/chrome/common/notification_source.h @@ -31,7 +31,7 @@ class NotificationSource { } protected: - NotificationSource(void* ptr) : ptr_(ptr) {} + explicit NotificationSource(void* ptr) : ptr_(ptr) {} void* ptr_; }; @@ -39,9 +39,9 @@ class NotificationSource { template class Source : public NotificationSource { public: - Source(T* ptr) : NotificationSource(ptr) {} + explicit Source(T* ptr) : NotificationSource(ptr) {} - Source(const NotificationSource& other) + explicit Source(const NotificationSource& other) : NotificationSource(other) {} T* operator->() const { return ptr(); } diff --git a/ipc/chromium/src/chrome/common/notification_type.h b/ipc/chromium/src/chrome/common/notification_type.h index 1f67ec394652..634d094264fb 100644 --- a/ipc/chromium/src/chrome/common/notification_type.h +++ b/ipc/chromium/src/chrome/common/notification_type.h @@ -552,7 +552,7 @@ class NotificationType { NOTIFICATION_TYPE_COUNT }; - NotificationType(Type v) : value(v) {} + explicit NotificationType(Type v) : value(v) {} bool operator==(NotificationType t) const { return value == t.value; } bool operator!=(NotificationType t) const { return value != t.value; } diff --git a/ipc/glue/BackgroundChildImpl.cpp b/ipc/glue/BackgroundChildImpl.cpp index 9e59303397e5..789aebc53059 100644 --- a/ipc/glue/BackgroundChildImpl.cpp +++ b/ipc/glue/BackgroundChildImpl.cpp @@ -15,7 +15,7 @@ class TestChild MOZ_FINAL : public mozilla::ipc::PBackgroundTestChild nsCString mTestArg; - TestChild(const nsCString& aTestArg) + explicit TestChild(const nsCString& aTestArg) : mTestArg(aTestArg) { MOZ_COUNT_CTOR(TestChild); diff --git a/ipc/glue/BackgroundImpl.cpp b/ipc/glue/BackgroundImpl.cpp index 272ccc2a40f7..b98c61fc57ce 100644 --- a/ipc/glue/BackgroundImpl.cpp +++ b/ipc/glue/BackgroundImpl.cpp @@ -327,7 +327,7 @@ class ChildImpl MOZ_FINAL : public BackgroundChildImpl struct ThreadLocalInfo { - ThreadLocalInfo(nsIIPCBackgroundChildCreateCallback* aCallback) + explicit ThreadLocalInfo(nsIIPCBackgroundChildCreateCallback* aCallback) { mCallbacks.AppendElement(aCallback); } @@ -498,7 +498,7 @@ class ParentImpl::RequestMessageLoopRunnable MOZ_FINAL : MessageLoop* mMessageLoop; public: - RequestMessageLoopRunnable(nsIThread* aTargetThread) + explicit RequestMessageLoopRunnable(nsIThread* aTargetThread) : mTargetThread(aTargetThread), mMessageLoop(nullptr) { AssertIsInMainProcess(); @@ -538,7 +538,7 @@ class ParentImpl::ForceCloseBackgroundActorsRunnable MOZ_FINAL : public nsRunnab nsTArray* mActorArray; public: - ForceCloseBackgroundActorsRunnable(nsTArray* aActorArray) + explicit ForceCloseBackgroundActorsRunnable(nsTArray* aActorArray) : mActorArray(aActorArray) { AssertIsInMainProcess(); @@ -560,7 +560,7 @@ class ParentImpl::CreateCallbackRunnable MOZ_FINAL : public nsRunnable nsRefPtr mCallback; public: - CreateCallbackRunnable(CreateCallback* aCallback) + explicit CreateCallbackRunnable(CreateCallback* aCallback) : mCallback(aCallback) { AssertIsInMainProcess(); @@ -674,7 +674,7 @@ class ChildImpl::ParentCreateCallback MOZ_FINAL : nsCOMPtr mEventTarget; public: - ParentCreateCallback(nsIEventTarget* aEventTarget) + explicit ParentCreateCallback(nsIEventTarget* aEventTarget) : mEventTarget(aEventTarget) { AssertIsInMainProcess(); diff --git a/ipc/glue/GeckoChildProcessHost.cpp b/ipc/glue/GeckoChildProcessHost.cpp index 6da996216c05..fd9434d1d6aa 100644 --- a/ipc/glue/GeckoChildProcessHost.cpp +++ b/ipc/glue/GeckoChildProcessHost.cpp @@ -154,7 +154,7 @@ GeckoChildProcessHost::GetPathToBinary(FilePath& exePath) #ifdef MOZ_WIDGET_COCOA class AutoCFTypeObject { public: - AutoCFTypeObject(CFTypeRef object) + explicit AutoCFTypeObject(CFTypeRef object) { mObject = object; } @@ -712,7 +712,7 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector& aExt MachPortSender parent_sender(child_message.GetTranslatedPort(1)); MachSendMessage parent_message(/* id= */0); - if (!parent_message.AddDescriptor(bootstrap_port)) { + if (!parent_message.AddDescriptor(MachMsgPortDescriptor(bootstrap_port))) { CHROMIUM_LOG(ERROR) << "parent AddDescriptor(" << bootstrap_port << ") failed."; return false; } diff --git a/ipc/glue/MessageChannel.cpp b/ipc/glue/MessageChannel.cpp index a5247d443b4a..8ba8b2c55ea4 100644 --- a/ipc/glue/MessageChannel.cpp +++ b/ipc/glue/MessageChannel.cpp @@ -195,8 +195,8 @@ namespace { class MOZ_STACK_CLASS MaybeScriptBlocker { public: - MaybeScriptBlocker(MessageChannel *aChannel - MOZ_GUARD_OBJECT_NOTIFIER_PARAM) + explicit MaybeScriptBlocker(MessageChannel *aChannel + MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : mBlocked(aChannel->ShouldBlockScripts()) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; diff --git a/ipc/glue/MessagePump.cpp b/ipc/glue/MessagePump.cpp index 50c2697cda62..d2118612840f 100644 --- a/ipc/glue/MessagePump.cpp +++ b/ipc/glue/MessagePump.cpp @@ -45,7 +45,7 @@ class DoWorkRunnable MOZ_FINAL : public nsICancelableRunnable, public nsITimerCallback { public: - DoWorkRunnable(MessagePump* aPump) + explicit DoWorkRunnable(MessagePump* aPump) : mPump(aPump) { MOZ_ASSERT(aPump); diff --git a/ipc/glue/ProcessChild.h b/ipc/glue/ProcessChild.h index f7c8809c54d4..204fd9ec0414 100644 --- a/ipc/glue/ProcessChild.h +++ b/ipc/glue/ProcessChild.h @@ -25,7 +25,7 @@ protected: typedef base::ProcessHandle ProcessHandle; public: - ProcessChild(ProcessHandle parentHandle); + explicit ProcessChild(ProcessHandle parentHandle); virtual ~ProcessChild(); virtual bool Init() = 0; diff --git a/toolkit/xre/nsEmbedFunctions.cpp b/toolkit/xre/nsEmbedFunctions.cpp index 3cdbb37a15ec..85b1afcbbd08 100644 --- a/toolkit/xre/nsEmbedFunctions.cpp +++ b/toolkit/xre/nsEmbedFunctions.cpp @@ -329,14 +329,14 @@ XRE_InitChildProcess(int aArgc, const int kTimeoutMs = 1000; MachSendMessage child_message(0); - if (!child_message.AddDescriptor(mach_task_self())) { + if (!child_message.AddDescriptor(MachMsgPortDescriptor(mach_task_self()))) { NS_WARNING("child AddDescriptor(mach_task_self()) failed."); return NS_ERROR_FAILURE; } ReceivePort child_recv_port; mach_port_t raw_child_recv_port = child_recv_port.GetPort(); - if (!child_message.AddDescriptor(raw_child_recv_port)) { + if (!child_message.AddDescriptor(MachMsgPortDescriptor(raw_child_recv_port))) { NS_WARNING("Adding descriptor to message failed"); return NS_ERROR_FAILURE; }