From c881ae98b93c729d09c5ab2bc48ca6795fa08a05 Mon Sep 17 00:00:00 2001 From: Uwe Seimet Date: Thu, 24 Oct 2024 09:33:21 +0200 Subject: [PATCH] Fix Sonar issue --- cpp/devices/tape.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/cpp/devices/tape.cpp b/cpp/devices/tape.cpp index 99fc3d44..3342a0f9 100644 --- a/cpp/devices/tape.cpp +++ b/cpp/devices/tape.cpp @@ -407,8 +407,14 @@ void Tape::Space6() if (tar_mode) { switch (code) { case object_type::BLOCK: - position += count * GetBlockSize(); - block_location += count; + if (block_location + count >= 0) { + position += count * GetBlockSize(); + block_location += count; + } + else { + position = 0; + block_location = 0; + } break; case object_type::END_OF_DATA: @@ -424,13 +430,6 @@ void Tape::Space6() throw scsi_exception(sense_key::illegal_request, asc::invalid_command_operation_code); } - if (position < 0) { - position = 0; - } - if (block_location < 0) { - block_location = 0; - } - StatusPhase(); return;