[Nearby Connections][C++] Fix integer comparison and includes

PiperOrigin-RevId: 385222885
This commit is contained in:
Josh Nohle
2021-07-16 14:22:34 -07:00
committed by Copybara-Service
parent ee320905b9
commit 7c1f423014
2 changed files with 5 additions and 2 deletions
+2 -1
View File
@@ -25,6 +25,7 @@
#include "platform/base/payload_id.h"
#include "platform/base/prng.h"
#include "platform/public/file.h"
#include "platform/public/logging.h"
#include "absl/types/variant.h"
namespace location {
@@ -94,7 +95,7 @@ class Payload {
CHECK(type_ == Type::kFile || type_ == Type::kStream);
InputFile* file = AsFile();
if (file != nullptr) {
CHECK(offset < file->GetTotalSize());
CHECK(file->GetTotalSize() > 0 && offset < (size_t)file->GetTotalSize());
}
offset_ = offset;
}
+3 -1
View File
@@ -14,6 +14,7 @@
#include "platform/base/input_stream.h"
#include <algorithm>
#include <cstddef>
#include <cstdint>
@@ -22,8 +23,9 @@
namespace location {
namespace nearby {
namespace {
constexpr size_t kSkipBufferSize = 64 * 1024;
} // namespace
ExceptionOr<size_t> InputStream::Skip(size_t offset) {
size_t bytes_left = offset;