summaryrefslogtreecommitdiff
path: root/p2p
diff options
context:
space:
mode:
authorpbos@webrtc.org <pbos@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d>2014-03-07 15:22:04 +0000
committerpbos@webrtc.org <pbos@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d>2014-03-07 15:22:04 +0000
commitb9518277716cf5081d3058d86ab7d98b78f696e8 (patch)
treeb0495e99f721a2a5b7079b5faba9b90db1914ce6 /p2p
parent3ca77cb43bc675f562521d4c90e8156a6e088cbc (diff)
downloadtalk-b9518277716cf5081d3058d86ab7d98b78f696e8.tar.gz
Remove std:: prefixes from C functions in talk/.
std::memcpy -> memcpy for instance. This change was motivated by a compile report complaining that std::rand() was used instead of rand(), probably with a stdlib.h include instead of cstdlib. Use of C functions without the std:: prefix is a lot more common, so removing std:: to address this. BUG= R=tommi@webrtc.org Review URL: https://webrtc-codereview.appspot.com/9559004 git-svn-id: http://webrtc.googlecode.com/svn/trunk/talk@5657 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'p2p')
-rw-r--r--p2p/base/asyncstuntcpsocket.cc2
-rw-r--r--p2p/base/candidate.h5
-rw-r--r--p2p/base/pseudotcp.cc5
-rw-r--r--p2p/base/relayport.cc7
-rw-r--r--p2p/base/relayserver.cc3
-rw-r--r--p2p/base/relayserver_unittest.cc8
-rw-r--r--p2p/base/session_unittest.cc17
-rw-r--r--p2p/base/stun.cc9
-rw-r--r--p2p/base/stun_unittest.cc59
-rw-r--r--p2p/base/stunserver_unittest.cc2
10 files changed, 54 insertions, 63 deletions
diff --git a/p2p/base/asyncstuntcpsocket.cc b/p2p/base/asyncstuntcpsocket.cc
index 22f15ea..8bcfa3a 100644
--- a/p2p/base/asyncstuntcpsocket.cc
+++ b/p2p/base/asyncstuntcpsocket.cc
@@ -27,7 +27,7 @@
#include "talk/p2p/base/asyncstuntcpsocket.h"
-#include <cstring>
+#include <string.h>
#include "talk/base/common.h"
#include "talk/base/logging.h"
diff --git a/p2p/base/candidate.h b/p2p/base/candidate.h
index 0fa9f0e..547725d 100644
--- a/p2p/base/candidate.h
+++ b/p2p/base/candidate.h
@@ -28,8 +28,9 @@
#ifndef TALK_P2P_BASE_CANDIDATE_H_
#define TALK_P2P_BASE_CANDIDATE_H_
-#include <climits>
-#include <cmath>
+#include <limits.h>
+#include <math.h>
+
#include <string>
#include <sstream>
#include <iomanip>
diff --git a/p2p/base/pseudotcp.cc b/p2p/base/pseudotcp.cc
index fce179b..8b83877 100644
--- a/p2p/base/pseudotcp.cc
+++ b/p2p/base/pseudotcp.cc
@@ -27,8 +27,9 @@
#include "talk/p2p/base/pseudotcp.h"
-#include <cstdio>
-#include <cstdlib>
+#include <stdio.h>
+#include <stdlib.h>
+
#include <set>
#include "talk/base/basictypes.h"
diff --git a/p2p/base/relayport.cc b/p2p/base/relayport.cc
index 0190aad..af768e4 100644
--- a/p2p/base/relayport.cc
+++ b/p2p/base/relayport.cc
@@ -258,8 +258,9 @@ bool RelayPort::HasMagicCookie(const char* data, size_t size) {
if (size < 24 + sizeof(TURN_MAGIC_COOKIE_VALUE)) {
return false;
} else {
- return 0 == std::memcmp(data + 24, TURN_MAGIC_COOKIE_VALUE,
- sizeof(TURN_MAGIC_COOKIE_VALUE));
+ return memcmp(data + 24,
+ TURN_MAGIC_COOKIE_VALUE,
+ sizeof(TURN_MAGIC_COOKIE_VALUE)) == 0;
}
}
@@ -430,7 +431,7 @@ void RelayConnection::OnSendPacket(const void* data, size_t size,
int sent = socket_->SendTo(data, size, GetAddress(), options);
if (sent <= 0) {
LOG(LS_VERBOSE) << "OnSendPacket: failed sending to " << GetAddress() <<
- std::strerror(socket_->GetError());
+ strerror(socket_->GetError());
ASSERT(sent < 0);
}
}
diff --git a/p2p/base/relayserver.cc b/p2p/base/relayserver.cc
index aacc2c8..990c818 100644
--- a/p2p/base/relayserver.cc
+++ b/p2p/base/relayserver.cc
@@ -713,8 +713,7 @@ bool RelayServerBinding::HasMagicCookie(const char* bytes, size_t size) const {
if (size < 24 + magic_cookie_.size()) {
return false;
} else {
- return 0 == std::memcmp(
- bytes + 24, magic_cookie_.c_str(), magic_cookie_.size());
+ return memcmp(bytes + 24, magic_cookie_.c_str(), magic_cookie_.size()) == 0;
}
}
diff --git a/p2p/base/relayserver_unittest.cc b/p2p/base/relayserver_unittest.cc
index ea4f6fc..239f644 100644
--- a/p2p/base/relayserver_unittest.cc
+++ b/p2p/base/relayserver_unittest.cc
@@ -197,7 +197,7 @@ class RelayServerTest : public testing::Test {
TEST_F(RelayServerTest, TestBadRequest) {
talk_base::scoped_ptr<StunMessage> res;
- SendRaw1(bad, static_cast<int>(std::strlen(bad)));
+ SendRaw1(bad, static_cast<int>(strlen(bad)));
res.reset(Receive1());
ASSERT_TRUE(!res);
@@ -340,7 +340,7 @@ TEST_F(RelayServerTest, TestRemoteBadRequest) {
Allocate();
Bind();
- SendRaw1(bad, static_cast<int>(std::strlen(bad)));
+ SendRaw1(bad, static_cast<int>(strlen(bad)));
EXPECT_TRUE(Receive1() == NULL);
EXPECT_TRUE(Receive2() == NULL);
}
@@ -486,7 +486,7 @@ TEST_F(RelayServerTest, TestSendRaw) {
Send1(req.get());
EXPECT_EQ(msg1, ReceiveRaw2());
- SendRaw2(msg2, static_cast<int>(std::strlen(msg2)));
+ SendRaw2(msg2, static_cast<int>(strlen(msg2)));
res.reset(Receive1());
ASSERT_TRUE(res);
@@ -539,6 +539,6 @@ TEST_F(RelayServerTest, TestExpiration) {
EXPECT_EQ("Operation Not Supported", err->reason());
// Also verify that traffic from the external client is ignored.
- SendRaw2(msg2, static_cast<int>(std::strlen(msg2)));
+ SendRaw2(msg2, static_cast<int>(strlen(msg2)));
EXPECT_TRUE(ReceiveRaw1().empty());
}
diff --git a/p2p/base/session_unittest.cc b/p2p/base/session_unittest.cc
index bfc4dcb..074cb1c 100644
--- a/p2p/base/session_unittest.cc
+++ b/p2p/base/session_unittest.cc
@@ -25,7 +25,8 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <cstring>
+#include <string.h>
+
#include <sstream>
#include <deque>
#include <map>
@@ -823,7 +824,7 @@ struct ChannelHandler : sigslot::has_slots<> {
EXPECT_LE(size, sizeof(last_data));
data_count += 1;
last_size = size;
- std::memcpy(last_data, buf, size);
+ memcpy(last_data, buf, size);
}
void Send(const char* data, size_t size) {
@@ -1170,14 +1171,10 @@ class SessionTest : public testing::Test {
EXPECT_EQ(strlen(dat1a), chan2a->last_size);
EXPECT_EQ(strlen(dat1b), chan2b->last_size);
- EXPECT_EQ(0, std::memcmp(chan1a->last_data, dat2a,
- strlen(dat2a)));
- EXPECT_EQ(0, std::memcmp(chan1b->last_data, dat2b,
- strlen(dat2b)));
- EXPECT_EQ(0, std::memcmp(chan2a->last_data, dat1a,
- strlen(dat1a)));
- EXPECT_EQ(0, std::memcmp(chan2b->last_data, dat1b,
- strlen(dat1b)));
+ EXPECT_EQ(0, memcmp(chan1a->last_data, dat2a, strlen(dat2a)));
+ EXPECT_EQ(0, memcmp(chan1b->last_data, dat2b, strlen(dat2b)));
+ EXPECT_EQ(0, memcmp(chan2a->last_data, dat1a, strlen(dat1a)));
+ EXPECT_EQ(0, memcmp(chan2b->last_data, dat1b, strlen(dat1b)));
}
}
diff --git a/p2p/base/stun.cc b/p2p/base/stun.cc
index 38fc96e..6331ba9 100644
--- a/p2p/base/stun.cc
+++ b/p2p/base/stun.cc
@@ -27,7 +27,7 @@
#include "talk/p2p/base/stun.h"
-#include <cstring>
+#include <string.h>
#include "talk/base/byteorder.h"
#include "talk/base/common.h"
@@ -217,8 +217,9 @@ bool StunMessage::ValidateMessageIntegrity(const char* data, size_t size,
return false;
// Comparing the calculated HMAC with the one present in the message.
- return (std::memcmp(data + current_pos + kStunAttributeHeaderSize,
- hmac, sizeof(hmac)) == 0);
+ return memcmp(data + current_pos + kStunAttributeHeaderSize,
+ hmac,
+ sizeof(hmac)) == 0;
}
bool StunMessage::AddMessageIntegrity(const std::string& password) {
@@ -734,7 +735,7 @@ void StunByteStringAttribute::CopyBytes(const char* bytes) {
void StunByteStringAttribute::CopyBytes(const void* bytes, size_t length) {
char* new_bytes = new char[length];
- std::memcpy(new_bytes, bytes, length);
+ memcpy(new_bytes, bytes, length);
SetBytes(new_bytes, length);
}
diff --git a/p2p/base/stun_unittest.cc b/p2p/base/stun_unittest.cc
index 6a5bcd9..dc78d38 100644
--- a/p2p/base/stun_unittest.cc
+++ b/p2p/base/stun_unittest.cc
@@ -50,8 +50,7 @@ class StunTest : public ::testing::Test {
ASSERT_EQ(length, msg.transaction_id().size());
ASSERT_EQ(length == kStunTransactionIdLength + 4, msg.IsLegacy());
ASSERT_EQ(length == kStunTransactionIdLength, !msg.IsLegacy());
- ASSERT_EQ(0, std::memcmp(msg.transaction_id().c_str(),
- expectedID, length));
+ ASSERT_EQ(0, memcmp(msg.transaction_id().c_str(), expectedID, length));
}
void CheckStunAddressAttribute(const StunAddressAttribute* addr,
@@ -64,13 +63,11 @@ class StunTest : public ::testing::Test {
if (addr->family() == STUN_ADDRESS_IPV4) {
in_addr v4_address = expected_address.ipv4_address();
in_addr stun_address = addr->ipaddr().ipv4_address();
- ASSERT_EQ(0, std::memcmp(&v4_address, &stun_address,
- sizeof(stun_address)));
+ ASSERT_EQ(0, memcmp(&v4_address, &stun_address, sizeof(stun_address)));
} else if (addr->family() == STUN_ADDRESS_IPV6) {
in6_addr v6_address = expected_address.ipv6_address();
in6_addr stun_address = addr->ipaddr().ipv6_address();
- ASSERT_EQ(0, std::memcmp(&v6_address, &stun_address,
- sizeof(stun_address)));
+ ASSERT_EQ(0, memcmp(&v6_address, &stun_address, sizeof(stun_address)));
} else {
ASSERT_TRUE(addr->family() == STUN_ADDRESS_IPV6 ||
addr->family() == STUN_ADDRESS_IPV4);
@@ -788,9 +785,8 @@ TEST_F(StunTest, SetIPv6XorAddressAttributeOwner) {
EXPECT_TRUE(addr->Write(&correct_buf));
EXPECT_TRUE(addr2.Write(&wrong_buf));
// But when written out, the buffers should look different.
- ASSERT_NE(0, std::memcmp(correct_buf.Data(),
- wrong_buf.Data(),
- wrong_buf.Length()));
+ ASSERT_NE(0,
+ memcmp(correct_buf.Data(), wrong_buf.Data(), wrong_buf.Length()));
// And when reading a known good value, the address should be wrong.
addr2.Read(&correct_buf);
ASSERT_NE(addr->ipaddr(), addr2.ipaddr());
@@ -836,9 +832,8 @@ TEST_F(StunTest, SetIPv4XorAddressAttributeOwner) {
EXPECT_TRUE(addr->Write(&correct_buf));
EXPECT_TRUE(addr2.Write(&wrong_buf));
// The same address data should be written.
- ASSERT_EQ(0, std::memcmp(correct_buf.Data(),
- wrong_buf.Data(),
- wrong_buf.Length()));
+ ASSERT_EQ(0,
+ memcmp(correct_buf.Data(), wrong_buf.Data(), wrong_buf.Length()));
// And an attribute should be able to un-XOR an address belonging to a message
// with a different transaction ID.
EXPECT_TRUE(addr2.Read(&correct_buf));
@@ -927,9 +922,7 @@ TEST_F(StunTest, WriteMessageWithIPv6AddressAttribute) {
int len1 = static_cast<int>(out.Length());
std::string bytes;
out.ReadString(&bytes, len1);
- ASSERT_EQ(0, std::memcmp(bytes.c_str(),
- kStunMessageWithIPv6MappedAddress,
- len1));
+ ASSERT_EQ(0, memcmp(bytes.c_str(), kStunMessageWithIPv6MappedAddress, len1));
}
TEST_F(StunTest, WriteMessageWithIPv4AddressAttribute) {
@@ -958,9 +951,7 @@ TEST_F(StunTest, WriteMessageWithIPv4AddressAttribute) {
int len1 = static_cast<int>(out.Length());
std::string bytes;
out.ReadString(&bytes, len1);
- ASSERT_EQ(0, std::memcmp(bytes.c_str(),
- kStunMessageWithIPv4MappedAddress,
- len1));
+ ASSERT_EQ(0, memcmp(bytes.c_str(), kStunMessageWithIPv4MappedAddress, len1));
}
TEST_F(StunTest, WriteMessageWithIPv6XorAddressAttribute) {
@@ -989,9 +980,8 @@ TEST_F(StunTest, WriteMessageWithIPv6XorAddressAttribute) {
int len1 = static_cast<int>(out.Length());
std::string bytes;
out.ReadString(&bytes, len1);
- ASSERT_EQ(0, std::memcmp(bytes.c_str(),
- kStunMessageWithIPv6XorMappedAddress,
- len1));
+ ASSERT_EQ(0,
+ memcmp(bytes.c_str(), kStunMessageWithIPv6XorMappedAddress, len1));
}
TEST_F(StunTest, WriteMessageWithIPv4XoreAddressAttribute) {
@@ -1020,9 +1010,8 @@ TEST_F(StunTest, WriteMessageWithIPv4XoreAddressAttribute) {
int len1 = static_cast<int>(out.Length());
std::string bytes;
out.ReadString(&bytes, len1);
- ASSERT_EQ(0, std::memcmp(bytes.c_str(),
- kStunMessageWithIPv4XorMappedAddress,
- len1));
+ ASSERT_EQ(0,
+ memcmp(bytes.c_str(), kStunMessageWithIPv4XorMappedAddress, len1));
}
TEST_F(StunTest, ReadByteStringAttribute) {
@@ -1107,7 +1096,7 @@ TEST_F(StunTest, WriteMessageWithAnErrorCodeAttribute) {
EXPECT_TRUE(msg.Write(&out));
ASSERT_EQ(size, out.Length());
// No padding.
- ASSERT_EQ(0, std::memcmp(out.Data(), kStunMessageWithErrorAttribute, size));
+ ASSERT_EQ(0, memcmp(out.Data(), kStunMessageWithErrorAttribute, size));
}
TEST_F(StunTest, WriteMessageWithAUInt16ListAttribute) {
@@ -1130,8 +1119,8 @@ TEST_F(StunTest, WriteMessageWithAUInt16ListAttribute) {
EXPECT_TRUE(msg.Write(&out));
ASSERT_EQ(size, out.Length());
// Check everything up to the padding.
- ASSERT_EQ(0, std::memcmp(out.Data(), kStunMessageWithUInt16ListAttribute,
- size - 2));
+ ASSERT_EQ(0,
+ memcmp(out.Data(), kStunMessageWithUInt16ListAttribute, size - 2));
}
// Test that we fail to read messages with invalid lengths.
@@ -1238,7 +1227,7 @@ TEST_F(StunTest, AddMessageIntegrity) {
const StunByteStringAttribute* mi_attr =
msg.GetByteString(STUN_ATTR_MESSAGE_INTEGRITY);
EXPECT_EQ(20U, mi_attr->length());
- EXPECT_EQ(0, std::memcmp(
+ EXPECT_EQ(0, memcmp(
mi_attr->bytes(), kCalculatedHmac1, sizeof(kCalculatedHmac1)));
talk_base::ByteBuffer buf1;
@@ -1256,8 +1245,8 @@ TEST_F(StunTest, AddMessageIntegrity) {
const StunByteStringAttribute* mi_attr2 =
msg2.GetByteString(STUN_ATTR_MESSAGE_INTEGRITY);
EXPECT_EQ(20U, mi_attr2->length());
- EXPECT_EQ(0, std::memcmp(
- mi_attr2->bytes(), kCalculatedHmac2, sizeof(kCalculatedHmac2)));
+ EXPECT_EQ(
+ 0, memcmp(mi_attr2->bytes(), kCalculatedHmac2, sizeof(kCalculatedHmac2)));
talk_base::ByteBuffer buf3;
EXPECT_TRUE(msg2.Write(&buf3));
@@ -1401,8 +1390,10 @@ TEST_F(StunTest, ReadRelayMessage) {
bytes = msg.GetByteString(STUN_ATTR_MAGIC_COOKIE);
ASSERT_TRUE(bytes != NULL);
EXPECT_EQ(4U, bytes->length());
- EXPECT_EQ(0, std::memcmp(bytes->bytes(), TURN_MAGIC_COOKIE_VALUE,
- sizeof(TURN_MAGIC_COOKIE_VALUE)));
+ EXPECT_EQ(0,
+ memcmp(bytes->bytes(),
+ TURN_MAGIC_COOKIE_VALUE,
+ sizeof(TURN_MAGIC_COOKIE_VALUE)));
bytes2 = StunAttribute::CreateByteString(STUN_ATTR_MAGIC_COOKIE);
bytes2->CopyBytes(reinterpret_cast<const char*>(TURN_MAGIC_COOKIE_VALUE),
@@ -1454,7 +1445,7 @@ TEST_F(StunTest, ReadRelayMessage) {
size_t len1 = out.Length();
std::string outstring;
out.ReadString(&outstring, len1);
- EXPECT_EQ(0, std::memcmp(outstring.c_str(), input, len1));
+ EXPECT_EQ(0, memcmp(outstring.c_str(), input, len1));
talk_base::ByteBuffer out2;
EXPECT_TRUE(msg2.Write(&out2));
@@ -1462,7 +1453,7 @@ TEST_F(StunTest, ReadRelayMessage) {
size_t len2 = out2.Length();
std::string outstring2;
out2.ReadString(&outstring2, len2);
- EXPECT_EQ(0, std::memcmp(outstring2.c_str(), input, len2));
+ EXPECT_EQ(0, memcmp(outstring2.c_str(), input, len2));
}
} // namespace cricket
diff --git a/p2p/base/stunserver_unittest.cc b/p2p/base/stunserver_unittest.cc
index abb1957..a6f56a5 100644
--- a/p2p/base/stunserver_unittest.cc
+++ b/p2p/base/stunserver_unittest.cc
@@ -119,7 +119,7 @@ TEST_F(StunServerTest, TestBad) {
const char* bad = "this is a completely nonsensical message whose only "
"purpose is to make the parser go 'ack'. it doesn't "
"look anything like a normal stun message";
- Send(bad, static_cast<int>(std::strlen(bad)));
+ Send(bad, static_cast<int>(strlen(bad)));
StunMessage* msg = Receive();
ASSERT_TRUE(msg == NULL);