From: JINMEI Tatuya Date: Thu, 23 Aug 2012 23:21:35 +0000 (-0700) Subject: [2096] editorial cleanups X-Git-Tag: trac2351_base~114^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=220c3ff25ab6bb3e0cd4f4888bdfdaadc87a2738;p=thirdparty%2Fkea.git [2096] editorial cleanups - spacing - const - type clarification - postion of ++ - indentation - comment wording --- diff --git a/src/lib/datasrc/memory/rdata_reader.cc b/src/lib/datasrc/memory/rdata_reader.cc index 664b9bbad2..5429fb9b22 100644 --- a/src/lib/datasrc/memory/rdata_reader.cc +++ b/src/lib/datasrc/memory/rdata_reader.cc @@ -54,7 +54,6 @@ RdataReader::Boundary RdataReader::nextInternal(const NameAction& name_action, const DataAction& data_action) { - if (spec_pos_ < spec_count_) { const RdataFieldSpec& spec(spec_.fields[(spec_pos_++) % spec_.field_count]); @@ -64,7 +63,7 @@ RdataReader::nextInternal(const NameAction& name_action, name_action(sequence, spec.name_attributes); } else { const size_t length(spec.type == RdataFieldSpec::FIXEDLEN_DATA ? - spec.fixeddata_len : lengths_[length_pos_ ++]); + spec.fixeddata_len : lengths_[length_pos_++]); const uint8_t* const pos = data_ + data_pos_; data_pos_ += length; data_action(pos, length); diff --git a/src/lib/datasrc/memory/rdata_reader.h b/src/lib/datasrc/memory/rdata_reader.h index b2aeb1f530..8f502253fd 100644 --- a/src/lib/datasrc/memory/rdata_reader.h +++ b/src/lib/datasrc/memory/rdata_reader.h @@ -47,11 +47,12 @@ namespace memory { /// sequence will be /// - 2 bytes of opaque data (which corresponds to the MX preference) /// - a domain name (which corresponds to the MX name) +/// /// If the encoded data contain multiple MX RDATAs, the same type of /// sequence continues for the number of RDATAs. Note that the opaque -/// data field does not always correspond to a specific RDATA field +/// data field does not always corresponds to a specific RDATA field /// as is the 2-byte preference field of MX. For example, the field -/// sequence for an SOA RDATA in terms of `RdataEncoder` will be: +/// sequence for an SOA RDATA in terms of RdataEncoder will be: /// - a domain name (which corresponds to the SOA MNAME) /// - a domain name (which corresponds to the SOA RNAME) /// - 20 bytes of opaque data (for the rest of fields) @@ -135,12 +136,13 @@ public: /// \brief Call next() until the end. /// /// This is just convenience method to iterate through all the data. - /// It calls next until it reaches the end (it does not rewind before, + /// It calls next until it reaches the end (it does not rewind beforehand, /// therefore if you already called next() yourself, it does not start /// at the beginning). void iterate() { - while (next() != RRSET_BOUNDARY) { } + while (next() != RRSET_BOUNDARY) {} } + /// \brief Call next() until the end of current rdata. /// /// This is a convenience method to iterate until the end of current @@ -150,7 +152,7 @@ public: /// \return If there was Rdata to iterate through. bool iterateRdata() { while (true) { - switch(next()) { + switch (next()) { case NO_BOUNDARY: break; case RDATA_BOUNDARY: return (true); case RRSET_BOUNDARY: return (false); @@ -169,7 +171,7 @@ public: /// This is almost the same as iterate(), but it iterates through the /// RRSig data instead. void iterateAllSigs() { - while (nextSig() != RRSET_BOUNDARY) { } + while (nextSig() != RRSET_BOUNDARY) {} } /// \brief Iterate through the current RRSig Rdata. @@ -180,7 +182,7 @@ public: /// In practice, this should process one DATA field. bool iterateSingleSig() { while (true) { - switch(nextSig()) { + switch (nextSig()) { case NO_BOUNDARY: break; case RDATA_BOUNDARY: return (true); case RRSET_BOUNDARY: return (false); diff --git a/src/lib/datasrc/memory/tests/rdata_serialization_unittest.cc b/src/lib/datasrc/memory/tests/rdata_serialization_unittest.cc index fbbd4ef94f..b7a13d94e8 100644 --- a/src/lib/datasrc/memory/tests/rdata_serialization_unittest.cc +++ b/src/lib/datasrc/memory/tests/rdata_serialization_unittest.cc @@ -102,23 +102,21 @@ const TestRdata test_rdata_list[] = { // from encoded representation of each RDATA. void renderNameField(MessageRenderer* renderer, bool additional_required, - const LabelSequence& labels, unsigned attributes) + const LabelSequence& labels, RdataNameAttributes attributes) { EXPECT_EQ(additional_required, (attributes & NAMEATTR_ADDITIONAL) != 0); renderer->writeName(labels, (attributes & NAMEATTR_COMPRESSIBLE) != 0); } void -renderDataField(MessageRenderer* renderer, const void* data, - size_t data_len) -{ +renderDataField(MessageRenderer* renderer, const void* data, size_t data_len) { renderer->writeData(data, data_len); } class RdataSerializationTest : public ::testing::Test { protected: RdataSerializationTest() : a_rdata_(createRdata(RRType::A(), RRClass::IN(), - "192.0.2.53")), + "192.0.2.53")), aaaa_rdata_(createRdata(RRType::AAAA(), RRClass::IN(), "2001:db8::53")), rrsig_rdata_(createRdata( @@ -167,8 +165,8 @@ public: // Used across more classes and scopes. But it's just uninteresting // constant. -const Name &dummyName2() { - static Name result("example.com"); +const Name& dummyName2() { + static const Name result("example.com"); return (result); } @@ -329,9 +327,9 @@ public: boost::bind(renderNameField, &renderer, additionalRequired(rrtype), _1, _2), boost::bind(renderDataField, &renderer, _1, _2)); - while (reader.next() != RdataReader::RRSET_BOUNDARY) { } + while (reader.next() != RdataReader::RRSET_BOUNDARY) {} renderer.writeName(dummyName2()); - while (reader.nextSig() != RdataReader::RRSET_BOUNDARY) { } + while (reader.nextSig() != RdataReader::RRSET_BOUNDARY) {} } }; @@ -378,7 +376,8 @@ appendOrRenderData(vector* where, MessageRenderer** renderer, class RewindAndDecode { private: static void writeName(MessageRenderer** renderer, - const LabelSequence& labels, unsigned attributes) + const LabelSequence& labels, + RdataNameAttributes attributes) { (*renderer)->writeName(labels, (attributes & NAMEATTR_COMPRESSIBLE) != 0); @@ -428,13 +427,13 @@ public: boost::bind(renderDataField, &renderer, _1, _2)); size_t actual_count = 0; while (reader.iterateRdata()) { - actual_count ++; + ++actual_count; } EXPECT_EQ(rdata_count, actual_count); actual_count = 0; renderer.writeName(dummyName2()); while (reader.iterateSingleSig()) { - actual_count ++; + ++actual_count; } EXPECT_EQ(sig_count, actual_count); } @@ -501,8 +500,8 @@ typedef ::testing::Types