Skip to content

Commit

Permalink
Remove duplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
uweseimet committed Dec 9, 2024
1 parent 61c931d commit 1c9933f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
20 changes: 4 additions & 16 deletions cpp/s2pdump/s2pdump_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@

#include "s2pdump_executor.h"
#include <spdlog/spdlog.h>
#include "shared/memory_util.h"

using namespace spdlog;
using namespace memory_util;

void S2pDumpExecutor::TestUnitReady() const
{
Expand Down Expand Up @@ -44,7 +46,7 @@ pair<uint64_t, uint32_t> S2pDumpExecutor::ReadCapacity()
return {0, 0};
}

uint64_t capacity = GetInt32(buffer);
uint64_t capacity = GetInt32(buffer, 0);

int sector_size_offset = 4;

Expand All @@ -58,7 +60,7 @@ pair<uint64_t, uint32_t> S2pDumpExecutor::ReadCapacity()
return {0, 0};
}

capacity = GetInt64(buffer);
capacity = GetInt64(buffer, 0);

sector_size_offset = 8;
}
Expand Down Expand Up @@ -142,17 +144,3 @@ set<int> S2pDumpExecutor::ReportLuns()

return luns;
}

uint32_t S2pDumpExecutor::GetInt32(span<uint8_t> buf, int offset)
{
return (static_cast<uint32_t>(buf[offset]) << 24) | (static_cast<uint32_t>(buf[offset + 1]) << 16) |
(static_cast<uint32_t>(buf[offset + 2]) << 8) | static_cast<uint32_t>(buf[offset + 3]);
}

uint64_t S2pDumpExecutor::GetInt64(span<uint8_t> buf, int offset)
{
return (static_cast<uint64_t>(buf[offset]) << 56) | (static_cast<uint64_t>(buf[offset + 1]) << 48) |
(static_cast<uint64_t>(buf[offset + 2]) << 40) | (static_cast<uint64_t>(buf[offset + 3]) << 32) |
(static_cast<uint64_t>(buf[offset + 4]) << 24) | (static_cast<uint64_t>(buf[offset + 5]) << 16) |
(static_cast<uint64_t>(buf[offset + 6]) << 8) | static_cast<uint64_t>(buf[offset + 7]);
}
3 changes: 0 additions & 3 deletions cpp/s2pdump/s2pdump_executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,5 @@ class S2pDumpExecutor

private:

static uint32_t GetInt32(span<uint8_t>, int = 0);
static uint64_t GetInt64(span<uint8_t>, int = 0);

unique_ptr<InitiatorExecutor> initiator_executor;
};

0 comments on commit 1c9933f

Please sign in to comment.