From 0f94c5fc019400d0b70cae1d1c13d1a246566b99 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sun, 13 Nov 2022 20:08:10 +0000 Subject: [PATCH] Convert local variable or field into constant. --- Aaru.Checksums | 2 +- Aaru.Core/Devices/Dumping/MiniDisc.cs | 4 +- Aaru.Core/Devices/Dumping/SSC.cs | 6 +- Aaru.Core/Devices/Dumping/SecureDigital.cs | 6 +- Aaru.Core/Devices/Report/ATA.cs | 2 +- Aaru.Core/Sidecar/BlockMedia.cs | 18 +++--- Aaru.Core/Sidecar/OpticalDisc.cs | 6 +- Aaru.Decoders | 2 +- Aaru.Devices/Device/MmcCommands/MMC.cs | 4 -- Aaru.Devices/Device/ScsiCommands/MiniDisc.cs | 10 +-- Aaru.Images/BLU/Read.cs | 16 ++--- Aaru.Images/CDRDAO/Read.cs | 6 +- Aaru.Images/CDRWin/Properties.cs | 6 +- Aaru.Tests.Devices/SCSI/MMC.cs | 2 +- Aaru.Tests.Devices/SCSI/Pioneer.cs | 2 +- Aaru.Tests.Devices/SCSI/SBC.cs | 68 ++++++++++---------- 16 files changed, 75 insertions(+), 85 deletions(-) diff --git a/Aaru.Checksums b/Aaru.Checksums index 18c1903d2..5764c3d84 160000 --- a/Aaru.Checksums +++ b/Aaru.Checksums @@ -1 +1 @@ -Subproject commit 18c1903d2f762bbd904113f9c12b051478573d2a +Subproject commit 5764c3d844e1fb252cec9a287b5a6ef6c8876be4 diff --git a/Aaru.Core/Devices/Dumping/MiniDisc.cs b/Aaru.Core/Devices/Dumping/MiniDisc.cs index f89a06370..4525eda17 100644 --- a/Aaru.Core/Devices/Dumping/MiniDisc.cs +++ b/Aaru.Core/Devices/Dumping/MiniDisc.cs @@ -109,7 +109,7 @@ partial class Dump return; } - MediaType dskType = MediaType.MDData; + const MediaType dskType = MediaType.MDData; if(scsiReader.FindReadCommand()) { @@ -524,7 +524,7 @@ partial class Dump if(dcMode6?.Pages != null) foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage => - modePage.Page == 0x01 && modePage.Subpage == 0x00)) + modePage.Page == 0x01 && modePage.Subpage == 0x00)) currentModePage = modePage; } diff --git a/Aaru.Core/Devices/Dumping/SSC.cs b/Aaru.Core/Devices/Dumping/SSC.cs index 4bdc0371c..163d801bb 100644 --- a/Aaru.Core/Devices/Dumping/SSC.cs +++ b/Aaru.Core/Devices/Dumping/SSC.cs @@ -1100,9 +1100,9 @@ partial class Dump _retryPasses > 0 && (canLocate || canLocateLong)) { - var pass = 1; - var forward = false; - var runningPersistent = false; + var pass = 1; + var forward = false; + const bool runningPersistent = false; Modes.ModePage? currentModePage = null; diff --git a/Aaru.Core/Devices/Dumping/SecureDigital.cs b/Aaru.Core/Devices/Dumping/SecureDigital.cs index 92f22bde1..cc6cbd881 100644 --- a/Aaru.Core/Devices/Dumping/SecureDigital.cs +++ b/Aaru.Core/Devices/Dumping/SecureDigital.cs @@ -756,9 +756,9 @@ public partial class Dump !_aborted && _retryPasses > 0) { - var pass = 1; - var forward = true; - var runningPersistent = false; + var pass = 1; + var forward = true; + const bool runningPersistent = false; InitProgress?.Invoke(); repeatRetryLba: diff --git a/Aaru.Core/Devices/Report/ATA.cs b/Aaru.Core/Devices/Report/ATA.cs index 2fd70d43e..52269774c 100644 --- a/Aaru.Core/Devices/Report/ATA.cs +++ b/Aaru.Core/Devices/Report/ATA.cs @@ -563,7 +563,7 @@ public sealed partial class DeviceReport capabilities.Manufacturer = ataId.MediaManufacturer; } - ulong checkCorrectRead = 0; + const ulong checkCorrectRead = 0; Spectre.ProgressSingleSpinner(ctx => { diff --git a/Aaru.Core/Sidecar/BlockMedia.cs b/Aaru.Core/Sidecar/BlockMedia.cs index 11905248e..e4c8c41b3 100644 --- a/Aaru.Core/Sidecar/BlockMedia.cs +++ b/Aaru.Core/Sidecar/BlockMedia.cs @@ -393,9 +393,9 @@ public sealed partial class Sidecar // For fast debugging, skip checksum //goto skipImageChecksum; - uint sectorsToRead = 64; - ulong sectors = image.Info.Sectors; - ulong doneSectors = 0; + const uint sectorsToRead = 64; + ulong sectors = image.Info.Sectors; + ulong doneSectors = 0; InitProgress2(); @@ -495,9 +495,9 @@ public sealed partial class Sidecar // For fast debugging, skip checksum //goto skipImageChecksum; - uint sectorsToRead = 64; - ulong sectors = tapePartition.LastBlock - tapePartition.FirstBlock + 1; - ulong doneSectors = 0; + const uint sectorsToRead = 64; + ulong sectors = tapePartition.LastBlock - tapePartition.FirstBlock + 1; + ulong doneSectors = 0; InitProgress2(); @@ -595,9 +595,9 @@ public sealed partial class Sidecar // For fast debugging, skip checksum //goto skipImageChecksum; - uint sectorsToRead = 64; - ulong sectors = tapeFile.LastBlock - tapeFile.FirstBlock + 1; - ulong doneSectors = 0; + const uint sectorsToRead = 64; + ulong sectors = tapeFile.LastBlock - tapeFile.FirstBlock + 1; + ulong doneSectors = 0; InitProgress2(); diff --git a/Aaru.Core/Sidecar/OpticalDisc.cs b/Aaru.Core/Sidecar/OpticalDisc.cs index 4dfa5bad8..47577030d 100644 --- a/Aaru.Core/Sidecar/OpticalDisc.cs +++ b/Aaru.Core/Sidecar/OpticalDisc.cs @@ -336,9 +336,9 @@ public sealed partial class Sidecar xmlTrk.BytesPerSector = (uint)trk.BytesPerSector; - uint sectorsToRead = 512; - ulong sectors = xmlTrk.EndSector - xmlTrk.StartSector + 1; - ulong doneSectors = 0; + const uint sectorsToRead = 512; + ulong sectors = xmlTrk.EndSector - xmlTrk.StartSector + 1; + ulong doneSectors = 0; // If there is only one track, and it's the same as the image file (e.g. ".iso" files), don't re-checksum. if(image.Id == new Guid("12345678-AAAA-BBBB-CCCC-123456789000") && diff --git a/Aaru.Decoders b/Aaru.Decoders index f0bee36d9..e449e5345 160000 --- a/Aaru.Decoders +++ b/Aaru.Decoders @@ -1 +1 @@ -Subproject commit f0bee36d9eddd7435f05e20587c18ff2d32b46ed +Subproject commit e449e534545e4a8a30902ea3b72ec28832416715 diff --git a/Aaru.Devices/Device/MmcCommands/MMC.cs b/Aaru.Devices/Device/MmcCommands/MMC.cs index 43de1d9c3..dafad9b70 100644 --- a/Aaru.Devices/Device/MmcCommands/MMC.cs +++ b/Aaru.Devices/Device/MmcCommands/MMC.cs @@ -222,7 +222,6 @@ public partial class Device ushort transferLength, bool byteAddressed, uint timeout, out double duration) { buffer = new byte[transferLength * blockSize]; - double setDuration = 0; uint address; response = null; @@ -239,10 +238,7 @@ public partial class Device Error = LastError != 0; if(transferLength > 1) - { - duration += setDuration; AaruConsole.DebugWriteLine("MMC Device", "READ_MULTIPLE_BLOCK took {0} ms.", duration); - } else AaruConsole.DebugWriteLine("MMC Device", "READ_SINGLE_BLOCK took {0} ms.", duration); diff --git a/Aaru.Devices/Device/ScsiCommands/MiniDisc.cs b/Aaru.Devices/Device/ScsiCommands/MiniDisc.cs index 0e10ff229..d3a1e0bae 100644 --- a/Aaru.Devices/Device/ScsiCommands/MiniDisc.cs +++ b/Aaru.Devices/Device/ScsiCommands/MiniDisc.cs @@ -49,7 +49,7 @@ public partial class Device /// true if the command failed and contains the sense buffer. public bool MiniDiscReadDataTOC(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration) { - ushort transferLength = 2336; + const ushort transferLength = 2336; senseBuffer = new byte[64]; var cdb = new byte[10]; @@ -80,7 +80,7 @@ public partial class Device public bool MiniDiscReadUserTOC(out byte[] buffer, out byte[] senseBuffer, uint sector, uint timeout, out double duration) { - ushort transferLength = 2336; + const ushort transferLength = 2336; senseBuffer = new byte[64]; var cdb = new byte[10]; @@ -113,7 +113,7 @@ public partial class Device /// true if the command failed and contains the sense buffer. public bool MiniDiscD5(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration) { - ushort transferLength = 4; + const ushort transferLength = 4; senseBuffer = new byte[64]; var cdb = new byte[10]; @@ -167,7 +167,7 @@ public partial class Device /// true if the command failed and contains the sense buffer. public bool MiniDiscReadPosition(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration) { - ushort transferLength = 4; + const ushort transferLength = 4; senseBuffer = new byte[64]; var cdb = new byte[10]; @@ -196,7 +196,7 @@ public partial class Device /// true if the command failed and contains the sense buffer. public bool MiniDiscGetType(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration) { - ushort transferLength = 8; + const ushort transferLength = 8; senseBuffer = new byte[64]; var cdb = new byte[10]; diff --git a/Aaru.Images/BLU/Read.cs b/Aaru.Images/BLU/Read.cs index 765ad151b..79418a826 100644 --- a/Aaru.Images/BLU/Read.cs +++ b/Aaru.Images/BLU/Read.cs @@ -167,17 +167,15 @@ public sealed partial class Blu if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; - var ms = new MemoryStream(); - var seek = 0; - var read = 0x200; - int skip = _bptag; + var ms = new MemoryStream(); + const int read = 0x200; + int skip = _bptag; Stream stream = _bluImageFilter.GetDataForkStream(); stream.Seek((long)((sectorAddress + 1) * _imageHeader.BytesPerBlock), SeekOrigin.Begin); for(var i = 0; i < length; i++) { - stream.Seek(seek, SeekOrigin.Current); var sector = new byte[read]; stream.Read(sector, 0, read); ms.Write(sector, 0, read); @@ -206,10 +204,9 @@ public sealed partial class Blu if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.SectorNotFound; - var ms = new MemoryStream(); - var seek = 0x200; - int read = _bptag; - var skip = 0; + var ms = new MemoryStream(); + const int seek = 0x200; + int read = _bptag; Stream stream = _bluImageFilter.GetDataForkStream(); stream.Seek((long)((sectorAddress + 1) * _imageHeader.BytesPerBlock), SeekOrigin.Begin); @@ -220,7 +217,6 @@ public sealed partial class Blu var sector = new byte[read]; stream.Read(sector, 0, read); ms.Write(sector, 0, read); - stream.Seek(skip, SeekOrigin.Current); } buffer = ms.ToArray(); diff --git a/Aaru.Images/CDRDAO/Read.cs b/Aaru.Images/CDRDAO/Read.cs index 67f8a731a..32ded6ec5 100644 --- a/Aaru.Images/CDRDAO/Read.cs +++ b/Aaru.Images/CDRDAO/Read.cs @@ -688,8 +688,6 @@ public sealed partial class Cdrdao for(var i = 0; i < _discimage.Tracks.Count; i++) { - ulong index0Len = 0; - if(_discimage.Tracks[i].Sequence == 1 && i != 0) { @@ -704,8 +702,8 @@ public sealed partial class Cdrdao Description = $"Track {_discimage.Tracks[i].Sequence}.", Name = _discimage.Tracks[i].Title, Start = _discimage.Tracks[i].StartSector, - Size = (_discimage.Tracks[i].Sectors - index0Len) * _discimage.Tracks[i].Bps, - Length = _discimage.Tracks[i].Sectors - index0Len, + Size = _discimage.Tracks[i].Sectors * _discimage.Tracks[i].Bps, + Length = _discimage.Tracks[i].Sectors, Sequence = partitionSequence, Offset = byteOffset, Type = _discimage.Tracks[i].Tracktype diff --git a/Aaru.Images/CDRWin/Properties.cs b/Aaru.Images/CDRWin/Properties.cs index b03352452..ee54dbfbc 100644 --- a/Aaru.Images/CDRWin/Properties.cs +++ b/Aaru.Images/CDRWin/Properties.cs @@ -76,9 +76,9 @@ public sealed partial class CdrWin { List tracks = new(); - ulong previousStartSector = 0; - ulong gdRomSession2Offset = 45000; - var previousTrackFile = ""; + ulong previousStartSector = 0; + const ulong gdRomSession2Offset = 45000; + var previousTrackFile = ""; foreach(CdrWinTrack cdrTrack in _discImage.Tracks) { diff --git a/Aaru.Tests.Devices/SCSI/MMC.cs b/Aaru.Tests.Devices/SCSI/MMC.cs index de0ba0f2c..6fea0129e 100644 --- a/Aaru.Tests.Devices/SCSI/MMC.cs +++ b/Aaru.Tests.Devices/SCSI/MMC.cs @@ -1061,7 +1061,7 @@ static class Mmc byte startSecond = 2; byte startMinute = 0; byte endFrame = 0; - byte endSecond = 0; + const byte endSecond = 0; byte endMinute = 0; MmcSectorTypes sectorType = MmcSectorTypes.AllTypes; var dap = false; diff --git a/Aaru.Tests.Devices/SCSI/Pioneer.cs b/Aaru.Tests.Devices/SCSI/Pioneer.cs index 173898cae..14b3daf79 100644 --- a/Aaru.Tests.Devices/SCSI/Pioneer.cs +++ b/Aaru.Tests.Devices/SCSI/Pioneer.cs @@ -281,7 +281,7 @@ static class Pioneer byte startSecond = 2; byte startMinute = 0; byte endFrame = 0; - byte endSecond = 0; + const byte endSecond = 0; byte endMinute = 0; PioneerSubchannel subchan = PioneerSubchannel.None; uint blockSize = 2352; diff --git a/Aaru.Tests.Devices/SCSI/SBC.cs b/Aaru.Tests.Devices/SCSI/SBC.cs index 71965a96d..302c787a2 100644 --- a/Aaru.Tests.Devices/SCSI/SBC.cs +++ b/Aaru.Tests.Devices/SCSI/SBC.cs @@ -291,17 +291,17 @@ static class Sbc static void Read10(string devPath, Device dev) { - uint lba = 0; - uint blockSize = 512; - byte count = 1; - byte rdprotect = 0; - var dpo = false; - var fua = false; - var fuaNv = false; - byte groupNumber = 0; - var relative = false; - string strDev; - int item; + uint lba = 0; + uint blockSize = 512; + byte count = 1; + byte rdprotect = 0; + var dpo = false; + var fua = false; + var fuaNv = false; + const byte groupNumber = 0; + var relative = false; + string strDev; + int item; parameters: @@ -547,18 +547,18 @@ static class Sbc static void Read12(string devPath, Device dev) { - uint lba = 0; - uint blockSize = 512; - byte count = 1; - byte rdprotect = 0; - var dpo = false; - var fua = false; - var fuaNv = false; - byte groupNumber = 0; - var relative = false; - var streaming = false; - string strDev; - int item; + uint lba = 0; + uint blockSize = 512; + byte count = 1; + byte rdprotect = 0; + var dpo = false; + var fua = false; + var fuaNv = false; + const byte groupNumber = 0; + var relative = false; + var streaming = false; + string strDev; + int item; parameters: @@ -817,17 +817,17 @@ static class Sbc static void Read16(string devPath, Device dev) { - ulong lba = 0; - uint blockSize = 512; - byte count = 1; - byte rdprotect = 0; - var dpo = false; - var fua = false; - var fuaNv = false; - byte groupNumber = 0; - var streaming = false; - string strDev; - int item; + ulong lba = 0; + uint blockSize = 512; + byte count = 1; + byte rdprotect = 0; + var dpo = false; + var fua = false; + var fuaNv = false; + const byte groupNumber = 0; + var streaming = false; + string strDev; + int item; parameters: