in resolution of [Wsign-compare] warning ids : [22, 23, 24, 25, 26, 27]

This commit is contained in:
Tare Gaskin 2020-06-04 20:27:56 +00:00
parent f25945196e
commit 49cf3e2341
6 changed files with 12 additions and 12 deletions

View File

@ -187,7 +187,7 @@ void TensorShapeBase<Shape>::InitDims(gtl::ArraySlice<int64> dim_sizes) {
"bad overflow check"); "bad overflow check");
bool large_size = false; bool large_size = false;
for (auto s : dim_sizes) { for (auto s : dim_sizes) {
if (s > kMaxSmall) { if (static_cast<size_t>(s) > static_cast<size_t>(kMaxSmall)) {
large_size = true; large_size = true;
break; break;
} }

View File

@ -85,7 +85,7 @@ Status InputBuffer::ReadNBytes(int64 bytes_to_read, string* result) {
result->resize(bytes_to_read); result->resize(bytes_to_read);
size_t bytes_read = 0; size_t bytes_read = 0;
Status status = ReadNBytes(bytes_to_read, &(*result)[0], &bytes_read); Status status = ReadNBytes(bytes_to_read, &(*result)[0], &bytes_read);
if (bytes_read < bytes_to_read) result->resize(bytes_read); if (static_cast<int64>(bytes_read) < bytes_to_read) result->resize(bytes_read);
return status; return status;
} }
@ -204,7 +204,7 @@ Status InputBuffer::Hint(int64 bytes_to_read) {
} }
// The internal buffer is too small. Do nothing. // The internal buffer is too small. Do nothing.
if (bytes_to_read > size_) { if (bytes_to_read > static_cast<int64>(size_)) {
return Status::OK(); return Status::OK();
} }
@ -230,7 +230,7 @@ Status InputBuffer::Hint(int64 bytes_to_read) {
limit_ += data.size(); limit_ += data.size();
file_pos_ += data.size(); file_pos_ += data.size();
if (errors::IsOutOfRange(s) && data.size() == bytes_to_read) { if (errors::IsOutOfRange(s) && data.size() == static_cast<size_t>(bytes_to_read)) {
return Status::OK(); return Status::OK();
} else { } else {
return s; return s;

View File

@ -92,7 +92,7 @@ Status RandomAccessInputStream::SkipNBytes(int64 bytes_to_skip) {
} else { } else {
return s; return s;
} }
if (data.size() < bytes_to_read) { if (data.size() < static_cast<size_t>(bytes_to_read)) {
return errors::OutOfRange("reached end of file"); return errors::OutOfRange("reached end of file");
} }
bytes_to_skip -= bytes_to_read; bytes_to_skip -= bytes_to_read;

View File

@ -134,7 +134,7 @@ Status SnappyInputBuffer::ReadCompressedBlockLength(uint32* length) {
} }
size_t readable = std::min(bytes_to_read, avail_in_); size_t readable = std::min(bytes_to_read, avail_in_);
for (int i = 0; i < readable; i++) { for (size_t i = 0; i < readable; i++) {
// The "unsigned char" type cast is intentional to avoid implicit type // The "unsigned char" type cast is intentional to avoid implicit type
// casting of the signed char to unsigned int during bitwise OR which // casting of the signed char to unsigned int during bitwise OR which
// causes weird overflow errors. // causes weird overflow errors.

View File

@ -76,7 +76,7 @@ Status SnappyOutputBuffer::Write(StringPiece data) {
// If there is sufficient free space in input_buffer_ to fit data we // If there is sufficient free space in input_buffer_ to fit data we
// add it there and return. // add it there and return.
if (bytes_to_write <= AvailableInputSpace()) { if (static_cast<int32>(bytes_to_write) <= AvailableInputSpace()) {
AddToInputBuffer(data); AddToInputBuffer(data);
return Status::OK(); return Status::OK();
} }
@ -87,7 +87,7 @@ Status SnappyOutputBuffer::Write(StringPiece data) {
TF_RETURN_IF_ERROR(DeflateBuffered()); TF_RETURN_IF_ERROR(DeflateBuffered());
// input_buffer_ should be empty at this point. // input_buffer_ should be empty at this point.
if (bytes_to_write <= AvailableInputSpace()) { if (static_cast<int32>(bytes_to_write) <= AvailableInputSpace()) {
AddToInputBuffer(data); AddToInputBuffer(data);
return Status::OK(); return Status::OK();
} }
@ -144,7 +144,7 @@ void SnappyOutputBuffer::AddToInputBuffer(StringPiece data) {
const int32 free_tail_bytes = const int32 free_tail_bytes =
input_buffer_capacity_ - (read_bytes + unread_bytes); input_buffer_capacity_ - (read_bytes + unread_bytes);
if (bytes_to_write > free_tail_bytes) { if (static_cast<int32>(bytes_to_write) > free_tail_bytes) {
memmove(input_buffer_.get(), next_in_, avail_in_); memmove(input_buffer_.get(), next_in_, avail_in_);
next_in_ = input_buffer_.get(); next_in_ = input_buffer_.get();
} }

View File

@ -98,7 +98,7 @@ void ZlibOutputBuffer::AddToInputBuffer(StringPiece data) {
int32 unread_bytes = z_stream_->avail_in; int32 unread_bytes = z_stream_->avail_in;
int32 free_tail_bytes = input_buffer_capacity_ - (read_bytes + unread_bytes); int32 free_tail_bytes = input_buffer_capacity_ - (read_bytes + unread_bytes);
if (bytes_to_write > free_tail_bytes) { if (static_cast<int32>(bytes_to_write) > free_tail_bytes) {
memmove(z_stream_input_.get(), z_stream_->next_in, z_stream_->avail_in); memmove(z_stream_input_.get(), z_stream_->next_in, z_stream_->avail_in);
z_stream_->next_in = z_stream_input_.get(); z_stream_->next_in = z_stream_input_.get();
} }
@ -154,7 +154,7 @@ Status ZlibOutputBuffer::Append(StringPiece data) {
size_t bytes_to_write = data.size(); size_t bytes_to_write = data.size();
if (bytes_to_write <= AvailableInputSpace()) { if (static_cast<int32>(bytes_to_write) <= AvailableInputSpace()) {
AddToInputBuffer(data); AddToInputBuffer(data);
return Status::OK(); return Status::OK();
} }
@ -162,7 +162,7 @@ Status ZlibOutputBuffer::Append(StringPiece data) {
TF_RETURN_IF_ERROR(DeflateBuffered(zlib_options_.flush_mode)); TF_RETURN_IF_ERROR(DeflateBuffered(zlib_options_.flush_mode));
// At this point input stream should be empty. // At this point input stream should be empty.
if (bytes_to_write <= AvailableInputSpace()) { if (static_cast<int32>(bytes_to_write) <= AvailableInputSpace()) {
AddToInputBuffer(data); AddToInputBuffer(data);
return Status::OK(); return Status::OK();
} }