summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@chromium.org>2012-02-16 12:11:37 -0500
committerGerrit <chrome-bot@google.com>2012-02-16 13:44:49 -0800
commit0f9547d10fc3df51c8dd3828a495e89ed0260037 (patch)
tree9fcbdf4365cb80b329259de2f1202828d593c27e
parent1877c3938afb2cc46c959d1158316671cf3460d9 (diff)
fix build warnings with type mismatches and base check helpers
Building with base headers in a SLOT-ed setup exposes build warnings (which causes failures due to -Werror). One such example: In file included from extent_writer.h:9:0, from bzip_extent_writer.h:10, from bzip_extent_writer.cc:5: .../base/logging.h: In function 'std::string* logging::CheckEQImpl(const t1&, const t2&, const char*) [with t1 = unsigned int, t2 = int, std::string = std::basic_string<char>]': bzip_extent_writer.cc:53:7: instantiated from here .../base/logging.h:512:1: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare] cc1plus: all warnings being treated as errors Explicitly cast the constants to avoid these. BUG=chromium-os:16623 TEST=`emerge-x86-alex update_engine` builds Change-Id: If3cc4e85fa54862b14305f9d045c73b5575efaa0 Reviewed-on: https://gerrit.chromium.org/gerrit/16035 Reviewed-by: Gilad Arnold <garnold@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org> Commit-Ready: Mike Frysinger <vapier@chromium.org>
-rw-r--r--bzip_extent_writer.cc2
-rw-r--r--cycle_breaker.cc3
-rw-r--r--delta_diff_generator.cc5
-rw-r--r--extent_writer.cc2
-rw-r--r--http_fetcher_unittest.cc2
-rw-r--r--metadata.cc2
-rw-r--r--multi_range_http_fetcher.h2
-rw-r--r--test_http_server.cc12
8 files changed, 16 insertions, 14 deletions
diff --git a/bzip_extent_writer.cc b/bzip_extent_writer.cc
index e200e2db..9d432c77 100644
--- a/bzip_extent_writer.cc
+++ b/bzip_extent_writer.cc
@@ -50,7 +50,7 @@ bool BzipExtentWriter::Write(const void* bytes, size_t count) {
output_buffer.size() - stream_.avail_out));
if (rc == BZ_STREAM_END)
- CHECK_EQ(stream_.avail_in, 0);
+ CHECK_EQ(stream_.avail_in, static_cast<unsigned int>(0));
if (stream_.avail_in == 0)
break; // no more input to process
}
diff --git a/cycle_breaker.cc b/cycle_breaker.cc
index 266c2df1..84003666 100644
--- a/cycle_breaker.cc
+++ b/cycle_breaker.cc
@@ -87,7 +87,8 @@ static const size_t kMaxEdgesToConsider = 2;
void CycleBreaker::HandleCircuit() {
stack_.push_back(current_vertex_);
- CHECK_GE(stack_.size(), 2);
+ CHECK_GE(stack_.size(),
+ static_cast<std::vector<Vertex::Index>::size_type>(2));
Edge min_edge = make_pair(stack_[0], stack_[1]);
uint64_t min_edge_weight = kuint64max;
size_t edges_considered = 0;
diff --git a/delta_diff_generator.cc b/delta_diff_generator.cc
index cc8f3525..67b917f3 100644
--- a/delta_diff_generator.cc
+++ b/delta_diff_generator.cc
@@ -531,7 +531,7 @@ bool DeltaDiffGenerator::ReadFileToDiff(
vector<char> bsdiff_delta;
TEST_AND_RETURN_FALSE(
BsdiffFiles(old_filename, new_filename, &bsdiff_delta));
- CHECK_GT(bsdiff_delta.size(), 0);
+ CHECK_GT(bsdiff_delta.size(), static_cast<vector<char>::size_type>(0));
if (bsdiff_delta.size() < current_best_size) {
operation.set_type(DeltaArchiveManifest_InstallOperation_Type_BSDIFF);
current_best_size = bsdiff_delta.size();
@@ -748,7 +748,8 @@ bool DeltaDiffGenerator::CutEdges(Graph* graph,
cuts.back().tmp_extents);
// delete the old edge
- CHECK_EQ(1, (*graph)[it->first].out_edges.erase(it->second));
+ CHECK_EQ(static_cast<Graph::size_type>(1),
+ (*graph)[it->first].out_edges.erase(it->second));
// Add an edge from dst to copy operation
EdgeProperties write_before_edge_properties;
diff --git a/extent_writer.cc b/extent_writer.cc
index baac66cb..c28956b5 100644
--- a/extent_writer.cc
+++ b/extent_writer.cc
@@ -23,7 +23,7 @@ bool DirectExtentWriter::Write(const void* bytes, size_t count) {
uint64_t bytes_remaining_next_extent =
extents_[next_extent_index_].num_blocks() * block_size_ -
extent_bytes_written_;
- CHECK_NE(bytes_remaining_next_extent, 0);
+ CHECK_NE(bytes_remaining_next_extent, static_cast<uint64_t>(0));
size_t bytes_to_write =
static_cast<size_t>(min(static_cast<uint64_t>(count - bytes_written),
bytes_remaining_next_extent));
diff --git a/http_fetcher_unittest.cc b/http_fetcher_unittest.cc
index 8814f1a2..eb107ef1 100644
--- a/http_fetcher_unittest.cc
+++ b/http_fetcher_unittest.cc
@@ -421,7 +421,7 @@ TYPED_TEST(HttpFetcherTest, ErrorTest) {
// Make sure that no bytes were received.
CHECK_EQ(delegate.times_received_bytes_called_, 0);
- CHECK_EQ(fetcher->GetBytesDownloaded(), 0);
+ CHECK_EQ(fetcher->GetBytesDownloaded(), static_cast<size_t>(0));
// Make sure that transfer completion was signaled once, and no termination
// was signaled.
diff --git a/metadata.cc b/metadata.cc
index 7dfc7872..6b52f290 100644
--- a/metadata.cc
+++ b/metadata.cc
@@ -151,7 +151,7 @@ bool AddMetadataExtents(Graph* graph,
TEST_AND_RETURN_FALSE(ComputeMetadataBsdiff(old_data,
new_data,
&bsdiff_delta));
- CHECK_GT(bsdiff_delta.size(), 0);
+ CHECK_GT(bsdiff_delta.size(), static_cast<vector<char>::size_type>(0));
if (bsdiff_delta.size() < current_best_size) {
op.set_type(DeltaArchiveManifest_InstallOperation_Type_BSDIFF);
diff --git a/multi_range_http_fetcher.h b/multi_range_http_fetcher.h
index 19982efd..10829ccd 100644
--- a/multi_range_http_fetcher.h
+++ b/multi_range_http_fetcher.h
@@ -46,7 +46,7 @@ class MultiRangeHttpFetcher : public HttpFetcher, public HttpFetcherDelegate {
void ClearRanges() { ranges_.clear(); }
void AddRange(off_t offset, size_t size) {
- CHECK_GT(size, 0);
+ CHECK_GT(size, static_cast<size_t>(0));
ranges_.push_back(Range(offset, size));
}
diff --git a/test_http_server.cc b/test_http_server.cc
index af10968b..6257e07a 100644
--- a/test_http_server.cc
+++ b/test_http_server.cc
@@ -77,7 +77,7 @@ bool ParseRequest(int fd, HttpRequest* request) {
// Decode URL line.
std::vector<string> terms;
base::SplitStringAlongWhitespace(lines[0], &terms);
- CHECK_EQ(terms.size(), 3);
+ CHECK_EQ(terms.size(), static_cast<vector<string>::size_type>(3));
CHECK_EQ(terms[0], "GET");
request->url = terms[1];
LOG(INFO) << "URL: " << request->url;
@@ -89,7 +89,7 @@ bool ParseRequest(int fd, HttpRequest* request) {
base::SplitStringAlongWhitespace(lines[i], &terms);
if (terms[0] == "Range:") {
- CHECK_EQ(terms.size(), 2);
+ CHECK_EQ(terms.size(), static_cast<vector<string>::size_type>(2));
string &range = terms[1];
LOG(INFO) << "range attribute: " << range;
CHECK(StartsWithASCII(range, "bytes=", true) &&
@@ -108,7 +108,7 @@ bool ParseRequest(int fd, HttpRequest* request) {
base::StringAppendF(&tmp_str, "unspecified");
LOG(INFO) << tmp_str;
} else if (terms[0] == "Host:") {
- CHECK_EQ(terms.size(), 2);
+ CHECK_EQ(terms.size(), static_cast<vector<string>::size_type>(2));
request->host = terms[1];
LOG(INFO) << "host attribute: " << request->host;
} else {
@@ -192,7 +192,7 @@ ssize_t WriteHeaders(int fd, const off_t start_offset, const off_t end_offset,
size_t WritePayload(int fd, const off_t start_offset, const off_t end_offset,
const char first_byte, const size_t line_len) {
CHECK_LE(start_offset, end_offset);
- CHECK_GT(line_len, 0);
+ CHECK_GT(line_len, static_cast<size_t>(0));
LOG(INFO) << "writing payload: " << line_len << "-byte lines starting with `"
<< first_byte << "', offset range " << start_offset << " -> "
@@ -348,7 +348,7 @@ ssize_t HandleGet(int fd, const HttpRequest& request,
void HandleRedirect(int fd, const HttpRequest& request) {
LOG(INFO) << "Redirecting...";
string url = request.url;
- CHECK_EQ(0, url.find("/redirect/"));
+ CHECK_EQ(static_cast<size_t>(0), url.find("/redirect/"));
url.erase(0, strlen("/redirect/"));
string::size_type url_start = url.find('/');
CHECK_NE(url_start, string::npos);
@@ -439,7 +439,7 @@ class UrlTerms {
public:
UrlTerms(string &url, size_t num_terms) {
// URL must be non-empty and start with a slash.
- CHECK_GT(url.size(), 0);
+ CHECK_GT(url.size(), static_cast<size_t>(0));
CHECK_EQ(url[0], '/');
// Split it into terms delimited by slashes, omitting the preceeding slash.