Skip to content

Commit

Permalink
Revert "Change cdb_t data type to uint8_t"
Browse files Browse the repository at this point in the history
This reverts commit 0252e67.
  • Loading branch information
uweseimet committed Dec 31, 2024
1 parent 0252e67 commit e15a826
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 14 deletions.
6 changes: 1 addition & 5 deletions cpp/controllers/abstract_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,20 +143,16 @@ class AbstractController : public PhaseHandler

private:

array<uint8_t, 16> cdb = { };
array<int, 16> cdb = { };

// Shared transfer data buffer, dynamically resized
inline static auto buffer = vector<uint8_t>(512);

// Transfer offset
int offset = 0;

// Total remaining bytes to be transferred, updated during the transfer
int remaining_length = 0;

// Remaining bytes to be transferred in a single handshake cycle
int current_length = 0;

// The number of bytes to be transferred with the current handshake cycle
int chunk_size = 0;

Expand Down
2 changes: 1 addition & 1 deletion cpp/devices/host_services.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ int HostServices::ModeSense6(cdb_t cdb, data_in_t buf) const
throw ScsiException(SenseKey::ILLEGAL_REQUEST, Asc::INVALID_FIELD_IN_CDB);
}

const int length = min(static_cast<int>(buf.size()), static_cast<int>(cdb[4]));
const int length = min(static_cast<int>(buf.size()), cdb[4]);
fill_n(buf.begin(), length, 0);

const int size = page_handler->AddModePages(cdb, buf, 4, length, 255);
Expand Down
2 changes: 1 addition & 1 deletion cpp/devices/storage_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ int StorageDevice::ModeSense6(cdb_t cdb, data_in_t buf) const
throw ScsiException(SenseKey::ILLEGAL_REQUEST, Asc::INVALID_FIELD_IN_CDB);
}

const int length = min(static_cast<int>(buf.size()), static_cast<int>(cdb[4]));
const int length = min(static_cast<int>(buf.size()), cdb[4]);
fill_n(buf.begin(), length, 0);

int size = 0;
Expand Down
2 changes: 1 addition & 1 deletion cpp/shared/s2p_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ enum class ProtobufFormat
};

// Command Descriptor Block
using cdb_t = span<const uint8_t>;
using cdb_t = span<const int>;

using data_in_t = span<uint8_t>;
using data_out_t = span<const uint8_t>;
Expand Down
2 changes: 1 addition & 1 deletion cpp/test/disk_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ TEST(DiskTest, WriteData)
{
MockDisk disk;

EXPECT_THAT([&] {disk.WriteData( vector {static_cast<uint8_t>(ScsiCommand::WRITE_6)}, {}, 0, 0);}, Throws<ScsiException>(AllOf(
EXPECT_THAT([&] {disk.WriteData( vector {static_cast<int>(ScsiCommand::WRITE_6)}, {}, 0, 0);}, Throws<ScsiException>(AllOf(
Property(&ScsiException::get_sense_key, SenseKey::NOT_READY),
Property(&ScsiException::get_asc, Asc::MEDIUM_NOT_PRESENT)))) << "Disk is not ready";
}
Expand Down
8 changes: 4 additions & 4 deletions cpp/test/test_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ pair<shared_ptr<MockAbstractController>, shared_ptr<PrimaryDevice>> testing::Cre
return {controller, device};
}

vector<uint8_t> testing::CreateCdb(ScsiCommand cmd, const string &hex)
vector<int> testing::CreateCdb(ScsiCommand cmd, const string &hex)
{
vector<uint8_t> cdb;
cdb.emplace_back(static_cast<uint8_t>(cmd));
ranges::transform(HexToBytes(hex), back_inserter(cdb), [](const byte b) {return static_cast<uint8_t>(b);});
vector<int> cdb;
cdb.emplace_back(static_cast<int>(cmd));
ranges::transform(HexToBytes(hex), back_inserter(cdb), [](const byte b) {return static_cast<int>(b);});
if (CommandMetaData::Instance().GetByteCount(cmd)) {
cdb.resize(CommandMetaData::Instance().GetByteCount(cmd));
}
Expand Down
2 changes: 1 addition & 1 deletion cpp/test/test_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace testing
pair<shared_ptr<MockAbstractController>, shared_ptr<PrimaryDevice>> CreateDevice(PbDeviceType, int lun = 0,
const string& = "");

vector<uint8_t> CreateCdb(ScsiCommand, const string& = "");
vector<int> CreateCdb(ScsiCommand, const string& = "");
vector<uint8_t> CreateParameters(const string&);

string CreateImageFile(StorageDevice&, size_t = 4096, const string& = "");
Expand Down

0 comments on commit e15a826

Please sign in to comment.