Bug 1372977 - Use nullptr in /media and /dom/media (clang-tidy: modernize-use-nullptr). r=bwc
authorJan Keromnes <janx@linux.com>
Wed, 28 Jun 2017 15:38:00 -0400
changeset 415365 fbfd540c840d25a7065852715f78a184b44f883a
parent 415364 8bf05205295ddc001d25fe683dbcee5541b285e6
child 415366 c69701b058e884aae56a2f80cc1d1931200c62fb
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbwc
bugs1372977
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1372977 - Use nullptr in /media and /dom/media (clang-tidy: modernize-use-nullptr). r=bwc
dom/media/gmp-plugin-openh264/gmp-fake-openh264.cpp
dom/media/gmp-plugin/gmp-fake.cpp
media/mtransport/dtlsidentity.cpp
media/mtransport/nr_socket_prsock.cpp
media/mtransport/nr_timer.cpp
media/mtransport/nricectx.cpp
media/mtransport/nricemediastream.cpp
media/mtransport/nriceresolver.cpp
media/mtransport/nriceresolverfake.cpp
media/mtransport/nrinterfaceprioritizer.cpp
media/mtransport/test/ice_unittest.cpp
media/mtransport/test/stunserver.cpp
media/mtransport/test_nr_socket.cpp
--- a/dom/media/gmp-plugin-openh264/gmp-fake-openh264.cpp
+++ b/dom/media/gmp-plugin-openh264/gmp-fake-openh264.cpp
@@ -86,17 +86,17 @@ static int g_log_level = GL_CRIT;
         if ((l >= 0) && (l <= 3)) {                        \
         log_string = kLogStrings[l];                       \
         }                                                  \
         std::cerr << log_string << ": " << x << std::endl; \
         }                                                  \
     } while(0)
 
 
-GMPPlatformAPI* g_platform_api = NULL;
+GMPPlatformAPI* g_platform_api = nullptr;
 
 class FakeVideoEncoder;
 class FakeVideoDecoder;
 
 struct EncodedFrame {
   uint32_t length_;
   uint8_t h264_compat_;
   uint32_t magic_;
@@ -146,17 +146,17 @@ class FakeEncoderTask : public GMPTask {
   GMPVideoi420Frame* frame_;
   GMPVideoFrameType type_;
 };
 
 class FakeVideoEncoder : public GMPVideoEncoder {
  public:
   explicit FakeVideoEncoder (GMPVideoHost* hostAPI) :
     host_ (hostAPI),
-    callback_ (NULL),
+    callback_ (nullptr),
     frames_encoded_(0) {}
 
   void InitEncode (const GMPVideoCodec& codecSettings,
                    const uint8_t* aCodecSpecific,
                    uint32_t aCodecSpecificSize,
                    GMPVideoEncoderCallback* callback,
                    int32_t numberOfCores,
                    uint32_t maxPayloadSize) override {
@@ -332,17 +332,17 @@ class FakeDecoderTask : public GMPTask {
   GMPVideoEncodedFrame* frame_;
   int64_t time_;
 };
 
 class FakeVideoDecoder : public GMPVideoDecoder {
  public:
   explicit FakeVideoDecoder (GMPVideoHost* hostAPI) :
     host_ (hostAPI),
-    callback_ (NULL) {}
+    callback_ (nullptr) {}
 
   ~FakeVideoDecoder() override = default;
 
   void InitDecode (const GMPVideoCodec& codecSettings,
                    const uint8_t* aCodecSpecific,
                    uint32_t aCodecSpecificSize,
                    GMPVideoDecoderCallback* callback,
                    int32_t coreCount) override {
@@ -410,17 +410,17 @@ class FakeVideoDecoder : public GMPVideo
 
     GMPLOG (GL_DEBUG, "Video frame ready for display "
             << width
             << "x"
             << height
             << " timestamp="
             << inputFrame->TimeStamp());
 
-    GMPVideoFrame* ftmp = NULL;
+    GMPVideoFrame* ftmp = nullptr;
 
     // Translate the image.
     GMPErr err = host_->CreateFrame (kGMPI420VideoFrame, &ftmp);
     if (err != GMPNoErr) {
       GMPLOG (GL_ERROR, "Couldn't allocate empty I420 frame");
       return;
     }
 
@@ -483,12 +483,12 @@ extern "C" {
       return GMPNoErr;
 #endif
     }
     return GMPGenericErr;
   }
 
   PUBLIC_FUNC void
   GMPShutdown (void) {
-    g_platform_api = NULL;
+    g_platform_api = nullptr;
   }
 
 } // extern "C"
--- a/dom/media/gmp-plugin/gmp-fake.cpp
+++ b/dom/media/gmp-plugin/gmp-fake.cpp
@@ -49,17 +49,17 @@
 #endif
 
 #if defined(_MSC_VER)
 #define PUBLIC_FUNC __declspec(dllexport)
 #else
 #define PUBLIC_FUNC
 #endif
 
-GMPPlatformAPI* g_platform_api = NULL;
+GMPPlatformAPI* g_platform_api = nullptr;
 
 extern "C" {
 
   PUBLIC_FUNC GMPErr
   GMPInit (GMPPlatformAPI* aPlatformAPI) {
     g_platform_api = aPlatformAPI;
     return GMPNoErr;
   }
@@ -78,12 +78,12 @@ extern "C" {
       return GMPNoErr;
 #endif
     }
     return GMPGenericErr;
   }
 
   PUBLIC_FUNC void
   GMPShutdown (void) {
-    g_platform_api = NULL;
+    g_platform_api = nullptr;
   }
 
 } // extern "C"
--- a/media/mtransport/dtlsidentity.cpp
+++ b/media/mtransport/dtlsidentity.cpp
@@ -111,17 +111,17 @@ RefPtr<DtlsIdentity> DtlsIdentity::Gener
                              certreq.get()));
   if (!certificate) {
     return nullptr;
   }
 
   PLArenaPool *arena = certificate->arena;
 
   rv = SECOID_SetAlgorithmID(arena, &certificate->signature,
-                             SEC_OID_ANSIX962_ECDSA_SHA256_SIGNATURE, 0);
+                             SEC_OID_ANSIX962_ECDSA_SHA256_SIGNATURE, nullptr);
   if (rv != SECSuccess)
     return nullptr;
 
   // Set version to X509v3.
   *(certificate->version.data) = SEC_CERTIFICATE_VERSION_3;
   certificate->version.len = 1;
 
   SECItem innerDER;
--- a/media/mtransport/nr_socket_prsock.cpp
+++ b/media/mtransport/nr_socket_prsock.cpp
@@ -2228,17 +2228,17 @@ abort:
 }
 
 
 static int nr_socket_local_destroy(void **objp) {
   if(!objp || !*objp)
     return 0;
 
   NrSocketBase *sock = static_cast<NrSocketBase *>(*objp);
-  *objp = 0;
+  *objp = nullptr;
 
   sock->close();  // Signal STS that we want not to listen
   sock->Release();  // Decrement the ref count
 
   return 0;
 }
 
 static int nr_socket_local_sendto(void *obj,const void *msg, size_t len,
--- a/media/mtransport/nr_timer.cpp
+++ b/media/mtransport/nr_timer.cpp
@@ -116,33 +116,33 @@ class nrappkitTimerCallback : public nra
 };
 
 NS_IMPL_ISUPPORTS(nrappkitTimerCallback, nsITimerCallback)
 
 NS_IMETHODIMP nrappkitTimerCallback::Notify(nsITimer *timer) {
   r_log(LOG_GENERIC, LOG_DEBUG, "Timer callback fired (set in %s:%d)",
         function_.c_str(), line_);
   MOZ_RELEASE_ASSERT(timer == timer_);
-  cb_(0, 0, cb_arg_);
+  cb_(nullptr, 0, cb_arg_);
 
   // Allow the timer to go away.
   timer_ = nullptr;
   return NS_OK;
 }
 
 class nrappkitScheduledCallback : public nrappkitCallback {
  public:
 
   nrappkitScheduledCallback(NR_async_cb cb, void *cb_arg,
                             const char *function, int line)
       : nrappkitCallback(cb, cb_arg, function, line) {}
 
   void Run() {
     if (cb_) {
-      cb_(0, 0, cb_arg_);
+      cb_(nullptr, 0, cb_arg_);
     }
   }
 
   virtual void Cancel() override {
     cb_ = nullptr;
   }
 
   ~nrappkitScheduledCallback() {}
--- a/media/mtransport/nricectx.cpp
+++ b/media/mtransport/nricectx.cpp
@@ -126,21 +126,21 @@ static int nr_crypto_nss_random_bytes(UC
     return R_INTERNAL;
 
   return 0;
 }
 
 static int nr_crypto_nss_hmac(UCHAR *key, int keyl, UCHAR *buf, int bufl,
                               UCHAR *result) {
   CK_MECHANISM_TYPE mech = CKM_SHA_1_HMAC;
-  PK11SlotInfo *slot = 0;
+  PK11SlotInfo *slot = nullptr;
   MOZ_ASSERT(keyl > 0);
   SECItem keyi = { siBuffer, key, static_cast<unsigned int>(keyl)};
-  PK11SymKey *skey = 0;
-  PK11Context *hmac_ctx = 0;
+  PK11SymKey *skey = nullptr;
+  PK11Context *hmac_ctx = nullptr;
   SECStatus status;
   unsigned int hmac_len;
   SECItem param = { siBuffer, nullptr, 0 };
   int err = R_INTERNAL;
 
   slot = PK11_GetInternalKeySlot();
   if (!slot)
     goto abort;
@@ -777,18 +777,18 @@ NrIceStats NrIceCtx::Destroy() {
   }
   if (ctx_) {
     nr_ice_ctx_destroy(&ctx_);
   }
 
   delete ice_handler_vtbl_;
   delete ice_handler_;
 
-  ice_handler_vtbl_ = 0;
-  ice_handler_ = 0;
+  ice_handler_vtbl_ = nullptr;
+  ice_handler_ = nullptr;
   streams_.clear();
 
   return stats;
 }
 
 NrIceCtx::~NrIceCtx() {
   Destroy();
 }
@@ -982,17 +982,17 @@ RefPtr<NrIceMediaStream> NrIceCtx::FindS
       return stream_;
     }
   }
 
   return nullptr;
 }
 
 std::vector<std::string> NrIceCtx::GetGlobalAttributes() {
-  char **attrs = 0;
+  char **attrs = nullptr;
   int attrct;
   int r;
   std::vector<std::string> ret;
 
   r = nr_ice_get_global_attributes(ctx_, &attrs, &attrct);
   if (r) {
     MOZ_MTLOG(ML_ERROR, "Couldn't get ufrag and password for '"
               << name_ << "'");
--- a/media/mtransport/nricemediastream.cpp
+++ b/media/mtransport/nricemediastream.cpp
@@ -448,17 +448,17 @@ nsresult NrIceMediaStream::GetDefaultCan
               << name_ << "'");
     return NS_ERROR_FAILURE;
   }
 
   return NS_OK;
 }
 
 std::vector<std::string> NrIceMediaStream::GetCandidates() const {
-  char **attrs = 0;
+  char **attrs = nullptr;
   int attrct;
   int r;
   std::vector<std::string> ret;
 
   if (!stream_) {
     return ret;
   }
 
--- a/media/mtransport/nriceresolver.cpp
+++ b/media/mtransport/nriceresolver.cpp
@@ -123,17 +123,17 @@ void NrIceResolver::DestroyResolver() {
   // Undoes Addref in AllocateResolver so the NrIceResolver can be freed.
   Release();
 }
 
 int NrIceResolver::destroy(void **objp) {
   if (!objp || !*objp)
     return 0;
   NrIceResolver *resolver = static_cast<NrIceResolver *>(*objp);
-  *objp = 0;
+  *objp = nullptr;
   resolver->DestroyResolver();
   return 0;
 }
 
 int NrIceResolver::resolve(void *obj,
                            nr_resolver_resource *resource,
                            int (*cb)(void *cb_arg, nr_transport_addr *addr),
                            void *cb_arg,
--- a/media/mtransport/nriceresolverfake.cpp
+++ b/media/mtransport/nriceresolverfake.cpp
@@ -90,17 +90,17 @@ void NrIceResolverFake::DestroyResolver(
   --allocated_resolvers_;
 }
 
 int NrIceResolverFake::destroy(void **objp) {
   if (!objp || !*objp)
     return 0;
 
   NrIceResolverFake *fake = static_cast<NrIceResolverFake *>(*objp);
-  *objp = 0;
+  *objp = nullptr;
 
   fake->DestroyResolver();
 
   return 0;
 }
 
 int NrIceResolverFake::resolve(void *obj,
                                nr_resolver_resource *resource,
--- a/media/mtransport/nrinterfaceprioritizer.cpp
+++ b/media/mtransport/nrinterfaceprioritizer.cpp
@@ -233,17 +233,17 @@ static int sort_preference(void *obj) {
 }
 
 static int destroy(void **objp) {
   if (!objp || !*objp) {
     return 0;
   }
 
   InterfacePrioritizer *ip = static_cast<InterfacePrioritizer*>(*objp);
-  *objp = 0;
+  *objp = nullptr;
   delete ip;
 
   return 0;
 }
 
 static nr_interface_prioritizer_vtbl priorizer_vtbl = {
   add_interface,
   get_priority,
--- a/media/mtransport/test/ice_unittest.cpp
+++ b/media/mtransport/test/ice_unittest.cpp
@@ -3802,28 +3802,28 @@ TEST_F(WebRtcIcePacketFilterTest, TestSe
 TEST_F(WebRtcIcePacketFilterTest, TestRecvNonStunPacket) {
   const unsigned char data[] = "12345abcde";
   TestIncoming(data, sizeof(data), 123, 45, false);
   TestIncomingTcp(data, sizeof(data), true);
 }
 
 TEST_F(WebRtcIcePacketFilterTest, TestSendStunPacket) {
   nr_stun_message *msg;
-  ASSERT_EQ(0, nr_stun_build_req_no_auth(NULL, &msg));
+  ASSERT_EQ(0, nr_stun_build_req_no_auth(nullptr, &msg));
   msg->header.type = NR_STUN_MSG_BINDING_REQUEST;
   ASSERT_EQ(0, nr_stun_encode_message(msg));
   TestOutgoing(msg->buffer, msg->length, 123, 45, true);
   TestOutgoingTcp(msg->buffer, msg->length, true);
   TestOutgoingTcpFramed(msg->buffer, msg->length, true);
   ASSERT_EQ(0, nr_stun_message_destroy(&msg));
 }
 
 TEST_F(WebRtcIcePacketFilterTest, TestRecvStunPacketWithoutAPendingId) {
   nr_stun_message *msg;
-  ASSERT_EQ(0, nr_stun_build_req_no_auth(NULL, &msg));
+  ASSERT_EQ(0, nr_stun_build_req_no_auth(nullptr, &msg));
 
   msg->header.id.octet[0] = 1;
   msg->header.type = NR_STUN_MSG_BINDING_REQUEST;
   ASSERT_EQ(0, nr_stun_encode_message(msg));
   TestOutgoing(msg->buffer, msg->length, 123, 45, true);
   TestOutgoingTcp(msg->buffer, msg->length, true);
 
   msg->header.id.octet[0] = 0;
@@ -3832,51 +3832,51 @@ TEST_F(WebRtcIcePacketFilterTest, TestRe
   TestIncoming(msg->buffer, msg->length, 123, 45, true);
   TestIncomingTcp(msg->buffer, msg->length, true);
 
   ASSERT_EQ(0, nr_stun_message_destroy(&msg));
 }
 
 TEST_F(WebRtcIcePacketFilterTest, TestRecvStunPacketWithoutAPendingIdTcpFramed) {
   nr_stun_message *msg;
-  ASSERT_EQ(0, nr_stun_build_req_no_auth(NULL, &msg));
+  ASSERT_EQ(0, nr_stun_build_req_no_auth(nullptr, &msg));
 
   msg->header.id.octet[0] = 1;
   msg->header.type = NR_STUN_MSG_BINDING_REQUEST;
   ASSERT_EQ(0, nr_stun_encode_message(msg));
   TestOutgoingTcpFramed(msg->buffer, msg->length, true);
 
   msg->header.id.octet[0] = 0;
   msg->header.type = NR_STUN_MSG_BINDING_RESPONSE;
   ASSERT_EQ(0, nr_stun_encode_message(msg));
   TestIncomingTcpFramed(msg->buffer, msg->length, true);
 
   ASSERT_EQ(0, nr_stun_message_destroy(&msg));
 }
 
 TEST_F(WebRtcIcePacketFilterTest, TestRecvStunPacketWithoutAPendingAddress) {
   nr_stun_message *msg;
-  ASSERT_EQ(0, nr_stun_build_req_no_auth(NULL, &msg));
+  ASSERT_EQ(0, nr_stun_build_req_no_auth(nullptr, &msg));
 
   msg->header.type = NR_STUN_MSG_BINDING_REQUEST;
   ASSERT_EQ(0, nr_stun_encode_message(msg));
   TestOutgoing(msg->buffer, msg->length, 123, 45, true);
   // nothing to test here for the TCP filter
 
   msg->header.type = NR_STUN_MSG_BINDING_RESPONSE;
   ASSERT_EQ(0, nr_stun_encode_message(msg));
   TestIncoming(msg->buffer, msg->length, 123, 46, false);
   TestIncoming(msg->buffer, msg->length, 124, 45, false);
 
   ASSERT_EQ(0, nr_stun_message_destroy(&msg));
 }
 
 TEST_F(WebRtcIcePacketFilterTest, TestRecvStunPacketWithPendingIdAndAddress) {
   nr_stun_message *msg;
-  ASSERT_EQ(0, nr_stun_build_req_no_auth(NULL, &msg));
+  ASSERT_EQ(0, nr_stun_build_req_no_auth(nullptr, &msg));
 
   msg->header.type = NR_STUN_MSG_BINDING_REQUEST;
   ASSERT_EQ(0, nr_stun_encode_message(msg));
   TestOutgoing(msg->buffer, msg->length, 123, 45, true);
   TestOutgoingTcp(msg->buffer, msg->length, true);
 
   msg->header.type = NR_STUN_MSG_BINDING_RESPONSE;
   ASSERT_EQ(0, nr_stun_encode_message(msg));
@@ -3907,17 +3907,17 @@ TEST_F(WebRtcIcePacketFilterTest, TestRe
   TestOutgoing(data, sizeof(data), 124, 45, false);
   TestIncoming(data, sizeof(data), 124, 45, false);
 
   ASSERT_EQ(0, nr_stun_message_destroy(&msg));
 }
 
 TEST_F(WebRtcIcePacketFilterTest, TestRecvStunPacketWithPendingIdTcpFramed) {
   nr_stun_message *msg;
-  ASSERT_EQ(0, nr_stun_build_req_no_auth(NULL, &msg));
+  ASSERT_EQ(0, nr_stun_build_req_no_auth(nullptr, &msg));
 
   msg->header.type = NR_STUN_MSG_BINDING_REQUEST;
   ASSERT_EQ(0, nr_stun_encode_message(msg));
   TestOutgoingTcpFramed(msg->buffer, msg->length, true);
 
   msg->header.type = NR_STUN_MSG_BINDING_RESPONSE;
   ASSERT_EQ(0, nr_stun_encode_message(msg));
   TestIncomingTcpFramed(msg->buffer, msg->length, true);
@@ -3928,17 +3928,17 @@ TEST_F(WebRtcIcePacketFilterTest, TestRe
   TestOutgoingTcpFramed(data, sizeof(data), true);
   TestIncomingTcpFramed(data, sizeof(data), true);
 
   ASSERT_EQ(0, nr_stun_message_destroy(&msg));
 }
 
 TEST_F(WebRtcIcePacketFilterTest, TestSendNonRequestStunPacket) {
   nr_stun_message *msg;
-  ASSERT_EQ(0, nr_stun_build_req_no_auth(NULL, &msg));
+  ASSERT_EQ(0, nr_stun_build_req_no_auth(nullptr, &msg));
 
   msg->header.type = NR_STUN_MSG_BINDING_RESPONSE;
   ASSERT_EQ(0, nr_stun_encode_message(msg));
   TestOutgoing(msg->buffer, msg->length, 123, 45, false);
   TestOutgoingTcp(msg->buffer, msg->length, false);
 
   // Send a packet so we allow the incoming request.
   msg->header.type = NR_STUN_MSG_BINDING_REQUEST;
@@ -3957,17 +3957,17 @@ TEST_F(WebRtcIcePacketFilterTest, TestSe
   TestOutgoing(msg->buffer, msg->length, 123, 45, true);
   TestOutgoingTcp(msg->buffer, msg->length, true);
 
   ASSERT_EQ(0, nr_stun_message_destroy(&msg));
 }
 
 TEST_F(WebRtcIcePacketFilterTest, TestRecvDataPacketWithAPendingAddress) {
   nr_stun_message *msg;
-  ASSERT_EQ(0, nr_stun_build_req_no_auth(NULL, &msg));
+  ASSERT_EQ(0, nr_stun_build_req_no_auth(nullptr, &msg));
 
   msg->header.type = NR_STUN_MSG_BINDING_REQUEST;
   ASSERT_EQ(0, nr_stun_encode_message(msg));
   TestOutgoing(msg->buffer, msg->length, 123, 45, true);
   TestOutgoingTcp(msg->buffer, msg->length, true);
 
   const unsigned char data[] = "12345abcde";
   TestIncoming(data, sizeof(data), 123, 45, true);
--- a/media/mtransport/test/stunserver.cpp
+++ b/media/mtransport/test/stunserver.cpp
@@ -116,17 +116,17 @@ struct nr_socket_wrapped {
   nr_transport_addr addr_;
 };
 
 static int nr_socket_wrapped_destroy(void **objp) {
   if (!objp || !*objp)
     return 0;
 
   nr_socket_wrapped *wrapped = static_cast<nr_socket_wrapped *>(*objp);
-  *objp = 0;
+  *objp = nullptr;
 
   delete wrapped;
 
   return 0;
 }
 
 static int nr_socket_wrapped_sendto(void *obj, const void *msg, size_t len, int flags,
     nr_transport_addr *addr) {
@@ -166,22 +166,22 @@ static int nr_socket_wrapped_set_send_ad
 
 static nr_socket_vtbl nr_socket_wrapped_vtbl = {
   2,
   nr_socket_wrapped_destroy,
   nr_socket_wrapped_sendto,
   nr_socket_wrapped_recvfrom,
   nr_socket_wrapped_getfd,
   nr_socket_wrapped_getaddr,
-  0,
-  0,
-  0,
+  nullptr,
+  nullptr,
+  nullptr,
   nr_socket_wrapped_close,
-  0,
-  0
+  nullptr,
+  nullptr
 };
 
 int nr_socket_wrapped_create(nr_socket *inner, nr_socket **outp) {
   auto wrapped = MakeUnique<nr_socket_wrapped>();
 
   wrapped->sock_ = inner;
 
   int r = nr_socket_create_int(wrapped.get(), &nr_socket_wrapped_vtbl, outp);
--- a/media/mtransport/test_nr_socket.cpp
+++ b/media/mtransport/test_nr_socket.cpp
@@ -258,17 +258,17 @@ int TestNrSocket::create(nr_transport_ad
 
 int TestNrSocket::getaddr(nr_transport_addr *addrp) {
   return internal_socket_->getaddr(addrp);
 }
 
 void TestNrSocket::close() {
   if (timer_handle_) {
     NR_async_timer_cancel(timer_handle_);
-    timer_handle_ = 0;
+    timer_handle_ = nullptr;
   }
   internal_socket_->close();
   for (RefPtr<PortMapping>& port_mapping : port_mappings_) {
     port_mapping->external_socket_->close();
   }
 }
 
 int TestNrSocket::listen(int backlog) {