0

Remove kuint16max.

BUG=138542

Committed: https://crrev.com/0d94fda8c494d7a6c27d065d782f42e99d834f46
Cr-Commit-Position: refs/heads/master@{#362431}

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

Cr-Commit-Position: refs/heads/master@{#362472}
This commit is contained in:
avi
2015-12-01 11:27:07 -08:00
committed by Commit bot
parent e5bfeba55d
commit 6516805e8c
19 changed files with 176 additions and 137 deletions

@ -27,7 +27,6 @@ typedef uint64_t uint64;
// (U)INT{8,16,32,64}_{MIN,MAX} in case of globals (and include <stdint.h>).
// http://crbug.com/138542
const uint8 kuint8max = 0xFF;
const uint16 kuint16max = 0xFFFF;
const uint32 kuint32max = 0xFFFFFFFF;
const uint64 kuint64max = 0xFFFFFFFFFFFFFFFFULL;
const int32 kint32min = -0x7FFFFFFF - 1;

@ -4,10 +4,12 @@
#include "chrome/browser/extensions/webstore_installer.h"
#include <stdint.h>
#include <limits>
#include <set>
#include <vector>
#include "base/basictypes.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/files/file_util.h"
@ -121,8 +123,8 @@ void GetDownloadFilePath(
// filename and when the download starts writing to it (think concurrently
// running sharded browser tests installing the same test file, for
// instance).
std::string random_number =
base::Uint64ToString(base::RandGenerator(kuint16max));
std::string random_number = base::Uint64ToString(
base::RandGenerator(std::numeric_limits<uint16_t>::max()));
base::FilePath file =
download_directory.AppendASCII(id + "_" + random_number + ".crx");
@ -768,14 +770,14 @@ void WebstoreInstaller::RecordInterrupt(const DownloadItem* download) const {
// Use logarithmic bin sizes up to 1 TB.
const int kNumBuckets = 30;
const int64 kMaxSizeKb = 1 << kNumBuckets;
const int64_t kMaxSizeKb = 1 << kNumBuckets;
UMA_HISTOGRAM_CUSTOM_COUNTS(
"Extensions.WebstoreDownload.InterruptReceivedKBytes",
download->GetReceivedBytes() / 1024,
1,
kMaxSizeKb,
kNumBuckets);
int64 total_bytes = download->GetTotalBytes();
int64_t total_bytes = download->GetTotalBytes();
if (total_bytes >= 0) {
UMA_HISTOGRAM_CUSTOM_COUNTS(
"Extensions.WebstoreDownload.InterruptTotalKBytes",

@ -4,9 +4,11 @@
#include "chrome/browser/sync/test/integration/sync_test.h"
#include <stdint.h>
#include <limits>
#include <vector>
#include "base/basictypes.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/guid.h"
@ -855,7 +857,7 @@ bool SyncTest::SetUpLocalPythonTestServer() {
LOG(ERROR) << "Could not find valid xmpp_port value";
return false;
}
if ((xmpp_port <= 0) || (xmpp_port > kuint16max)) {
if ((xmpp_port <= 0) || (xmpp_port > std::numeric_limits<uint16_t>::max())) {
LOG(ERROR) << "Invalid xmpp port: " << xmpp_port;
return false;
}

@ -4,6 +4,8 @@
#include "cloud_print/gcp20/prototype/command_line_reader.h"
#include <limits>
#include "base/command_line.h"
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
@ -11,8 +13,8 @@
namespace command_line_reader {
uint16 ReadHttpPort(uint16 default_value) {
uint32 http_port = 0;
uint16_t ReadHttpPort(uint16_t default_value) {
uint32_t http_port = 0;
std::string http_port_string =
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
@ -21,17 +23,17 @@ uint16 ReadHttpPort(uint16 default_value) {
if (!base::StringToUint(http_port_string, &http_port))
http_port = default_value;
if (http_port > kuint16max) {
if (http_port > std::numeric_limits<uint16_t>::max()) {
LOG(ERROR) << "HTTP Port is too large";
http_port = default_value;
}
VLOG(1) << "HTTP port for responses: " << http_port;
return static_cast<uint16>(http_port);
return static_cast<uint16_t>(http_port);
}
uint32 ReadTtl(uint32 default_value) {
uint32 ttl = 0;
uint32_t ReadTtl(uint32_t default_value) {
uint32_t ttl = 0;
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (!base::StringToUint(

@ -5,15 +5,15 @@
#ifndef CLOUD_PRINT_GCP20_PROTOTYPE_COMMAND_LINE_READER_H_
#define CLOUD_PRINT_GCP20_PROTOTYPE_COMMAND_LINE_READER_H_
#include <string>
#include <stdint.h>
#include "base/basictypes.h"
#include <string>
namespace command_line_reader {
uint16 ReadHttpPort(uint16 default_value);
uint16_t ReadHttpPort(uint16_t default_value);
uint32 ReadTtl(uint32 default_value);
uint32_t ReadTtl(uint32_t default_value);
std::string ReadServiceNamePrefix(const std::string& default_value);

@ -4,6 +4,10 @@
#include "components/policy/core/browser/url_blacklist_manager.h"
#include <stdint.h>
#include <limits>
#include "base/bind.h"
#include "base/files/file_path.h"
#include "base/location.h"
@ -137,7 +141,7 @@ struct URLBlacklist::FilterComponents {
std::string scheme;
std::string host;
uint16 port;
uint16_t port;
std::string path;
std::string query;
int number_of_key_value_pairs;
@ -235,7 +239,7 @@ bool URLBlacklist::FilterToComponents(SegmentURLCallback segment_url,
std::string* scheme,
std::string* host,
bool* match_subdomains,
uint16* port,
uint16_t* port,
std::string* path,
std::string* query) {
url::Parsed parsed;
@ -298,7 +302,7 @@ bool URLBlacklist::FilterToComponents(SegmentURLCallback segment_url,
&int_port)) {
return false;
}
if (int_port <= 0 || int_port > kuint16max)
if (int_port <= 0 || int_port > std::numeric_limits<uint16_t>::max())
return false;
*port = int_port;
} else {
@ -328,7 +332,7 @@ scoped_refptr<URLMatcherConditionSet> URLBlacklist::CreateConditionSet(
const std::string& scheme,
const std::string& host,
bool match_subdomains,
uint16 port,
uint16_t port,
const std::string& path,
const std::string& query,
bool allow) {

@ -4,6 +4,7 @@
#include "extensions/common/permissions/usb_device_permission_data.h"
#include <limits>
#include <string>
#include <tuple>
#include <vector>
@ -30,13 +31,12 @@ UsbDevicePermissionData::UsbDevicePermissionData()
: vendor_id_(0), product_id_(0), interface_id_(ANY_INTERFACE) {
}
UsbDevicePermissionData::UsbDevicePermissionData(uint16 vendor_id,
uint16 product_id,
UsbDevicePermissionData::UsbDevicePermissionData(uint16_t vendor_id,
uint16_t product_id,
int interface_id)
: vendor_id_(vendor_id),
product_id_(product_id),
interface_id_(interface_id) {
}
: vendor_id_(vendor_id),
product_id_(product_id),
interface_id_(interface_id) {}
bool UsbDevicePermissionData::Check(
const APIPermission::CheckParam* param) const {
@ -69,19 +69,19 @@ bool UsbDevicePermissionData::FromValue(const base::Value* value) {
int temp;
if (!dict_value->GetInteger(kVendorIdKey, &temp))
return false;
if (temp < 0 || temp > kuint16max)
if (temp < 0 || temp > std::numeric_limits<uint16_t>::max())
return false;
vendor_id_ = temp;
if (!dict_value->GetInteger(kProductIdKey, &temp))
return false;
if (temp < 0 || temp > kuint16max)
if (temp < 0 || temp > std::numeric_limits<uint16_t>::max())
return false;
product_id_ = temp;
if (!dict_value->GetInteger(kInterfaceIdKey, &temp))
interface_id_ = ANY_INTERFACE;
else if (temp < ANY_INTERFACE || temp > kuint8max)
else if (temp < ANY_INTERFACE || temp > std::numeric_limits<uint8_t>::max())
return false;
else
interface_id_ = temp;

@ -4,9 +4,10 @@
#ifndef EXTENSIONS_COMMON_PERMISSIONS_USB_DEVICE_PERMISSION_DATA_H_
#define EXTENSIONS_COMMON_PERMISSIONS_USB_DEVICE_PERMISSION_DATA_H_
#include <stdint.h>
#include <string>
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "extensions/common/permissions/api_permission.h"
@ -20,7 +21,7 @@ namespace extensions {
// A pattern that can be used to match a USB device permission.
// Should be of the format: vendorId:productId, where both vendorId and
// productId are decimal strings representing uint16 values.
// productId are decimal strings representing uint16_t values.
class UsbDevicePermissionData {
public:
enum SpecialInterfaces {
@ -35,8 +36,8 @@ class UsbDevicePermissionData {
};
UsbDevicePermissionData();
UsbDevicePermissionData(uint16 vendor_id,
uint16 product_id,
UsbDevicePermissionData(uint16_t vendor_id,
uint16_t product_id,
int interface_id);
// Check if |param| (which must be a UsbDevicePermissionData::CheckParam)
@ -52,17 +53,17 @@ class UsbDevicePermissionData {
bool operator<(const UsbDevicePermissionData& rhs) const;
bool operator==(const UsbDevicePermissionData& rhs) const;
const uint16& vendor_id() const { return vendor_id_; }
const uint16& product_id() const { return product_id_; }
const uint16_t& vendor_id() const { return vendor_id_; }
const uint16_t& product_id() const { return product_id_; }
// These accessors are provided for IPC_STRUCT_TRAITS_MEMBER. Please
// think twice before using them for anything else.
uint16& vendor_id() { return vendor_id_; }
uint16& product_id() { return product_id_; }
uint16_t& vendor_id() { return vendor_id_; }
uint16_t& product_id() { return product_id_; }
private:
uint16 vendor_id_;
uint16 product_id_;
uint16_t vendor_id_;
uint16_t product_id_;
int interface_id_;
};

@ -2,11 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <string>
#include "jingle/notifier/communicator/single_login_attempt.h"
#include "base/basictypes.h"
#include <stdint.h>
#include <limits>
#include <string>
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
@ -73,7 +75,7 @@ net::HostPortPair ParseRedirectText(const std::string& redirect_text) {
if (!base::StringToInt(parts[1], &port)) {
port = kDefaultXmppPort;
}
if (port <= 0 || port > kuint16max) {
if (port <= 0 || port > std::numeric_limits<uint16_t>::max()) {
port = kDefaultXmppPort;
}
redirect_server.set_port(port);

@ -4,7 +4,10 @@
#include "net/dns/dns_session.h"
#include "base/basictypes.h"
#include <stdint.h>
#include <limits>
#include "base/bind.h"
#include "base/lazy_instance.h"
#include "base/metrics/histogram_macros.h"
@ -86,7 +89,9 @@ DnsSession::DnsSession(const DnsConfig& config,
NetLog* net_log)
: config_(config),
socket_pool_(socket_pool.Pass()),
rand_callback_(base::Bind(rand_int_callback, 0, kuint16max)),
rand_callback_(base::Bind(rand_int_callback,
0,
std::numeric_limits<uint16_t>::max())),
net_log_(net_log),
server_index_(0) {
socket_pool_->Initialize(&config_.nameservers, net_log);
@ -102,8 +107,8 @@ DnsSession::~DnsSession() {
RecordServerStats();
}
uint16 DnsSession::NextQueryId() const {
return static_cast<uint16>(rand_callback_.Run());
uint16_t DnsSession::NextQueryId() const {
return static_cast<uint16_t>(rand_callback_.Run());
}
unsigned DnsSession::NextFirstServerIndex() {

@ -65,7 +65,7 @@ class NET_EXPORT_PRIVATE DnsSession
NetLog* net_log() const { return net_log_; }
// Return the next random query ID.
uint16 NextQueryId() const;
uint16_t NextQueryId() const;
// Return the index of the first configured server to use on first attempt.
unsigned NextFirstServerIndex();

@ -4,6 +4,10 @@
#include "net/dns/dns_transaction.h"
#include <stdint.h>
#include <limits>
#include "base/bind.h"
#include "base/memory/scoped_ptr.h"
#include "base/rand_util.h"
@ -33,19 +37,19 @@ std::string DomainFromDot(const base::StringPiece& dotted) {
class DnsSocketData {
public:
// The ctor takes parameters for the DnsQuery.
DnsSocketData(uint16 id,
DnsSocketData(uint16_t id,
const char* dotted_name,
uint16 qtype,
uint16_t qtype,
IoMode mode,
bool use_tcp)
: query_(new DnsQuery(id, DomainFromDot(dotted_name), qtype)),
use_tcp_(use_tcp) {
if (use_tcp_) {
scoped_ptr<uint16> length(new uint16);
scoped_ptr<uint16_t> length(new uint16_t);
*length = base::HostToNet16(query_->io_buffer()->size());
writes_.push_back(MockWrite(mode,
reinterpret_cast<const char*>(length.get()),
sizeof(uint16), num_reads_and_writes()));
sizeof(uint16_t), num_reads_and_writes()));
lengths_.push_back(length.Pass());
}
writes_.push_back(MockWrite(mode, query_->io_buffer()->data(),
@ -57,15 +61,16 @@ class DnsSocketData {
// All responses must be added before GetProvider.
// Adds pre-built DnsResponse. |tcp_length| will be used in TCP mode only.
void AddResponseWithLength(scoped_ptr<DnsResponse> response, IoMode mode,
uint16 tcp_length) {
void AddResponseWithLength(scoped_ptr<DnsResponse> response,
IoMode mode,
uint16_t tcp_length) {
CHECK(!provider_.get());
if (use_tcp_) {
scoped_ptr<uint16> length(new uint16);
scoped_ptr<uint16_t> length(new uint16_t);
*length = base::HostToNet16(tcp_length);
reads_.push_back(MockRead(mode,
reinterpret_cast<const char*>(length.get()),
sizeof(uint16), num_reads_and_writes()));
sizeof(uint16_t), num_reads_and_writes()));
lengths_.push_back(length.Pass());
}
reads_.push_back(MockRead(mode, response->io_buffer()->data(),
@ -76,12 +81,12 @@ class DnsSocketData {
// Adds pre-built DnsResponse.
void AddResponse(scoped_ptr<DnsResponse> response, IoMode mode) {
uint16 tcp_length = response->io_buffer()->size();
uint16_t tcp_length = response->io_buffer()->size();
AddResponseWithLength(response.Pass(), mode, tcp_length);
}
// Adds pre-built response from |data| buffer.
void AddResponseData(const uint8* data, size_t length, IoMode mode) {
void AddResponseData(const uint8_t* data, size_t length, IoMode mode) {
CHECK(!provider_.get());
AddResponse(make_scoped_ptr(
new DnsResponse(reinterpret_cast<const char*>(data), length, 0)), mode);
@ -121,16 +126,14 @@ class DnsSocketData {
return provider_.get();
}
uint16 query_id() const {
return query_->id();
}
uint16_t query_id() const { return query_->id(); }
private:
size_t num_reads_and_writes() const { return reads_.size() + writes_.size(); }
scoped_ptr<DnsQuery> query_;
bool use_tcp_;
std::vector<scoped_ptr<uint16>> lengths_;
std::vector<scoped_ptr<uint16_t>> lengths_;
std::vector<scoped_ptr<DnsResponse>> responses_;
std::vector<MockWrite> writes_;
std::vector<MockRead> reads_;
@ -220,15 +223,14 @@ class TransactionHelper {
public:
// If |expected_answer_count| < 0 then it is the expected net error.
TransactionHelper(const char* hostname,
uint16 qtype,
uint16_t qtype,
int expected_answer_count)
: hostname_(hostname),
qtype_(qtype),
expected_answer_count_(expected_answer_count),
cancel_in_callback_(false),
quit_in_callback_(false),
completed_(false) {
}
completed_(false) {}
// Mark that the transaction shall be destroyed immediately upon callback.
void set_cancel_in_callback() {
@ -314,7 +316,7 @@ class TransactionHelper {
private:
std::string hostname_;
uint16 qtype_;
uint16_t qtype_;
scoped_ptr<DnsTransaction> transaction_;
int expected_answer_count_;
bool cancel_in_callback_;
@ -364,10 +366,10 @@ class DnsTransactionTest : public testing::Test {
// Add expected query for |dotted_name| and |qtype| with |id| and response
// taken verbatim from |data| of |data_length| bytes. The transaction id in
// |data| should equal |id|, unless testing mismatched response.
void AddQueryAndResponse(uint16 id,
void AddQueryAndResponse(uint16_t id,
const char* dotted_name,
uint16 qtype,
const uint8* response_data,
uint16_t qtype,
const uint8_t* response_data,
size_t response_length,
IoMode mode,
bool use_tcp) {
@ -378,27 +380,27 @@ class DnsTransactionTest : public testing::Test {
AddSocketData(data.Pass());
}
void AddAsyncQueryAndResponse(uint16 id,
void AddAsyncQueryAndResponse(uint16_t id,
const char* dotted_name,
uint16 qtype,
const uint8* data,
uint16_t qtype,
const uint8_t* data,
size_t data_length) {
AddQueryAndResponse(id, dotted_name, qtype, data, data_length, ASYNC,
false);
}
void AddSyncQueryAndResponse(uint16 id,
void AddSyncQueryAndResponse(uint16_t id,
const char* dotted_name,
uint16 qtype,
const uint8* data,
uint16_t qtype,
const uint8_t* data,
size_t data_length) {
AddQueryAndResponse(id, dotted_name, qtype, data, data_length, SYNCHRONOUS,
false);
}
// Add expected query of |dotted_name| and |qtype| and no response.
void AddQueryAndTimeout(const char* dotted_name, uint16 qtype) {
uint16 id = base::RandInt(0, kuint16max);
void AddQueryAndTimeout(const char* dotted_name, uint16_t qtype) {
uint16_t id = base::RandInt(0, std::numeric_limits<uint16_t>::max());
scoped_ptr<DnsSocketData> data(
new DnsSocketData(id, dotted_name, qtype, ASYNC, false));
AddSocketData(data.Pass());
@ -407,23 +409,27 @@ class DnsTransactionTest : public testing::Test {
// Add expected query of |dotted_name| and |qtype| and matching response with
// no answer and RCODE set to |rcode|. The id will be generated randomly.
void AddQueryAndRcode(const char* dotted_name,
uint16 qtype,
uint16_t qtype,
int rcode,
IoMode mode,
bool use_tcp) {
CHECK_NE(dns_protocol::kRcodeNOERROR, rcode);
uint16 id = base::RandInt(0, kuint16max);
uint16_t id = base::RandInt(0, std::numeric_limits<uint16_t>::max());
scoped_ptr<DnsSocketData> data(
new DnsSocketData(id, dotted_name, qtype, mode, use_tcp));
data->AddRcode(rcode, mode);
AddSocketData(data.Pass());
}
void AddAsyncQueryAndRcode(const char* dotted_name, uint16 qtype, int rcode) {
void AddAsyncQueryAndRcode(const char* dotted_name,
uint16_t qtype,
int rcode) {
AddQueryAndRcode(dotted_name, qtype, rcode, ASYNC, false);
}
void AddSyncQueryAndRcode(const char* dotted_name, uint16 qtype, int rcode) {
void AddSyncQueryAndRcode(const char* dotted_name,
uint16_t qtype,
int rcode) {
AddQueryAndRcode(dotted_name, qtype, rcode, SYNCHRONOUS, false);
}
@ -784,19 +790,15 @@ TEST_F(DnsTransactionTest, DontAppendToMultiLabelName) {
EXPECT_TRUE(helper2.Run(transaction_factory_.get()));
}
const uint8 kResponseNoData[] = {
0x00, 0x00, 0x81, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
// Question
0x01, 'x', 0x01, 'y', 0x01, 'z', 0x01, 'b', 0x00, 0x00, 0x01, 0x00, 0x01,
// Authority section, SOA record, TTL 0x3E6
0x01, 'z', 0x00, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x03, 0xE6,
// Minimal RDATA, 18 bytes
0x00, 0x12,
0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
const uint8_t kResponseNoData[] = {
0x00, 0x00, 0x81, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
// Question
0x01, 'x', 0x01, 'y', 0x01, 'z', 0x01, 'b', 0x00, 0x00, 0x01, 0x00, 0x01,
// Authority section, SOA record, TTL 0x3E6
0x01, 'z', 0x00, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x03, 0xE6,
// Minimal RDATA, 18 bytes
0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
TEST_F(DnsTransactionTest, SuffixSearchStop) {
@ -915,8 +917,7 @@ TEST_F(DnsTransactionTest, TCPMalformed) {
make_scoped_ptr(
new DnsResponse(reinterpret_cast<const char*>(kT0ResponseDatagram),
arraysize(kT0ResponseDatagram), 0)),
ASYNC,
static_cast<uint16>(kT0QuerySize - 1));
ASYNC, static_cast<uint16_t>(kT0QuerySize - 1));
AddSocketData(data.Pass());
TransactionHelper helper0(kT0HostName, kT0Qtype, ERR_DNS_MALFORMED_RESPONSE);
@ -945,8 +946,7 @@ TEST_F(DnsTransactionTest, TCPReadReturnsZeroAsync) {
make_scoped_ptr(
new DnsResponse(reinterpret_cast<const char*>(kT0ResponseDatagram),
arraysize(kT0ResponseDatagram) - 1, 0)),
ASYNC,
static_cast<uint16>(arraysize(kT0ResponseDatagram)));
ASYNC, static_cast<uint16_t>(arraysize(kT0ResponseDatagram)));
// Then return a 0-length read.
data->AddReadError(0, ASYNC);
AddSocketData(data.Pass());
@ -965,8 +965,7 @@ TEST_F(DnsTransactionTest, TCPReadReturnsZeroSynchronous) {
make_scoped_ptr(
new DnsResponse(reinterpret_cast<const char*>(kT0ResponseDatagram),
arraysize(kT0ResponseDatagram) - 1, 0)),
SYNCHRONOUS,
static_cast<uint16>(arraysize(kT0ResponseDatagram)));
SYNCHRONOUS, static_cast<uint16_t>(arraysize(kT0ResponseDatagram)));
// Then return a 0-length read.
data->AddReadError(0, SYNCHRONOUS);
AddSocketData(data.Pass());

@ -4,6 +4,9 @@
#include "net/test/spawned_test_server/base_test_server.h"
#include <stdint.h>
#include <limits>
#include <string>
#include <vector>
@ -285,11 +288,11 @@ bool BaseTestServer::GetAddressList(AddressList* address_list) const {
return true;
}
uint16 BaseTestServer::GetPort() {
uint16_t BaseTestServer::GetPort() {
return host_port_pair_.port();
}
void BaseTestServer::SetPort(uint16 port) {
void BaseTestServer::SetPort(uint16_t port) {
host_port_pair_.set_port(port);
}
@ -414,7 +417,7 @@ bool BaseTestServer::ParseServerData(const std::string& server_data) {
LOG(ERROR) << "Could not find port value";
return false;
}
if ((port <= 0) || (port > kuint16max)) {
if ((port <= 0) || (port > std::numeric_limits<uint16_t>::max())) {
LOG(ERROR) << "Invalid port value: " << port;
return false;
}

@ -4,6 +4,9 @@
#include "net/test/spawned_test_server/remote_test_server.h"
#include <stdint.h>
#include <limits>
#include <vector>
#include "base/base_paths.h"
@ -108,7 +111,7 @@ bool RemoteTestServer::Start() {
return false;
// Start the Python test server on the remote machine.
uint16 test_server_port;
uint16_t test_server_port;
if (!spawner_communicator_->StartServer(arguments_string,
&test_server_port)) {
return false;
@ -184,13 +187,15 @@ bool RemoteTestServer::Init(const base::FilePath& document_root) {
// Verify the ports information.
base::StringToInt(ports[0], &spawner_server_port_);
if (!spawner_server_port_ ||
static_cast<uint32>(spawner_server_port_) >= kuint16max)
static_cast<uint32_t>(spawner_server_port_) >=
std::numeric_limits<uint16_t>::max())
return false;
// Allow the test_server_port to be 0, which means the test server spawner
// will pick up a random port to run the test server.
base::StringToInt(ports[1], &test_server_port);
if (static_cast<uint32>(test_server_port) >= kuint16max)
if (static_cast<uint32_t>(test_server_port) >=
std::numeric_limits<uint16_t>::max())
return false;
SetPort(test_server_port);

@ -4,6 +4,8 @@
#include "net/test/spawned_test_server/spawner_communicator.h"
#include <limits>
#include "base/json/json_reader.h"
#include "base/logging.h"
#include "base/strings/stringprintf.h"
@ -24,7 +26,7 @@ namespace net {
namespace {
GURL GenerateSpawnerCommandURL(const std::string& command, uint16 port) {
GURL GenerateSpawnerCommandURL(const std::string& command, uint16_t port) {
// Always performs HTTP request for sending command to the spawner server.
return GURL(base::StringPrintf("%s:%u/%s", "http://127.0.0.1", port,
command.c_str()));
@ -98,7 +100,7 @@ class SpawnerRequestData : public base::SupportsUserData::Data {
} // namespace
SpawnerCommunicator::SpawnerCommunicator(uint16 port)
SpawnerCommunicator::SpawnerCommunicator(uint16_t port)
: io_thread_("spawner_communicator"),
event_(false, false),
port_(port),
@ -324,7 +326,7 @@ void SpawnerCommunicator::OnReadCompleted(URLRequest* request, int num_bytes) {
}
bool SpawnerCommunicator::StartServer(const std::string& arguments,
uint16* port) {
uint16_t* port) {
*port = 0;
// Send the start command to spawner server to start the Python test server
// on remote machine.
@ -352,11 +354,11 @@ bool SpawnerCommunicator::StartServer(const std::string& arguments,
}
int int_port;
if (!server_data->GetInteger("port", &int_port) || int_port <= 0 ||
int_port > kuint16max) {
int_port > std::numeric_limits<uint16_t>::max()) {
LOG(ERROR) << "Invalid port value: " << int_port;
return false;
}
*port = static_cast<uint16>(int_port);
*port = static_cast<uint16_t>(int_port);
return true;
}

@ -5,9 +5,10 @@
#ifndef NET_TEST_SPAWNED_TEST_SERVER_SPAWNER_COMMUNICATOR_H_
#define NET_TEST_SPAWNED_TEST_SERVER_SPAWNER_COMMUNICATOR_H_
#include <stdint.h>
#include <string>
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/synchronization/waitable_event.h"
@ -60,7 +61,7 @@ class ScopedPortException;
// fetched from spawner server or timed-out.
class SpawnerCommunicator : public URLRequest::Delegate {
public:
explicit SpawnerCommunicator(uint16 port);
explicit SpawnerCommunicator(uint16_t port);
~SpawnerCommunicator() override;
// Starts an instance of the Python test server on the host/ machine.
@ -68,7 +69,7 @@ class SpawnerCommunicator : public URLRequest::Delegate {
// on the local machine that can be used to communicate with the remote
// test server.
bool StartServer(const std::string& arguments,
uint16* port) WARN_UNUSED_RESULT;
uint16_t* port) WARN_UNUSED_RESULT;
bool StopServer() WARN_UNUSED_RESULT;
@ -122,7 +123,7 @@ class SpawnerCommunicator : public URLRequest::Delegate {
// used to control the startup and shutdown of the Python TestServer running
// on the remote machine. On Android, this port will be redirected to the
// same port on the host machine.
const uint16 port_;
const uint16_t port_;
// Helper to add |port_| to the list of the globally explicitly allowed ports.
scoped_ptr<ScopedPortException> allowed_port_;

@ -2,12 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <stdint.h>
#include <algorithm>
#include <limits>
#include <sstream>
#include <string>
#include <vector>
#include "base/basictypes.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/json/json_reader.h"
@ -39,15 +41,17 @@ void CrashNullPointerDereference(void) {
}
bool FitsUint8(int num) {
return (num >= 0) && (num <= kuint8max);
return (num >= 0) && (num <= std::numeric_limits<uint8_t>::max());
}
bool FitsUint16(int num) {
return (num >= 0) && (num <= kuint16max);
return (num >= 0) && (num <= std::numeric_limits<uint16_t>::max());
}
bool ReadTestCase(const char* filename,
uint16* id, std::string* qname, uint16* qtype,
uint16_t* id,
std::string* qname,
uint16_t* qtype,
std::vector<char>* resp_buf,
bool* crash_test) {
base::FilePath filepath = base::FilePath::FromUTF8Unsafe(filename);
@ -85,7 +89,7 @@ bool ReadTestCase(const char* filename,
LOG(ERROR) << filename << ": id is out of range.";
return false;
}
*id = static_cast<uint16>(id_int);
*id = static_cast<uint16_t>(id_int);
if (!dict->GetStringASCII("qname", qname)) {
LOG(ERROR) << filename << ": qname is missing or not a string.";
@ -101,7 +105,7 @@ bool ReadTestCase(const char* filename,
LOG(ERROR) << filename << ": qtype is out of range.";
return false;
}
*qtype = static_cast<uint16>(qtype_int);
*qtype = static_cast<uint16_t>(qtype_int);
base::ListValue* resp_list;
if (!dict->GetList("response", &resp_list)) {
@ -134,7 +138,9 @@ bool ReadTestCase(const char* filename,
return true;
}
void RunTestCase(uint16 id, std::string& qname, uint16 qtype,
void RunTestCase(uint16_t id,
std::string& qname,
uint16_t qtype,
std::vector<char>& resp_buf) {
net::DnsQuery query(id, qname, qtype);
net::DnsResponse response;
@ -165,9 +171,9 @@ void RunTestCase(uint16 id, std::string& qname, uint16 qtype,
}
bool ReadAndRunTestCase(const char* filename) {
uint16 id = 0;
uint16_t id = 0;
std::string qname;
uint16 qtype = 0;
uint16_t qtype = 0;
std::vector<char> resp_buf;
bool crash_test = false;

@ -290,7 +290,8 @@ NTSTATUS AllocAndGetFullPath(HANDLE root,
// Hacky code... replace with AllocAndCopyObjectAttributes.
NTSTATUS AllocAndCopyName(const OBJECT_ATTRIBUTES* in_object,
wchar_t** out_name, uint32* attributes,
wchar_t** out_name,
uint32_t* attributes,
HANDLE* root) {
if (!InitHeap())
return STATUS_NO_MEMORY;
@ -433,7 +434,7 @@ UNICODE_STRING* AnsiToUnicode(const char* string) {
return out_string;
}
UNICODE_STRING* GetImageInfoFromModule(HMODULE module, uint32* flags) {
UNICODE_STRING* GetImageInfoFromModule(HMODULE module, uint32_t* flags) {
// PEImage's dtor won't be run during SEH unwinding, but that's OK.
#pragma warning(push)
#pragma warning(disable: 4509)
@ -529,7 +530,7 @@ UNICODE_STRING* ExtractModuleName(const UNICODE_STRING* module_path) {
// Based on the code above, size_bytes should always be small enough
// to make the static_cast below safe.
DCHECK_NT(kuint16max > size_bytes);
DCHECK_NT(UINT16_MAX > size_bytes);
char* str_buffer = new(NT_ALLOC) char[size_bytes + sizeof(UNICODE_STRING)];
if (!str_buffer)
return NULL;
@ -585,8 +586,9 @@ NTSTATUS AutoProtectMemory::RevertProtection() {
return ret;
}
bool IsSupportedRenameCall(FILE_RENAME_INFORMATION* file_info, DWORD length,
uint32 file_info_class) {
bool IsSupportedRenameCall(FILE_RENAME_INFORMATION* file_info,
DWORD length,
uint32_t file_info_class) {
if (FileRenameInformation != file_info_class)
return false;
@ -606,7 +608,7 @@ bool IsSupportedRenameCall(FILE_RENAME_INFORMATION* file_info, DWORD length,
// Check if it starts with \\??\\. We don't support relative paths.
if (file_info->FileNameLength < sizeof(kPathPrefix) ||
file_info->FileNameLength > kuint16max)
file_info->FileNameLength > UINT16_MAX)
return false;
if (file_info->FileName[0] != kPathPrefix[0] ||

@ -6,8 +6,9 @@
#define SANDBOX_SRC_SANDBOX_NT_UTIL_H_
#include <intrin.h>
#include <stdint.h>
#include "base/basictypes.h"
#include "base/macros.h"
#include "sandbox/win/src/nt_internals.h"
#include "sandbox/win/src/sandbox_nt_types.h"
@ -101,7 +102,9 @@ NTSTATUS CopyData(void* destination, const void* source, size_t bytes);
// Copies the name from an object attributes.
NTSTATUS AllocAndCopyName(const OBJECT_ATTRIBUTES* in_object,
wchar_t** out_name, uint32* attributes, HANDLE* root);
wchar_t** out_name,
uint32_t* attributes,
HANDLE* root);
// Determine full path name from object root and path.
NTSTATUS AllocAndGetFullPath(HANDLE root,
@ -134,7 +137,7 @@ enum MappedModuleFlags {
// }
// InsertYourLogicHere(name);
// operator delete(name, NT_ALLOC);
UNICODE_STRING* GetImageInfoFromModule(HMODULE module, uint32* flags);
UNICODE_STRING* GetImageInfoFromModule(HMODULE module, uint32_t* flags);
// Returns the full path and filename for a given dll.
// May return NULL if the provided address is not backed by a named section, or
@ -182,8 +185,9 @@ class AutoProtectMemory {
// Returns true if the file_rename_information structure is supported by our
// rename handler.
bool IsSupportedRenameCall(FILE_RENAME_INFORMATION* file_info, DWORD length,
uint32 file_info_class);
bool IsSupportedRenameCall(FILE_RENAME_INFORMATION* file_info,
DWORD length,
uint32_t file_info_class);
} // namespace sandbox