Skip to content

Commit 275ba75

Browse files
undo unnecessary partial change
1 parent cc36385 commit 275ba75

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

scsi.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ scsi::~scsi()
9191
// 0: pointer
9292
// 1: size of data
9393
// 2: how much is allowed to be written of it by iSCSI layer
94-
std::optional<scsi_response> scsi::send(const uint64_t lun, const uint8_t *const CDB, const size_t size, std::tuple<uint8_t *, size_t> data)
94+
std::optional<scsi_response> scsi::send(const uint64_t lun, const uint8_t *const CDB, const size_t size, std::pair<uint8_t *, size_t> data)
9595
{
9696
assert(size >= 16);
9797

@@ -397,11 +397,11 @@ std::optional<scsi_response> scsi::send(const uint64_t lun, const uint8_t *const
397397
DOLOG(logging::ll_debug, "scsi::send", lun_identifier, "WRITE_1x parameters invalid");
398398
response.sense_data = vr.value();
399399
}
400-
else if (std::get<0>(data)) {
401-
DOLOG(logging::ll_debug, "scsi::send", lun_identifier, "write command includes data (%zu bytes)", std::get<1>(data));
400+
else if (data.first) {
401+
DOLOG(logging::ll_debug, "scsi::send", lun_identifier, "write command includes data (%zu bytes)", data.second);
402402

403403
size_t expected_size = transfer_length * backend_block_size;
404-
size_t received_size = std::get<1>(data);
404+
size_t received_size = data.second;
405405
size_t received_blocks = received_size / backend_block_size;
406406
if (received_blocks)
407407
DOLOG(logging::ll_debug, "scsi::send", lun_identifier, "WRITE_xx to LBA %" PRIu64 " is %zu in bytes, %zu bytes", lba, lba * backend_block_size, received_size);
@@ -411,7 +411,7 @@ std::optional<scsi_response> scsi::send(const uint64_t lun, const uint8_t *const
411411

412412
uint32_t work_n_blocks = std::min(transfer_length, uint32_t(received_blocks));
413413
if (received_blocks > 0) {
414-
rc = write(lba, work_n_blocks, std::get<0>(data));
414+
rc = write(lba, work_n_blocks, data.first);
415415
ok = rc == scsi_rw_result::rw_ok;
416416
}
417417

@@ -422,7 +422,7 @@ std::optional<scsi_response> scsi::send(const uint64_t lun, const uint8_t *const
422422
// received_blocks is rounded down above
423423
rc = read(lba + work_n_blocks, 1, temp_buffer);
424424
if (rc == scsi_rw_result::rw_ok) {
425-
memcpy(temp_buffer, &std::get<0>(data)[work_n_blocks * backend_block_size], fragment_size);
425+
memcpy(temp_buffer, &data.first[work_n_blocks * backend_block_size], fragment_size);
426426
rc = write(lba + received_blocks, 1, temp_buffer);
427427
}
428428

@@ -597,8 +597,8 @@ std::optional<scsi_response> scsi::send(const uint64_t lun, const uint8_t *const
597597

598598
auto block_size = b->get_block_size();
599599
auto expected_data_size = block_size * block_count * 2;
600-
if (expected_data_size != std::get<1>(data))
601-
DOLOG(logging::ll_warning, "scsi::send", lun_identifier, "COMPARE AND WRITE: data count mismatch (%zu versus %zu)", size_t(expected_data_size), std::get<1>(data));
600+
if (expected_data_size != data.second)
601+
DOLOG(logging::ll_warning, "scsi::send", lun_identifier, "COMPARE AND WRITE: data count mismatch (%zu versus %zu)", size_t(expected_data_size), data.second);
602602

603603
response.amount_of_data_expected = expected_data_size;
604604

@@ -612,7 +612,7 @@ std::optional<scsi_response> scsi::send(const uint64_t lun, const uint8_t *const
612612
response.sense_data = error_compare_and_write_count();
613613
}
614614
else {
615-
auto result = cmpwrite(lba, block_count, &std::get<0>(data)[block_count * block_size], &std::get<0>(data)[0]);
615+
auto result = cmpwrite(lba, block_count, &data.first[block_count * block_size], &data.first[0]);
616616

617617
if (result == scsi_rw_result::rw_ok)
618618
response.type = ir_empty_sense;
@@ -674,9 +674,9 @@ std::optional<scsi_response> scsi::send(const uint64_t lun, const uint8_t *const
674674
else if (opcode == o_unmap) {
675675
DOLOG(logging::ll_debug, "scsi::send", lun_identifier, "UNMAP");
676676

677-
const uint8_t *const pd = std::get<0>(data);
677+
const uint8_t *const pd = data.first;
678678
scsi_rw_result rc = rw_ok;
679-
for(size_t i=8; i<std::get<1>(data); i+= 16) {
679+
for(size_t i=8; i<data.second; i+= 16) {
680680
uint64_t lba = get_uint64_t(&pd[i]);
681681
uint32_t transfer_length = get_uint32_t(&pd[i + 8]);
682682

@@ -742,11 +742,11 @@ std::optional<scsi_response> scsi::send(const uint64_t lun, const uint8_t *const
742742
DOLOG(logging::ll_debug, "scsi::send", lun_identifier, "WRITE_SAME parameters invalid");
743743
response.sense_data = vr.value();
744744
}
745-
else if (std::get<0>(data)) {
746-
DOLOG(logging::ll_debug, "scsi::send", lun_identifier, "WRITE SAME command includes data (%zu bytes)", std::get<1>(data));
745+
else if (data.first) {
746+
DOLOG(logging::ll_debug, "scsi::send", lun_identifier, "WRITE SAME command includes data (%zu bytes)", data.second);
747747

748-
size_t received_size = std::get<1>(data);
749-
size_t received_blocks = received_size / backend_block_size;
748+
size_t received_size = data.second;
749+
size_t received_blocks = received_size / backend_block_size;
750750

751751
bool ok = true;
752752

@@ -763,7 +763,7 @@ std::optional<scsi_response> scsi::send(const uint64_t lun, const uint8_t *const
763763
for(uint32_t i=0; i<transfer_length; i++) {
764764
rc = response.r2t.write_same_is_unmap ?
765765
trim(lba, 1) :
766-
write(lba, 1, std::get<0>(data));
766+
write(lba, 1, data.first);
767767
if (rc != rw_ok)
768768
break;
769769

scsi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,5 +135,5 @@ class scsi
135135
scsi_rw_result read (const uint64_t block_nr, const uint32_t n_blocks, uint8_t *const data);
136136
scsi_rw_result cmpwrite(const uint64_t block_nr, const uint32_t n_blocks, const uint8_t *const write_data, const uint8_t *const compare_data);
137137

138-
std::optional<scsi_response> send(const uint64_t lun, const uint8_t *const CDB, const size_t size, std::tuple<uint8_t *, size_t> data);
138+
std::optional<scsi_response> send(const uint64_t lun, const uint8_t *const CDB, const size_t size, std::pair<uint8_t *, size_t> data);
139139
};

0 commit comments

Comments
 (0)