From b40c6b114432424bae5953c8cb884c7190d327bb Mon Sep 17 00:00:00 2001 From: Uwe Seimet Date: Mon, 23 Aug 2021 19:01:19 +0200 Subject: [PATCH] Logging update, improved locality of code --- src/raspberrypi/devices/disk.cpp | 2 +- src/raspberrypi/devices/scsi_daynaport.cpp | 2 +- src/raspberrypi/devices/scsi_host_bridge.cpp | 9 +++------ src/raspberrypi/devices/scsicd.cpp | 17 ++++++----------- src/raspberrypi/devices/scsihd_nec.cpp | 3 +-- 5 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/raspberrypi/devices/disk.cpp b/src/raspberrypi/devices/disk.cpp index 45a0d022..ae62e8ca 100644 --- a/src/raspberrypi/devices/disk.cpp +++ b/src/raspberrypi/devices/disk.cpp @@ -1160,7 +1160,7 @@ bool Disk::Dispatch(SCSIDEV *controller) if (commands.count(static_cast(ctrl->cmd[0]))) { command_t *command = commands[static_cast(ctrl->cmd[0])]; - LOGDEBUG("%s received %s ($%02X)", __PRETTY_FUNCTION__, command->name, (unsigned int)ctrl->cmd[0]); + LOGDEBUG("%s Executing %s ($%02X)", __PRETTY_FUNCTION__, command->name, (unsigned int)ctrl->cmd[0]); (this->*command->execute)(controller); diff --git a/src/raspberrypi/devices/scsi_daynaport.cpp b/src/raspberrypi/devices/scsi_daynaport.cpp index fcb0a601..7add4f25 100644 --- a/src/raspberrypi/devices/scsi_daynaport.cpp +++ b/src/raspberrypi/devices/scsi_daynaport.cpp @@ -131,7 +131,7 @@ void SCSIDaynaPort::Open(const Filepath& path) if (commands.count(static_cast(ctrl->cmd[0]))) { command_t *command = commands[static_cast(ctrl->cmd[0])]; - LOGDEBUG("%s received %s ($%02X)", __PRETTY_FUNCTION__, command->name, (unsigned int)ctrl->cmd[0]); + LOGDEBUG("%s Executing %s ($%02X)", __PRETTY_FUNCTION__, command->name, (unsigned int)ctrl->cmd[0]); (this->*command->execute)(controller); diff --git a/src/raspberrypi/devices/scsi_host_bridge.cpp b/src/raspberrypi/devices/scsi_host_bridge.cpp index 1fb21017..22321af7 100644 --- a/src/raspberrypi/devices/scsi_host_bridge.cpp +++ b/src/raspberrypi/devices/scsi_host_bridge.cpp @@ -104,7 +104,7 @@ bool SCSIBR::Dispatch(SCSIDEV *controller) if (commands.count(static_cast(ctrl->cmd[0]))) { command_t *command = commands[static_cast(ctrl->cmd[0])]; - LOGDEBUG("%s received %s ($%02X)", __PRETTY_FUNCTION__, command->name, (unsigned int)ctrl->cmd[0]); + LOGDEBUG("%s Executing %s ($%02X)", __PRETTY_FUNCTION__, command->name, (unsigned int)ctrl->cmd[0]); (this->*command->execute)(controller); @@ -180,7 +180,6 @@ void SCSIBR::TestUnitReady(SASIDEV *controller) { // TEST UNIT READY Success - // status phase controller->Status();} //--------------------------------------------------------------------------- @@ -264,7 +263,7 @@ int SCSIBR::GetMessage10(const DWORD *cdb, BYTE *buf) } // Error - ASSERT(FALSE); + ASSERT(false); return 0; } @@ -326,7 +325,7 @@ bool SCSIBR::SendMessage10(const DWORD *cdb, BYTE *buf) } // Error - ASSERT(FALSE); + ASSERT(false); return false; } @@ -355,7 +354,6 @@ void SCSIBR::GetMessage10(SASIDEV *controller) ctrl->blocks = 1; ctrl->next = 1; - // Data in phase controller->DataIn(); } @@ -392,7 +390,6 @@ void SCSIBR::SendMessage10(SASIDEV *controller) ctrl->blocks = 1; ctrl->next = 1; - // Data out phase controller->DataOut(); } diff --git a/src/raspberrypi/devices/scsicd.cpp b/src/raspberrypi/devices/scsicd.cpp index 2bde9c2b..c4c324ef 100644 --- a/src/raspberrypi/devices/scsicd.cpp +++ b/src/raspberrypi/devices/scsicd.cpp @@ -279,7 +279,7 @@ bool SCSICD::Dispatch(SCSIDEV *controller) if (commands.count(static_cast(ctrl->cmd[0]))) { command_t *command = commands[static_cast(ctrl->cmd[0])]; - LOGDEBUG("%s received %s ($%02X)", __PRETTY_FUNCTION__, command->name, (unsigned int)ctrl->cmd[0]); + LOGDEBUG("%s Executing %s ($%02X)", __PRETTY_FUNCTION__, command->name, (unsigned int)ctrl->cmd[0]); (this->*command->execute)(controller); @@ -299,9 +299,7 @@ bool SCSICD::Dispatch(SCSIDEV *controller) //--------------------------------------------------------------------------- void SCSICD::Open(const Filepath& path) { - Fileio fio; off_t size; - TCHAR file[5]; ASSERT(!IsReady()); @@ -311,6 +309,7 @@ void SCSICD::Open(const Filepath& path) ClearTrack(); // Open as read-only + Fileio fio; if (!fio.Open(path, Fileio::ReadOnly)) { throw io_exception("Can't open CD-ROM file read-only"); } @@ -331,12 +330,13 @@ void SCSICD::Open(const Filepath& path) } // Judge whether it is a CUE sheet or an ISO file + TCHAR file[5]; fio.Read(file, 4); file[4] = '\0'; fio.Close(); // If it starts with FILE, consider it as a CUE sheet - if (strncasecmp(file, _T("FILE"), 4) == 0) { + if (!strncasecmp(file, _T("FILE"), 4)) { // Open as CUE OpenCue(path); } else { @@ -381,9 +381,6 @@ void SCSICD::OpenCue(const Filepath& /*path*/) //--------------------------------------------------------------------------- void SCSICD::OpenIso(const Filepath& path) { - BYTE header[12]; - BYTE sync[12]; - // Open as read-only Fileio fio; if (!fio.Open(path, Fileio::ReadOnly)) { @@ -398,12 +395,14 @@ void SCSICD::OpenIso(const Filepath& path) } // Read the first 12 bytes and close + BYTE header[12]; if (!fio.Read(header, sizeof(header))) { fio.Close(); throw io_exception("Can't read header of ISO CD-ROM file"); } // Check if it is RAW format + BYTE sync[12]; memset(sync, 0xff, sizeof(sync)); sync[0] = 0x00; sync[11] = 0x00; @@ -514,7 +513,6 @@ void SCSICD::CmdReadToc(SASIDEV *controller) return; } - // Data-in Phase controller->DataIn(); } @@ -528,7 +526,6 @@ void SCSICD::CmdPlayAudio10(SASIDEV *controller) return; } - // Status phase controller->Status(); } @@ -542,7 +539,6 @@ void SCSICD::CmdPlayAudioMSF(SASIDEV *controller) return; } - // Status phase controller->Status(); } @@ -556,7 +552,6 @@ void SCSICD::CmdPlayAudioTrack(SASIDEV *controller) return; } - // Status phase controller->Status(); } diff --git a/src/raspberrypi/devices/scsihd_nec.cpp b/src/raspberrypi/devices/scsihd_nec.cpp index d7b5eac2..f22e6e13 100644 --- a/src/raspberrypi/devices/scsihd_nec.cpp +++ b/src/raspberrypi/devices/scsihd_nec.cpp @@ -61,8 +61,7 @@ static inline WORD getWordLE(const BYTE *b) //--------------------------------------------------------------------------- static inline DWORD getDwordLE(const BYTE *b) { - return ((DWORD)(b[3]) << 24) | ((DWORD)(b[2]) << 16) | - ((DWORD)(b[1]) << 8) | b[0]; + return ((DWORD)(b[3]) << 24) | ((DWORD)(b[2]) << 16) | ((DWORD)(b[1]) << 8) | b[0]; } //---------------------------------------------------------------------------