Skip to content

Commit

Permalink
Fix unused result errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
szmyd committed Sep 26, 2023
1 parent a5646bb commit f757951
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
18 changes: 12 additions & 6 deletions src/lib/file/blob_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ BlobManager::Result< blob_id > FileHomeObject::_put_blob(ShardInfo const& _shard
WITH_ROUTE(shard.shard_offset_.fetch_add(t_size, std::memory_order_relaxed))
WITH_SHARD_FILE(O_WRONLY)

pwrite(shard_fd, &h_size, sizeof(h_size), route.blob);
pwrite(shard_fd, serialize.c_str(), h_size, sizeof(h_size) + route.blob);
pwrite(shard_fd, _blob.body.bytes, _blob.body.size, sizeof(h_size) + h_size + route.blob);
auto err = pwrite(shard_fd, &h_size, sizeof(h_size), route.blob);
RELEASE_ASSERT(sizeof(h_size) == err, "Failed to write to: {}", shard_file.string());
err = err || pwrite(shard_fd, serialize.c_str(), h_size, sizeof(h_size) + route.blob);
RELEASE_ASSERT(h_size == err, "Failed to write to: {}", shard_file.string());
err = err || pwrite(shard_fd, _blob.body.bytes, _blob.body.size, sizeof(h_size) + h_size + route.blob);
RELEASE_ASSERT(_blob.body.size == err, "Failed to write to: {}", shard_file.string());
auto [_, happened] = shard.btree_.try_emplace(route, true);
RELEASE_ASSERT(happened, "Generated duplicate BlobRoute!");
close(shard_fd);
Expand All @@ -56,15 +59,18 @@ BlobManager::Result< Blob > FileHomeObject::_get_blob(ShardInfo const& _shard, b
IF_BLOB_ALIVE {
WITH_SHARD_FILE(O_RDONLY)
size_t h_size = 0ull;
pread(shard_fd, &h_size, sizeof(h_size), route.blob);
auto err = pread(shard_fd, &h_size, sizeof(h_size), route.blob);
RELEASE_ASSERT(sizeof(h_size) == err, "Failed to read from: {}", shard_file.string());

auto j_str = std::string(h_size, '\0');
pread(shard_fd, const_cast< char* >(j_str.c_str()), h_size, sizeof(h_size) + route.blob);
err = pread(shard_fd, const_cast< char* >(j_str.c_str()), h_size, sizeof(h_size) + route.blob);
RELEASE_ASSERT(h_size == err, "Failed to read from: {}", shard_file.string());
auto shard_json = nlohmann::json::parse(j_str);

auto const body_size = shard_json["body_size"].get< uint64_t >();
auto b = Blob{sisl::io_blob_safe(body_size), "", 0};
pread(shard_fd, b.body.bytes, body_size, sizeof(h_size) + h_size + route.blob);
err = pread(shard_fd, b.body.bytes, body_size, sizeof(h_size) + h_size + route.blob);
RELEASE_ASSERT(body_size == err, "Failed to read from: {}", shard_file.string());

b.user_key = shard_json["user_key"].get< std::string >();
b.object_off = shard_json["object_off"].get< uint64_t >();
Expand Down
3 changes: 2 additions & 1 deletion src/lib/file/shard_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ ShardManager::Result< ShardInfo > FileHomeObject::_create_shard(pg_id pg_owner,
j["available_capacity"] = info.available_capacity_bytes;
j["deleted_capacity"] = info.deleted_capacity_bytes;
auto serialize = j.dump();
pwrite(shard_fd, serialize.c_str(), serialize.size(), 0ull);
auto err = pwrite(shard_fd, serialize.c_str(), serialize.size(), 0ull);
RELEASE_ASSERT(serialize.size() == err, "Failed to write to: {}", shard_file.string());

auto [it, happened] = index_.try_emplace(info.id, std::make_unique< ShardIndex >());
RELEASE_ASSERT(happened, "Could not create BTree!");
Expand Down

0 comments on commit f757951

Please sign in to comment.