Bug 1337358 - Converts for(...; ...; ...) loops to use the new range-based loops in C++11 in security/ r?keeler draft
authorSylvestre Ledru <sledru@mozilla.com>
Tue, 07 Feb 2017 13:22:44 +0100
changeset 482832 f6b6587b148cceb25006bdcb8991e70b363621f2
parent 482831 9f657693145931ef5d322b2379a29b9b41ad52c4
child 482833 d58f824aac71321eab59ce05e4b81afdef1867a3
push id45175
push userbmo:sledru@mozilla.com
push dateMon, 13 Feb 2017 14:41:08 +0000
reviewerskeeler
bugs1337358
milestone54.0a1
Bug 1337358 - Converts for(...; ...; ...) loops to use the new range-based loops in C++11 in security/ r?keeler MozReview-Commit-ID: yfkQVEp2do
security/pkix/lib/pkixnames.cpp
security/pkix/lib/pkixocsp.cpp
--- a/security/pkix/lib/pkixnames.cpp
+++ b/security/pkix/lib/pkixnames.cpp
@@ -1603,22 +1603,22 @@ LocaleInsensitveToLower(uint8_t a)
   return a;
 }
 
 bool
 StartsWithIDNALabel(Input id)
 {
   static const uint8_t IDN_ALABEL_PREFIX[4] = { 'x', 'n', '-', '-' };
   Reader input(id);
-  for (size_t i = 0; i < sizeof(IDN_ALABEL_PREFIX); ++i) {
+  for (const uint8_t prefixByte : IDN_ALABEL_PREFIX) {
     uint8_t b;
     if (input.Read(b) != Success) {
       return false;
     }
-    if (b != IDN_ALABEL_PREFIX[i]) {
+    if (b != prefixByte) {
       return false;
     }
   }
   return true;
 }
 
 bool
 ReadIPv4AddressComponent(Reader& input, bool lastComponent,
--- a/security/pkix/lib/pkixocsp.cpp
+++ b/security/pkix/lib/pkixocsp.cpp
@@ -959,18 +959,18 @@ CreateEncodedOCSPRequest(TrustDomain& tr
   uint8_t* d = out;
   *d++ = 0x30; *d++ = totalLen - 2u;  // OCSPRequest (SEQUENCE)
   *d++ = 0x30; *d++ = totalLen - 4u;  //   tbsRequest (SEQUENCE)
   *d++ = 0x30; *d++ = totalLen - 6u;  //     requestList (SEQUENCE OF)
   *d++ = 0x30; *d++ = totalLen - 8u;  //       Request (SEQUENCE)
   *d++ = 0x30; *d++ = totalLen - 10u; //         reqCert (CertID SEQUENCE)
 
   // reqCert.hashAlgorithm
-  for (size_t i = 0; i < sizeof(hashAlgorithm); ++i) {
-    *d++ = hashAlgorithm[i];
+  for (const uint8_t hashAlgorithmByte : hashAlgorithm) {
+    *d++ = hashAlgorithmByte;
   }
 
   // reqCert.issuerNameHash (OCTET STRING)
   *d++ = 0x04;
   *d++ = hashLen;
   Result rv = trustDomain.DigestBuf(certID.issuer, DigestAlgorithm::sha1, d,
                                     hashLen);
   if (rv != Success) {