summaryrefslogtreecommitdiff
path: root/klm/util/stream/io.cc
diff options
context:
space:
mode:
authorPatrick Simianer <simianer@cl.uni-heidelberg.de>2013-02-18 18:31:23 +0100
committerPatrick Simianer <simianer@cl.uni-heidelberg.de>2013-02-18 18:31:23 +0100
commit7deec52e8feb1c908a91224f308e8cbd9a170576 (patch)
treec8fb09523f5fef8873bd921da000d42ad5e59b6f /klm/util/stream/io.cc
parentb89fd90083b22e6d4ab469af001a1f15fbcd7da9 (diff)
parentc17d9c23d023a5c08656376944f636180f0a437b (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'klm/util/stream/io.cc')
-rw-r--r--klm/util/stream/io.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/klm/util/stream/io.cc b/klm/util/stream/io.cc
index c7ad2980..0459f706 100644
--- a/klm/util/stream/io.cc
+++ b/klm/util/stream/io.cc
@@ -29,15 +29,17 @@ void Read::Run(const ChainPosition &position) {
void PRead::Run(const ChainPosition &position) {
scoped_fd owner;
if (own_) owner.reset(file_);
- uint64_t size = SizeOrThrow(file_);
+ const uint64_t size = SizeOrThrow(file_);
UTIL_THROW_IF(size % static_cast<uint64_t>(position.GetChain().EntrySize()), ReadSizeException, "File size " << file_ << " size is " << size << " not a multiple of " << position.GetChain().EntrySize());
- std::size_t block_size = position.GetChain().BlockSize();
+ const std::size_t block_size = position.GetChain().BlockSize();
+ const uint64_t block_size64 = static_cast<uint64_t>(block_size);
Link link(position);
uint64_t offset = 0;
- for (; offset + block_size < size; offset += block_size, ++link) {
+ for (; offset + block_size64 < size; offset += block_size64, ++link) {
PReadOrThrow(file_, link->Get(), block_size, offset);
link->SetValidSize(block_size);
}
+ // size - offset is <= block_size, so it casts to 32-bit fine.
if (size - offset) {
PReadOrThrow(file_, link->Get(), size - offset, offset);
link->SetValidSize(size - offset);