Bug 1337358 - Converts for(...; ...; ...) loops to use the new range-based loops in C++11 in media/mtransport/ r=bwc=jesup
authorSylvestre Ledru <sledru@mozilla.com>
Mon, 13 Feb 2017 14:42:00 +0100
changeset 389163 dcd3b1f4bc69dcd481f53ff84de46bb6702f936c
parent 389162 6be51ae5d931a68cd85288faeed3969f318af51a
child 389164 7bdff34f5eab7677cbd7aef45f04dfc40eb1f638
push id7198
push userjlorenzo@mozilla.com
push dateTue, 18 Apr 2017 12:07:49 +0000
treeherdermozilla-beta@d57aa49c3948 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbwc
bugs1337358
milestone54.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 1337358 - Converts for(...; ...; ...) loops to use the new range-based loops in C++11 in media/mtransport/ r=bwc=jesup MozReview-Commit-ID: 1ALL9rdhk24
media/mtransport/dtlsidentity.cpp
media/mtransport/nricectx.cpp
media/mtransport/nricemediastream.cpp
media/mtransport/nrinterfaceprioritizer.cpp
media/mtransport/test/ice_unittest.cpp
media/mtransport/test/multi_tcp_socket_unittest.cpp
media/mtransport/test/transport_unittests.cpp
media/mtransport/transportflow.cpp
media/mtransport/transportlayerdtls.cpp
--- a/media/mtransport/dtlsidentity.cpp
+++ b/media/mtransport/dtlsidentity.cpp
@@ -28,18 +28,18 @@ RefPtr<DtlsIdentity> DtlsIdentity::Gener
 
   SECStatus rv = PK11_GenerateRandomOnSlot(slot.get(), random_name,
                                            sizeof(random_name));
   if (rv != SECSuccess)
     return nullptr;
 
   std::string name;
   char chunk[3];
-  for (size_t i = 0; i < sizeof(random_name); ++i) {
-    SprintfLiteral(chunk, "%.2x", random_name[i]);
+  for (unsigned char r_name : random_name) {
+    SprintfLiteral(chunk, "%.2x", r_name);
     name += chunk;
   }
 
   std::string subject_name_string = "CN=" + name;
   UniqueCERTName subject_name(CERT_AsciiToName(subject_name_string.c_str()));
   if (!subject_name) {
     return nullptr;
   }
--- a/media/mtransport/nricectx.cpp
+++ b/media/mtransport/nricectx.cpp
@@ -697,19 +697,19 @@ void NrIceCtx::AccumulateStats(const NrI
   nr_ice_accumulate_count(&(ctx_->stats.turn_403s), stats.turn_403s);
   nr_ice_accumulate_count(&(ctx_->stats.turn_438s), stats.turn_438s);
 }
 
 NrIceStats NrIceCtx::Destroy() {
   // designed to be called more than once so if stats are desired, this can be
   // called just prior to the destructor
   MOZ_MTLOG(ML_DEBUG, "Destroying ICE ctx '" << name_ <<"'");
-  for (auto stream = streams_.begin(); stream != streams_.end(); stream++) {
-    if (*stream) {
-      (*stream)->Close();
+  for (auto& stream : streams_) {
+    if (stream) {
+      stream->Close();
     }
   }
 
   NrIceStats stats;
   if (ctx_) {
     stats.stun_retransmits = ctx_->stats.stun_retransmits;
     stats.turn_401s = ctx_->stats.turn_401s;
     stats.turn_403s = ctx_->stats.turn_403s;
@@ -916,19 +916,19 @@ nsresult NrIceCtx::StartGathering(bool d
     return NS_ERROR_FAILURE;
   }
 
   return NS_OK;
 }
 
 RefPtr<NrIceMediaStream> NrIceCtx::FindStream(
     nr_ice_media_stream *stream) {
-  for (size_t i=0; i<streams_.size(); ++i) {
-    if (streams_[i] && (streams_[i]->stream() == stream)) {
-      return streams_[i];
+  for (auto& stream_ : streams_) {
+    if (stream_ && (stream_->stream() == stream)) {
+      return stream_;
     }
   }
 
   return nullptr;
 }
 
 std::vector<std::string> NrIceCtx::GetGlobalAttributes() {
   char **attrs = 0;
@@ -950,18 +950,18 @@ std::vector<std::string> NrIceCtx::GetGl
   RFREE(attrs);
 
   return ret;
 }
 
 nsresult NrIceCtx::ParseGlobalAttributes(std::vector<std::string> attrs) {
   std::vector<char *> attrs_in;
 
-  for (size_t i=0; i<attrs.size(); ++i) {
-    attrs_in.push_back(const_cast<char *>(attrs[i].c_str()));
+  for (auto& attr : attrs) {
+    attrs_in.push_back(const_cast<char *>(attr.c_str()));
   }
 
   int r = nr_ice_peer_ctx_parse_global_attributes(peer_,
                                                   attrs_in.size() ?
                                                   &attrs_in[0] : nullptr,
                                                   attrs_in.size());
   if (r) {
     MOZ_MTLOG(ML_ERROR, "Couldn't parse global attributes for "
@@ -1035,18 +1035,18 @@ void NrIceCtx::SetConnectionState(Connec
   MOZ_MTLOG(ML_INFO, "NrIceCtx(" << name_ << "): state " <<
             connection_state_ << "->" << state);
   connection_state_ = state;
 
   if (connection_state_ == ICE_CTX_FAILED) {
     MOZ_MTLOG(ML_INFO, "NrIceCtx(" << name_ << "): dumping r_log ringbuffer... ");
     std::deque<std::string> logs;
     RLogConnector::GetInstance()->GetAny(0, &logs);
-    for (auto l = logs.begin(); l != logs.end(); ++l) {
-      MOZ_MTLOG(ML_INFO, *l);
+    for (auto& log : logs) {
+      MOZ_MTLOG(ML_INFO, log);
     }
   }
 
   SignalConnectionStateChange(this, state);
 }
 
 void NrIceCtx::SetGatheringState(GatheringState state) {
   if (state == gathering_state_)
--- a/media/mtransport/nricemediastream.cpp
+++ b/media/mtransport/nricemediastream.cpp
@@ -223,18 +223,18 @@ NrIceMediaStream::~NrIceMediaStream() {
 
 nsresult NrIceMediaStream::ParseAttributes(std::vector<std::string>&
                                            attributes) {
   if (!stream_)
     return NS_ERROR_FAILURE;
 
   std::vector<char *> attributes_in;
 
-  for (size_t i=0; i<attributes.size(); ++i) {
-    attributes_in.push_back(const_cast<char *>(attributes[i].c_str()));
+  for (auto& attribute : attributes) {
+    attributes_in.push_back(const_cast<char *>(attribute.c_str()));
   }
 
   // Still need to call nr_ice_ctx_parse_stream_attributes.
   int r = nr_ice_peer_ctx_parse_stream_attributes(ctx_peer_,
                                                   stream_,
                                                   attributes_in.size() ?
                                                   &attributes_in[0] : nullptr,
                                                   attributes_in.size());
--- a/media/mtransport/nrinterfaceprioritizer.cpp
+++ b/media/mtransport/nrinterfaceprioritizer.cpp
@@ -182,22 +182,21 @@ public:
     }
     sorted_ = false;
     return 0;
   }
 
   int sort() {
     UCHAR tmp_pref = 127;
     preference_map_.clear();
-    for (std::set<LocalAddress>::iterator i = local_addrs_.begin();
-         i != local_addrs_.end(); ++i) {
+    for (const auto& local_addr : local_addrs_) {
       if (tmp_pref == 0) {
         return R_FAILED;
       }
-      preference_map_.insert(make_pair(i->GetKey(), tmp_pref--));
+      preference_map_.insert(make_pair(local_addr.GetKey(), tmp_pref--));
     }
     sorted_ = true;
     return 0;
   }
 
   int getPreference(const char *key, UCHAR *pref) {
     if (!sorted_) {
       return R_FAILED;
--- a/media/mtransport/test/ice_unittest.cpp
+++ b/media/mtransport/test/ice_unittest.cpp
@@ -251,18 +251,18 @@ static std::string SabotageHostCandidate
   if (candidate.find("typ host") != std::string::npos) {
     return kUnreachableHostIceCandidate;
   }
 
   return candidate;
 }
 
 bool ContainsSucceededPair(const std::vector<NrIceCandidatePair>& pairs) {
-  for (size_t i = 0; i < pairs.size(); ++i) {
-    if (pairs[i].state == NrIceCandidatePair::STATE_SUCCEEDED) {
+  for (const auto& pair : pairs) {
+    if (pair.state == NrIceCandidatePair::STATE_SUCCEEDED) {
       return true;
     }
   }
   return false;
 }
 
 // Note: Does not correspond to any notion of prioritization; this is just
 // so we can use stl containers/algorithms that need a comparator
@@ -612,18 +612,18 @@ class IceTestPeer : public sigslot::has_
         !ice_ctx_->ctx()->GetStream(stream)) {
       EXPECT_TRUE(false) << "No such stream " << stream;
       return candidates;
     }
 
     std::vector<std::string> candidates_in =
       ice_ctx_->ctx()->GetStream(stream)->GetCandidates();
 
-    for (size_t i=0; i < candidates_in.size(); i++) {
-      std::string candidate(FilterCandidate(candidates_in[i]));
+    for (const auto& a_candidate : candidates_in) {
+      std::string candidate(FilterCandidate(a_candidate));
       if (!candidate.empty()) {
         std::cerr << name_ << " Returning candidate: "
                            << candidate << std::endl;
         candidates.push_back(candidate);
       }
     }
 
     return candidates;
@@ -765,18 +765,18 @@ class IceTestPeer : public sigslot::has_
       for (size_t i=0; i<ice_ctx_->ctx()->GetStreamCount(); ++i) {
         RefPtr<NrIceMediaStream> aStream = ice_ctx_->ctx()->GetStream(i);
         if (!aStream || aStream->HasParsedAttributes()) {
           continue;
         }
         std::vector<std::string> candidates =
             remote->GetCandidates(i);
 
-        for (size_t j=0; j<candidates.size(); ++j) {
-          std::cerr << name_ << " Adding remote candidate: " + candidates[j] << std::endl;
+        for (const auto& candidate : candidates) {
+          std::cerr << name_ << " Adding remote candidate: " + candidate << std::endl;
         }
         res = aStream->ParseAttributes(candidates);
         ASSERT_TRUE(NS_SUCCEEDED(res));
       }
     } else {
       // Parse empty attributes and then trickle them out later
       for (size_t i=0; i<ice_ctx_->ctx()->GetStreamCount(); ++i) {
         RefPtr<NrIceMediaStream> aStream = ice_ctx_->ctx()->GetStream(i);
@@ -812,34 +812,34 @@ class IceTestPeer : public sigslot::has_
 
     // We should be safe here since stream changes happen on STS thread.
     ASSERT_GT(remote_->ice_ctx_->ctx()->GetStreamCount(), stream);
     ASSERT_TRUE(remote_->ice_ctx_->ctx()->GetStream(stream).get());
 
     std::vector<SchedulableTrickleCandidate*>& candidates =
       ControlTrickle(stream);
 
-    for (auto i = candidates.begin(); i != candidates.end(); ++i) {
-      (*i)->Schedule(0);
+    for (auto& candidate : candidates) {
+      candidate->Schedule(0);
     }
   }
 
   // Allows test case to completely control when/if candidates are trickled
   // (test could also do things like insert extra trickle candidates, or
   // change existing ones, or insert duplicates, really anything is fair game)
   std::vector<SchedulableTrickleCandidate*>& ControlTrickle(size_t stream) {
     std::cerr << "Doing controlled trickle for stream " << stream << std::endl;
 
     std::vector<std::string> candidates =
       remote_->GetCandidates(stream);
 
-    for (size_t j=0; j<candidates.size(); j++) {
+    for (const auto& candidate : candidates) {
       controlled_trickle_candidates_[stream].push_back(
           new SchedulableTrickleCandidate(
-              this, stream, candidates[j], test_utils_));
+              this, stream, candidate, test_utils_));
     }
 
     return controlled_trickle_candidates_[stream];
   }
 
   nsresult TrickleCandidate_s(const std::string &candidate, size_t stream) {
     if (!ice_ctx_->ctx()->GetStream(stream)) {
       // stream might have gone away before the trickle timer popped
@@ -975,21 +975,19 @@ class IceTestPeer : public sigslot::has_
     test_utils_->sts_target()->Dispatch(
       WrapRunnable(ice_ctx_->ctx(), &NrIceCtx::destroy_peer_ctx),
       NS_DISPATCH_SYNC);
   }
 
   void Shutdown() {
     std::cerr << name_ << " Shutdown" << std::endl;
     shutting_down_ = true;
-    for (auto s = controlled_trickle_candidates_.begin();
-         s != controlled_trickle_candidates_.end();
-         ++s) {
-      for (auto cand = s->second.begin(); cand != s->second.end(); ++cand) {
-        delete *cand;
+    for (auto& controlled_trickle_candidate : controlled_trickle_candidates_) {
+      for (auto& cand : controlled_trickle_candidate.second) {
+        delete cand;
       }
     }
 
     ice_ctx_ = nullptr;
 
     if (remote_) {
       remote_->UnsetRemote();
       remote_ = nullptr;
@@ -1031,18 +1029,18 @@ class IceTestPeer : public sigslot::has_
       if (!ice_ctx_->ctx()->GetStream(i)) {
         std::cerr << "DISABLED" << std::endl;
         continue;
       }
 
       std::vector<std::string> candidates =
           ice_ctx_->ctx()->GetStream(i)->GetCandidates();
 
-      for(size_t j=0; j<candidates.size(); ++j) {
-        std::cerr << candidates[j] << std::endl;
+      for(const auto& candidate : candidates) {
+        std::cerr << candidate << std::endl;
       }
     }
     std::cerr << std::endl;
 
   }
 
   void CandidateInitialized(NrIceMediaStream *stream, const std::string &raw_candidate) {
     std::string candidate(FilterCandidate(raw_candidate));
@@ -1110,19 +1108,18 @@ class IceTestPeer : public sigslot::has_
 
   void DumpCandidatePairs_s(NrIceMediaStream *stream) {
     std::vector<NrIceCandidatePair> pairs;
     nsresult res = stream->GetCandidatePairs(&pairs);
     ASSERT_TRUE(NS_SUCCEEDED(res));
 
     std::cerr << "Begin list of candidate pairs [" << std::endl;
 
-    for (std::vector<NrIceCandidatePair>::iterator p = pairs.begin();
-         p != pairs.end(); ++p) {
-      DumpCandidatePair(*p);
+    for (auto& pair : pairs) {
+      DumpCandidatePair(pair);
     }
     std::cerr << "]" << std::endl;
   }
 
   void DumpCandidatePairs_s() {
     std::cerr << "Dumping candidate pairs for all streams [" << std::endl;
     for (size_t s = 0; s < ice_ctx_->ctx()->GetStreamCount(); ++s) {
       if (!ice_ctx_->ctx()->GetStream(s)) {
@@ -1189,26 +1186,24 @@ class IceTestPeer : public sigslot::has_
 
     std::set_difference(old_pairs.begin(),
                         old_pairs.end(),
                         (*new_pairs).begin(),
                         (*new_pairs).end(),
                         std::inserter(removed_pairs, removed_pairs.begin()),
                         IceCandidatePairCompare());
 
-    for (std::vector<NrIceCandidatePair>::iterator a = added_pairs.begin();
-         a != added_pairs.end(); ++a) {
+    for (auto& added_pair : added_pairs) {
         std::cerr << "Found new candidate pair." << std::endl;
-        DumpCandidatePair(*a);
+        DumpCandidatePair(added_pair);
     }
 
-    for (std::vector<NrIceCandidatePair>::iterator r = removed_pairs.begin();
-         r != removed_pairs.end(); ++r) {
+    for (auto& removed_pair : removed_pairs) {
         std::cerr << "Pre-existing candidate pair is now missing:" << std::endl;
-        DumpCandidatePair(*r);
+        DumpCandidatePair(removed_pair);
     }
 
     ASSERT_TRUE(removed_pairs.empty()) << "At least one candidate pair has "
                                           "gone missing.";
   }
 
   void StreamReady(NrIceMediaStream *stream) {
     ++ready_ct_;
@@ -1607,20 +1602,20 @@ class WebRtcIceGatherTest : public StunT
   }
 
   // NB: Only does substring matching, watch out for stuff like "1.2.3.4"
   // matching "21.2.3.47". " 1.2.3.4 " should not have false positives.
   bool StreamHasMatchingCandidate(unsigned int stream,
                                   const std::string& match,
                                   const std::string& match2 = "") {
     std::vector<std::string> candidates = peer_->GetCandidates(stream);
-    for (size_t c = 0; c < candidates.size(); ++c) {
-      if (std::string::npos != candidates[c].find(match)) {
+    for (auto& candidate : candidates) {
+      if (std::string::npos != candidate.find(match)) {
         if (!match2.length() ||
-            std::string::npos != candidates[c].find(match2)) {
+            std::string::npos != candidate.find(match2)) {
           return true;
         }
       }
     }
     return false;
   }
 
   void DumpCandidates(unsigned int stream) {
@@ -2380,19 +2375,19 @@ TEST_F(WebRtcIceGatherTest, TestGatherDi
   EnsurePeer();
   peer_->SetStunServer(stun_server_hostname_, kDefaultStunServerPort);
   peer_->AddStream(2);
   peer_->DisableComponent(1, 2);
   Gather();
   std::vector<std::string> candidates =
     peer_->GetCandidates(1);
 
-  for (size_t i=0; i<candidates.size(); ++i) {
-    size_t sp1 = candidates[i].find(' ');
-    ASSERT_EQ(0, candidates[i].compare(sp1+1, 1, "1", 1));
+  for (auto& candidate : candidates) {
+    size_t sp1 = candidate.find(' ');
+    ASSERT_EQ(0, candidate.compare(sp1+1, 1, "1", 1));
   }
 }
 
 TEST_F(WebRtcIceGatherTest, TestGatherVerifyNoLoopback) {
   Gather();
   ASSERT_FALSE(StreamHasMatchingCandidate(0, "127.0.0.1"));
 }
 
@@ -3083,21 +3078,21 @@ void RealisticTrickleDelay(
       cand->Schedule(i*10 + 200);
     }
   }
 }
 
 void DelayRelayCandidates(
     std::vector<SchedulableTrickleCandidate*>& candidates,
     unsigned int ms) {
-  for (auto i = candidates.begin(); i != candidates.end(); ++i) {
-    if ((*i)->IsRelay()) {
-      (*i)->Schedule(ms);
+  for (auto& candidate : candidates) {
+    if (candidate->IsRelay()) {
+      candidate->Schedule(ms);
     } else {
-      (*i)->Schedule(0);
+      candidate->Schedule(0);
     }
   }
 }
 
 void AddNonPairableCandidates(
     std::vector<SchedulableTrickleCandidate*>& candidates,
     IceTestPeer *peer, size_t stream, int net_type,
     MtransportTestUtils* test_utils_) {
@@ -3749,28 +3744,28 @@ TEST_F(WebRtcIceConnectTest, TestRLogCon
   p2_->UpdateAndValidateCandidatePairs(0, &pairs2);
 
   WaitForConnectedStreams();
   p1_->UpdateAndValidateCandidatePairs(0, &pairs1);
   p2_->UpdateAndValidateCandidatePairs(0, &pairs2);
   ASSERT_TRUE(ContainsSucceededPair(pairs1));
   ASSERT_TRUE(ContainsSucceededPair(pairs2));
 
-  for (auto p = pairs1.begin(); p != pairs1.end(); ++p) {
+  for (auto& p : pairs1) {
     std::deque<std::string> logs;
     std::string substring("CAND-PAIR(");
-    substring += p->codeword;
+    substring += p.codeword;
     RLogConnector::GetInstance()->Filter(substring, 0, &logs);
     ASSERT_NE(0U, logs.size());
   }
 
-  for (auto p = pairs2.begin(); p != pairs2.end(); ++p) {
+  for (auto& p : pairs2) {
     std::deque<std::string> logs;
     std::string substring("CAND-PAIR(");
-    substring += p->codeword;
+    substring += p.codeword;
     RLogConnector::GetInstance()->Filter(substring, 0, &logs);
     ASSERT_NE(0U, logs.size());
   }
 }
 
 TEST_F(WebRtcIcePrioritizerTest, TestPrioritizer) {
   SetPriorizer(::mozilla::CreateInterfacePrioritizer());
 
--- a/media/mtransport/test/multi_tcp_socket_unittest.cpp
+++ b/media/mtransport/test/multi_tcp_socket_unittest.cpp
@@ -71,19 +71,18 @@ class MultiTcpSocketTest : public Mtrans
 
   static void SockReadable(NR_SOCKET s, int how, void *arg) {
     MultiTcpSocketTest *obj=static_cast<MultiTcpSocketTest *>(arg);
     obj->SetReadable(true);
   }
 
   void Shutdown_s() {
     ice_ctx_ = nullptr;
-    for (std::vector<nr_socket *>::iterator it=socks.begin();
-         it!=socks.end(); ++it) {
-      nr_socket_destroy(&(*it));
+    for (auto& sock : socks) {
+      nr_socket_destroy(&sock);
     }
   }
 
   static uint16_t GetRandomPort() {
     uint16_t result;
     if (PK11_GenerateRandom((unsigned char*)&result, 2) != SECSuccess) {
       MOZ_ASSERT(false);
       return 0;
--- a/media/mtransport/test/transport_unittests.cpp
+++ b/media/mtransport/test/transport_unittests.cpp
@@ -573,23 +573,21 @@ class TransportTestPeer : public sigslot
         ASSERT_EQ(SECSuccess, rv);
       }
     }
 
     flow_->SignalPacketReceived.connect(this, &TransportTestPeer::PacketReceived);
   }
 
   void TweakCiphers(PRFileDesc* fd) {
-    for (auto it = enabled_cipersuites_.begin();
-         it != enabled_cipersuites_.end(); ++it) {
-      SSL_CipherPrefSet(fd, *it, PR_TRUE);
+    for (unsigned short& enabled_cipersuite : enabled_cipersuites_) {
+      SSL_CipherPrefSet(fd, enabled_cipersuite, PR_TRUE);
     }
-    for (auto it = disabled_cipersuites_.begin();
-         it != disabled_cipersuites_.end(); ++it) {
-      SSL_CipherPrefSet(fd, *it, PR_FALSE);
+    for (unsigned short& disabled_cipersuite : disabled_cipersuites_) {
+      SSL_CipherPrefSet(fd, disabled_cipersuite, PR_FALSE);
     }
   }
 
   void ConnectSocket(TransportTestPeer *peer) {
     RUN_ON_THREAD(test_utils_->sts_target(),
                   WrapRunnable(this, & TransportTestPeer::ConnectSocket_s,
                                peer),
                   NS_DISPATCH_SYNC);
--- a/media/mtransport/transportflow.cpp
+++ b/media/mtransport/transportflow.cpp
@@ -198,18 +198,18 @@ TransportResult TransportFlow::SendPacke
   if (state_ != TransportLayer::TS_OPEN) {
     return TE_ERROR;
   }
   return top() ? top()->SendPacket(data, len) : TE_ERROR;
 }
 
 bool TransportFlow::Contains(TransportLayer *layer) const {
   if (layers_) {
-    for (auto l = layers_->begin(); l != layers_->end(); ++l) {
-      if (*l == layer) {
+    for (auto& l : *layers_) {
+      if (l == layer) {
         return true;
       }
     }
   }
   return false;
 }
 
 void TransportFlow::EnsureSameThread(TransportLayer *layer)  {
--- a/media/mtransport/transportlayerdtls.cpp
+++ b/media/mtransport/transportlayerdtls.cpp
@@ -659,25 +659,24 @@ bool TransportLayerDtls::SetupAlpn(Uniqu
   rv = SSL_OptionSet(ssl_fd.get(), SSL_ENABLE_ALPN, PR_TRUE);
   if (rv != SECSuccess) {
     MOZ_MTLOG(ML_ERROR, "Couldn't enable ALPN");
     return false;
   }
 
   unsigned char buf[MAX_ALPN_LENGTH];
   size_t offset = 0;
-  for (auto tag = alpn_allowed_.begin();
-       tag != alpn_allowed_.end(); ++tag) {
-    if ((offset + 1 + tag->length()) >= sizeof(buf)) {
+  for (const auto& tag : alpn_allowed_) {
+    if ((offset + 1 + tag.length()) >= sizeof(buf)) {
       MOZ_MTLOG(ML_ERROR, "ALPN too long");
       return false;
     }
-    buf[offset++] = tag->length();
-    memcpy(buf + offset, tag->c_str(), tag->length());
-    offset += tag->length();
+    buf[offset++] = tag.length();
+    memcpy(buf + offset, tag.c_str(), tag.length());
+    offset += tag.length();
   }
   rv = SSL_SetNextProtoNego(ssl_fd.get(), buf, offset);
   if (rv != SECSuccess) {
     MOZ_MTLOG(ML_ERROR, "Couldn't set ALPN string");
     return false;
   }
   return true;
 }
@@ -1227,18 +1226,17 @@ SECStatus TransportLayerDtls::AuthCertif
 
     case VERIFY_DIGEST:
       {
         MOZ_ASSERT(digests_.size() != 0);
         // Check all the provided digests
 
         // Checking functions call PR_SetError()
         SECStatus rv = SECFailure;
-        for (size_t i = 0; i < digests_.size(); i++) {
-          RefPtr<VerificationDigest> digest = digests_[i];
+        for (auto digest : digests_) {
           rv = CheckDigest(digest, peer_cert);
 
           // Matches a digest, we are good to go
           if (rv == SECSuccess) {
             cert_ok_ = true;
             return SECSuccess;
           }
         }