Skip to content

Commit

Permalink
net: calculate the start of question section through the size of dns …
Browse files Browse the repository at this point in the history
…Header type

Employ the same trick used at other places in DnsQuery to calculate the
beginning of the question section.

This allow us to write the code without the reinterpret_cast.

BUG=None
TEST=net_unittests --gtest_filter=*Dns*
R=ttuttle@chromium.org

Review URL: https://codereview.chromium.org/1579413002

Cr-Commit-Position: refs/heads/master@{#369433}
  • Loading branch information
tfarina authored and Commit bot committed Jan 14, 2016
1 parent fdc89d8 commit e4e1609
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/dns/dns_query.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ DnsQuery::DnsQuery(uint16_t id, const base::StringPiece& qname, uint16_t qtype)
header()->qdcount = base::HostToNet16(1);

// Write question section after the header.
base::BigEndianWriter writer(reinterpret_cast<char*>(header() + 1),
question_size());
base::BigEndianWriter writer(
io_buffer_->data() + sizeof(dns_protocol::Header), question_size());
writer.WriteBytes(qname.data(), qname.size());
writer.WriteU16(qtype);
writer.WriteU16(dns_protocol::kClassIN);
Expand Down

0 comments on commit e4e1609

Please sign in to comment.