From 9647357b1fb9059f14988185a56ebd1019c977e5 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Fri, 15 Aug 2014 17:41:29 -0400 Subject: [PATCH] Bug 1053792 - Fix some bad implicit constructors in the mtransport code; r=jesup --- media/mtransport/nr_socket_prsock.h | 2 +- media/mtransport/nricectx.h | 2 +- media/mtransport/runnable_utils.py | 10 +++++++++- media/mtransport/runnable_utils_generated.h | 2 +- media/mtransport/sigslot.h | 2 +- media/mtransport/stun_udp_socket_filter.cpp | 5 +++-- media/mtransport/transportflow.h | 2 +- media/mtransport/transportlayerdtls.h | 2 +- media/mtransport/transportlayerloopback.h | 2 +- 9 files changed, 19 insertions(+), 10 deletions(-) diff --git a/media/mtransport/nr_socket_prsock.h b/media/mtransport/nr_socket_prsock.h index 30949b45fd34..533c4c65f7dd 100644 --- a/media/mtransport/nr_socket_prsock.h +++ b/media/mtransport/nr_socket_prsock.h @@ -202,7 +202,7 @@ public: NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSIUDPSOCKETINTERNAL - NrSocketIpc(const nsCOMPtr &main_thread); + explicit NrSocketIpc(const nsCOMPtr &main_thread); // Implementations of the NrSocketBase APIs virtual int create(nr_transport_addr *addr); diff --git a/media/mtransport/nricectx.h b/media/mtransport/nricectx.h index 315a91aedd73..d0be5ca9de99 100644 --- a/media/mtransport/nricectx.h +++ b/media/mtransport/nricectx.h @@ -93,7 +93,7 @@ extern const char kNrIceTransportTcp[]; class NrIceStunServer { public: - NrIceStunServer(const PRNetAddr& addr) : has_addr_(true) { + explicit NrIceStunServer(const PRNetAddr& addr) : has_addr_(true) { memcpy(&addr_, &addr, sizeof(addr)); } diff --git a/media/mtransport/runnable_utils.py b/media/mtransport/runnable_utils.py index 9ef23f11764d..50c599475372 100644 --- a/media/mtransport/runnable_utils.py +++ b/media/mtransport/runnable_utils.py @@ -7,6 +7,11 @@ boilerplate = "/* This Source Code Form is subject to the terms of the Mozilla P * License, v. 2.0. If a copy of the MPL was not distributed with this\n\ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n" +def get_args_count(args, member): + if member: + return args + 2 + return args + 1 + def gen_args_type(args, member): if member: ret = ["C o"] @@ -98,7 +103,10 @@ def generate_class_template(args, ret = False, member = True): print " public:" if not ret: - print " %s(" % class_name + gen_args_type(args, member) + ") :" + explicit = "" + if get_args_count(args, member) == 1: + explicit = "explicit " + print " %s%s(" % (explicit, class_name) + gen_args_type(args, member) + ") :" print " " + gen_init(args, False, member) + " {}" else: print " %s(" % class_name + gen_args_type(args, member) + ", R *r) :" diff --git a/media/mtransport/runnable_utils_generated.h b/media/mtransport/runnable_utils_generated.h index 5a45d82f4e35..d349827dc920 100644 --- a/media/mtransport/runnable_utils_generated.h +++ b/media/mtransport/runnable_utils_generated.h @@ -6,7 +6,7 @@ // 0 arguments -- template class runnable_args_nm_0 : public detail::runnable_args_base { public: - runnable_args_nm_0(M m) : + explicit runnable_args_nm_0(M m) : m_(m) {} NS_IMETHOD Run() { diff --git a/media/mtransport/sigslot.h b/media/mtransport/sigslot.h index 5d7fc9d67981..91cd76f25293 100644 --- a/media/mtransport/sigslot.h +++ b/media/mtransport/sigslot.h @@ -307,7 +307,7 @@ namespace sigslot { public: mt_policy *m_mutex; - lock_block(mt_policy *mtx) + explicit lock_block(mt_policy *mtx) : m_mutex(mtx) { m_mutex->lock(); diff --git a/media/mtransport/stun_udp_socket_filter.cpp b/media/mtransport/stun_udp_socket_filter.cpp index 2d0e1aef0a5f..9b530e1e0144 100644 --- a/media/mtransport/stun_udp_socket_filter.cpp +++ b/media/mtransport/stun_udp_socket_filter.cpp @@ -10,6 +10,7 @@ extern "C" { #include "stun.h" } +#include "mozilla/Attributes.h" #include "mozilla/net/DNS.h" #include "stun_udp_socket_filter.h" #include "nr_socket_prsock.h" @@ -18,7 +19,7 @@ namespace { class NetAddressAdapter { public: - NetAddressAdapter(const mozilla::net::NetAddr& netaddr) + MOZ_IMPLICIT NetAddressAdapter(const mozilla::net::NetAddr& netaddr) : addr_(ntohl(netaddr.inet.ip)), port_(ntohs(netaddr.inet.port)) { MOZ_ASSERT(netaddr.raw.family == AF_INET); @@ -44,7 +45,7 @@ class PendingSTUNRequest { net_addr_(netaddr), is_id_set_(true) {} - PendingSTUNRequest(const NetAddressAdapter& netaddr) + MOZ_IMPLICIT PendingSTUNRequest(const NetAddressAdapter& netaddr) : id_(), net_addr_(netaddr), is_id_set_(false) {} diff --git a/media/mtransport/transportflow.h b/media/mtransport/transportflow.h index 151f82fe9864..eddff571659d 100644 --- a/media/mtransport/transportflow.h +++ b/media/mtransport/transportflow.h @@ -56,7 +56,7 @@ class TransportFlow : public nsISupports, : id_("(anonymous)"), state_(TransportLayer::TS_NONE), layers_(new std::deque) {} - TransportFlow(const std::string id) + explicit TransportFlow(const std::string id) : id_(id), state_(TransportLayer::TS_NONE), layers_(new std::deque) {} diff --git a/media/mtransport/transportlayerdtls.h b/media/mtransport/transportlayerdtls.h index 725ddb768b2e..999b420d7b32 100644 --- a/media/mtransport/transportlayerdtls.h +++ b/media/mtransport/transportlayerdtls.h @@ -30,7 +30,7 @@ struct Packet; class TransportLayerNSPRAdapter { public: - TransportLayerNSPRAdapter(TransportLayer *output) : + explicit TransportLayerNSPRAdapter(TransportLayer *output) : output_(output), input_() {} diff --git a/media/mtransport/transportlayerloopback.h b/media/mtransport/transportlayerloopback.h index b24ccf1f7b39..2790834dad01 100644 --- a/media/mtransport/transportlayerloopback.h +++ b/media/mtransport/transportlayerloopback.h @@ -107,7 +107,7 @@ class TransportLayerLoopback : public TransportLayer { // Fires every 100 ms class Deliverer : public nsITimerCallback { public: - Deliverer(TransportLayerLoopback *layer) : + explicit Deliverer(TransportLayerLoopback *layer) : layer_(layer) {} void Detach() { layer_ = nullptr;