Browse Source

[2512] Update check to an assertion

All the constructors currently check that the tag field is not empty.
Mukund Sivaraman 11 years ago
parent
commit
79defea75c
1 changed files with 10 additions and 8 deletions
  1. 10 8
      src/lib/dns/rdata/generic/caa_257.cc

+ 10 - 8
src/lib/dns/rdata/generic/caa_257.cc

@@ -242,11 +242,12 @@ CAA::~CAA() {
 void
 CAA::toWire(OutputBuffer& buffer) const {
     buffer.writeUint8(impl_->flags_);
+
+    // The constructors must ensure that the tag field is not empty.
+    assert(!impl_->tag_.empty());
     buffer.writeUint8(impl_->tag_.size());
-    if (!impl_->tag_.empty()) {
-        buffer.writeData(&impl_->tag_[0],
-                         impl_->tag_.size());
-    }
+    buffer.writeData(&impl_->tag_[0], impl_->tag_.size());
+
     if (impl_->value_.size() > 1) {
         buffer.writeData(&impl_->value_[1],
                          impl_->value_.size() - 1);
@@ -256,11 +257,12 @@ CAA::toWire(OutputBuffer& buffer) const {
 void
 CAA::toWire(AbstractMessageRenderer& renderer) const {
     renderer.writeUint8(impl_->flags_);
+
+    // The constructors must ensure that the tag field is not empty.
+    assert(!impl_->tag_.empty());
     renderer.writeUint8(impl_->tag_.size());
-    if (!impl_->tag_.empty()) {
-        renderer.writeData(&impl_->tag_[0],
-                           impl_->tag_.size());
-    }
+    renderer.writeData(&impl_->tag_[0], impl_->tag_.size());
+
     if (impl_->value_.size() > 1) {
         renderer.writeData(&impl_->value_[1],
                            impl_->value_.size() - 1);