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@5657 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
pbos@webrtc.org
2014-03-07 15:22:04 +00:00
parent 46509c8d58
commit 371243dfa3
58 changed files with 162 additions and 154 deletions

View File

@@ -27,8 +27,9 @@
#include "talk/app/webrtc/webrtcsession.h" #include "talk/app/webrtc/webrtcsession.h"
#include <limits.h>
#include <algorithm> #include <algorithm>
#include <climits>
#include <vector> #include <vector>
#include "talk/app/webrtc/jsepicecandidate.h" #include "talk/app/webrtc/jsepicecandidate.h"

View File

@@ -27,7 +27,7 @@
#include "talk/base/asynctcpsocket.h" #include "talk/base/asynctcpsocket.h"
#include <cstring> #include <string.h>
#include "talk/base/byteorder.h" #include "talk/base/byteorder.h"
#include "talk/base/common.h" #include "talk/base/common.h"

View File

@@ -28,7 +28,7 @@
#ifndef TALK_BASE_BUFFER_H_ #ifndef TALK_BASE_BUFFER_H_
#define TALK_BASE_BUFFER_H_ #define TALK_BASE_BUFFER_H_
#include <cstring> #include <string.h>
#include "talk/base/scoped_ptr.h" #include "talk/base/scoped_ptr.h"

View File

@@ -27,9 +27,10 @@
#include "talk/base/bytebuffer.h" #include "talk/base/bytebuffer.h"
#include <assert.h>
#include <string.h>
#include <algorithm> #include <algorithm>
#include <cassert>
#include <cstring>
#include "talk/base/basictypes.h" #include "talk/base/basictypes.h"
#include "talk/base/byteorder.h" #include "talk/base/byteorder.h"

View File

@@ -28,9 +28,11 @@
#ifndef _TALK_BASE_CRYPTSTRING_H_ #ifndef _TALK_BASE_CRYPTSTRING_H_
#define _TALK_BASE_CRYPTSTRING_H_ #define _TALK_BASE_CRYPTSTRING_H_
#include <cstring> #include <string.h>
#include <string> #include <string>
#include <vector> #include <vector>
#include "talk/base/linked_ptr.h" #include "talk/base/linked_ptr.h"
#include "talk/base/scoped_ptr.h" #include "talk/base/scoped_ptr.h"

View File

@@ -68,9 +68,10 @@ class FakeSSLCertificate : public talk_base::SSLCertificate {
*algorithm = digest_algorithm_; *algorithm = digest_algorithm_;
return true; return true;
} }
virtual bool ComputeDigest(const std::string &algorithm, virtual bool ComputeDigest(const std::string& algorithm,
unsigned char *digest, std::size_t size, unsigned char* digest,
std::size_t *length) const { size_t size,
size_t* length) const {
*length = talk_base::ComputeDigest(algorithm, data_.c_str(), data_.size(), *length = talk_base::ComputeDigest(algorithm, data_.c_str(), data_.size(),
digest, size); digest, size);
return (*length != 0); return (*length != 0);

View File

@@ -25,7 +25,7 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <cassert> #include <assert.h>
#ifdef WIN32 #ifdef WIN32
// TODO(grunell): Remove io.h includes when Chromium has started // TODO(grunell): Remove io.h includes when Chromium has started

View File

@@ -27,7 +27,8 @@
#include "talk/base/firewallsocketserver.h" #include "talk/base/firewallsocketserver.h"
#include <cassert> #include <assert.h>
#include <algorithm> #include <algorithm>
#include "talk/base/asyncsocket.h" #include "talk/base/asyncsocket.h"

View File

@@ -28,9 +28,9 @@
#include "talk/base/json.h" #include "talk/base/json.h"
#include <errno.h> #include <errno.h>
#include <limits.h>
#include <stdlib.h>
#include <climits>
#include <cstdlib>
#include <sstream> #include <sstream>
bool GetStringFromJson(const Json::Value& in, std::string* out) { bool GetStringFromJson(const Json::Value& in, std::string* out) {

View File

@@ -28,8 +28,9 @@
#ifndef TALK_BASE_MESSAGEQUEUE_H_ #ifndef TALK_BASE_MESSAGEQUEUE_H_
#define TALK_BASE_MESSAGEQUEUE_H_ #define TALK_BASE_MESSAGEQUEUE_H_
#include <string.h>
#include <algorithm> #include <algorithm>
#include <cstring>
#include <list> #include <list>
#include <queue> #include <queue>
#include <vector> #include <vector>

View File

@@ -155,7 +155,7 @@ void NATServer::OnExternalPacket(
remote_addr); remote_addr);
// Copy the data part after the address. // Copy the data part after the address.
talk_base::PacketOptions options; talk_base::PacketOptions options;
std::memcpy(real_buf.get() + addrlength, buf, size); memcpy(real_buf.get() + addrlength, buf, size);
server_socket_->SendTo(real_buf.get(), size + addrlength, server_socket_->SendTo(real_buf.get(), size + addrlength,
iter->second->route.source(), options); iter->second->route.source(), options);
} }

View File

@@ -47,12 +47,12 @@ size_t PackAddressForNAT(char* buf, size_t buf_size,
if (family == AF_INET) { if (family == AF_INET) {
ASSERT(buf_size >= kNATEncodedIPv4AddressSize); ASSERT(buf_size >= kNATEncodedIPv4AddressSize);
in_addr v4addr = ip.ipv4_address(); in_addr v4addr = ip.ipv4_address();
std::memcpy(&buf[4], &v4addr, kNATEncodedIPv4AddressSize - 4); memcpy(&buf[4], &v4addr, kNATEncodedIPv4AddressSize - 4);
return kNATEncodedIPv4AddressSize; return kNATEncodedIPv4AddressSize;
} else if (family == AF_INET6) { } else if (family == AF_INET6) {
ASSERT(buf_size >= kNATEncodedIPv6AddressSize); ASSERT(buf_size >= kNATEncodedIPv6AddressSize);
in6_addr v6addr = ip.ipv6_address(); in6_addr v6addr = ip.ipv6_address();
std::memcpy(&buf[4], &v6addr, kNATEncodedIPv6AddressSize - 4); memcpy(&buf[4], &v6addr, kNATEncodedIPv6AddressSize - 4);
return kNATEncodedIPv6AddressSize; return kNATEncodedIPv6AddressSize;
} }
return 0U; return 0U;
@@ -159,7 +159,7 @@ class NATSocket : public AsyncSocket, public sigslot::has_slots<> {
size + kNATEncodedIPv6AddressSize, size + kNATEncodedIPv6AddressSize,
addr); addr);
size_t encoded_size = size + addrlength; size_t encoded_size = size + addrlength;
std::memcpy(buf.get() + addrlength, data, size); memcpy(buf.get() + addrlength, data, size);
int result = socket_->SendTo(buf.get(), encoded_size, server_addr_); int result = socket_->SendTo(buf.get(), encoded_size, server_addr_);
if (result >= 0) { if (result >= 0) {
ASSERT(result == static_cast<int>(encoded_size)); ASSERT(result == static_cast<int>(encoded_size));
@@ -196,7 +196,7 @@ class NATSocket : public AsyncSocket, public sigslot::has_slots<> {
SocketAddress real_remote_addr; SocketAddress real_remote_addr;
size_t addrlength = size_t addrlength =
UnpackAddressFromNAT(buf_, result, &real_remote_addr); UnpackAddressFromNAT(buf_, result, &real_remote_addr);
std::memcpy(data, buf_ + addrlength, result - addrlength); memcpy(data, buf_ + addrlength, result - addrlength);
// Make sure this packet should be delivered before returning it. // Make sure this packet should be delivered before returning it.
if (!connected_ || (real_remote_addr == remote_addr_)) { if (!connected_ || (real_remote_addr == remote_addr_)) {

View File

@@ -25,7 +25,7 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <cassert> #include <assert.h>
#include "talk/base/nattypes.h" #include "talk/base/nattypes.h"

View File

@@ -30,7 +30,7 @@
#ifdef POSIX #ifdef POSIX
#include <netdb.h> #include <netdb.h>
#include <cstddef> #include <stddef.h>
#elif WIN32 #elif WIN32
#include <winsock2.h> // NOLINT #include <winsock2.h> // NOLINT
#endif #endif

View File

@@ -60,8 +60,9 @@
#include <Iphlpapi.h> #include <Iphlpapi.h>
#endif #endif
#include <stdio.h>
#include <algorithm> #include <algorithm>
#include <cstdio>
#include "talk/base/logging.h" #include "talk/base/logging.h"
#include "talk/base/scoped_ptr.h" #include "talk/base/scoped_ptr.h"

View File

@@ -211,8 +211,8 @@ bool NSSCertificate::IsValidChain(const CERTCertList* cert_list) {
return true; return true;
} }
bool NSSCertificate::GetDigestLength(const std::string &algorithm, bool NSSCertificate::GetDigestLength(const std::string& algorithm,
std::size_t *length) { size_t* length) {
const SECHashObject *ho; const SECHashObject *ho;
if (!GetDigestObject(algorithm, &ho)) if (!GetDigestObject(algorithm, &ho))
@@ -271,9 +271,10 @@ bool NSSCertificate::GetSignatureDigestAlgorithm(std::string* algorithm) const {
return true; return true;
} }
bool NSSCertificate::ComputeDigest(const std::string &algorithm, bool NSSCertificate::ComputeDigest(const std::string& algorithm,
unsigned char *digest, std::size_t size, unsigned char* digest,
std::size_t *length) const { size_t size,
size_t* length) const {
const SECHashObject *ho; const SECHashObject *ho;
if (!GetDigestObject(algorithm, &ho)) if (!GetDigestObject(algorithm, &ho))

View File

@@ -84,8 +84,9 @@ class NSSCertificate : public SSLCertificate {
virtual bool GetSignatureDigestAlgorithm(std::string* algorithm) const; virtual bool GetSignatureDigestAlgorithm(std::string* algorithm) const;
virtual bool ComputeDigest(const std::string& algorithm, virtual bool ComputeDigest(const std::string& algorithm,
unsigned char* digest, std::size_t size, unsigned char* digest,
std::size_t* length) const; size_t size,
size_t* length) const;
virtual bool GetChain(SSLCertChain** chain) const; virtual bool GetChain(SSLCertChain** chain) const;
@@ -97,8 +98,7 @@ class NSSCertificate : public SSLCertificate {
static bool IsValidChain(const CERTCertList* cert_list); static bool IsValidChain(const CERTCertList* cert_list);
// Helper function to get the length of a digest // Helper function to get the length of a digest
static bool GetDigestLength(const std::string& algorithm, static bool GetDigestLength(const std::string& algorithm, size_t* length);
std::size_t* length);
// Comparison. Only the certificate itself is considered, not the chain. // Comparison. Only the certificate itself is considered, not the chain.
bool Equals(const NSSCertificate* tocompare) const; bool Equals(const NSSCertificate* tocompare) const;

View File

@@ -825,7 +825,7 @@ SECStatus NSSStreamAdapter::AuthCertificateHook(void *arg,
LOG(LS_INFO) << "Checking against specified digest"; LOG(LS_INFO) << "Checking against specified digest";
// The peer certificate digest was specified // The peer certificate digest was specified
unsigned char digest[64]; // Maximum size unsigned char digest[64]; // Maximum size
std::size_t digest_length; size_t digest_length;
if (!peer_cert.ComputeDigest( if (!peer_cert.ComputeDigest(
stream->peer_certificate_digest_algorithm_, stream->peer_certificate_digest_algorithm_,

View File

@@ -103,8 +103,7 @@ class NSSStreamAdapter : public SSLStreamAdapterHelper {
// Override SSLStreamAdapterHelper // Override SSLStreamAdapterHelper
virtual int BeginSSL(); virtual int BeginSSL();
virtual void Cleanup(); virtual void Cleanup();
virtual bool GetDigestLength(const std::string &algorithm, virtual bool GetDigestLength(const std::string& algorithm, size_t* length) {
std::size_t *length) {
return NSSCertificate::GetDigestLength(algorithm, length); return NSSCertificate::GetDigestLength(algorithm, length);
} }

View File

@@ -235,18 +235,18 @@ bool OpenSSLCertificate::GetSignatureDigestAlgorithm(
EVP_get_digestbyobj(x509_->sig_alg->algorithm), algorithm); EVP_get_digestbyobj(x509_->sig_alg->algorithm), algorithm);
} }
bool OpenSSLCertificate::ComputeDigest(const std::string &algorithm, bool OpenSSLCertificate::ComputeDigest(const std::string& algorithm,
unsigned char *digest, unsigned char* digest,
std::size_t size, size_t size,
std::size_t *length) const { size_t* length) const {
return ComputeDigest(x509_, algorithm, digest, size, length); return ComputeDigest(x509_, algorithm, digest, size, length);
} }
bool OpenSSLCertificate::ComputeDigest(const X509 *x509, bool OpenSSLCertificate::ComputeDigest(const X509* x509,
const std::string &algorithm, const std::string& algorithm,
unsigned char *digest, unsigned char* digest,
std::size_t size, size_t size,
std::size_t *length) { size_t* length) {
const EVP_MD *md; const EVP_MD *md;
unsigned int n; unsigned int n;

View File

@@ -94,16 +94,17 @@ class OpenSSLCertificate : public SSLCertificate {
virtual void ToDER(Buffer* der_buffer) const; virtual void ToDER(Buffer* der_buffer) const;
// Compute the digest of the certificate given algorithm // Compute the digest of the certificate given algorithm
virtual bool ComputeDigest(const std::string &algorithm, virtual bool ComputeDigest(const std::string& algorithm,
unsigned char *digest, std::size_t size, unsigned char* digest,
std::size_t *length) const; size_t size,
size_t* length) const;
// Compute the digest of a certificate as an X509 * // Compute the digest of a certificate as an X509 *
static bool ComputeDigest(const X509 *x509, static bool ComputeDigest(const X509* x509,
const std::string &algorithm, const std::string& algorithm,
unsigned char *digest, unsigned char* digest,
std::size_t size, size_t size,
std::size_t *length); size_t* length);
virtual bool GetSignatureDigestAlgorithm(std::string* algorithm) const; virtual bool GetSignatureDigestAlgorithm(std::string* algorithm) const;

View File

@@ -780,7 +780,7 @@ int OpenSSLStreamAdapter::SSLVerifyCallback(int ok, X509_STORE_CTX* store) {
} }
X509* cert = X509_STORE_CTX_get_current_cert(store); X509* cert = X509_STORE_CTX_get_current_cert(store);
unsigned char digest[EVP_MAX_MD_SIZE]; unsigned char digest[EVP_MAX_MD_SIZE];
std::size_t digest_length; size_t digest_length;
if (!OpenSSLCertificate::ComputeDigest( if (!OpenSSLCertificate::ComputeDigest(
cert, cert,
stream->peer_certificate_digest_algorithm_, stream->peer_certificate_digest_algorithm_,

View File

@@ -29,7 +29,7 @@
#pragma warning(disable:4786) #pragma warning(disable:4786)
#endif #endif
#include <cassert> #include <assert.h>
#ifdef POSIX #ifdef POSIX
#include <string.h> #include <string.h>

View File

@@ -28,7 +28,7 @@
#ifndef TALK_APP_BASE_REFCOUNT_H_ #ifndef TALK_APP_BASE_REFCOUNT_H_
#define TALK_APP_BASE_REFCOUNT_H_ #define TALK_APP_BASE_REFCOUNT_H_
#include <cstring> #include <string.h>
#include "talk/base/criticalsection.h" #include "talk/base/criticalsection.h"

View File

@@ -88,8 +88,8 @@
#ifndef TALK_BASE_SCOPED_PTR_H__ #ifndef TALK_BASE_SCOPED_PTR_H__
#define TALK_BASE_SCOPED_PTR_H__ #define TALK_BASE_SCOPED_PTR_H__
#include <cstddef> // for std::ptrdiff_t #include <stddef.h> // for ptrdiff_t
#include <stdlib.h> // for free() decl #include <stdlib.h> // for free() decl
#include <algorithm> // For std::swap(). #include <algorithm> // For std::swap().

View File

@@ -81,9 +81,10 @@ class SSLCertificate {
virtual bool GetSignatureDigestAlgorithm(std::string* algorithm) const = 0; virtual bool GetSignatureDigestAlgorithm(std::string* algorithm) const = 0;
// Compute the digest of the certificate given algorithm // Compute the digest of the certificate given algorithm
virtual bool ComputeDigest(const std::string &algorithm, virtual bool ComputeDigest(const std::string& algorithm,
unsigned char* digest, std::size_t size, unsigned char* digest,
std::size_t* length) const = 0; size_t size,
size_t* length) const = 0;
}; };
// SSLCertChain is a simple wrapper for a vector of SSLCertificates. It serves // SSLCertChain is a simple wrapper for a vector of SSLCertificates. It serves

View File

@@ -87,8 +87,8 @@ class SSLStreamAdapterHelper : public SSLStreamAdapter {
// Must be implemented by descendents // Must be implemented by descendents
virtual int BeginSSL() = 0; virtual int BeginSSL() = 0;
virtual void Cleanup() = 0; virtual void Cleanup() = 0;
virtual bool GetDigestLength(const std::string &algorithm, virtual bool GetDigestLength(const std::string& algorithm,
std::size_t *length) = 0; size_t* length) = 0;
enum SSLState { enum SSLState {
// Before calling one of the StartSSL methods, data flows // Before calling one of the StartSSL methods, data flows

View File

@@ -27,8 +27,8 @@
#include "talk/base/stringencode.h" #include "talk/base/stringencode.h"
#include <cstdio> #include <stdio.h>
#include <cstdlib> #include <stdlib.h>
#include "talk/base/basictypes.h" #include "talk/base/basictypes.h"
#include "talk/base/common.h" #include "talk/base/common.h"

View File

@@ -31,6 +31,7 @@
#include <ctype.h> #include <ctype.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
#ifdef WIN32 #ifdef WIN32
#include <malloc.h> #include <malloc.h>
@@ -46,7 +47,6 @@
#endif // !BSD #endif // !BSD
#endif // POSIX #endif // POSIX
#include <cstring>
#include <string> #include <string>
#include "talk/base/basictypes.h" #include "talk/base/basictypes.h"

View File

@@ -5,7 +5,7 @@
#ifndef TALK_BASE_TEMPLATE_UTIL_H_ #ifndef TALK_BASE_TEMPLATE_UTIL_H_
#define TALK_BASE_TEMPLATE_UTIL_H_ #define TALK_BASE_TEMPLATE_UTIL_H_
#include <cstddef> // For size_t. #include <stddef.h> // For size_t.
namespace talk_base { namespace talk_base {

View File

@@ -107,7 +107,7 @@ bool TestClient::CheckNextPacket(const char* buf, size_t size,
bool res = false; bool res = false;
Packet* packet = NextPacket(); Packet* packet = NextPacket();
if (packet) { if (packet) {
res = (packet->size == size && std::memcmp(packet->buf, buf, size) == 0); res = (packet->size == size && memcmp(packet->buf, buf, size) == 0);
if (addr) if (addr)
*addr = packet->addr; *addr = packet->addr;
delete packet; delete packet;

View File

@@ -27,7 +27,7 @@
#include "talk/base/transformadapter.h" #include "talk/base/transformadapter.h"
#include <cstring> #include <string.h>
#include "talk/base/common.h" #include "talk/base/common.h"

View File

@@ -27,7 +27,7 @@
#include "talk/base/versionparsing.h" #include "talk/base/versionparsing.h"
#include <cstdlib> #include <stdlib.h>
namespace talk_base { namespace talk_base {

View File

@@ -25,11 +25,11 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <math.h>
#include <time.h> #include <time.h>
#ifdef POSIX #ifdef POSIX
#include <netinet/in.h> #include <netinet/in.h>
#endif #endif
#include <cmath>
#include "talk/base/logging.h" #include "talk/base/logging.h"
#include "talk/base/gunit.h" #include "talk/base/gunit.h"
@@ -686,7 +686,7 @@ class VirtualSocketServerTest : public testing::Test {
double num = double num =
receiver.samples * receiver.sum_sq - receiver.sum * receiver.sum; receiver.samples * receiver.sum_sq - receiver.sum * receiver.sum;
double den = receiver.samples * (receiver.samples - 1); double den = receiver.samples * (receiver.samples - 1);
const double sample_stddev = std::sqrt(num / den); const double sample_stddev = sqrt(num / den);
LOG(LS_VERBOSE) << "mean=" << sample_mean << " stddev=" << sample_stddev; LOG(LS_VERBOSE) << "mean=" << sample_mean << " stddev=" << sample_stddev;
EXPECT_LE(500u, receiver.samples); EXPECT_LE(500u, receiver.samples);
@@ -1002,7 +1002,7 @@ TEST_F(VirtualSocketServerTest, CreatesStandardDistribution) {
double dev = (*f)[i].second - mean; double dev = (*f)[i].second - mean;
sum_sq_dev += dev * dev; sum_sq_dev += dev * dev;
} }
const double stddev = std::sqrt(sum_sq_dev / f->size()); const double stddev = sqrt(sum_sq_dev / f->size());
EXPECT_NEAR(kTestMean[midx], mean, 0.1 * kTestMean[midx]) EXPECT_NEAR(kTestMean[midx], mean, 0.1 * kTestMean[midx])
<< "M=" << kTestMean[midx] << "M=" << kTestMean[midx]
<< " SD=" << kStdDev << " SD=" << kStdDev

View File

@@ -28,9 +28,9 @@
#include "talk/base/virtualsocketserver.h" #include "talk/base/virtualsocketserver.h"
#include <errno.h> #include <errno.h>
#include <math.h>
#include <algorithm> #include <algorithm>
#include <cmath>
#include <map> #include <map>
#include <vector> #include <vector>
@@ -80,7 +80,7 @@ class Packet : public MessageData {
: size_(size), consumed_(0), from_(from) { : size_(size), consumed_(0), from_(from) {
ASSERT(NULL != data); ASSERT(NULL != data);
data_ = new char[size_]; data_ = new char[size_];
std::memcpy(data_, data, size_); memcpy(data_, data, size_);
} }
virtual ~Packet() { virtual ~Packet() {
@@ -283,7 +283,7 @@ class VirtualSocket : public AsyncSocket, public MessageHandler {
// Return the packet at the front of the queue. // Return the packet at the front of the queue.
Packet* packet = recv_buffer_.front(); Packet* packet = recv_buffer_.front();
size_t data_read = _min(cb, packet->size()); size_t data_read = _min(cb, packet->size());
std::memcpy(pv, packet->data(), data_read); memcpy(pv, packet->data(), data_read);
*paddr = packet->from(); *paddr = packet->from();
if (data_read < packet->size()) { if (data_read < packet->size()) {
@@ -963,11 +963,11 @@ void VirtualSocketServer::UpdateDelayDistribution() {
} }
} }
static double PI = 4 * std::atan(1.0); static double PI = 4 * atan(1.0);
static double Normal(double x, double mean, double stddev) { static double Normal(double x, double mean, double stddev) {
double a = (x - mean) * (x - mean) / (2 * stddev * stddev); double a = (x - mean) * (x - mean) / (2 * stddev * stddev);
return std::exp(-a) / (stddev * sqrt(2 * PI)); return exp(-a) / (stddev * sqrt(2 * PI));
} }
#if 0 // static unused gives a warning #if 0 // static unused gives a warning

View File

@@ -28,7 +28,8 @@
#ifndef TALK_BASE_VIRTUALSOCKETSERVER_H_ #ifndef TALK_BASE_VIRTUALSOCKETSERVER_H_
#define TALK_BASE_VIRTUALSOCKETSERVER_H_ #define TALK_BASE_VIRTUALSOCKETSERVER_H_
#include <cassert> #include <assert.h>
#include <deque> #include <deque>
#include <map> #include <map>

View File

@@ -27,8 +27,8 @@
#include "talk/base/winping.h" #include "talk/base/winping.h"
#include <assert.h>
#include <Iphlpapi.h> #include <Iphlpapi.h>
#include <cassert>
#include "talk/base/byteorder.h" #include "talk/base/byteorder.h"
#include "talk/base/common.h" #include "talk/base/common.h"

View File

@@ -25,9 +25,10 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <cstdio> #include <stdio.h>
#include <cstring> #include <string.h>
#include <time.h> #include <time.h>
#include <iomanip> #include <iomanip>
#include <iostream> #include <iostream>
#include <vector> #include <vector>

View File

@@ -27,12 +27,14 @@
#define _CRT_SECURE_NO_DEPRECATE 1 #define _CRT_SECURE_NO_DEPRECATE 1
#include <assert.h>
#ifdef POSIX #ifdef POSIX
#include <signal.h> #include <signal.h>
#include <termios.h> #include <termios.h>
#include <unistd.h> #include <unistd.h>
#endif // POSIX #endif // POSIX
#include <cassert>
#include "talk/base/logging.h" #include "talk/base/logging.h"
#include "talk/base/messagequeue.h" #include "talk/base/messagequeue.h"
#include "talk/base/stringutils.h" #include "talk/base/stringutils.h"

View File

@@ -28,7 +28,7 @@
#ifndef TALK_EXAMPLES_CALL_CONSOLE_H_ #ifndef TALK_EXAMPLES_CALL_CONSOLE_H_
#define TALK_EXAMPLES_CALL_CONSOLE_H_ #define TALK_EXAMPLES_CALL_CONSOLE_H_
#include <cstdio> #include <stdio.h>
#include "talk/base/thread.h" #include "talk/base/thread.h"
#include "talk/base/messagequeue.h" #include "talk/base/messagequeue.h"

View File

@@ -25,7 +25,8 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <cstdio> #include <stdio.h>
#include <iostream> #include <iostream>
#include "talk/base/thread.h" #include "talk/base/thread.h"

View File

@@ -25,7 +25,7 @@
#include "talk/media/base/filemediaengine.h" #include "talk/media/base/filemediaengine.h"
#include <climits> #include <limits.h>
#include "talk/base/buffer.h" #include "talk/base/buffer.h"
#include "talk/base/event.h" #include "talk/base/event.h"

View File

@@ -32,7 +32,8 @@
#include <CoreAudio/CoreAudio.h> #include <CoreAudio/CoreAudio.h>
#endif #endif
#include <climits> #include <limits.h>
#include <string> #include <string>
#include <vector> #include <vector>

View File

@@ -28,7 +28,8 @@
#ifndef TALK_MEDIA_BASE_RTPDUMP_H_ #ifndef TALK_MEDIA_BASE_RTPDUMP_H_
#define TALK_MEDIA_BASE_RTPDUMP_H_ #define TALK_MEDIA_BASE_RTPDUMP_H_
#include <cstring> #include <string.h>
#include <string> #include <string>
#include <vector> #include <vector>

View File

@@ -27,7 +27,7 @@
#include "talk/media/base/videoframe.h" #include "talk/media/base/videoframe.h"
#include <cstring> #include <string.h>
#if !defined(DISABLE_YUV) #if !defined(DISABLE_YUV)
#include "libyuv/compare.h" #include "libyuv/compare.h"

View File

@@ -12,13 +12,12 @@
#include <fcntl.h> #include <fcntl.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/videodev2.h> #include <linux/videodev2.h>
#include <string.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <cstring>
#include "talk/base/logging.h" #include "talk/base/logging.h"
namespace cricket { namespace cricket {

View File

@@ -27,7 +27,7 @@
#include "talk/p2p/base/asyncstuntcpsocket.h" #include "talk/p2p/base/asyncstuntcpsocket.h"
#include <cstring> #include <string.h>
#include "talk/base/common.h" #include "talk/base/common.h"
#include "talk/base/logging.h" #include "talk/base/logging.h"

View File

@@ -28,8 +28,9 @@
#ifndef TALK_P2P_BASE_CANDIDATE_H_ #ifndef TALK_P2P_BASE_CANDIDATE_H_
#define TALK_P2P_BASE_CANDIDATE_H_ #define TALK_P2P_BASE_CANDIDATE_H_
#include <climits> #include <limits.h>
#include <cmath> #include <math.h>
#include <string> #include <string>
#include <sstream> #include <sstream>
#include <iomanip> #include <iomanip>

View File

@@ -27,8 +27,9 @@
#include "talk/p2p/base/pseudotcp.h" #include "talk/p2p/base/pseudotcp.h"
#include <cstdio> #include <stdio.h>
#include <cstdlib> #include <stdlib.h>
#include <set> #include <set>
#include "talk/base/basictypes.h" #include "talk/base/basictypes.h"

View File

@@ -258,8 +258,9 @@ bool RelayPort::HasMagicCookie(const char* data, size_t size) {
if (size < 24 + sizeof(TURN_MAGIC_COOKIE_VALUE)) { if (size < 24 + sizeof(TURN_MAGIC_COOKIE_VALUE)) {
return false; return false;
} else { } else {
return 0 == std::memcmp(data + 24, TURN_MAGIC_COOKIE_VALUE, return memcmp(data + 24,
sizeof(TURN_MAGIC_COOKIE_VALUE)); 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); int sent = socket_->SendTo(data, size, GetAddress(), options);
if (sent <= 0) { if (sent <= 0) {
LOG(LS_VERBOSE) << "OnSendPacket: failed sending to " << GetAddress() << LOG(LS_VERBOSE) << "OnSendPacket: failed sending to " << GetAddress() <<
std::strerror(socket_->GetError()); strerror(socket_->GetError());
ASSERT(sent < 0); ASSERT(sent < 0);
} }
} }

View File

@@ -713,8 +713,7 @@ bool RelayServerBinding::HasMagicCookie(const char* bytes, size_t size) const {
if (size < 24 + magic_cookie_.size()) { if (size < 24 + magic_cookie_.size()) {
return false; return false;
} else { } else {
return 0 == std::memcmp( return memcmp(bytes + 24, magic_cookie_.c_str(), magic_cookie_.size()) == 0;
bytes + 24, magic_cookie_.c_str(), magic_cookie_.size());
} }
} }

View File

@@ -197,7 +197,7 @@ class RelayServerTest : public testing::Test {
TEST_F(RelayServerTest, TestBadRequest) { TEST_F(RelayServerTest, TestBadRequest) {
talk_base::scoped_ptr<StunMessage> res; talk_base::scoped_ptr<StunMessage> res;
SendRaw1(bad, static_cast<int>(std::strlen(bad))); SendRaw1(bad, static_cast<int>(strlen(bad)));
res.reset(Receive1()); res.reset(Receive1());
ASSERT_TRUE(!res); ASSERT_TRUE(!res);
@@ -340,7 +340,7 @@ TEST_F(RelayServerTest, TestRemoteBadRequest) {
Allocate(); Allocate();
Bind(); Bind();
SendRaw1(bad, static_cast<int>(std::strlen(bad))); SendRaw1(bad, static_cast<int>(strlen(bad)));
EXPECT_TRUE(Receive1() == NULL); EXPECT_TRUE(Receive1() == NULL);
EXPECT_TRUE(Receive2() == NULL); EXPECT_TRUE(Receive2() == NULL);
} }
@@ -486,7 +486,7 @@ TEST_F(RelayServerTest, TestSendRaw) {
Send1(req.get()); Send1(req.get());
EXPECT_EQ(msg1, ReceiveRaw2()); EXPECT_EQ(msg1, ReceiveRaw2());
SendRaw2(msg2, static_cast<int>(std::strlen(msg2))); SendRaw2(msg2, static_cast<int>(strlen(msg2)));
res.reset(Receive1()); res.reset(Receive1());
ASSERT_TRUE(res); ASSERT_TRUE(res);
@@ -539,6 +539,6 @@ TEST_F(RelayServerTest, TestExpiration) {
EXPECT_EQ("Operation Not Supported", err->reason()); EXPECT_EQ("Operation Not Supported", err->reason());
// Also verify that traffic from the external client is ignored. // 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()); EXPECT_TRUE(ReceiveRaw1().empty());
} }

View File

@@ -25,7 +25,8 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <cstring> #include <string.h>
#include <sstream> #include <sstream>
#include <deque> #include <deque>
#include <map> #include <map>
@@ -823,7 +824,7 @@ struct ChannelHandler : sigslot::has_slots<> {
EXPECT_LE(size, sizeof(last_data)); EXPECT_LE(size, sizeof(last_data));
data_count += 1; data_count += 1;
last_size = size; last_size = size;
std::memcpy(last_data, buf, size); memcpy(last_data, buf, size);
} }
void Send(const char* data, size_t 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(dat1a), chan2a->last_size);
EXPECT_EQ(strlen(dat1b), chan2b->last_size); EXPECT_EQ(strlen(dat1b), chan2b->last_size);
EXPECT_EQ(0, std::memcmp(chan1a->last_data, dat2a, EXPECT_EQ(0, memcmp(chan1a->last_data, dat2a, strlen(dat2a)));
strlen(dat2a))); EXPECT_EQ(0, memcmp(chan1b->last_data, dat2b, strlen(dat2b)));
EXPECT_EQ(0, std::memcmp(chan1b->last_data, dat2b, EXPECT_EQ(0, memcmp(chan2a->last_data, dat1a, strlen(dat1a)));
strlen(dat2b))); EXPECT_EQ(0, memcmp(chan2b->last_data, dat1b, strlen(dat1b)));
EXPECT_EQ(0, std::memcmp(chan2a->last_data, dat1a,
strlen(dat1a)));
EXPECT_EQ(0, std::memcmp(chan2b->last_data, dat1b,
strlen(dat1b)));
} }
} }

View File

@@ -27,7 +27,7 @@
#include "talk/p2p/base/stun.h" #include "talk/p2p/base/stun.h"
#include <cstring> #include <string.h>
#include "talk/base/byteorder.h" #include "talk/base/byteorder.h"
#include "talk/base/common.h" #include "talk/base/common.h"
@@ -217,8 +217,9 @@ bool StunMessage::ValidateMessageIntegrity(const char* data, size_t size,
return false; return false;
// Comparing the calculated HMAC with the one present in the message. // Comparing the calculated HMAC with the one present in the message.
return (std::memcmp(data + current_pos + kStunAttributeHeaderSize, return memcmp(data + current_pos + kStunAttributeHeaderSize,
hmac, sizeof(hmac)) == 0); hmac,
sizeof(hmac)) == 0;
} }
bool StunMessage::AddMessageIntegrity(const std::string& password) { 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) { void StunByteStringAttribute::CopyBytes(const void* bytes, size_t length) {
char* new_bytes = new char[length]; char* new_bytes = new char[length];
std::memcpy(new_bytes, bytes, length); memcpy(new_bytes, bytes, length);
SetBytes(new_bytes, length); SetBytes(new_bytes, length);
} }

View File

@@ -50,8 +50,7 @@ class StunTest : public ::testing::Test {
ASSERT_EQ(length, msg.transaction_id().size()); ASSERT_EQ(length, msg.transaction_id().size());
ASSERT_EQ(length == kStunTransactionIdLength + 4, msg.IsLegacy()); ASSERT_EQ(length == kStunTransactionIdLength + 4, msg.IsLegacy());
ASSERT_EQ(length == kStunTransactionIdLength, !msg.IsLegacy()); ASSERT_EQ(length == kStunTransactionIdLength, !msg.IsLegacy());
ASSERT_EQ(0, std::memcmp(msg.transaction_id().c_str(), ASSERT_EQ(0, memcmp(msg.transaction_id().c_str(), expectedID, length));
expectedID, length));
} }
void CheckStunAddressAttribute(const StunAddressAttribute* addr, void CheckStunAddressAttribute(const StunAddressAttribute* addr,
@@ -64,13 +63,11 @@ class StunTest : public ::testing::Test {
if (addr->family() == STUN_ADDRESS_IPV4) { if (addr->family() == STUN_ADDRESS_IPV4) {
in_addr v4_address = expected_address.ipv4_address(); in_addr v4_address = expected_address.ipv4_address();
in_addr stun_address = addr->ipaddr().ipv4_address(); in_addr stun_address = addr->ipaddr().ipv4_address();
ASSERT_EQ(0, std::memcmp(&v4_address, &stun_address, ASSERT_EQ(0, memcmp(&v4_address, &stun_address, sizeof(stun_address)));
sizeof(stun_address)));
} else if (addr->family() == STUN_ADDRESS_IPV6) { } else if (addr->family() == STUN_ADDRESS_IPV6) {
in6_addr v6_address = expected_address.ipv6_address(); in6_addr v6_address = expected_address.ipv6_address();
in6_addr stun_address = addr->ipaddr().ipv6_address(); in6_addr stun_address = addr->ipaddr().ipv6_address();
ASSERT_EQ(0, std::memcmp(&v6_address, &stun_address, ASSERT_EQ(0, memcmp(&v6_address, &stun_address, sizeof(stun_address)));
sizeof(stun_address)));
} else { } else {
ASSERT_TRUE(addr->family() == STUN_ADDRESS_IPV6 || ASSERT_TRUE(addr->family() == STUN_ADDRESS_IPV6 ||
addr->family() == STUN_ADDRESS_IPV4); addr->family() == STUN_ADDRESS_IPV4);
@@ -788,9 +785,8 @@ TEST_F(StunTest, SetIPv6XorAddressAttributeOwner) {
EXPECT_TRUE(addr->Write(&correct_buf)); EXPECT_TRUE(addr->Write(&correct_buf));
EXPECT_TRUE(addr2.Write(&wrong_buf)); EXPECT_TRUE(addr2.Write(&wrong_buf));
// But when written out, the buffers should look different. // But when written out, the buffers should look different.
ASSERT_NE(0, std::memcmp(correct_buf.Data(), ASSERT_NE(0,
wrong_buf.Data(), memcmp(correct_buf.Data(), wrong_buf.Data(), wrong_buf.Length()));
wrong_buf.Length()));
// And when reading a known good value, the address should be wrong. // And when reading a known good value, the address should be wrong.
addr2.Read(&correct_buf); addr2.Read(&correct_buf);
ASSERT_NE(addr->ipaddr(), addr2.ipaddr()); ASSERT_NE(addr->ipaddr(), addr2.ipaddr());
@@ -836,9 +832,8 @@ TEST_F(StunTest, SetIPv4XorAddressAttributeOwner) {
EXPECT_TRUE(addr->Write(&correct_buf)); EXPECT_TRUE(addr->Write(&correct_buf));
EXPECT_TRUE(addr2.Write(&wrong_buf)); EXPECT_TRUE(addr2.Write(&wrong_buf));
// The same address data should be written. // The same address data should be written.
ASSERT_EQ(0, std::memcmp(correct_buf.Data(), ASSERT_EQ(0,
wrong_buf.Data(), memcmp(correct_buf.Data(), wrong_buf.Data(), wrong_buf.Length()));
wrong_buf.Length()));
// And an attribute should be able to un-XOR an address belonging to a message // And an attribute should be able to un-XOR an address belonging to a message
// with a different transaction ID. // with a different transaction ID.
EXPECT_TRUE(addr2.Read(&correct_buf)); EXPECT_TRUE(addr2.Read(&correct_buf));
@@ -927,9 +922,7 @@ TEST_F(StunTest, WriteMessageWithIPv6AddressAttribute) {
int len1 = static_cast<int>(out.Length()); int len1 = static_cast<int>(out.Length());
std::string bytes; std::string bytes;
out.ReadString(&bytes, len1); out.ReadString(&bytes, len1);
ASSERT_EQ(0, std::memcmp(bytes.c_str(), ASSERT_EQ(0, memcmp(bytes.c_str(), kStunMessageWithIPv6MappedAddress, len1));
kStunMessageWithIPv6MappedAddress,
len1));
} }
TEST_F(StunTest, WriteMessageWithIPv4AddressAttribute) { TEST_F(StunTest, WriteMessageWithIPv4AddressAttribute) {
@@ -958,9 +951,7 @@ TEST_F(StunTest, WriteMessageWithIPv4AddressAttribute) {
int len1 = static_cast<int>(out.Length()); int len1 = static_cast<int>(out.Length());
std::string bytes; std::string bytes;
out.ReadString(&bytes, len1); out.ReadString(&bytes, len1);
ASSERT_EQ(0, std::memcmp(bytes.c_str(), ASSERT_EQ(0, memcmp(bytes.c_str(), kStunMessageWithIPv4MappedAddress, len1));
kStunMessageWithIPv4MappedAddress,
len1));
} }
TEST_F(StunTest, WriteMessageWithIPv6XorAddressAttribute) { TEST_F(StunTest, WriteMessageWithIPv6XorAddressAttribute) {
@@ -989,9 +980,8 @@ TEST_F(StunTest, WriteMessageWithIPv6XorAddressAttribute) {
int len1 = static_cast<int>(out.Length()); int len1 = static_cast<int>(out.Length());
std::string bytes; std::string bytes;
out.ReadString(&bytes, len1); out.ReadString(&bytes, len1);
ASSERT_EQ(0, std::memcmp(bytes.c_str(), ASSERT_EQ(0,
kStunMessageWithIPv6XorMappedAddress, memcmp(bytes.c_str(), kStunMessageWithIPv6XorMappedAddress, len1));
len1));
} }
TEST_F(StunTest, WriteMessageWithIPv4XoreAddressAttribute) { TEST_F(StunTest, WriteMessageWithIPv4XoreAddressAttribute) {
@@ -1020,9 +1010,8 @@ TEST_F(StunTest, WriteMessageWithIPv4XoreAddressAttribute) {
int len1 = static_cast<int>(out.Length()); int len1 = static_cast<int>(out.Length());
std::string bytes; std::string bytes;
out.ReadString(&bytes, len1); out.ReadString(&bytes, len1);
ASSERT_EQ(0, std::memcmp(bytes.c_str(), ASSERT_EQ(0,
kStunMessageWithIPv4XorMappedAddress, memcmp(bytes.c_str(), kStunMessageWithIPv4XorMappedAddress, len1));
len1));
} }
TEST_F(StunTest, ReadByteStringAttribute) { TEST_F(StunTest, ReadByteStringAttribute) {
@@ -1107,7 +1096,7 @@ TEST_F(StunTest, WriteMessageWithAnErrorCodeAttribute) {
EXPECT_TRUE(msg.Write(&out)); EXPECT_TRUE(msg.Write(&out));
ASSERT_EQ(size, out.Length()); ASSERT_EQ(size, out.Length());
// No padding. // No padding.
ASSERT_EQ(0, std::memcmp(out.Data(), kStunMessageWithErrorAttribute, size)); ASSERT_EQ(0, memcmp(out.Data(), kStunMessageWithErrorAttribute, size));
} }
TEST_F(StunTest, WriteMessageWithAUInt16ListAttribute) { TEST_F(StunTest, WriteMessageWithAUInt16ListAttribute) {
@@ -1130,8 +1119,8 @@ TEST_F(StunTest, WriteMessageWithAUInt16ListAttribute) {
EXPECT_TRUE(msg.Write(&out)); EXPECT_TRUE(msg.Write(&out));
ASSERT_EQ(size, out.Length()); ASSERT_EQ(size, out.Length());
// Check everything up to the padding. // Check everything up to the padding.
ASSERT_EQ(0, std::memcmp(out.Data(), kStunMessageWithUInt16ListAttribute, ASSERT_EQ(0,
size - 2)); memcmp(out.Data(), kStunMessageWithUInt16ListAttribute, size - 2));
} }
// Test that we fail to read messages with invalid lengths. // Test that we fail to read messages with invalid lengths.
@@ -1238,7 +1227,7 @@ TEST_F(StunTest, AddMessageIntegrity) {
const StunByteStringAttribute* mi_attr = const StunByteStringAttribute* mi_attr =
msg.GetByteString(STUN_ATTR_MESSAGE_INTEGRITY); msg.GetByteString(STUN_ATTR_MESSAGE_INTEGRITY);
EXPECT_EQ(20U, mi_attr->length()); EXPECT_EQ(20U, mi_attr->length());
EXPECT_EQ(0, std::memcmp( EXPECT_EQ(0, memcmp(
mi_attr->bytes(), kCalculatedHmac1, sizeof(kCalculatedHmac1))); mi_attr->bytes(), kCalculatedHmac1, sizeof(kCalculatedHmac1)));
talk_base::ByteBuffer buf1; talk_base::ByteBuffer buf1;
@@ -1256,8 +1245,8 @@ TEST_F(StunTest, AddMessageIntegrity) {
const StunByteStringAttribute* mi_attr2 = const StunByteStringAttribute* mi_attr2 =
msg2.GetByteString(STUN_ATTR_MESSAGE_INTEGRITY); msg2.GetByteString(STUN_ATTR_MESSAGE_INTEGRITY);
EXPECT_EQ(20U, mi_attr2->length()); EXPECT_EQ(20U, mi_attr2->length());
EXPECT_EQ(0, std::memcmp( EXPECT_EQ(
mi_attr2->bytes(), kCalculatedHmac2, sizeof(kCalculatedHmac2))); 0, memcmp(mi_attr2->bytes(), kCalculatedHmac2, sizeof(kCalculatedHmac2)));
talk_base::ByteBuffer buf3; talk_base::ByteBuffer buf3;
EXPECT_TRUE(msg2.Write(&buf3)); EXPECT_TRUE(msg2.Write(&buf3));
@@ -1401,8 +1390,10 @@ TEST_F(StunTest, ReadRelayMessage) {
bytes = msg.GetByteString(STUN_ATTR_MAGIC_COOKIE); bytes = msg.GetByteString(STUN_ATTR_MAGIC_COOKIE);
ASSERT_TRUE(bytes != NULL); ASSERT_TRUE(bytes != NULL);
EXPECT_EQ(4U, bytes->length()); EXPECT_EQ(4U, bytes->length());
EXPECT_EQ(0, std::memcmp(bytes->bytes(), TURN_MAGIC_COOKIE_VALUE, EXPECT_EQ(0,
sizeof(TURN_MAGIC_COOKIE_VALUE))); memcmp(bytes->bytes(),
TURN_MAGIC_COOKIE_VALUE,
sizeof(TURN_MAGIC_COOKIE_VALUE)));
bytes2 = StunAttribute::CreateByteString(STUN_ATTR_MAGIC_COOKIE); bytes2 = StunAttribute::CreateByteString(STUN_ATTR_MAGIC_COOKIE);
bytes2->CopyBytes(reinterpret_cast<const char*>(TURN_MAGIC_COOKIE_VALUE), bytes2->CopyBytes(reinterpret_cast<const char*>(TURN_MAGIC_COOKIE_VALUE),
@@ -1454,7 +1445,7 @@ TEST_F(StunTest, ReadRelayMessage) {
size_t len1 = out.Length(); size_t len1 = out.Length();
std::string outstring; std::string outstring;
out.ReadString(&outstring, len1); 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; talk_base::ByteBuffer out2;
EXPECT_TRUE(msg2.Write(&out2)); EXPECT_TRUE(msg2.Write(&out2));
@@ -1462,7 +1453,7 @@ TEST_F(StunTest, ReadRelayMessage) {
size_t len2 = out2.Length(); size_t len2 = out2.Length();
std::string outstring2; std::string outstring2;
out2.ReadString(&outstring2, len2); 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 } // namespace cricket

View File

@@ -119,7 +119,7 @@ TEST_F(StunServerTest, TestBad) {
const char* bad = "this is a completely nonsensical message whose only " const char* bad = "this is a completely nonsensical message whose only "
"purpose is to make the parser go 'ack'. it doesn't " "purpose is to make the parser go 'ack'. it doesn't "
"look anything like a normal stun message"; "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(); StunMessage* msg = Receive();
ASSERT_TRUE(msg == NULL); ASSERT_TRUE(msg == NULL);

View File

@@ -27,7 +27,7 @@
#include "talk/session/media/audiomonitor.h" #include "talk/session/media/audiomonitor.h"
#include "talk/session/media/voicechannel.h" #include "talk/session/media/voicechannel.h"
#include <cassert> #include <assert.h>
namespace cricket { namespace cricket {

View File

@@ -29,8 +29,9 @@
#include "talk/session/media/srtpfilter.h" #include "talk/session/media/srtpfilter.h"
#include <string.h>
#include <algorithm> #include <algorithm>
#include <cstring>
#include "talk/base/base64.h" #include "talk/base/base64.h"
#include "talk/base/logging.h" #include "talk/base/logging.h"