From b0936d51c51293b174e13270d8a37d9a40838fe1 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Wed, 20 Dec 2017 17:26:28 +0000 Subject: [PATCH] REFACTOR: Remove redundant parentheses. --- DiscImageChef.Checksums/CDChecksums.cs | 2 +- DiscImageChef.Checksums/ReedSolomon.cs | 20 +-- DiscImageChef.Checksums/SpamSumContext.cs | 8 +- DiscImageChef.Core/Benchmark.cs | 32 ++--- DiscImageChef.Core/Devices/Dumping/ATA.cs | 30 ++-- .../Devices/Dumping/Alcohol120.cs | 2 +- .../Devices/Dumping/CompactDisc.cs | 20 +-- DiscImageChef.Core/Devices/Dumping/MMC.cs | 4 +- DiscImageChef.Core/Devices/Dumping/SBC.cs | 16 +-- DiscImageChef.Core/Devices/Dumping/SSC.cs | 18 +-- .../Devices/Dumping/SecureDigital.cs | 16 +-- DiscImageChef.Core/Devices/Dumping/XGD.cs | 32 ++--- DiscImageChef.Core/Devices/ReaderATA.cs | 27 ++-- DiscImageChef.Core/Devices/ReaderSCSI.cs | 10 +- DiscImageChef.Core/Devices/Report/ATA.cs | 100 ++++++------- .../Devices/Report/SCSI/General.cs | 14 +- DiscImageChef.Core/Devices/Report/SCSI/MMC.cs | 6 +- DiscImageChef.Core/Devices/Scanning/ATA.cs | 12 +- DiscImageChef.Core/Devices/Scanning/SCSI.cs | 14 +- .../Devices/Scanning/SecureDigital.cs | 8 +- DiscImageChef.Core/Logging/IBGLog.cs | 2 +- DiscImageChef.Core/Sidecar/BlockMedia.cs | 14 +- DiscImageChef.Core/Sidecar/BlockTape.cs | 6 +- DiscImageChef.Core/Sidecar/OpticalDisc.cs | 12 +- DiscImageChef.Core/Sidecar/Sidecar.cs | 2 +- DiscImageChef.Decoders/ATA/Identify.cs | 76 +++++----- DiscImageChef.Decoders/CD/CDTextOnLeadIn.cs | 2 +- DiscImageChef.Decoders/CD/FullTOC.cs | 4 +- DiscImageChef.Decoders/CD/PMA.cs | 2 +- DiscImageChef.Decoders/CD/Session.cs | 2 +- DiscImageChef.Decoders/CD/TOC.cs | 2 +- DiscImageChef.Decoders/DVD/PFI.cs | 16 +-- DiscImageChef.Decoders/Floppy/Apple2.cs | 12 +- DiscImageChef.Decoders/SCSI/Inquiry.cs | 56 ++++---- .../SCSI/MMC/DiscInformation.cs | 12 +- DiscImageChef.Decoders/SCSI/MMC/Features.cs | 124 ++++++++-------- DiscImageChef.Decoders/SCSI/Modes.cs | 52 +++---- DiscImageChef.Decoders/SecureDigital/CSD.cs | 2 +- DiscImageChef.Decoders/Sega/Dreamcast.cs | 2 +- DiscImageChef.Devices/Command.cs | 20 ++- DiscImageChef.Devices/Device/Constructor.cs | 2 +- DiscImageChef.Devices/FreeBSD/Command.cs | 2 +- DiscImageChef.Devices/Linux/Command.cs | 6 +- DiscImageChef.Devices/Windows/Usb.cs | 4 +- DiscImageChef.DiscImages/Alcohol120.cs | 16 +-- DiscImageChef.DiscImages/AppleDOS.cs | 2 +- DiscImageChef.DiscImages/Apridisk.cs | 10 +- DiscImageChef.DiscImages/BLU.cs | 2 +- DiscImageChef.DiscImages/BlindWrite4.cs | 32 ++--- DiscImageChef.DiscImages/BlindWrite5.cs | 36 ++--- DiscImageChef.DiscImages/CDRDAO.cs | 16 +-- DiscImageChef.DiscImages/CDRWin.cs | 32 ++--- DiscImageChef.DiscImages/CHD.cs | 48 +++---- DiscImageChef.DiscImages/CloneCD.cs | 22 +-- DiscImageChef.DiscImages/CopyQM.cs | 12 +- DiscImageChef.DiscImages/DART.cs | 10 +- DiscImageChef.DiscImages/DiscJuggler.cs | 16 +-- DiscImageChef.DiscImages/DiskCopy42.cs | 22 +-- DiscImageChef.DiscImages/DriDiskCopy.cs | 4 +- DiscImageChef.DiscImages/GDI.cs | 44 +++--- DiscImageChef.DiscImages/HDCopy.cs | 8 +- DiscImageChef.DiscImages/NDIF.cs | 16 +-- DiscImageChef.DiscImages/Nero.cs | 136 +++++++++--------- DiscImageChef.DiscImages/Parallels.cs | 4 +- DiscImageChef.DiscImages/QCOW.cs | 4 +- DiscImageChef.DiscImages/QCOW2.cs | 6 +- DiscImageChef.DiscImages/QED.cs | 10 +- DiscImageChef.DiscImages/RsIde.cs | 2 +- DiscImageChef.DiscImages/SaveDskF.cs | 2 +- DiscImageChef.DiscImages/T98.cs | 4 +- DiscImageChef.DiscImages/TeleDisk.cs | 48 +++---- DiscImageChef.DiscImages/UDIF.cs | 14 +- DiscImageChef.DiscImages/UkvFdi.cs | 4 +- DiscImageChef.DiscImages/VDI.cs | 6 +- DiscImageChef.DiscImages/VHD.cs | 42 +++--- DiscImageChef.DiscImages/VHDX.cs | 18 +-- DiscImageChef.DiscImages/VMware.cs | 6 +- DiscImageChef.DiscImages/ZZZRawImage.cs | 6 +- DiscImageChef.Filesystems/Acorn.cs | 30 ++-- DiscImageChef.Filesystems/AmigaDOS.cs | 18 +-- DiscImageChef.Filesystems/AppleDOS/Dir.cs | 4 +- DiscImageChef.Filesystems/AppleDOS/File.cs | 6 +- DiscImageChef.Filesystems/AppleHFS.cs | 5 +- DiscImageChef.Filesystems/AppleHFSPlus.cs | 8 +- DiscImageChef.Filesystems/AppleMFS/Dir.cs | 4 +- DiscImageChef.Filesystems/AppleMFS/File.cs | 14 +- DiscImageChef.Filesystems/AppleMFS/Info.cs | 2 +- DiscImageChef.Filesystems/AppleMFS/Super.cs | 8 +- DiscImageChef.Filesystems/AtheOS.cs | 2 +- DiscImageChef.Filesystems/BFS.cs | 4 +- DiscImageChef.Filesystems/BTRFS.cs | 2 +- DiscImageChef.Filesystems/CPM/Dir.cs | 2 +- DiscImageChef.Filesystems/CPM/Info.cs | 30 ++-- DiscImageChef.Filesystems/CPM/Super.cs | 20 +-- DiscImageChef.Filesystems/FAT.cs | 62 ++++---- DiscImageChef.Filesystems/FFS.cs | 14 +- DiscImageChef.Filesystems/Fossil.cs | 2 +- DiscImageChef.Filesystems/HAMMER.cs | 2 +- DiscImageChef.Filesystems/HPFS.cs | 2 +- DiscImageChef.Filesystems/ISO9660/Info.cs | 6 +- DiscImageChef.Filesystems/LisaFS/Dir.cs | 2 +- DiscImageChef.Filesystems/LisaFS/Extent.cs | 4 +- DiscImageChef.Filesystems/LisaFS/File.cs | 6 +- DiscImageChef.Filesystems/Locus.cs | 8 +- DiscImageChef.Filesystems/MicroDOS.cs | 2 +- DiscImageChef.Filesystems/MinixFS.cs | 4 +- DiscImageChef.Filesystems/NTFS.cs | 2 +- DiscImageChef.Filesystems/Nintendo.cs | 16 +-- DiscImageChef.Filesystems/ODS.cs | 4 +- DiscImageChef.Filesystems/Opera.cs | 2 +- DiscImageChef.Filesystems/PCEngine.cs | 2 +- DiscImageChef.Filesystems/ProDOS.cs | 6 +- DiscImageChef.Filesystems/QNX4.cs | 2 +- DiscImageChef.Filesystems/RT11.cs | 2 +- DiscImageChef.Filesystems/Reiser4.cs | 2 +- DiscImageChef.Filesystems/SolarFS.cs | 2 +- DiscImageChef.Filesystems/Squash.cs | 2 +- DiscImageChef.Filesystems/SysV.cs | 22 +-- DiscImageChef.Filesystems/UCSDPascal/File.cs | 4 +- DiscImageChef.Filesystems/UCSDPascal/Super.cs | 6 +- DiscImageChef.Filesystems/UDF.cs | 6 +- DiscImageChef.Filesystems/UNICOS.cs | 8 +- DiscImageChef.Filesystems/UNIXBFS.cs | 2 +- DiscImageChef.Filesystems/ZFS.cs | 4 +- DiscImageChef.Filesystems/dump.cs | 8 +- DiscImageChef.Filesystems/exFAT.cs | 4 +- DiscImageChef.Filesystems/ext2FS.cs | 2 +- DiscImageChef.Filesystems/extFS.cs | 4 +- DiscImageChef.Filters/MacBinary.cs | 24 ++-- DiscImageChef.Filters/PCExchange.cs | 8 +- DiscImageChef.Helpers/DateHandlers.cs | 6 +- DiscImageChef.Helpers/StringHandlers.cs | 2 +- DiscImageChef.Interop/DetectOS.cs | 4 +- DiscImageChef.Partitions/Acorn.cs | 2 +- DiscImageChef.Partitions/AppleMap.cs | 16 +-- DiscImageChef.Partitions/Atari.cs | 10 +- DiscImageChef.Partitions/BSD.cs | 14 +- DiscImageChef.Partitions/DragonFlyBSD.cs | 8 +- DiscImageChef.Partitions/GPT.cs | 10 +- DiscImageChef.Partitions/MBR.cs | 4 +- DiscImageChef.Partitions/NeXT.cs | 6 +- DiscImageChef.Partitions/Plan9.cs | 4 +- DiscImageChef.Partitions/SGI.cs | 8 +- DiscImageChef.Partitions/Sun.cs | 18 +-- DiscImageChef.Partitions/VTOC.cs | 2 +- DiscImageChef.Partitions/XENIX.cs | 4 +- DiscImageChef.Server/App_Start/Ata.cs | 56 ++++---- DiscImageChef.Server/App_Start/TestedMedia.cs | 36 ++--- DiscImageChef.Server/ViewReport.aspx.cs | 20 +-- .../DecodeATARegisters.cs | 6 +- DiscImageChef.Tests/Images/2MG.cs | 4 +- DiscImageChef.Tests/Images/Anex86.cs | 4 +- DiscImageChef.Tests/Images/CisCopy.cs | 4 +- DiscImageChef.Tests/Images/CopyQM.cs | 4 +- DiscImageChef.Tests/Images/D88.cs | 4 +- DiscImageChef.Tests/Images/DART.cs | 4 +- DiscImageChef.Tests/Images/DiskCopy42.cs | 4 +- DiscImageChef/Commands/Checksum.cs | 12 +- DiscImageChef/Commands/DeviceInfo.cs | 10 +- DiscImageChef/Commands/MediaInfo.cs | 14 +- 160 files changed, 1096 insertions(+), 1106 deletions(-) diff --git a/DiscImageChef.Checksums/CDChecksums.cs b/DiscImageChef.Checksums/CDChecksums.cs index 173b73a6..f01bc710 100644 --- a/DiscImageChef.Checksums/CDChecksums.cs +++ b/DiscImageChef.Checksums/CDChecksums.cs @@ -109,7 +109,7 @@ namespace DiscImageChef.Checksums } eccA = eccBTable[eccFTable[eccA] ^ eccB]; - if(ecc[major] != (eccA) || ecc[major + majorCount] != (eccA ^ eccB)) { return false; } + if(ecc[major] != eccA || ecc[major + majorCount] != (eccA ^ eccB)) { return false; } } return true; diff --git a/DiscImageChef.Checksums/ReedSolomon.cs b/DiscImageChef.Checksums/ReedSolomon.cs index 12cb5e08..c40e6c39 100644 --- a/DiscImageChef.Checksums/ReedSolomon.cs +++ b/DiscImageChef.Checksums/ReedSolomon.cs @@ -169,25 +169,25 @@ namespace DiscImageChef.Checksums static int Min(int a, int b) { - return ((a) < (b) ? (a) : (b)); + return a < b ? a : b; } static void Clear(ref int[] a, int n) { int ci; - for(ci = (n) - 1; ci >= 0; ci--) (a)[ci] = 0; + for(ci = n - 1; ci >= 0; ci--) a[ci] = 0; } static void Copy(ref int[] a, ref int[] b, int n) { int ci; - for(ci = (n) - 1; ci >= 0; ci--) (a)[ci] = (b)[ci]; + for(ci = n - 1; ci >= 0; ci--) a[ci] = b[ci]; } static void Copydown(ref int[] a, ref int[] b, int n) { int ci; - for(ci = (n) - 1; ci >= 0; ci--) (a)[ci] = (b)[ci]; + for(ci = n - 1; ci >= 0; ci--) a[ci] = b[ci]; } /* generate GF(2**m) from the irreducible polynomial p(X) in p[0]..p[m] @@ -280,10 +280,10 @@ namespace DiscImageChef.Checksums * (@**(B0+i-1) + x) */ for(j = i - 1; j > 0; j--) - if(gg[j] != 0) gg[j] = gg[j - 1] ^ alpha_to[Modnn((index_of[gg[j]]) + B0 + i - 1)]; + if(gg[j] != 0) gg[j] = gg[j - 1] ^ alpha_to[Modnn(index_of[gg[j]] + B0 + i - 1)]; else gg[j] = gg[j - 1]; /* Gg[0] can never be zero */ - gg[0] = alpha_to[Modnn((index_of[gg[0]]) + B0 + i - 1)]; + gg[0] = alpha_to[Modnn(index_of[gg[0]] + B0 + i - 1)]; } /* convert Gg[] to index form for quicker encoding */ for(i = 0; i <= nn - kk; i++) gg[i] = index_of[gg[i]]; @@ -485,7 +485,7 @@ namespace DiscImageChef.Checksums discrR = 0; for(i = 0; i < r; i++) { - if((lambda[i] != 0) && (s[r - i] != a0)) + if(lambda[i] != 0 && s[r - i] != a0) { discrR ^= alpha_to[Modnn(index_of[lambda[i]] + s[r - i])]; } @@ -516,7 +516,7 @@ namespace DiscImageChef.Checksums * lambda(x) */ for(i = 0; i <= nn - kk; i++) - b[i] = (lambda[i] == 0) ? a0 : Modnn(index_of[lambda[i]] - discrR + nn); + b[i] = lambda[i] == 0 ? a0 : Modnn(index_of[lambda[i]] - discrR + nn); } else { @@ -586,10 +586,10 @@ namespace DiscImageChef.Checksums for(i = 0; i < nn - kk; i++) { tmp = 0; - j = (degLambda < i) ? degLambda : i; + j = degLambda < i ? degLambda : i; for(; j >= 0; j--) { - if((s[i + 1 - j] != a0) && (lambda[j] != a0)) tmp ^= alpha_to[Modnn(s[i + 1 - j] + lambda[j])]; + if(s[i + 1 - j] != a0 && lambda[j] != a0) tmp ^= alpha_to[Modnn(s[i + 1 - j] + lambda[j])]; } if(tmp != 0) degOmega = i; diff --git a/DiscImageChef.Checksums/SpamSumContext.cs b/DiscImageChef.Checksums/SpamSumContext.cs index 017fe41a..ad4d6c8d 100644 --- a/DiscImageChef.Checksums/SpamSumContext.cs +++ b/DiscImageChef.Checksums/SpamSumContext.cs @@ -55,7 +55,7 @@ namespace DiscImageChef.Checksums const uint HASH_INIT = 0x28021967; const uint NUM_BLOCKHASHES = 31; const uint SPAMSUM_LENGTH = 64; - const uint FUZZY_MAX_RESULT = (2 * SPAMSUM_LENGTH + 20); + const uint FUZZY_MAX_RESULT = 2 * SPAMSUM_LENGTH + 20; //"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; readonly byte[] b64 = { @@ -169,7 +169,7 @@ namespace DiscImageChef.Checksums static uint SSDEEP_BS(uint index) { - return (MIN_BLOCKSIZE << (int)index); + return MIN_BLOCKSIZE << (int)index; } void fuzzy_try_fork_blockhash() @@ -249,7 +249,7 @@ namespace DiscImageChef.Checksums * our signature. This has the effect of combining the * last few pieces of the message into a single piece * */ - self.Bh[i].Digest[++(self.Bh[i].Dlen)] = 0; + self.Bh[i].Digest[++self.Bh[i].Dlen] = 0; self.Bh[i].H = HASH_INIT; if(self.Bh[i].Dlen < SPAMSUM_LENGTH / 2) { @@ -306,7 +306,7 @@ namespace DiscImageChef.Checksums while(bi >= self.Bhend) --bi; while(bi > self.Bhstart && self.Bh[bi].Dlen < SPAMSUM_LENGTH / 2) --bi; - if((bi > 0 && self.Bh[bi].Dlen < SPAMSUM_LENGTH / 2)) throw new Exception("Assertion failed"); + if(bi > 0 && self.Bh[bi].Dlen < SPAMSUM_LENGTH / 2) throw new Exception("Assertion failed"); sb.AppendFormat("{0}:", SSDEEP_BS(bi)); i = Encoding.ASCII.GetBytes(sb.ToString()).Length; diff --git a/DiscImageChef.Core/Benchmark.cs b/DiscImageChef.Core/Benchmark.cs index 47812974..a633df4a 100644 --- a/DiscImageChef.Core/Benchmark.cs +++ b/DiscImageChef.Core/Benchmark.cs @@ -110,7 +110,7 @@ namespace DiscImageChef.Core end = DateTime.Now; results.FillTime = (end - start).TotalSeconds; - results.FillSpeed = (bufferSize / 1048576) / (end - start).TotalSeconds; + results.FillSpeed = bufferSize / 1048576 / (end - start).TotalSeconds; ms.Seek(0, SeekOrigin.Begin); mem = GC.GetTotalMemory(false); @@ -132,7 +132,7 @@ namespace DiscImageChef.Core if(mem < results.MinMemory) results.MinMemory = mem; results.ReadTime = (end - start).TotalSeconds; - results.ReadSpeed = (bufferSize / 1048576) / (end - start).TotalSeconds; + results.ReadSpeed = bufferSize / 1048576 / (end - start).TotalSeconds; #region Adler32 ctx = new Adler32Context(); @@ -162,7 +162,7 @@ namespace DiscImageChef.Core new BenchmarkEntry() { TimeSpan = (end - start).TotalSeconds, - Speed = (bufferSize / 1048576) / (end - start).TotalSeconds + Speed = bufferSize / 1048576 / (end - start).TotalSeconds }); results.SeparateTime += (end - start).TotalSeconds; #endregion Adler32 @@ -195,7 +195,7 @@ namespace DiscImageChef.Core new BenchmarkEntry() { TimeSpan = (end - start).TotalSeconds, - Speed = (bufferSize / 1048576) / (end - start).TotalSeconds + Speed = bufferSize / 1048576 / (end - start).TotalSeconds }); results.SeparateTime += (end - start).TotalSeconds; #endregion CRC16 @@ -228,7 +228,7 @@ namespace DiscImageChef.Core new BenchmarkEntry() { TimeSpan = (end - start).TotalSeconds, - Speed = (bufferSize / 1048576) / (end - start).TotalSeconds + Speed = bufferSize / 1048576 / (end - start).TotalSeconds }); results.SeparateTime += (end - start).TotalSeconds; #endregion CRC32 @@ -261,7 +261,7 @@ namespace DiscImageChef.Core new BenchmarkEntry() { TimeSpan = (end - start).TotalSeconds, - Speed = (bufferSize / 1048576) / (end - start).TotalSeconds + Speed = bufferSize / 1048576 / (end - start).TotalSeconds }); results.SeparateTime += (end - start).TotalSeconds; #endregion CRC64 @@ -294,7 +294,7 @@ namespace DiscImageChef.Core new BenchmarkEntry() { TimeSpan = (end - start).TotalSeconds, - Speed = (bufferSize / 1048576) / (end - start).TotalSeconds + Speed = bufferSize / 1048576 / (end - start).TotalSeconds }); results.SeparateTime += (end - start).TotalSeconds; #endregion MD5 @@ -327,7 +327,7 @@ namespace DiscImageChef.Core new BenchmarkEntry() { TimeSpan = (end - start).TotalSeconds, - Speed = (bufferSize / 1048576) / (end - start).TotalSeconds + Speed = bufferSize / 1048576 / (end - start).TotalSeconds }); results.SeparateTime += (end - start).TotalSeconds; #endregion RIPEMD160 @@ -360,7 +360,7 @@ namespace DiscImageChef.Core new BenchmarkEntry() { TimeSpan = (end - start).TotalSeconds, - Speed = (bufferSize / 1048576) / (end - start).TotalSeconds + Speed = bufferSize / 1048576 / (end - start).TotalSeconds }); results.SeparateTime += (end - start).TotalSeconds; #endregion SHA1 @@ -393,7 +393,7 @@ namespace DiscImageChef.Core new BenchmarkEntry() { TimeSpan = (end - start).TotalSeconds, - Speed = (bufferSize / 1048576) / (end - start).TotalSeconds + Speed = bufferSize / 1048576 / (end - start).TotalSeconds }); results.SeparateTime += (end - start).TotalSeconds; #endregion SHA256 @@ -426,7 +426,7 @@ namespace DiscImageChef.Core new BenchmarkEntry() { TimeSpan = (end - start).TotalSeconds, - Speed = (bufferSize / 1048576) / (end - start).TotalSeconds + Speed = bufferSize / 1048576 / (end - start).TotalSeconds }); results.SeparateTime += (end - start).TotalSeconds; #endregion SHA384 @@ -459,7 +459,7 @@ namespace DiscImageChef.Core new BenchmarkEntry() { TimeSpan = (end - start).TotalSeconds, - Speed = (bufferSize / 1048576) / (end - start).TotalSeconds + Speed = bufferSize / 1048576 / (end - start).TotalSeconds }); results.SeparateTime += (end - start).TotalSeconds; #endregion SHA512 @@ -492,7 +492,7 @@ namespace DiscImageChef.Core new BenchmarkEntry() { TimeSpan = (end - start).TotalSeconds, - Speed = (bufferSize / 1048576) / (end - start).TotalSeconds + Speed = bufferSize / 1048576 / (end - start).TotalSeconds }); results.SeparateTime += (end - start).TotalSeconds; #endregion SpamSum @@ -529,7 +529,7 @@ namespace DiscImageChef.Core if(mem < results.MinMemory) results.MinMemory = mem; results.EntropyTime = (end - start).TotalSeconds; - results.EntropySpeed = (bufferSize / 1048576) / (end - start).TotalSeconds; + results.EntropySpeed = bufferSize / 1048576 / (end - start).TotalSeconds; #endregion Entropy #region Multitasking @@ -555,10 +555,10 @@ namespace DiscImageChef.Core if(mem < results.MinMemory) results.MinMemory = mem; results.TotalTime = (end - start).TotalSeconds; - results.TotalSpeed = (bufferSize / 1048576) / results.TotalTime; + results.TotalSpeed = bufferSize / 1048576 / results.TotalTime; #endregion - results.SeparateSpeed = (bufferSize / 1048576) / results.SeparateTime; + results.SeparateSpeed = bufferSize / 1048576 / results.SeparateTime; return results; } diff --git a/DiscImageChef.Core/Devices/Dumping/ATA.cs b/DiscImageChef.Core/Devices/Dumping/ATA.cs index 36ce0534..f60841f5 100644 --- a/DiscImageChef.Core/Devices/Dumping/ATA.cs +++ b/DiscImageChef.Core/Devices/Dumping/ATA.cs @@ -216,10 +216,10 @@ namespace DiscImageChef.Core.Devices.Dumping dumpLog.WriteLine("Device reports {0} bytes per logical block.", blockSize); dumpLog.WriteLine("Device reports {0} bytes per physical block.", physicalsectorsize); - bool removable = false || (!dev.IsCompactFlash && - ataId.GeneralConfiguration.HasFlag(Decoders.ATA.Identify - .GeneralConfigurationBit - .Removable)); + bool removable = false || !dev.IsCompactFlash && + ataId.GeneralConfiguration.HasFlag(Decoders.ATA.Identify + .GeneralConfigurationBit + .Removable); DumpHardwareType currentTry = null; ExtentsULong extents = null; ResumeSupport.Process(ataReader.IsLba, removable, blocks, dev.Manufacturer, dev.Model, dev.Serial, @@ -248,7 +248,7 @@ namespace DiscImageChef.Core.Devices.Dumping break; } - if((blocks - i) < blocksToRead) blocksToRead = (byte)(blocks - i); + if(blocks - i < blocksToRead) blocksToRead = (byte)(blocks - i); #pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator if(currentSpeed > maxSpeed && currentSpeed != 0) maxSpeed = currentSpeed; @@ -279,7 +279,7 @@ namespace DiscImageChef.Core.Devices.Dumping } #pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created - currentSpeed = ((double)blockSize * blocksToRead / (double)1048576) / (duration / (double)1000); + currentSpeed = (double)blockSize * blocksToRead / (double)1048576 / (duration / (double)1000); #pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created GC.Collect(); resume.NextBlock = i + blocksToRead; @@ -290,12 +290,12 @@ namespace DiscImageChef.Core.Devices.Dumping mhddLog.Close(); #pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created ibgLog.Close(dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, - (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalDuration / 1000), + (double)blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), devicePath); #pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created dumpLog.WriteLine("Dump finished in {0} seconds.", (end - start).TotalSeconds); dumpLog.WriteLine("Average dump speed {0:F3} KiB/sec.", - (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalDuration / 1000)); + (double)blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000)); #region Error handling if(resume.BadBlocks.Count > 0 && !aborted) @@ -401,7 +401,7 @@ namespace DiscImageChef.Core.Devices.Dumping } #pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created - currentSpeed = ((double)blockSize / (double)1048576) / (duration / (double)1000); + currentSpeed = (double)blockSize / (double)1048576 / (duration / (double)1000); #pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created GC.Collect(); @@ -415,12 +415,12 @@ namespace DiscImageChef.Core.Devices.Dumping mhddLog.Close(); #pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created ibgLog.Close(dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, - (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalDuration / 1000), + (double)blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), devicePath); #pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created dumpLog.WriteLine("Dump finished in {0} seconds.", (end - start).TotalSeconds); dumpLog.WriteLine("Average dump speed {0:F3} KiB/sec.", - (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalDuration / 1000)); + (double)blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000)); } dataChk = new Checksum(); @@ -436,7 +436,7 @@ namespace DiscImageChef.Core.Devices.Dumping break; } - if((blocks - i) < blocksToRead) blocksToRead = (byte)(blocks - i); + if(blocks - i < blocksToRead) blocksToRead = (byte)(blocks - i); DicConsole.Write("\rChecksumming sector {0} of {1} ({2:F3} MiB/sec.)", i, blocks, currentSpeed); @@ -449,7 +449,7 @@ namespace DiscImageChef.Core.Devices.Dumping double chkDuration = (chkEnd - chkStart).TotalMilliseconds; totalChkDuration += chkDuration; - currentSpeed = ((double)blockSize * blocksToRead / (double)1048576) / (chkDuration / (double)1000); + currentSpeed = (double)blockSize * blocksToRead / (double)1048576 / (chkDuration / (double)1000); } DicConsole.WriteLine(); @@ -457,7 +457,7 @@ namespace DiscImageChef.Core.Devices.Dumping end = DateTime.UtcNow; dumpLog.WriteLine("Checksum finished in {0} seconds.", (end - start).TotalSeconds); dumpLog.WriteLine("Average checksum speed {0:F3} KiB/sec.", - (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalChkDuration / 1000)); + (double)blockSize * (double)(blocks + 1) / 1024 / (totalChkDuration / 1000)); PluginBase plugins = new PluginBase(); plugins.RegisterAllPlugins(encoding); @@ -606,7 +606,7 @@ namespace DiscImageChef.Core.Devices.Dumping DicConsole.WriteLine("Took a total of {0:F3} seconds ({1:F3} processing commands, {2:F3} checksumming).", (end - start).TotalSeconds, totalDuration / 1000, totalChkDuration / 1000); DicConsole.WriteLine("Avegare speed: {0:F3} MiB/sec.", - (((double)blockSize * (double)(blocks + 1)) / 1048576) / (totalDuration / 1000)); + (double)blockSize * (double)(blocks + 1) / 1048576 / (totalDuration / 1000)); DicConsole.WriteLine("Fastest speed burst: {0:F3} MiB/sec.", maxSpeed); DicConsole.WriteLine("Slowest speed burst: {0:F3} MiB/sec.", minSpeed); DicConsole.WriteLine("{0} sectors could not be read.", resume.BadBlocks.Count); diff --git a/DiscImageChef.Core/Devices/Dumping/Alcohol120.cs b/DiscImageChef.Core/Devices/Dumping/Alcohol120.cs index 5513baf0..d0373edd 100644 --- a/DiscImageChef.Core/Devices/Dumping/Alcohol120.cs +++ b/DiscImageChef.Core/Devices/Dumping/Alcohol120.cs @@ -191,7 +191,7 @@ namespace DiscImageChef.Core.Devices.Dumping AlcoholSession[] sessionsArray = sessions.ToArray(); for(int i = 0; i < sessionsArray.Length; i++) { - sessionsArray[i].allBlocks = (byte)(((sessionsArray[i].lastTrack - sessionsArray[i].firstTrack) + 1) + + sessionsArray[i].allBlocks = (byte)(sessionsArray[i].lastTrack - sessionsArray[i].firstTrack + 1 + sessionsArray[i].nonTrackBlocks); sessionsArray[i].trackOffset = (uint)nextOffset; nextOffset += sessionsArray[i].allBlocks * 80; diff --git a/DiscImageChef.Core/Devices/Dumping/CompactDisc.cs b/DiscImageChef.Core/Devices/Dumping/CompactDisc.cs index ee860756..dbdc7fe0 100644 --- a/DiscImageChef.Core/Devices/Dumping/CompactDisc.cs +++ b/DiscImageChef.Core/Devices/Dumping/CompactDisc.cs @@ -466,7 +466,7 @@ namespace DiscImageChef.Core.Devices.Dumping } #pragma warning disable IDE0004 // Remove Unnecessary Cast - currentSpeed = ((double)blockSize / (double)1048576) / (cmdDuration / (double)1000); + currentSpeed = (double)blockSize / (double)1048576 / (cmdDuration / (double)1000); #pragma warning restore IDE0004 // Remove Unnecessary Cast } @@ -562,7 +562,7 @@ namespace DiscImageChef.Core.Devices.Dumping } alcohol.SetTrackSizes((byte)(t + 1), sectorSize, tracks[t].StartSector, dumpFile.Position, - (tracks[t].EndSector - tracks[t].StartSector + 1)); + tracks[t].EndSector - tracks[t].StartSector + 1); bool checkedDataFormat = false; @@ -577,7 +577,7 @@ namespace DiscImageChef.Core.Devices.Dumping double cmdDuration = 0; - if(((ulong)tracks[t].EndSector + 1 - i) < blocksToRead) + if((ulong)tracks[t].EndSector + 1 - i < blocksToRead) blocksToRead = (uint)((ulong)tracks[t].EndSector + 1 - i); #pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator @@ -664,7 +664,7 @@ namespace DiscImageChef.Core.Devices.Dumping } #pragma warning disable IDE0004 // Remove Unnecessary Cast - currentSpeed = ((double)blockSize * blocksToRead / (double)1048576) / (cmdDuration / (double)1000); + currentSpeed = (double)blockSize * blocksToRead / (double)1048576 / (cmdDuration / (double)1000); #pragma warning restore IDE0004 // Remove Unnecessary Cast resume.NextBlock = i + blocksToRead; } @@ -708,11 +708,11 @@ namespace DiscImageChef.Core.Devices.Dumping mhddLog.Close(); #pragma warning disable IDE0004 // Remove Unnecessary Cast ibgLog.Close(dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, - (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalDuration / 1000), devicePath); + (double)blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), devicePath); #pragma warning restore IDE0004 // Remove Unnecessary Cast dumpLog.WriteLine("Dump finished in {0} seconds.", (end - start).TotalSeconds); dumpLog.WriteLine("Average dump speed {0:F3} KiB/sec.", - (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalDuration / 1000)); + (double)blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000)); #region Compact Disc Error handling if(resume.BadBlocks.Count > 0 && !aborted) @@ -746,7 +746,7 @@ namespace DiscImageChef.Core.Devices.Dumping totalDuration += cmdDuration; } - if((!sense && !dev.Error) || runningPersistent) + if(!sense && !dev.Error || runningPersistent) { if(!sense && !dev.Error) { @@ -862,7 +862,7 @@ namespace DiscImageChef.Core.Devices.Dumping break; } - if(((ulong)tracks[t].EndSector + 1 - i) < blocksToRead) + if((ulong)tracks[t].EndSector + 1 - i < blocksToRead) blocksToRead = (uint)((ulong)tracks[t].EndSector + 1 - i); DicConsole.Write("\rChecksumming sector {0} of {1} at track {3} ({2:F3} MiB/sec.)", i, blocks, @@ -896,7 +896,7 @@ namespace DiscImageChef.Core.Devices.Dumping totalChkDuration += chkDuration; #pragma warning disable IDE0004 // Remove Unnecessary Cast - currentSpeed = ((double)blockSize * blocksToRead / (double)1048576) / (chkDuration / (double)1000); + currentSpeed = (double)blockSize * blocksToRead / (double)1048576 / (chkDuration / (double)1000); #pragma warning restore IDE0004 // Remove Unnecessary Cast } @@ -910,7 +910,7 @@ namespace DiscImageChef.Core.Devices.Dumping end = DateTime.UtcNow; dumpLog.WriteLine("Checksum finished in {0} seconds.", (end - start).TotalSeconds); dumpLog.WriteLine("Average checksum speed {0:F3} KiB/sec.", - (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalChkDuration / 1000)); + (double)blockSize * (double)(blocks + 1) / 1024 / (totalChkDuration / 1000)); // TODO: Correct this sidecar.OpticalDisc[0].Checksums = dataChk.End().ToArray(); diff --git a/DiscImageChef.Core/Devices/Dumping/MMC.cs b/DiscImageChef.Core/Devices/Dumping/MMC.cs index f007ca08..29272b85 100644 --- a/DiscImageChef.Core/Devices/Dumping/MMC.cs +++ b/DiscImageChef.Core/Devices/Dumping/MMC.cs @@ -308,8 +308,8 @@ namespace DiscImageChef.Core.Devices.Dumping sense = dev.ScsiInquiry(out byte[] inqBuf, out senseBuf); if(sense || !Decoders.SCSI.Inquiry.Decode(inqBuf).HasValue || - (Decoders.SCSI.Inquiry.Decode(inqBuf).HasValue && - !Decoders.SCSI.Inquiry.Decode(inqBuf).Value.KreonPresent)) + Decoders.SCSI.Inquiry.Decode(inqBuf).HasValue && + !Decoders.SCSI.Inquiry.Decode(inqBuf).Value.KreonPresent) { dumpLog.WriteLine("Dumping Xbox Game Discs requires a drive with Kreon firmware."); throw new diff --git a/DiscImageChef.Core/Devices/Dumping/SBC.cs b/DiscImageChef.Core/Devices/Dumping/SBC.cs index 627c344b..2259c2dd 100644 --- a/DiscImageChef.Core/Devices/Dumping/SBC.cs +++ b/DiscImageChef.Core/Devices/Dumping/SBC.cs @@ -372,7 +372,7 @@ namespace DiscImageChef.Core.Devices.Dumping break; } - if((blocks - i) < blocksToRead) blocksToRead = (uint)(blocks - i); + if(blocks - i < blocksToRead) blocksToRead = (uint)(blocks - i); #pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator if(currentSpeed > maxSpeed && currentSpeed != 0) maxSpeed = currentSpeed; @@ -410,7 +410,7 @@ namespace DiscImageChef.Core.Devices.Dumping } #pragma warning disable IDE0004 // Remove Unnecessary Cast - currentSpeed = ((double)blockSize * blocksToRead / (double)1048576) / (cmdDuration / (double)1000); + currentSpeed = (double)blockSize * blocksToRead / (double)1048576 / (cmdDuration / (double)1000); #pragma warning restore IDE0004 // Remove Unnecessary Cast resume.NextBlock = i + blocksToRead; } @@ -420,11 +420,11 @@ namespace DiscImageChef.Core.Devices.Dumping mhddLog.Close(); #pragma warning disable IDE0004 // Remove Unnecessary Cast ibgLog.Close(dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, - (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalDuration / 1000), devicePath); + (double)blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), devicePath); #pragma warning restore IDE0004 // Remove Unnecessary Cast dumpLog.WriteLine("Dump finished in {0} seconds.", (end - start).TotalSeconds); dumpLog.WriteLine("Average dump speed {0:F3} KiB/sec.", - (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalDuration / 1000)); + (double)blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000)); #region Error handling if(resume.BadBlocks.Count > 0 && !aborted) @@ -592,7 +592,7 @@ namespace DiscImageChef.Core.Devices.Dumping break; } - if((blocks - i) < blocksToRead) blocksToRead = (uint)(blocks - i); + if(blocks - i < blocksToRead) blocksToRead = (uint)(blocks - i); DicConsole.Write("\rChecksumming sector {0} of {1} ({2:F3} MiB/sec.)", i, blocks, currentSpeed); @@ -606,7 +606,7 @@ namespace DiscImageChef.Core.Devices.Dumping totalChkDuration += chkDuration; #pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created - currentSpeed = ((double)blockSize * blocksToRead / (double)1048576) / (chkDuration / (double)1000); + currentSpeed = (double)blockSize * blocksToRead / (double)1048576 / (chkDuration / (double)1000); #pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created } @@ -615,7 +615,7 @@ namespace DiscImageChef.Core.Devices.Dumping end = DateTime.UtcNow; dumpLog.WriteLine("Checksum finished in {0} seconds.", (end - start).TotalSeconds); dumpLog.WriteLine("Average checksum speed {0:F3} KiB/sec.", - (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalChkDuration / 1000)); + (double)blockSize * (double)(blocks + 1) / 1024 / (totalChkDuration / 1000)); PluginBase plugins = new PluginBase(); plugins.RegisterAllPlugins(encoding); @@ -844,7 +844,7 @@ namespace DiscImageChef.Core.Devices.Dumping (end - start).TotalSeconds, totalDuration / 1000, totalChkDuration / 1000); #pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created DicConsole.WriteLine("Avegare speed: {0:F3} MiB/sec.", - (((double)blockSize * (double)(blocks + 1)) / 1048576) / (totalDuration / 1000)); + (double)blockSize * (double)(blocks + 1) / 1048576 / (totalDuration / 1000)); #pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created DicConsole.WriteLine("Fastest speed burst: {0:F3} MiB/sec.", maxSpeed); DicConsole.WriteLine("Slowest speed burst: {0:F3} MiB/sec.", minSpeed); diff --git a/DiscImageChef.Core/Devices/Dumping/SSC.cs b/DiscImageChef.Core/Devices/Dumping/SSC.cs index 52888062..c90257cf 100644 --- a/DiscImageChef.Core/Devices/Dumping/SSC.cs +++ b/DiscImageChef.Core/Devices/Dumping/SSC.cs @@ -101,7 +101,7 @@ namespace DiscImageChef.Core.Devices.Dumping fxSense = Decoders.SCSI.Sense.DecodeFixed(senseBuf, out strSense); // And yet, did not rewind! - if(fxSense.HasValue && ((fxSense.Value.ASC == 0x00 && fxSense.Value.ASCQ != 0x04) || + if(fxSense.HasValue && (fxSense.Value.ASC == 0x00 && fxSense.Value.ASCQ != 0x04 || fxSense.Value.ASC != 0x00)) { DicConsole.WriteLine(); @@ -126,7 +126,7 @@ namespace DiscImageChef.Core.Devices.Dumping // Anyway, <=SCSI-1 tapes do not support partitions fxSense = Decoders.SCSI.Sense.DecodeFixed(senseBuf, out strSense); - if(fxSense.HasValue && ((fxSense.Value.ASC == 0x20 && fxSense.Value.ASCQ != 0x00) || + if(fxSense.HasValue && (fxSense.Value.ASC == 0x20 && fxSense.Value.ASCQ != 0x00 || fxSense.Value.ASC != 0x20 && fxSense.Value.SenseKey != Decoders.SCSI.SenseKeys.IllegalRequest)) { @@ -171,7 +171,7 @@ namespace DiscImageChef.Core.Devices.Dumping (fxSense.Value.ASCQ == 0x1A || fxSense.Value.ASCQ == 0x19)); // And yet, did not rewind! - if(fxSense.HasValue && ((fxSense.Value.ASC == 0x00 && fxSense.Value.ASCQ != 0x04) || + if(fxSense.HasValue && (fxSense.Value.ASC == 0x00 && fxSense.Value.ASCQ != 0x04 || fxSense.Value.ASC != 0x00)) { DicConsole.WriteLine(); @@ -616,7 +616,7 @@ namespace DiscImageChef.Core.Devices.Dumping totalChkDuration += chkDuration; if(currentBlock % 10 == 0) - currentSpeed = ((double)blockSize / (double)1048576) / (duration / (double)1000); + currentSpeed = (double)blockSize / (double)1048576 / (duration / (double)1000); currentBlock++; currentSize += blockSize; currentFileSize += blockSize; @@ -628,18 +628,18 @@ namespace DiscImageChef.Core.Devices.Dumping end = DateTime.UtcNow; mhddLog.Close(); ibgLog.Close(dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, - (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalDuration / 1000), devicePath); + (double)blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), devicePath); dumpLog.WriteLine("Dump finished in {0} seconds.", (end - start).TotalSeconds); dumpLog.WriteLine("Average dump speed {0:F3} KiB/sec.", - (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalDuration / 1000)); + (double)blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000)); dumpLog.WriteLine("Average checksum speed {0:F3} KiB/sec.", - (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalChkDuration / 1000)); + (double)blockSize * (double)(blocks + 1) / 1024 / (totalChkDuration / 1000)); DicConsole.WriteLine("Took a total of {0:F3} seconds ({1:F3} processing commands, {2:F3} checksumming).", (end - start).TotalSeconds, totalDuration / 1000, totalChkDuration / 1000); #pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created DicConsole.WriteLine("Avegare speed: {0:F3} MiB/sec.", - (((double)blockSize * (double)(blocks + 1)) / 1048576) / (totalDuration / 1000)); + (double)blockSize * (double)(blocks + 1) / 1048576 / (totalDuration / 1000)); #pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created DicConsole.WriteLine("Fastest speed burst: {0:F3} MiB/sec.", maxSpeed); DicConsole.WriteLine("Slowest speed burst: {0:F3} MiB/sec.", minSpeed); @@ -656,7 +656,7 @@ namespace DiscImageChef.Core.Devices.Dumping Value = outputPrefix + ".bin" }; sidecar.BlockMedia[0].LogicalBlocks = (long)blocks; - sidecar.BlockMedia[0].Size = (long)(currentSize); + sidecar.BlockMedia[0].Size = (long)currentSize; sidecar.BlockMedia[0].DumpHardwareArray = new DumpHardwareType[1]; sidecar.BlockMedia[0].DumpHardwareArray[0] = new DumpHardwareType {Extents = new ExtentType[1]}; sidecar.BlockMedia[0].DumpHardwareArray[0].Extents[0] = new ExtentType {Start = 0, End = blocks - 1}; diff --git a/DiscImageChef.Core/Devices/Dumping/SecureDigital.cs b/DiscImageChef.Core/Devices/Dumping/SecureDigital.cs index ed6f534f..a421650a 100644 --- a/DiscImageChef.Core/Devices/Dumping/SecureDigital.cs +++ b/DiscImageChef.Core/Devices/Dumping/SecureDigital.cs @@ -306,7 +306,7 @@ namespace DiscImageChef.Core.Devices.Dumping break; } - if((blocks - i) < blocksToRead) blocksToRead = (byte)(blocks - i); + if(blocks - i < blocksToRead) blocksToRead = (byte)(blocks - i); #pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator if(currentSpeed > maxSpeed && currentSpeed != 0) maxSpeed = currentSpeed; @@ -338,7 +338,7 @@ namespace DiscImageChef.Core.Devices.Dumping } #pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created - currentSpeed = ((double)blockSize * blocksToRead / (double)1048576) / (duration / (double)1000); + currentSpeed = (double)blockSize * blocksToRead / (double)1048576 / (duration / (double)1000); #pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created GC.Collect(); resume.NextBlock = i + blocksToRead; @@ -349,11 +349,11 @@ namespace DiscImageChef.Core.Devices.Dumping mhddLog.Close(); #pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created ibgLog.Close(dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, - (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalDuration / 1000), devicePath); + (double)blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), devicePath); #pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created dumpLog.WriteLine("Dump finished in {0} seconds.", (end - start).TotalSeconds); dumpLog.WriteLine("Average dump speed {0:F3} KiB/sec.", - (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalDuration / 1000)); + (double)blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000)); #region Error handling if(resume.BadBlocks.Count > 0 && !aborted) @@ -420,7 +420,7 @@ namespace DiscImageChef.Core.Devices.Dumping break; } - if((blocks - i) < blocksToRead) blocksToRead = (byte)(blocks - i); + if(blocks - i < blocksToRead) blocksToRead = (byte)(blocks - i); DicConsole.Write("\rChecksumming sector {0} of {1} ({2:F3} MiB/sec.)", i, blocks, currentSpeed); @@ -433,7 +433,7 @@ namespace DiscImageChef.Core.Devices.Dumping double chkDuration = (chkEnd - chkStart).TotalMilliseconds; totalChkDuration += chkDuration; - currentSpeed = ((double)blockSize * blocksToRead / (double)1048576) / (chkDuration / (double)1000); + currentSpeed = (double)blockSize * blocksToRead / (double)1048576 / (chkDuration / (double)1000); } DicConsole.WriteLine(); @@ -441,7 +441,7 @@ namespace DiscImageChef.Core.Devices.Dumping end = DateTime.UtcNow; dumpLog.WriteLine("Checksum finished in {0} seconds.", (end - start).TotalSeconds); dumpLog.WriteLine("Average checksum speed {0:F3} KiB/sec.", - (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalChkDuration / 1000)); + (double)blockSize * (double)(blocks + 1) / 1024 / (totalChkDuration / 1000)); PluginBase plugins = new PluginBase(); plugins.RegisterAllPlugins(encoding); @@ -582,7 +582,7 @@ namespace DiscImageChef.Core.Devices.Dumping DicConsole.WriteLine("Took a total of {0:F3} seconds ({1:F3} processing commands, {2:F3} checksumming).", (end - start).TotalSeconds, totalDuration / 1000, totalChkDuration / 1000); DicConsole.WriteLine("Avegare speed: {0:F3} MiB/sec.", - (((double)blockSize * (double)(blocks + 1)) / 1048576) / (totalDuration / 1000)); + (double)blockSize * (double)(blocks + 1) / 1048576 / (totalDuration / 1000)); DicConsole.WriteLine("Fastest speed burst: {0:F3} MiB/sec.", maxSpeed); DicConsole.WriteLine("Slowest speed burst: {0:F3} MiB/sec.", minSpeed); DicConsole.WriteLine("{0} sectors could not be read.", resume.BadBlocks.Count); diff --git a/DiscImageChef.Core/Devices/Dumping/XGD.cs b/DiscImageChef.Core/Devices/Dumping/XGD.cs index 187d294f..d7ebb366 100644 --- a/DiscImageChef.Core/Devices/Dumping/XGD.cs +++ b/DiscImageChef.Core/Devices/Dumping/XGD.cs @@ -134,7 +134,7 @@ namespace DiscImageChef.Core.Devices.Dumping return; } - totalSize = (ulong)((readBuffer[0] << 24) + (readBuffer[1] << 16) + (readBuffer[2] << 8) + (readBuffer[3])); + totalSize = (ulong)((readBuffer[0] << 24) + (readBuffer[1] << 16) + (readBuffer[2] << 8) + readBuffer[3]); dumpLog.WriteLine("Reading Physical Format Information."); sense = dev.ReadDiscStructure(out readBuffer, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, MmcDiscStructureFormat.PhysicalInformation, 0, 0, out duration); @@ -198,7 +198,7 @@ namespace DiscImageChef.Core.Devices.Dumping return; } - gameSize = (ulong)((readBuffer[0] << 24) + (readBuffer[1] << 16) + (readBuffer[2] << 8) + (readBuffer[3])) + + gameSize = (ulong)((readBuffer[0] << 24) + (readBuffer[1] << 16) + (readBuffer[2] << 8) + readBuffer[3]) + 1; DicConsole.DebugWriteLine("Dump-media command", "Game partition total size: {0} sectors", gameSize); @@ -222,7 +222,7 @@ namespace DiscImageChef.Core.Devices.Dumping return; } - totalSize = (ulong)((readBuffer[0] << 24) + (readBuffer[1] << 16) + (readBuffer[2] << 8) + (readBuffer[3])); + totalSize = (ulong)((readBuffer[0] << 24) + (readBuffer[1] << 16) + (readBuffer[2] << 8) + readBuffer[3]); dumpLog.WriteLine("Reading Physical Format Information."); sense = dev.ReadDiscStructure(out readBuffer, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, MmcDiscStructureFormat.PhysicalInformation, 0, 0, out duration); @@ -389,7 +389,7 @@ namespace DiscImageChef.Core.Devices.Dumping break; } - if((extentStart - i) < blocksToRead) blocksToRead = (uint)(extentStart - i); + if(extentStart - i < blocksToRead) blocksToRead = (uint)(extentStart - i); #pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator if(currentSpeed > maxSpeed && currentSpeed != 0) maxSpeed = currentSpeed; @@ -435,7 +435,7 @@ namespace DiscImageChef.Core.Devices.Dumping } #pragma warning disable IDE0004 // Remove Unnecessary Cast - currentSpeed = ((double)blockSize * blocksToRead / (double)1048576) / (cmdDuration / (double)1000); + currentSpeed = (double)blockSize * blocksToRead / (double)1048576 / (cmdDuration / (double)1000); #pragma warning restore IDE0004 // Remove Unnecessary Cast blocksToRead = saveBlocksToRead; currentSector = i + 1; @@ -452,7 +452,7 @@ namespace DiscImageChef.Core.Devices.Dumping break; } - if((extentEnd - i) < blocksToRead) blocksToRead = (uint)(extentEnd - i) + 1; + if(extentEnd - i < blocksToRead) blocksToRead = (uint)(extentEnd - i) + 1; mhddLog.Write(i, cmdDuration); ibgLog.Write(i, currentSpeed * 1024); @@ -468,7 +468,7 @@ namespace DiscImageChef.Core.Devices.Dumping // Middle Zone D dumpLog.WriteLine("Writing Middle Zone D (empty)."); - for(ulong middle = currentSector - blocks - 1; middle < (middleZone - 1); middle += blocksToRead) + for(ulong middle = currentSector - blocks - 1; middle < middleZone - 1; middle += blocksToRead) { if(aborted) { @@ -477,7 +477,7 @@ namespace DiscImageChef.Core.Devices.Dumping break; } - if(((middleZone - 1) - middle) < blocksToRead) blocksToRead = (uint)((middleZone - 1) - middle); + if(middleZone - 1 - middle < blocksToRead) blocksToRead = (uint)(middleZone - 1 - middle); DicConsole.Write("\rReading sector {0} of {1} ({2:F3} MiB/sec.)", middle + currentSector, totalSize, currentSpeed); @@ -511,7 +511,7 @@ namespace DiscImageChef.Core.Devices.Dumping // Video Layer 1 dumpLog.WriteLine("Reading Video Layer 1."); - for(ulong l1 = currentSector - blocks - middleZone + l0Video; l1 < (l0Video + l1Video); l1 += blocksToRead) + for(ulong l1 = currentSector - blocks - middleZone + l0Video; l1 < l0Video + l1Video; l1 += blocksToRead) { if(aborted) { @@ -520,7 +520,7 @@ namespace DiscImageChef.Core.Devices.Dumping break; } - if(((l0Video + l1Video) - l1) < blocksToRead) blocksToRead = (uint)((l0Video + l1Video) - l1); + if(l0Video + l1Video - l1 < blocksToRead) blocksToRead = (uint)(l0Video + l1Video - l1); #pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator if(currentSpeed > maxSpeed && currentSpeed != 0) maxSpeed = currentSpeed; @@ -566,7 +566,7 @@ namespace DiscImageChef.Core.Devices.Dumping } #pragma warning disable IDE0004 // Remove Unnecessary Cast - currentSpeed = ((double)blockSize * blocksToRead / (double)1048576) / (cmdDuration / (double)1000); + currentSpeed = (double)blockSize * blocksToRead / (double)1048576 / (cmdDuration / (double)1000); #pragma warning restore IDE0004 // Remove Unnecessary Cast currentSector += blocksToRead; resume.NextBlock = currentSector; @@ -593,11 +593,11 @@ namespace DiscImageChef.Core.Devices.Dumping mhddLog.Close(); #pragma warning disable IDE0004 // Remove Unnecessary Cast ibgLog.Close(dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, - (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalDuration / 1000), devicePath); + (double)blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), devicePath); #pragma warning restore IDE0004 // Remove Unnecessary Cast dumpLog.WriteLine("Dump finished in {0} seconds.", (end - start).TotalSeconds); dumpLog.WriteLine("Average dump speed {0:F3} KiB/sec.", - (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalDuration / 1000)); + (double)blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000)); #region Error handling if(resume.BadBlocks.Count > 0 && !aborted) @@ -778,7 +778,7 @@ namespace DiscImageChef.Core.Devices.Dumping break; } - if((blocks - i) < blocksToRead) blocksToRead = (uint)(blocks - i); + if(blocks - i < blocksToRead) blocksToRead = (uint)(blocks - i); DicConsole.Write("\rChecksumming sector {0} of {1} ({2:F3} MiB/sec.)", i, blocks, currentSpeed); @@ -792,7 +792,7 @@ namespace DiscImageChef.Core.Devices.Dumping totalChkDuration += chkDuration; #pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created - currentSpeed = ((double)blockSize * blocksToRead / (double)1048576) / (chkDuration / (double)1000); + currentSpeed = (double)blockSize * blocksToRead / (double)1048576 / (chkDuration / (double)1000); #pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created } @@ -801,7 +801,7 @@ namespace DiscImageChef.Core.Devices.Dumping end = DateTime.UtcNow; dumpLog.WriteLine("Checksum finished in {0} seconds.", (end - start).TotalSeconds); dumpLog.WriteLine("Average checksum speed {0:F3} KiB/sec.", - (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalChkDuration / 1000)); + (double)blockSize * (double)(blocks + 1) / 1024 / (totalChkDuration / 1000)); PluginBase plugins = new PluginBase(); plugins.RegisterAllPlugins(encoding); diff --git a/DiscImageChef.Core/Devices/ReaderATA.cs b/DiscImageChef.Core/Devices/ReaderATA.cs index dd494c45..fc110f44 100644 --- a/DiscImageChef.Core/Devices/ReaderATA.cs +++ b/DiscImageChef.Core/Devices/ReaderATA.cs @@ -86,8 +86,7 @@ namespace DiscImageChef.Core.Devices blocks = (ulong)(cylinders * heads * sectors); } - if((ataId.CurrentCylinders == 0 || ataId.CurrentHeads == 0 || ataId.CurrentSectorsPerTrack == 0) && - (ataId.Cylinders > 0 && ataId.Heads > 0 && ataId.SectorsPerTrack > 0)) + if((ataId.CurrentCylinders == 0 || ataId.CurrentHeads == 0 || ataId.CurrentSectorsPerTrack == 0) && ataId.Cylinders > 0 && ataId.Heads > 0 && ataId.SectorsPerTrack > 0) { cylinders = ataId.Cylinders; heads = (byte)ataId.Heads; @@ -127,32 +126,32 @@ namespace DiscImageChef.Core.Devices double duration; sense = dev.Read(out cmdBuf, out errorChs, false, 0, 0, 1, 1, timeout, out duration); - ataRead = (!sense && (errorChs.status & 0x27) == 0 && errorChs.error == 0 && cmdBuf.Length > 0); + ataRead = !sense && (errorChs.status & 0x27) == 0 && errorChs.error == 0 && cmdBuf.Length > 0; sense = dev.Read(out cmdBuf, out errorChs, true, 0, 0, 1, 1, timeout, out duration); - ataReadRetry = (!sense && (errorChs.status & 0x27) == 0 && errorChs.error == 0 && cmdBuf.Length > 0); + ataReadRetry = !sense && (errorChs.status & 0x27) == 0 && errorChs.error == 0 && cmdBuf.Length > 0; sense = dev.ReadDma(out cmdBuf, out errorChs, false, 0, 0, 1, 1, timeout, out duration); - ataReadDma = (!sense && (errorChs.status & 0x27) == 0 && errorChs.error == 0 && cmdBuf.Length > 0); + ataReadDma = !sense && (errorChs.status & 0x27) == 0 && errorChs.error == 0 && cmdBuf.Length > 0; sense = dev.ReadDma(out cmdBuf, out errorChs, true, 0, 0, 1, 1, timeout, out duration); - ataReadDmaRetry = (!sense && (errorChs.status & 0x27) == 0 && errorChs.error == 0 && cmdBuf.Length > 0); + ataReadDmaRetry = !sense && (errorChs.status & 0x27) == 0 && errorChs.error == 0 && cmdBuf.Length > 0; sense = dev.Read(out cmdBuf, out errorLba, false, 0, 1, timeout, out duration); - ataReadLba = (!sense && (errorLba.status & 0x27) == 0 && errorLba.error == 0 && cmdBuf.Length > 0); + ataReadLba = !sense && (errorLba.status & 0x27) == 0 && errorLba.error == 0 && cmdBuf.Length > 0; sense = dev.Read(out cmdBuf, out errorLba, true, 0, 1, timeout, out duration); - ataReadRetryLba = (!sense && (errorLba.status & 0x27) == 0 && errorLba.error == 0 && cmdBuf.Length > 0); + ataReadRetryLba = !sense && (errorLba.status & 0x27) == 0 && errorLba.error == 0 && cmdBuf.Length > 0; sense = dev.ReadDma(out cmdBuf, out errorLba, false, 0, 1, timeout, out duration); - ataReadDmaLba = (!sense && (errorLba.status & 0x27) == 0 && errorLba.error == 0 && cmdBuf.Length > 0); + ataReadDmaLba = !sense && (errorLba.status & 0x27) == 0 && errorLba.error == 0 && cmdBuf.Length > 0; sense = dev.ReadDma(out cmdBuf, out errorLba, true, 0, 1, timeout, out duration); - ataReadDmaRetryLba = (!sense && (errorLba.status & 0x27) == 0 && errorLba.error == 0 && cmdBuf.Length > 0); + ataReadDmaRetryLba = !sense && (errorLba.status & 0x27) == 0 && errorLba.error == 0 && cmdBuf.Length > 0; sense = dev.Read(out cmdBuf, out errorLba48, 0, 1, timeout, out duration); - ataReadLba48 = (!sense && (errorLba48.status & 0x27) == 0 && errorLba48.error == 0 && cmdBuf.Length > 0); + ataReadLba48 = !sense && (errorLba48.status & 0x27) == 0 && errorLba48.error == 0 && cmdBuf.Length > 0; sense = dev.ReadDma(out cmdBuf, out errorLba48, 0, 1, timeout, out duration); - ataReadDmaLba48 = (!sense && (errorLba48.status & 0x27) == 0 && errorLba48.error == 0 && cmdBuf.Length > 0); + ataReadDmaLba48 = !sense && (errorLba48.status & 0x27) == 0 && errorLba48.error == 0 && cmdBuf.Length > 0; sense = dev.Seek(out errorChs, 0, 0, 1, timeout, out duration); - ataSeek = (!sense && (errorChs.status & 0x27) == 0 && errorChs.error == 0); + ataSeek = !sense && (errorChs.status & 0x27) == 0 && errorChs.error == 0; sense = dev.Seek(out errorLba, 0, timeout, out duration); - ataSeekLba = (!sense && (errorLba.status & 0x27) == 0 && errorChs.error == 0); + ataSeekLba = !sense && (errorLba.status & 0x27) == 0 && errorChs.error == 0; if(lbaMode) { diff --git a/DiscImageChef.Core/Devices/ReaderSCSI.cs b/DiscImageChef.Core/Devices/ReaderSCSI.cs index 34f7d746..37721e0a 100644 --- a/DiscImageChef.Core/Devices/ReaderSCSI.cs +++ b/DiscImageChef.Core/Devices/ReaderSCSI.cs @@ -84,7 +84,7 @@ namespace DiscImageChef.Core.Devices return true; } - if(read6 && !read10 && !read12 && !read16 && blocks > (0x001FFFFF + 1)) + if(read6 && !read10 && !read12 && !read16 && blocks > 0x001FFFFF + 1) { errorMessage = string.Format("Device only supports SCSI READ (6) but has more than {0} blocks ({1} blocks total)", @@ -93,7 +93,7 @@ namespace DiscImageChef.Core.Devices } #pragma warning disable IDE0004 // Remove Unnecessary Cast - if(!read16 && blocks > ((long)0xFFFFFFFF + (long)1)) + if(!read16 && blocks > (long)0xFFFFFFFF + (long)1) #pragma warning restore IDE0004 // Remove Unnecessary Cast { #pragma warning disable IDE0004 // Remove Unnecessary Cast @@ -406,8 +406,8 @@ namespace DiscImageChef.Core.Devices sense = dev.ReadCapacity(out cmdBuf, out senseBuf, timeout, out duration); if(!sense) { - blocks = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + (cmdBuf[3])); - blockSize = (uint)((cmdBuf[5] << 24) + (cmdBuf[5] << 16) + (cmdBuf[6] << 8) + (cmdBuf[7])); + blocks = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]); + blockSize = (uint)((cmdBuf[5] << 24) + (cmdBuf[5] << 16) + (cmdBuf[6] << 8) + cmdBuf[7]); } if(sense || blocks == 0xFFFFFFFF) @@ -433,7 +433,7 @@ namespace DiscImageChef.Core.Devices Array.Copy(cmdBuf, 0, temp, 0, 8); Array.Reverse(temp); blocks = BitConverter.ToUInt64(temp, 0); - blockSize = (uint)((cmdBuf[5] << 24) + (cmdBuf[5] << 16) + (cmdBuf[6] << 8) + (cmdBuf[7])); + blockSize = (uint)((cmdBuf[5] << 24) + (cmdBuf[5] << 16) + (cmdBuf[6] << 8) + cmdBuf[7]); } } diff --git a/DiscImageChef.Core/Devices/Report/ATA.cs b/DiscImageChef.Core/Devices/Report/ATA.cs index a816c1f8..21b30f56 100644 --- a/DiscImageChef.Core/Devices/Report/ATA.cs +++ b/DiscImageChef.Core/Devices/Report/ATA.cs @@ -690,8 +690,8 @@ namespace DiscImageChef.Core.Devices.Report DicConsole.WriteLine("Trying READ SECTOR(S) in CHS mode..."); sense = dev.Read(out readBuf, out errorChs, false, 0, 0, 1, 1, timeout, out duration); mediaTest.SupportsRead = - (!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && - readBuf.Length > 0); + !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && + readBuf.Length > 0; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); @@ -703,8 +703,8 @@ namespace DiscImageChef.Core.Devices.Report DicConsole.WriteLine("Trying READ SECTOR(S) RETRY in CHS mode..."); sense = dev.Read(out readBuf, out errorChs, true, 0, 0, 1, 1, timeout, out duration); mediaTest.SupportsReadRetry = - (!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && - readBuf.Length > 0); + !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && + readBuf.Length > 0; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); @@ -717,8 +717,8 @@ namespace DiscImageChef.Core.Devices.Report sense = dev.ReadDma(out readBuf, out errorChs, false, 0, 0, 1, 1, timeout, out duration); mediaTest.SupportsReadDma = - (!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && - readBuf.Length > 0); + !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && + readBuf.Length > 0; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); @@ -730,8 +730,8 @@ namespace DiscImageChef.Core.Devices.Report DicConsole.WriteLine("Trying READ DMA RETRY in CHS mode..."); sense = dev.ReadDma(out readBuf, out errorChs, true, 0, 0, 1, 1, timeout, out duration); mediaTest.SupportsReadDmaRetry = - (!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && - readBuf.Length > 0); + !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && + readBuf.Length > 0; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); @@ -743,7 +743,7 @@ namespace DiscImageChef.Core.Devices.Report DicConsole.WriteLine("Trying SEEK in CHS mode..."); sense = dev.Seek(out errorChs, 0, 0, 1, timeout, out duration); mediaTest.SupportsSeek = - (!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0); + !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}", sense, errorChs.status, errorChs.error); @@ -751,8 +751,8 @@ namespace DiscImageChef.Core.Devices.Report DicConsole.WriteLine("Trying READ SECTOR(S) in LBA mode..."); sense = dev.Read(out readBuf, out errorLba, false, 0, 1, timeout, out duration); mediaTest.SupportsReadLba = - (!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && - readBuf.Length > 0); + !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && + readBuf.Length > 0; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); @@ -764,8 +764,8 @@ namespace DiscImageChef.Core.Devices.Report DicConsole.WriteLine("Trying READ SECTOR(S) RETRY in LBA mode..."); sense = dev.Read(out readBuf, out errorLba, true, 0, 1, timeout, out duration); mediaTest.SupportsReadRetryLba = - (!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && - readBuf.Length > 0); + !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && + readBuf.Length > 0; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); @@ -777,8 +777,8 @@ namespace DiscImageChef.Core.Devices.Report DicConsole.WriteLine("Trying READ DMA in LBA mode..."); sense = dev.ReadDma(out readBuf, out errorLba, false, 0, 1, timeout, out duration); mediaTest.SupportsReadDmaLba = - (!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && - readBuf.Length > 0); + !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && + readBuf.Length > 0; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); @@ -790,8 +790,8 @@ namespace DiscImageChef.Core.Devices.Report DicConsole.WriteLine("Trying READ DMA RETRY in LBA mode..."); sense = dev.ReadDma(out readBuf, out errorLba, true, 0, 1, timeout, out duration); mediaTest.SupportsReadDmaRetryLba = - (!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && - readBuf.Length > 0); + !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && + readBuf.Length > 0; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); @@ -803,7 +803,7 @@ namespace DiscImageChef.Core.Devices.Report DicConsole.WriteLine("Trying SEEK in LBA mode..."); sense = dev.Seek(out errorLba, 0, timeout, out duration); mediaTest.SupportsSeekLba = - (!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0); + !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}", sense, errorChs.status, errorChs.error); @@ -811,8 +811,8 @@ namespace DiscImageChef.Core.Devices.Report DicConsole.WriteLine("Trying READ SECTOR(S) in LBA48 mode..."); sense = dev.Read(out readBuf, out errorLba48, 0, 1, timeout, out duration); mediaTest.SupportsReadLba48 = - (!sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 && - readBuf.Length > 0); + !sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 && + readBuf.Length > 0; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); @@ -824,8 +824,8 @@ namespace DiscImageChef.Core.Devices.Report DicConsole.WriteLine("Trying READ DMA in LBA48 mode..."); sense = dev.ReadDma(out readBuf, out errorLba48, 0, 1, timeout, out duration); mediaTest.SupportsReadDmaLba48 = - (!sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 && - readBuf.Length > 0); + !sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 && + readBuf.Length > 0; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); @@ -838,8 +838,8 @@ namespace DiscImageChef.Core.Devices.Report sense = dev.ReadLong(out readBuf, out errorChs, false, 0, 0, 1, mediaTest.LongBlockSize, timeout, out duration); mediaTest.SupportsReadLong = - (!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && - readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead); + !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && + readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); @@ -852,8 +852,8 @@ namespace DiscImageChef.Core.Devices.Report sense = dev.ReadLong(out readBuf, out errorChs, true, 0, 0, 1, mediaTest.LongBlockSize, timeout, out duration); mediaTest.SupportsReadLongRetry = - (!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && - readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead); + !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && + readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); @@ -866,8 +866,8 @@ namespace DiscImageChef.Core.Devices.Report sense = dev.ReadLong(out readBuf, out errorLba, false, 0, mediaTest.LongBlockSize, timeout, out duration); mediaTest.SupportsReadLongLba = - (!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && - readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead); + !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && + readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); @@ -880,8 +880,8 @@ namespace DiscImageChef.Core.Devices.Report sense = dev.ReadLong(out readBuf, out errorLba, true, 0, mediaTest.LongBlockSize, timeout, out duration); mediaTest.SupportsReadLongRetryLba = - (!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && - readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead); + !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && + readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); @@ -1065,7 +1065,7 @@ namespace DiscImageChef.Core.Devices.Report DicConsole.WriteLine("Trying READ SECTOR(S) in CHS mode..."); sense = dev.Read(out readBuf, out errorChs, false, 0, 0, 1, 1, timeout, out duration); report.ATA.ReadCapabilities.SupportsRead = - (!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0); + !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); @@ -1076,7 +1076,7 @@ namespace DiscImageChef.Core.Devices.Report DicConsole.WriteLine("Trying READ SECTOR(S) RETRY in CHS mode..."); sense = dev.Read(out readBuf, out errorChs, true, 0, 0, 1, 1, timeout, out duration); report.ATA.ReadCapabilities.SupportsReadRetry = - (!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0); + !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); @@ -1087,7 +1087,7 @@ namespace DiscImageChef.Core.Devices.Report DicConsole.WriteLine("Trying READ DMA in CHS mode..."); sense = dev.ReadDma(out readBuf, out errorChs, false, 0, 0, 1, 1, timeout, out duration); report.ATA.ReadCapabilities.SupportsReadDma = - (!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0); + !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); @@ -1098,7 +1098,7 @@ namespace DiscImageChef.Core.Devices.Report DicConsole.WriteLine("Trying READ DMA RETRY in CHS mode..."); sense = dev.ReadDma(out readBuf, out errorChs, true, 0, 0, 1, 1, timeout, out duration); report.ATA.ReadCapabilities.SupportsReadDmaRetry = - (!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0); + !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); @@ -1109,14 +1109,14 @@ namespace DiscImageChef.Core.Devices.Report DicConsole.WriteLine("Trying SEEK in CHS mode..."); sense = dev.Seek(out errorChs, 0, 0, 1, timeout, out duration); report.ATA.ReadCapabilities.SupportsSeek = - (!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0); + !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}", sense, errorChs.status, errorChs.error); DicConsole.WriteLine("Trying READ SECTOR(S) in LBA mode..."); sense = dev.Read(out readBuf, out errorLba, false, 0, 1, timeout, out duration); report.ATA.ReadCapabilities.SupportsReadLba = - (!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0); + !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorLba.status, errorLba.error, readBuf.Length); @@ -1127,7 +1127,7 @@ namespace DiscImageChef.Core.Devices.Report DicConsole.WriteLine("Trying READ SECTOR(S) RETRY in LBA mode..."); sense = dev.Read(out readBuf, out errorLba, true, 0, 1, timeout, out duration); report.ATA.ReadCapabilities.SupportsReadRetryLba = - (!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0); + !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorLba.status, errorLba.error, readBuf.Length); @@ -1138,7 +1138,7 @@ namespace DiscImageChef.Core.Devices.Report DicConsole.WriteLine("Trying READ DMA in LBA mode..."); sense = dev.ReadDma(out readBuf, out errorLba, false, 0, 1, timeout, out duration); report.ATA.ReadCapabilities.SupportsReadDmaLba = - (!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0); + !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorLba.status, errorLba.error, readBuf.Length); @@ -1149,7 +1149,7 @@ namespace DiscImageChef.Core.Devices.Report DicConsole.WriteLine("Trying READ DMA RETRY in LBA mode..."); sense = dev.ReadDma(out readBuf, out errorLba, true, 0, 1, timeout, out duration); report.ATA.ReadCapabilities.SupportsReadDmaRetryLba = - (!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0); + !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorLba.status, errorLba.error, readBuf.Length); @@ -1160,14 +1160,14 @@ namespace DiscImageChef.Core.Devices.Report DicConsole.WriteLine("Trying SEEK in LBA mode..."); sense = dev.Seek(out errorLba, 0, timeout, out duration); report.ATA.ReadCapabilities.SupportsSeekLba = - (!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0); + !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}", sense, errorLba.status, errorLba.error); DicConsole.WriteLine("Trying READ SECTOR(S) in LBA48 mode..."); sense = dev.Read(out readBuf, out errorLba48, 0, 1, timeout, out duration); report.ATA.ReadCapabilities.SupportsReadLba48 = - (!sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 && readBuf.Length > 0); + !sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 && readBuf.Length > 0; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorLba48.status, errorLba48.error, readBuf.Length); @@ -1178,7 +1178,7 @@ namespace DiscImageChef.Core.Devices.Report DicConsole.WriteLine("Trying READ DMA in LBA48 mode..."); sense = dev.ReadDma(out readBuf, out errorLba48, 0, 1, timeout, out duration); report.ATA.ReadCapabilities.SupportsReadDmaLba48 = - (!sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 && readBuf.Length > 0); + !sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 && readBuf.Length > 0; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorLba48.status, errorLba48.error, readBuf.Length); @@ -1190,8 +1190,8 @@ namespace DiscImageChef.Core.Devices.Report sense = dev.ReadLong(out readBuf, out errorChs, false, 0, 0, 1, report.ATA.ReadCapabilities.LongBlockSize, timeout, out duration); report.ATA.ReadCapabilities.SupportsReadLong = - (!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0 && - BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead); + !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0 && + BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); @@ -1203,8 +1203,8 @@ namespace DiscImageChef.Core.Devices.Report sense = dev.ReadLong(out readBuf, out errorChs, true, 0, 0, 1, report.ATA.ReadCapabilities.LongBlockSize, timeout, out duration); report.ATA.ReadCapabilities.SupportsReadLongRetry = - (!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0 && - BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead); + !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0 && + BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); @@ -1216,8 +1216,8 @@ namespace DiscImageChef.Core.Devices.Report sense = dev.ReadLong(out readBuf, out errorLba, false, 0, report.ATA.ReadCapabilities.LongBlockSize, timeout, out duration); report.ATA.ReadCapabilities.SupportsReadLongLba = - (!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0 && - BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead); + !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0 && + BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorLba.status, errorLba.error, readBuf.Length); @@ -1229,8 +1229,8 @@ namespace DiscImageChef.Core.Devices.Report sense = dev.ReadLong(out readBuf, out errorLba, true, 0, report.ATA.ReadCapabilities.LongBlockSize, timeout, out duration); report.ATA.ReadCapabilities.SupportsReadLongRetryLba = - (!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0 && - BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead); + !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0 && + BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorLba.status, errorLba.error, readBuf.Length); diff --git a/DiscImageChef.Core/Devices/Report/SCSI/General.cs b/DiscImageChef.Core/Devices/Report/SCSI/General.cs index 759e1e95..ab0fe709 100644 --- a/DiscImageChef.Core/Devices/Report/SCSI/General.cs +++ b/DiscImageChef.Core/Devices/Report/SCSI/General.cs @@ -268,7 +268,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI if(!sense && !dev.Error && !decMode.HasValue) decMode = Decoders.SCSI.Modes.DecodeMode6(mode6Buffer, devType); - report.SCSI.SupportsModeSense6 |= (!sense && !dev.Error); + report.SCSI.SupportsModeSense6 |= !sense && !dev.Error; Decoders.SCSI.Modes.ModePage_2A? cdromMode = null; @@ -408,9 +408,9 @@ namespace DiscImageChef.Core.Devices.Report.SCSI mediaTest.SupportsReadCapacity = true; mediaTest.Blocks = (ulong)((buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + - (buffer[3])) + 1; + buffer[3]) + 1; mediaTest.BlockSize = - (uint)((buffer[4] << 24) + (buffer[5] << 16) + (buffer[6] << 8) + (buffer[7])); + (uint)((buffer[4] << 24) + (buffer[5] << 16) + (buffer[6] << 8) + buffer[7]); mediaTest.BlocksSpecified = true; mediaTest.BlockSizeSpecified = true; } @@ -426,7 +426,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI mediaTest.Blocks = BitConverter.ToUInt64(temp, 0) + 1; mediaTest.BlockSize = (uint)((buffer[8] << 24) + (buffer[9] << 16) + (buffer[10] << 8) + - (buffer[11])); + buffer[11]); mediaTest.BlocksSpecified = true; mediaTest.BlockSizeSpecified = true; } @@ -685,9 +685,9 @@ namespace DiscImageChef.Core.Devices.Report.SCSI { report.SCSI.ReadCapabilities.SupportsReadCapacity = true; report.SCSI.ReadCapabilities.Blocks = - (ulong)((buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + (buffer[3])) + 1; + (ulong)((buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + buffer[3]) + 1; report.SCSI.ReadCapabilities.BlockSize = - (uint)((buffer[4] << 24) + (buffer[5] << 16) + (buffer[6] << 8) + (buffer[7])); + (uint)((buffer[4] << 24) + (buffer[5] << 16) + (buffer[6] << 8) + buffer[7]); report.SCSI.ReadCapabilities.BlocksSpecified = true; report.SCSI.ReadCapabilities.BlockSizeSpecified = true; } @@ -702,7 +702,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI Array.Reverse(temp); report.SCSI.ReadCapabilities.Blocks = BitConverter.ToUInt64(temp, 0) + 1; report.SCSI.ReadCapabilities.BlockSize = - (uint)((buffer[8] << 24) + (buffer[9] << 16) + (buffer[10] << 8) + (buffer[11])); + (uint)((buffer[8] << 24) + (buffer[9] << 16) + (buffer[10] << 8) + buffer[11]); report.SCSI.ReadCapabilities.BlocksSpecified = true; report.SCSI.ReadCapabilities.BlockSizeSpecified = true; } diff --git a/DiscImageChef.Core/Devices/Report/SCSI/MMC.cs b/DiscImageChef.Core/Devices/Report/SCSI/MMC.cs index b5ac6c16..f32aefe5 100644 --- a/DiscImageChef.Core/Devices/Report/SCSI/MMC.cs +++ b/DiscImageChef.Core/Devices/Report/SCSI/MMC.cs @@ -841,9 +841,9 @@ namespace DiscImageChef.Core.Devices.Report.SCSI { mediaTest.SupportsReadCapacity = true; mediaTest.Blocks = - (ulong)((buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + (buffer[3])) + 1; + (ulong)((buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + buffer[3]) + 1; mediaTest.BlockSize = - (uint)((buffer[5] << 24) + (buffer[5] << 16) + (buffer[6] << 8) + (buffer[7])); + (uint)((buffer[5] << 24) + (buffer[5] << 16) + (buffer[6] << 8) + buffer[7]); mediaTest.BlocksSpecified = true; mediaTest.BlockSizeSpecified = true; } @@ -858,7 +858,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI Array.Reverse(temp); mediaTest.Blocks = BitConverter.ToUInt64(temp, 0) + 1; mediaTest.BlockSize = - (uint)((buffer[5] << 24) + (buffer[5] << 16) + (buffer[6] << 8) + (buffer[7])); + (uint)((buffer[5] << 24) + (buffer[5] << 16) + (buffer[6] << 8) + buffer[7]); mediaTest.BlocksSpecified = true; mediaTest.BlockSizeSpecified = true; } diff --git a/DiscImageChef.Core/Devices/Scanning/ATA.cs b/DiscImageChef.Core/Devices/Scanning/ATA.cs index eff7be6b..f688f4db 100644 --- a/DiscImageChef.Core/Devices/Scanning/ATA.cs +++ b/DiscImageChef.Core/Devices/Scanning/ATA.cs @@ -131,7 +131,7 @@ namespace DiscImageChef.Core.Devices.Scanning { if(aborted) break; - if((results.Blocks - i) < blocksToRead) blocksToRead = (byte)(results.Blocks - i); + if(results.Blocks - i < blocksToRead) blocksToRead = (byte)(results.Blocks - i); #pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator if(currentSpeed > results.MaxSpeed && currentSpeed != 0) results.MaxSpeed = currentSpeed; @@ -167,7 +167,7 @@ namespace DiscImageChef.Core.Devices.Scanning } #pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values - currentSpeed = ((double)blockSize * blocksToRead / (double)1048576) / (duration / (double)1000); + currentSpeed = (double)blockSize * blocksToRead / (double)1048576 / (duration / (double)1000); #pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values GC.Collect(); } @@ -177,7 +177,7 @@ namespace DiscImageChef.Core.Devices.Scanning mhddLog.Close(); #pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values ibgLog.Close(dev, results.Blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, - (((double)blockSize * (double)(results.Blocks + 1)) / 1024) / + (double)blockSize * (double)(results.Blocks + 1) / 1024 / (results.ProcessingTime / 1000), devicePath); #pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values @@ -254,7 +254,7 @@ namespace DiscImageChef.Core.Devices.Scanning } #pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values - currentSpeed = ((double)blockSize / (double)1048576) / (duration / (double)1000); + currentSpeed = (double)blockSize / (double)1048576 / (duration / (double)1000); #pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values GC.Collect(); @@ -268,7 +268,7 @@ namespace DiscImageChef.Core.Devices.Scanning mhddLog.Close(); #pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values ibgLog.Close(dev, results.Blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, - (((double)blockSize * (double)(results.Blocks + 1)) / 1024) / + (double)blockSize * (double)(results.Blocks + 1) / 1024 / (results.ProcessingTime / 1000), devicePath); #pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values @@ -303,7 +303,7 @@ namespace DiscImageChef.Core.Devices.Scanning results.ProcessingTime /= 1000; results.TotalTime = (end - start).TotalSeconds; #pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values - results.AvgSpeed = (((double)blockSize * (double)(results.Blocks + 1)) / 1048576) / + results.AvgSpeed = (double)blockSize * (double)(results.Blocks + 1) / 1048576 / results.ProcessingTime; #pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values results.SeekTimes = SEEK_TIMES; diff --git a/DiscImageChef.Core/Devices/Scanning/SCSI.cs b/DiscImageChef.Core/Devices/Scanning/SCSI.cs index dcf1a447..bcbb378d 100644 --- a/DiscImageChef.Core/Devices/Scanning/SCSI.cs +++ b/DiscImageChef.Core/Devices/Scanning/SCSI.cs @@ -288,7 +288,7 @@ namespace DiscImageChef.Core.Devices.Scanning double cmdDuration = 0; - if((results.Blocks - i) < blocksToRead) blocksToRead = (uint)(results.Blocks - i); + if(results.Blocks - i < blocksToRead) blocksToRead = (uint)(results.Blocks - i); #pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator if(currentSpeed > results.MaxSpeed && currentSpeed != 0) results.MaxSpeed = currentSpeed; @@ -354,7 +354,7 @@ namespace DiscImageChef.Core.Devices.Scanning } #pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values - currentSpeed = ((double)blockSize * blocksToRead / (double)1048576) / (cmdDuration / (double)1000); + currentSpeed = (double)blockSize * blocksToRead / (double)1048576 / (cmdDuration / (double)1000); #pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values GC.Collect(); } @@ -364,7 +364,7 @@ namespace DiscImageChef.Core.Devices.Scanning mhddLog.Close(); #pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values ibgLog.Close(dev, results.Blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, - (((double)blockSize * (double)(results.Blocks + 1)) / 1024) / + (double)blockSize * (double)(results.Blocks + 1) / 1024 / (results.ProcessingTime / 1000), devicePath); #pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values } @@ -383,7 +383,7 @@ namespace DiscImageChef.Core.Devices.Scanning double cmdDuration = 0; - if((results.Blocks - i) < blocksToRead) blocksToRead = (uint)(results.Blocks - i); + if(results.Blocks - i < blocksToRead) blocksToRead = (uint)(results.Blocks - i); #pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator if(currentSpeed > results.MaxSpeed && currentSpeed != 0) results.MaxSpeed = currentSpeed; @@ -419,7 +419,7 @@ namespace DiscImageChef.Core.Devices.Scanning } #pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values - currentSpeed = ((double)blockSize * blocksToRead / (double)1048576) / (cmdDuration / (double)1000); + currentSpeed = (double)blockSize * blocksToRead / (double)1048576 / (cmdDuration / (double)1000); #pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values } @@ -428,7 +428,7 @@ namespace DiscImageChef.Core.Devices.Scanning mhddLog.Close(); #pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values ibgLog.Close(dev, results.Blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, - (((double)blockSize * (double)(results.Blocks + 1)) / 1024) / + (double)blockSize * (double)(results.Blocks + 1) / 1024 / (results.ProcessingTime / 1000), devicePath); #pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values } @@ -469,7 +469,7 @@ namespace DiscImageChef.Core.Devices.Scanning results.ProcessingTime /= 1000; results.TotalTime = (end - start).TotalSeconds; #pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values - results.AvgSpeed = (((double)blockSize * (double)(results.Blocks + 1)) / 1048576) / results.ProcessingTime; + results.AvgSpeed = (double)blockSize * (double)(results.Blocks + 1) / 1048576 / results.ProcessingTime; #pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values results.SeekTimes = SEEK_TIMES; diff --git a/DiscImageChef.Core/Devices/Scanning/SecureDigital.cs b/DiscImageChef.Core/Devices/Scanning/SecureDigital.cs index 2282dcba..5e346e3c 100644 --- a/DiscImageChef.Core/Devices/Scanning/SecureDigital.cs +++ b/DiscImageChef.Core/Devices/Scanning/SecureDigital.cs @@ -165,7 +165,7 @@ namespace DiscImageChef.Core.Devices.Scanning { if(aborted) break; - if((results.Blocks - i) < blocksToRead) blocksToRead = (byte)(results.Blocks - i); + if(results.Blocks - i < blocksToRead) blocksToRead = (byte)(results.Blocks - i); #pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator if(currentSpeed > results.MaxSpeed && currentSpeed != 0) results.MaxSpeed = currentSpeed; @@ -201,7 +201,7 @@ namespace DiscImageChef.Core.Devices.Scanning } #pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values - currentSpeed = ((double)blockSize * blocksToRead / (double)1048576) / (duration / (double)1000); + currentSpeed = (double)blockSize * blocksToRead / (double)1048576 / (duration / (double)1000); #pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values GC.Collect(); } @@ -211,7 +211,7 @@ namespace DiscImageChef.Core.Devices.Scanning mhddLog.Close(); #pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values ibgLog.Close(dev, results.Blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, - (((double)blockSize * (double)(results.Blocks + 1)) / 1024) / (results.ProcessingTime / 1000), + (double)blockSize * (double)(results.Blocks + 1) / 1024 / (results.ProcessingTime / 1000), devicePath); #pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values @@ -240,7 +240,7 @@ namespace DiscImageChef.Core.Devices.Scanning results.ProcessingTime /= 1000; results.TotalTime = (end - start).TotalSeconds; #pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values - results.AvgSpeed = (((double)blockSize * (double)(results.Blocks + 1)) / 1048576) / results.ProcessingTime; + results.AvgSpeed = (double)blockSize * (double)(results.Blocks + 1) / 1048576 / results.ProcessingTime; #pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values results.SeekTimes = SEEK_TIMES; diff --git a/DiscImageChef.Core/Logging/IBGLog.cs b/DiscImageChef.Core/Logging/IBGLog.cs index 3de9021b..fb4c0b5f 100644 --- a/DiscImageChef.Core/Logging/IBGLog.cs +++ b/DiscImageChef.Core/Logging/IBGLog.cs @@ -211,7 +211,7 @@ namespace DiscImageChef.Core.Logging ibgSb.AppendFormat("{0:0.00},{1},{2:0},0", ibgIntSpeed / ibgSnaps / ibgDivider, ibgIntSector, ibgSampleRate).AppendLine(); - if((ibgIntSpeed / ibgSnaps / ibgDivider) > ibgMaxSpeed) ibgMaxSpeed = ibgIntSpeed / ibgDivider; + if(ibgIntSpeed / ibgSnaps / ibgDivider > ibgMaxSpeed) ibgMaxSpeed = ibgIntSpeed / ibgDivider; ibgDatePoint = DateTime.Now; ibgIntSpeed = 0; diff --git a/DiscImageChef.Core/Sidecar/BlockMedia.cs b/DiscImageChef.Core/Sidecar/BlockMedia.cs index 0aa8d52e..0c755026 100644 --- a/DiscImageChef.Core/Sidecar/BlockMedia.cs +++ b/DiscImageChef.Core/Sidecar/BlockMedia.cs @@ -254,7 +254,7 @@ namespace DiscImageChef.Core { byte[] sector; - if((sectors - doneSectors) >= sectorsToRead) + if(sectors - doneSectors >= sectorsToRead) { sector = image.ReadSectors(doneSectors, sectorsToRead); UpdateProgress2("Hashings sector {0} of {1}", (long)doneSectors, (long)sectors); @@ -264,7 +264,7 @@ namespace DiscImageChef.Core { sector = image.ReadSectors(doneSectors, (uint)(sectors - doneSectors)); UpdateProgress2("Hashings sector {0} of {1}", (long)doneSectors, (long)sectors); - doneSectors += (sectors - doneSectors); + doneSectors += sectors - doneSectors; } contentChkWorker.Update(sector); @@ -306,7 +306,7 @@ namespace DiscImageChef.Core sidecar.BlockMedia[0].FileSystemInformation[i] = new PartitionType { Description = partitions[i].Description, - EndSector = (int)(partitions[i].End), + EndSector = (int)partitions[i].End, Name = partitions[i].Name, Sequence = (int)partitions[i].Sequence, StartSector = (int)partitions[i].Start, @@ -545,8 +545,8 @@ namespace DiscImageChef.Core try { scpImage.OpenImage(scpFilter); } catch(NotImplementedException) { } - if((image.ImageInfo.Heads == 2 && scpImage.Header.heads == 0) || - (image.ImageInfo.Heads == 1 && (scpImage.Header.heads == 1 || scpImage.Header.heads == 2))) + if(image.ImageInfo.Heads == 2 && scpImage.Header.heads == 0 || + image.ImageInfo.Heads == 1 && (scpImage.Header.heads == 1 || scpImage.Header.heads == 2)) { if(scpImage.Header.end + 1 >= image.ImageInfo.Cylinders) { @@ -577,8 +577,8 @@ namespace DiscImageChef.Core if(scpImage.Tracks.TryGetValue(t, out SuperCardPro.TrackHeader scpTrack)) { byte[] trackContents = - new byte[(scpTrack.Entries.Last().dataOffset + - scpTrack.Entries.Last().trackLength) - scpImage.Header.offsets[t] + + new byte[scpTrack.Entries.Last().dataOffset + + scpTrack.Entries.Last().trackLength - scpImage.Header.offsets[t] + 1]; scpStream.Position = scpImage.Header.offsets[t]; scpStream.Read(trackContents, 0, trackContents.Length); diff --git a/DiscImageChef.Core/Sidecar/BlockTape.cs b/DiscImageChef.Core/Sidecar/BlockTape.cs index 3eb8065d..0a4085dc 100644 --- a/DiscImageChef.Core/Sidecar/BlockTape.cs +++ b/DiscImageChef.Core/Sidecar/BlockTape.cs @@ -98,7 +98,7 @@ namespace DiscImageChef.Core { byte[] sector; - if((sectors - doneSectors) >= sectorsToRead) + if(sectors - doneSectors >= sectorsToRead) { sector = new byte[sectorsToRead * blockSize]; fs.Read(sector, 0, sector.Length); @@ -112,14 +112,14 @@ namespace DiscImageChef.Core fs.Read(sector, 0, sector.Length); UpdateProgress2(string.Format("Hashing block {0} of {1} on file {2} of {3}", doneSectors, sectors, i + 1, files.Count), doneSectors, sectors); - doneSectors += (sectors - doneSectors); + doneSectors += sectors - doneSectors; } fileWorker.Update(sector); tapeWorker.Update(sector); } - tapeFile.EndBlock = (tapeFile.StartBlock + sectors) - 1; + tapeFile.EndBlock = tapeFile.StartBlock + sectors - 1; currentBlock += sectors; totalSize += fs.Length; tapeFile.Checksums = fileWorker.End().ToArray(); diff --git a/DiscImageChef.Core/Sidecar/OpticalDisc.cs b/DiscImageChef.Core/Sidecar/OpticalDisc.cs index bac5e733..4c7d44b3 100644 --- a/DiscImageChef.Core/Sidecar/OpticalDisc.cs +++ b/DiscImageChef.Core/Sidecar/OpticalDisc.cs @@ -351,7 +351,7 @@ namespace DiscImageChef.Core { byte[] sector; - if((sectors - doneSectors) >= sectorsToRead) + if(sectors - doneSectors >= sectorsToRead) { sector = image.ReadSectorsLong(doneSectors, sectorsToRead, (uint)xmlTrk.Sequence.TrackNumber); @@ -365,7 +365,7 @@ namespace DiscImageChef.Core (uint)xmlTrk.Sequence.TrackNumber); UpdateProgress2("Hashings sector {0} of {1}", (long)doneSectors, (long)(trk.TrackEndSector - trk.TrackStartSector + 1)); - doneSectors += (sectors - doneSectors); + doneSectors += sectors - doneSectors; } trkChkWorker.Update(sector); @@ -419,7 +419,7 @@ namespace DiscImageChef.Core { byte[] sector; - if((sectors - doneSectors) >= sectorsToRead) + if(sectors - doneSectors >= sectorsToRead) { sector = image.ReadSectorsTag(doneSectors, sectorsToRead, (uint)xmlTrk.Sequence.TrackNumber, SectorTagType.CdSectorSubchannel); @@ -434,7 +434,7 @@ namespace DiscImageChef.Core SectorTagType.CdSectorSubchannel); UpdateProgress2("Hashings subchannel sector {0} of {1}", (long)doneSectors, (long)(trk.TrackEndSector - trk.TrackStartSector + 1)); - doneSectors += (sectors - doneSectors); + doneSectors += sectors - doneSectors; } subChkWorker.Update(sector); @@ -465,7 +465,7 @@ namespace DiscImageChef.Core xmlTrk.FileSystemInformation[i] = new PartitionType { Description = partitions[i].Description, - EndSector = (int)(partitions[i].End), + EndSector = (int)partitions[i].End, Name = partitions[i].Name, Sequence = (int)partitions[i].Sequence, StartSector = (int)partitions[i].Start, @@ -514,7 +514,7 @@ namespace DiscImageChef.Core Partition xmlPart = new Partition { Start = (ulong)xmlTrk.StartSector, - Length = (ulong)((xmlTrk.EndSector - xmlTrk.StartSector) + 1), + Length = (ulong)(xmlTrk.EndSector - xmlTrk.StartSector + 1), Type = xmlTrk.TrackType1.ToString(), Size = (ulong)xmlTrk.Size, Sequence = (ulong)xmlTrk.Sequence.TrackNumber diff --git a/DiscImageChef.Core/Sidecar/Sidecar.cs b/DiscImageChef.Core/Sidecar/Sidecar.cs index ac966e11..d51a371a 100644 --- a/DiscImageChef.Core/Sidecar/Sidecar.cs +++ b/DiscImageChef.Core/Sidecar/Sidecar.cs @@ -57,7 +57,7 @@ namespace DiscImageChef.Core byte[] data; long position = 0; InitProgress(); - while(position < (fi.Length - 1048576)) + while(position < fi.Length - 1048576) { data = new byte[1048576]; fs.Read(data, 0, 1048576); diff --git a/DiscImageChef.Decoders/ATA/Identify.cs b/DiscImageChef.Decoders/ATA/Identify.cs index 53d42104..02106f27 100644 --- a/DiscImageChef.Decoders/ATA/Identify.cs +++ b/DiscImageChef.Decoders/ATA/Identify.cs @@ -2417,7 +2417,7 @@ namespace DiscImageChef.Decoders.ATA sb.AppendFormat("Physical sector size: {0} bytes", physicalsectorsize).AppendLine(); sb.AppendFormat("Logical sector size: {0} bytes", logicalsectorsize).AppendLine(); - if((logicalsectorsize != physicalsectorsize) && (ATAID.LogicalAlignment & 0x8000) == 0x0000 && + if(logicalsectorsize != physicalsectorsize && (ATAID.LogicalAlignment & 0x8000) == 0x0000 && (ATAID.LogicalAlignment & 0x4000) == 0x4000) { sb.AppendFormat("Logical sector starts at offset {0} from physical sector", @@ -2462,40 +2462,40 @@ namespace DiscImageChef.Decoders.ATA if(ATAID.CurrentSectors > 0) sb.AppendFormat("Device size in CHS mode: {0} bytes, {1} Mb, {2} MiB", (ulong)ATAID.CurrentSectors * logicalsectorsize, - ((ulong)ATAID.CurrentSectors * logicalsectorsize) / 1000 / 1000, - ((ulong)ATAID.CurrentSectors * 512) / 1024 / 1024).AppendLine(); + (ulong)ATAID.CurrentSectors * logicalsectorsize / 1000 / 1000, + (ulong)ATAID.CurrentSectors * 512 / 1024 / 1024).AppendLine(); else { ulong currentSectors = (ulong)(ATAID.Cylinders * ATAID.Heads * ATAID.SectorsPerTrack); sb.AppendFormat("Device size in CHS mode: {0} bytes, {1} Mb, {2} MiB", currentSectors * logicalsectorsize, - (currentSectors * logicalsectorsize) / 1000 / 1000, - (currentSectors * 512) / 1024 / 1024).AppendLine(); + currentSectors * logicalsectorsize / 1000 / 1000, + currentSectors * 512 / 1024 / 1024).AppendLine(); } } if(ATAID.Capabilities.HasFlag(CapabilitiesBit.LBASupport)) { - if((((ulong)ATAID.LBASectors * logicalsectorsize) / 1024 / 1024) > 1000000) + if((ulong)ATAID.LBASectors * logicalsectorsize / 1024 / 1024 > 1000000) { sb.AppendFormat("Device size in 28-bit LBA mode: {0} bytes, {1} Tb, {2} TiB", (ulong)ATAID.LBASectors * logicalsectorsize, - ((ulong)ATAID.LBASectors * logicalsectorsize) / 1000 / 1000 / 1000 / 1000, - ((ulong)ATAID.LBASectors * 512) / 1024 / 1024 / 1024 / 1024).AppendLine(); + (ulong)ATAID.LBASectors * logicalsectorsize / 1000 / 1000 / 1000 / 1000, + (ulong)ATAID.LBASectors * 512 / 1024 / 1024 / 1024 / 1024).AppendLine(); } - else if((((ulong)ATAID.LBASectors * logicalsectorsize) / 1024 / 1024) > 1000) + else if((ulong)ATAID.LBASectors * logicalsectorsize / 1024 / 1024 > 1000) { sb.AppendFormat("Device size in 28-bit LBA mode: {0} bytes, {1} Gb, {2} GiB", (ulong)ATAID.LBASectors * logicalsectorsize, - ((ulong)ATAID.LBASectors * logicalsectorsize) / 1000 / 1000 / 1000, - ((ulong)ATAID.LBASectors * 512) / 1024 / 1024 / 1024).AppendLine(); + (ulong)ATAID.LBASectors * logicalsectorsize / 1000 / 1000 / 1000, + (ulong)ATAID.LBASectors * 512 / 1024 / 1024 / 1024).AppendLine(); } else { sb.AppendFormat("Device size in 28-bit LBA mode: {0} bytes, {1} Mb, {2} MiB", (ulong)ATAID.LBASectors * logicalsectorsize, - ((ulong)ATAID.LBASectors * logicalsectorsize) / 1000 / 1000, - ((ulong)ATAID.LBASectors * 512) / 1024 / 1024).AppendLine(); + (ulong)ATAID.LBASectors * logicalsectorsize / 1000 / 1000, + (ulong)ATAID.LBASectors * 512 / 1024 / 1024).AppendLine(); } } @@ -2503,53 +2503,53 @@ namespace DiscImageChef.Decoders.ATA { if(ATAID.CommandSet5.HasFlag(CommandSetBit5.ExtSectors)) { - if(((ATAID.ExtendedUserSectors * logicalsectorsize) / 1024 / 1024) > 1000000) + if(ATAID.ExtendedUserSectors * logicalsectorsize / 1024 / 1024 > 1000000) { sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Tb, {2} TiB", ATAID.ExtendedUserSectors * logicalsectorsize, - (ATAID.ExtendedUserSectors * logicalsectorsize) / 1000 / 1000 / 1000 / 1000, - (ATAID.ExtendedUserSectors * logicalsectorsize) / 1024 / 1024 / 1024 / 1024) + ATAID.ExtendedUserSectors * logicalsectorsize / 1000 / 1000 / 1000 / 1000, + ATAID.ExtendedUserSectors * logicalsectorsize / 1024 / 1024 / 1024 / 1024) .AppendLine(); } - else if(((ATAID.ExtendedUserSectors * logicalsectorsize) / 1024 / 1024) > 1000) + else if(ATAID.ExtendedUserSectors * logicalsectorsize / 1024 / 1024 > 1000) { sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Gb, {2} GiB", ATAID.ExtendedUserSectors * logicalsectorsize, - (ATAID.ExtendedUserSectors * logicalsectorsize) / 1000 / 1000 / 1000, - (ATAID.ExtendedUserSectors * logicalsectorsize) / 1024 / 1024 / 1024) + ATAID.ExtendedUserSectors * logicalsectorsize / 1000 / 1000 / 1000, + ATAID.ExtendedUserSectors * logicalsectorsize / 1024 / 1024 / 1024) .AppendLine(); } else { sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Mb, {2} MiB", ATAID.ExtendedUserSectors * logicalsectorsize, - (ATAID.ExtendedUserSectors * logicalsectorsize) / 1000 / 1000, - (ATAID.ExtendedUserSectors * logicalsectorsize) / 1024 / 1024).AppendLine(); + ATAID.ExtendedUserSectors * logicalsectorsize / 1000 / 1000, + ATAID.ExtendedUserSectors * logicalsectorsize / 1024 / 1024).AppendLine(); } } else { - if(((ATAID.LBA48Sectors * logicalsectorsize) / 1024 / 1024) > 1000000) + if(ATAID.LBA48Sectors * logicalsectorsize / 1024 / 1024 > 1000000) { sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Tb, {2} TiB", ATAID.LBA48Sectors * logicalsectorsize, - (ATAID.LBA48Sectors * logicalsectorsize) / 1000 / 1000 / 1000 / 1000, - (ATAID.LBA48Sectors * logicalsectorsize) / 1024 / 1024 / 1024 / 1024) + ATAID.LBA48Sectors * logicalsectorsize / 1000 / 1000 / 1000 / 1000, + ATAID.LBA48Sectors * logicalsectorsize / 1024 / 1024 / 1024 / 1024) .AppendLine(); } - else if(((ATAID.LBA48Sectors * logicalsectorsize) / 1024 / 1024) > 1000) + else if(ATAID.LBA48Sectors * logicalsectorsize / 1024 / 1024 > 1000) { sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Gb, {2} GiB", ATAID.LBA48Sectors * logicalsectorsize, - (ATAID.LBA48Sectors * logicalsectorsize) / 1000 / 1000 / 1000, - (ATAID.LBA48Sectors * logicalsectorsize) / 1024 / 1024 / 1024).AppendLine(); + ATAID.LBA48Sectors * logicalsectorsize / 1000 / 1000 / 1000, + ATAID.LBA48Sectors * logicalsectorsize / 1024 / 1024 / 1024).AppendLine(); } else { sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Mb, {2} MiB", ATAID.LBA48Sectors * logicalsectorsize, - (ATAID.LBA48Sectors * logicalsectorsize) / 1000 / 1000, - (ATAID.LBA48Sectors * logicalsectorsize) / 1024 / 1024).AppendLine(); + ATAID.LBA48Sectors * logicalsectorsize / 1000 / 1000, + ATAID.LBA48Sectors * logicalsectorsize / 1024 / 1024).AppendLine(); } } } @@ -2594,18 +2594,18 @@ namespace DiscImageChef.Decoders.ATA { case 1: sb.AppendFormat("{0} KiB of single ported single sector buffer", - (ATAID.BufferSize * 512) / 1024).AppendLine(); + ATAID.BufferSize * 512 / 1024).AppendLine(); break; case 2: - sb.AppendFormat("{0} KiB of dual ported multi sector buffer", (ATAID.BufferSize * 512) / 1024) + sb.AppendFormat("{0} KiB of dual ported multi sector buffer", ATAID.BufferSize * 512 / 1024) .AppendLine(); break; case 3: sb.AppendFormat("{0} KiB of dual ported multi sector buffer with read caching", - (ATAID.BufferSize * 512) / 1024).AppendLine(); + ATAID.BufferSize * 512 / 1024).AppendLine(); break; default: - sb.AppendFormat("{0} KiB of unknown type {1} buffer", (ATAID.BufferSize * 512) / 1024, + sb.AppendFormat("{0} KiB of unknown type {1} buffer", ATAID.BufferSize * 512 / 1024, ATAID.BufferType).AppendLine(); break; } @@ -2846,8 +2846,8 @@ namespace DiscImageChef.Decoders.ATA ATAID.ServiceBusyClear); } - if(((ATAID.TransportMajorVersion & 0xF000) >> 12) == 0x1 || - ((ATAID.TransportMajorVersion & 0xF000) >> 12) == 0xE) + if((ATAID.TransportMajorVersion & 0xF000) >> 12 == 0x1 || + (ATAID.TransportMajorVersion & 0xF000) >> 12 == 0xE) { if(!ATAID.SATACapabilities.HasFlag(SATACapabilitiesBit.Clear)) { @@ -2974,7 +2974,7 @@ namespace DiscImageChef.Decoders.ATA sb.AppendLine().Append("CompactFlash power mode 1 is disabled"); sb.AppendLine().AppendFormat("CompactFlash device uses a maximum of {0} mA", - (ATAID.CFAPowerMode & 0x0FFF)); + ATAID.CFAPowerMode & 0x0FFF); } } @@ -3346,8 +3346,8 @@ namespace DiscImageChef.Decoders.ATA sb.AppendLine().Append("Trusted Computing feature set is supported"); } - if(((ATAID.TransportMajorVersion & 0xF000) >> 12) == 0x1 || - ((ATAID.TransportMajorVersion & 0xF000) >> 12) == 0xE) + if((ATAID.TransportMajorVersion & 0xF000) >> 12 == 0x1 || + (ATAID.TransportMajorVersion & 0xF000) >> 12 == 0xE) { if(!ATAID.SATACapabilities.HasFlag(SATACapabilitiesBit.Clear)) { diff --git a/DiscImageChef.Decoders/CD/CDTextOnLeadIn.cs b/DiscImageChef.Decoders/CD/CDTextOnLeadIn.cs index 725baad8..236c8d6a 100644 --- a/DiscImageChef.Decoders/CD/CDTextOnLeadIn.cs +++ b/DiscImageChef.Decoders/CD/CDTextOnLeadIn.cs @@ -208,7 +208,7 @@ namespace DiscImageChef.Decoders.CD return null; } - for(int i = 0; i < ((decoded.DataLength - 2) / 18); i++) + for(int i = 0; i < (decoded.DataLength - 2) / 18; i++) { decoded.DataPacks[i].HeaderID1 = CDTextResponse[0 + i * 18 + 4]; decoded.DataPacks[i].HeaderID2 = CDTextResponse[1 + i * 18 + 4]; diff --git a/DiscImageChef.Decoders/CD/FullTOC.cs b/DiscImageChef.Decoders/CD/FullTOC.cs index a8788826..a4da3108 100644 --- a/DiscImageChef.Decoders/CD/FullTOC.cs +++ b/DiscImageChef.Decoders/CD/FullTOC.cs @@ -166,7 +166,7 @@ namespace DiscImageChef.Decoders.CD return null; } - for(int i = 0; i < ((decoded.DataLength - 2) / 11); i++) + for(int i = 0; i < (decoded.DataLength - 2) / 11; i++) { decoded.TrackDescriptors[i].SessionNumber = CDFullTOCResponse[0 + i * 11 + 4]; decoded.TrackDescriptors[i].ADR = (byte)((CDFullTOCResponse[1 + i * 11 + 4] & 0xF0) >> 4); @@ -202,7 +202,7 @@ namespace DiscImageChef.Decoders.CD foreach(TrackDataDescriptor descriptor in response.TrackDescriptors) { if((descriptor.CONTROL & 0x08) == 0x08 || - (descriptor.ADR != 1 && descriptor.ADR != 5 && descriptor.ADR != 4 && descriptor.ADR != 6) || + descriptor.ADR != 1 && descriptor.ADR != 5 && descriptor.ADR != 4 && descriptor.ADR != 6 || descriptor.TNO != 0) { sb.AppendLine("Unknown TOC entry format, printing values as-is"); diff --git a/DiscImageChef.Decoders/CD/PMA.cs b/DiscImageChef.Decoders/CD/PMA.cs index ce5f6391..30dbb848 100644 --- a/DiscImageChef.Decoders/CD/PMA.cs +++ b/DiscImageChef.Decoders/CD/PMA.cs @@ -153,7 +153,7 @@ namespace DiscImageChef.Decoders.CD return null; } - for(int i = 0; i < ((decoded.DataLength - 2) / 11); i++) + for(int i = 0; i < (decoded.DataLength - 2) / 11; i++) { decoded.PMADescriptors[i].Reserved = CDPMAResponse[0 + i * 11 + 4]; decoded.PMADescriptors[i].ADR = (byte)((CDPMAResponse[1 + i * 11 + 4] & 0xF0) >> 4); diff --git a/DiscImageChef.Decoders/CD/Session.cs b/DiscImageChef.Decoders/CD/Session.cs index c95e5ebe..b39bc09b 100644 --- a/DiscImageChef.Decoders/CD/Session.cs +++ b/DiscImageChef.Decoders/CD/Session.cs @@ -128,7 +128,7 @@ namespace DiscImageChef.Decoders.CD return null; } - for(int i = 0; i < ((decoded.DataLength - 2) / 8); i++) + for(int i = 0; i < (decoded.DataLength - 2) / 8; i++) { decoded.TrackDescriptors[i].Reserved1 = CDSessionInfoResponse[0 + i * 8 + 4]; decoded.TrackDescriptors[i].ADR = (byte)((CDSessionInfoResponse[1 + i * 8 + 4] & 0xF0) >> 4); diff --git a/DiscImageChef.Decoders/CD/TOC.cs b/DiscImageChef.Decoders/CD/TOC.cs index 5643382c..3f5b7b2e 100644 --- a/DiscImageChef.Decoders/CD/TOC.cs +++ b/DiscImageChef.Decoders/CD/TOC.cs @@ -130,7 +130,7 @@ namespace DiscImageChef.Decoders.CD return null; } - for(int i = 0; i < ((decoded.DataLength - 2) / 8); i++) + for(int i = 0; i < (decoded.DataLength - 2) / 8; i++) { decoded.TrackDescriptors[i].Reserved1 = CDTOCResponse[0 + i * 8 + 4]; decoded.TrackDescriptors[i].ADR = (byte)((CDTOCResponse[1 + i * 8 + 4] & 0xF0) >> 4); diff --git a/DiscImageChef.Decoders/DVD/PFI.cs b/DiscImageChef.Decoders/DVD/PFI.cs index fae1214b..39d2fabc 100644 --- a/DiscImageChef.Decoders/DVD/PFI.cs +++ b/DiscImageChef.Decoders/DVD/PFI.cs @@ -1182,8 +1182,8 @@ namespace DiscImageChef.Decoders.DVD } // DVD-R and DVD-RW - if((pfi.DiskCategory == DiskCategory.DVDR && pfi.PartVersion < 6) || - (pfi.DiskCategory == DiskCategory.DVDRW && pfi.PartVersion < 3)) + if(pfi.DiskCategory == DiskCategory.DVDR && pfi.PartVersion < 6 || + pfi.DiskCategory == DiskCategory.DVDRW && pfi.PartVersion < 3) { pfi.CurrentBorderOutSector = (uint)((response[36] << 24) + (response[37] << 16) + (response[38] << 8) + response[39]); @@ -1302,8 +1302,8 @@ namespace DiscImageChef.Decoders.DVD } // DVD-R DL and DVD-RW DL - if((pfi.DiskCategory == DiskCategory.DVDR && pfi.PartVersion == 6) || - (pfi.DiskCategory == DiskCategory.DVDRW && pfi.PartVersion == 3)) + if(pfi.DiskCategory == DiskCategory.DVDR && pfi.PartVersion == 6 || + pfi.DiskCategory == DiskCategory.DVDRW && pfi.PartVersion == 3) { pfi.MaxRecordingSpeed = (DVDRecordingSpeed)response[21]; pfi.MinRecordingSpeed = (DVDRecordingSpeed)response[22]; @@ -1616,8 +1616,8 @@ namespace DiscImageChef.Decoders.DVD } } - if((decoded.DiskCategory == DiskCategory.DVDR && decoded.PartVersion < 6) || - (decoded.DiskCategory == DiskCategory.DVDRW && decoded.PartVersion < 3)) + if(decoded.DiskCategory == DiskCategory.DVDR && decoded.PartVersion < 6 || + decoded.DiskCategory == DiskCategory.DVDRW && decoded.PartVersion < 3) { sb.AppendFormat("Current Border-Out first sector is PSN {0:X}h", decoded.CurrentBorderOutSector) .AppendLine(); @@ -1634,8 +1634,8 @@ namespace DiscImageChef.Decoders.DVD sb.AppendFormat("Disc product revision is {0}", decoded.ProductRevision).AppendLine(); } - if((decoded.DiskCategory == DiskCategory.DVDR && decoded.PartVersion >= 6) || - (decoded.DiskCategory == DiskCategory.DVDRW && decoded.PartVersion >= 3)) + if(decoded.DiskCategory == DiskCategory.DVDR && decoded.PartVersion >= 6 || + decoded.DiskCategory == DiskCategory.DVDRW && decoded.PartVersion >= 3) { sb.AppendFormat("Current RMD in extra Border zone starts at PSN {0:X}h", decoded.CurrentRMDExtraBorderPSN).AppendLine(); diff --git a/DiscImageChef.Decoders/Floppy/Apple2.cs b/DiscImageChef.Decoders/Floppy/Apple2.cs index 7f3831e5..2ddda2d0 100644 --- a/DiscImageChef.Decoders/Floppy/Apple2.cs +++ b/DiscImageChef.Decoders/Floppy/Apple2.cs @@ -270,18 +270,18 @@ namespace DiscImageChef.Decoders.Floppy if(i < 86) { - output[i] |= (byte)((((buffer[i] & 1) << 1)) & 0xFF); - output[i] |= (byte)((((buffer[i] & 2) >> 1)) & 0xFF); + output[i] |= (byte)((buffer[i] & 1) << 1 & 0xFF); + output[i] |= (byte)((buffer[i] & 2) >> 1 & 0xFF); } else if(i < 86 * 2) { - output[i] |= (byte)((((buffer[i - 86] & 4) >> 1)) & 0xFF); - output[i] |= (byte)((((buffer[i - 86] & 8) >> 3)) & 0xFF); + output[i] |= (byte)((buffer[i - 86] & 4) >> 1 & 0xFF); + output[i] |= (byte)((buffer[i - 86] & 8) >> 3 & 0xFF); } else { - output[i] |= (byte)((((buffer[i - 86 * 2] & 0x10) >> 3)) & 0xFF); - output[i] |= (byte)((((buffer[i - 86 * 2] & 0x20) >> 5)) & 0xFF); + output[i] |= (byte)((buffer[i - 86 * 2] & 0x10) >> 3 & 0xFF); + output[i] |= (byte)((buffer[i - 86 * 2] & 0x20) >> 5 & 0xFF); } } diff --git a/DiscImageChef.Decoders/SCSI/Inquiry.cs b/DiscImageChef.Decoders/SCSI/Inquiry.cs index 8212695c..f6aac148 100644 --- a/DiscImageChef.Decoders/SCSI/Inquiry.cs +++ b/DiscImageChef.Decoders/SCSI/Inquiry.cs @@ -80,7 +80,7 @@ namespace DiscImageChef.Decoders.SCSI } if(SCSIInquiryResponse.Length >= 2) { - decoded.RMB = Convert.ToBoolean((SCSIInquiryResponse[1] & 0x80)); + decoded.RMB = Convert.ToBoolean(SCSIInquiryResponse[1] & 0x80); decoded.DeviceTypeModifier = (byte)(SCSIInquiryResponse[1] & 0x7F); } if(SCSIInquiryResponse.Length >= 3) @@ -91,43 +91,43 @@ namespace DiscImageChef.Decoders.SCSI } if(SCSIInquiryResponse.Length >= 4) { - decoded.AERC = Convert.ToBoolean((SCSIInquiryResponse[3] & 0x80)); - decoded.TrmTsk = Convert.ToBoolean((SCSIInquiryResponse[3] & 0x40)); - decoded.NormACA = Convert.ToBoolean((SCSIInquiryResponse[3] & 0x20)); - decoded.HiSup = Convert.ToBoolean((SCSIInquiryResponse[3] & 0x10)); + decoded.AERC = Convert.ToBoolean(SCSIInquiryResponse[3] & 0x80); + decoded.TrmTsk = Convert.ToBoolean(SCSIInquiryResponse[3] & 0x40); + decoded.NormACA = Convert.ToBoolean(SCSIInquiryResponse[3] & 0x20); + decoded.HiSup = Convert.ToBoolean(SCSIInquiryResponse[3] & 0x10); decoded.ResponseDataFormat = (byte)(SCSIInquiryResponse[3] & 0x07); } if(SCSIInquiryResponse.Length >= 5) decoded.AdditionalLength = SCSIInquiryResponse[4]; if(SCSIInquiryResponse.Length >= 6) { - decoded.SCCS = Convert.ToBoolean((SCSIInquiryResponse[5] & 0x80)); - decoded.ACC = Convert.ToBoolean((SCSIInquiryResponse[5] & 0x40)); + decoded.SCCS = Convert.ToBoolean(SCSIInquiryResponse[5] & 0x80); + decoded.ACC = Convert.ToBoolean(SCSIInquiryResponse[5] & 0x40); decoded.TPGS = (byte)((SCSIInquiryResponse[5] & 0x30) >> 4); - decoded.ThreePC = Convert.ToBoolean((SCSIInquiryResponse[5] & 0x08)); + decoded.ThreePC = Convert.ToBoolean(SCSIInquiryResponse[5] & 0x08); decoded.Reserved2 = (byte)((SCSIInquiryResponse[5] & 0x06) >> 1); - decoded.Protect = Convert.ToBoolean((SCSIInquiryResponse[5] & 0x01)); + decoded.Protect = Convert.ToBoolean(SCSIInquiryResponse[5] & 0x01); } if(SCSIInquiryResponse.Length >= 7) { - decoded.BQue = Convert.ToBoolean((SCSIInquiryResponse[6] & 0x80)); - decoded.EncServ = Convert.ToBoolean((SCSIInquiryResponse[6] & 0x40)); - decoded.VS1 = Convert.ToBoolean((SCSIInquiryResponse[6] & 0x20)); - decoded.MultiP = Convert.ToBoolean((SCSIInquiryResponse[6] & 0x10)); - decoded.MChngr = Convert.ToBoolean((SCSIInquiryResponse[6] & 0x08)); - decoded.ACKREQQ = Convert.ToBoolean((SCSIInquiryResponse[6] & 0x04)); - decoded.Addr32 = Convert.ToBoolean((SCSIInquiryResponse[6] & 0x02)); - decoded.Addr16 = Convert.ToBoolean((SCSIInquiryResponse[6] & 0x01)); + decoded.BQue = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x80); + decoded.EncServ = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x40); + decoded.VS1 = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x20); + decoded.MultiP = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x10); + decoded.MChngr = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x08); + decoded.ACKREQQ = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x04); + decoded.Addr32 = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x02); + decoded.Addr16 = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x01); } if(SCSIInquiryResponse.Length >= 8) { - decoded.RelAddr = Convert.ToBoolean((SCSIInquiryResponse[7] & 0x80)); - decoded.WBus32 = Convert.ToBoolean((SCSIInquiryResponse[7] & 0x40)); - decoded.WBus16 = Convert.ToBoolean((SCSIInquiryResponse[7] & 0x20)); - decoded.Sync = Convert.ToBoolean((SCSIInquiryResponse[7] & 0x10)); - decoded.Linked = Convert.ToBoolean((SCSIInquiryResponse[7] & 0x08)); - decoded.TranDis = Convert.ToBoolean((SCSIInquiryResponse[7] & 0x04)); - decoded.CmdQue = Convert.ToBoolean((SCSIInquiryResponse[7] & 0x02)); - decoded.SftRe = Convert.ToBoolean((SCSIInquiryResponse[7] & 0x01)); + decoded.RelAddr = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x80); + decoded.WBus32 = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x40); + decoded.WBus16 = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x20); + decoded.Sync = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x10); + decoded.Linked = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x08); + decoded.TranDis = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x04); + decoded.CmdQue = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x02); + decoded.SftRe = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x01); } if(SCSIInquiryResponse.Length >= 16) { @@ -211,8 +211,8 @@ namespace DiscImageChef.Decoders.SCSI { decoded.Reserved3 = (byte)((SCSIInquiryResponse[56] & 0xF0) >> 4); decoded.Clocking = (byte)((SCSIInquiryResponse[56] & 0x0C) >> 2); - decoded.QAS = Convert.ToBoolean((SCSIInquiryResponse[56] & 0x02)); - decoded.IUS = Convert.ToBoolean((SCSIInquiryResponse[56] & 0x01)); + decoded.QAS = Convert.ToBoolean(SCSIInquiryResponse[56] & 0x02); + decoded.IUS = Convert.ToBoolean(SCSIInquiryResponse[56] & 0x01); } if(SCSIInquiryResponse.Length >= 58) decoded.Reserved4 = SCSIInquiryResponse[57]; if(SCSIInquiryResponse.Length >= 60) @@ -225,7 +225,7 @@ namespace DiscImageChef.Decoders.SCSI decoded.VersionDescriptors = new ushort[descriptorsNo]; for(int i = 0; i < descriptorsNo; i++) { - decoded.VersionDescriptors[i] = BitConverter.ToUInt16(SCSIInquiryResponse, 58 + (i * 2)); + decoded.VersionDescriptors[i] = BitConverter.ToUInt16(SCSIInquiryResponse, 58 + i * 2); } } diff --git a/DiscImageChef.Decoders/SCSI/MMC/DiscInformation.cs b/DiscImageChef.Decoders/SCSI/MMC/DiscInformation.cs index 20114dbd..2e9f3231 100644 --- a/DiscImageChef.Decoders/SCSI/MMC/DiscInformation.cs +++ b/DiscImageChef.Decoders/SCSI/MMC/DiscInformation.cs @@ -282,7 +282,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC StandardDiscInformation decoded = new StandardDiscInformation(); decoded.DataLength = (ushort)((response[0] << 8) + response[1]); - if((decoded.DataLength + 2) != response.Length) return null; + if(decoded.DataLength + 2 != response.Length) return null; decoded.DataType = (byte)((response[2] & 0xE0) >> 5); decoded.Erasable |= (response[2] & 0x10) == 0x10; @@ -316,7 +316,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC decoded.DiscApplicationCode = response[32]; decoded.OPCTablesNumber = response[33]; - if(decoded.OPCTablesNumber > 0 && response.Length == (decoded.OPCTablesNumber * 8) + 34) + if(decoded.OPCTablesNumber > 0 && response.Length == decoded.OPCTablesNumber * 8 + 34) { decoded.OPCTables = new OPCTable[decoded.OPCTablesNumber]; for(int i = 0; i < decoded.OPCTablesNumber; i++) @@ -412,11 +412,11 @@ namespace DiscImageChef.Decoders.SCSI.MMC sb.AppendFormat("Last session Lead-In address is {0} (as LBA) or {1:X2}:{2:X2}:{3:X2}", decoded.LastSessionLeadInStartLBA, (decoded.LastSessionLeadInStartLBA & 0xFF0000) >> 16, (decoded.LastSessionLeadInStartLBA & 0xFF00) >> 8, - (decoded.LastSessionLeadInStartLBA & 0xFF)).AppendLine(); + decoded.LastSessionLeadInStartLBA & 0xFF).AppendLine(); sb.AppendFormat("Last possible Lead-Out address is {0} (as LBA) or {1:X2}:{2:X2}:{3:X2}", decoded.LastPossibleLeadOutStartLBA, (decoded.LastPossibleLeadOutStartLBA & 0xFF0000) >> 16, (decoded.LastPossibleLeadOutStartLBA & 0xFF00) >> 8, - (decoded.LastPossibleLeadOutStartLBA & 0xFF)).AppendLine(); + decoded.LastPossibleLeadOutStartLBA & 0xFF).AppendLine(); if(decoded.URU) sb.AppendLine("Disc is defined for unrestricted use"); else sb.AppendLine("Disc is defined for restricted use"); @@ -447,7 +447,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC TrackResourcesInformation decoded = new TrackResourcesInformation(); decoded.DataLength = (ushort)((response[0] << 8) + response[1]); - if((decoded.DataLength + 2) != response.Length) return null; + if(decoded.DataLength + 2 != response.Length) return null; decoded.DataType = (byte)((response[2] & 0xE0) >> 5); decoded.MaxTracks = (ushort)((response[4] << 8) + response[5]); @@ -486,7 +486,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC POWResourcesInformation decoded = new POWResourcesInformation(); decoded.DataLength = (ushort)((response[0] << 8) + response[1]); - if((decoded.DataLength + 2) != response.Length) return null; + if(decoded.DataLength + 2 != response.Length) return null; decoded.DataType = (byte)((response[2] & 0xE0) >> 5); decoded.RemainingPOWReplacements = diff --git a/DiscImageChef.Decoders/SCSI/MMC/Features.cs b/DiscImageChef.Decoders/SCSI/MMC/Features.cs index 2a1d845d..828de814 100644 --- a/DiscImageChef.Decoders/SCSI/MMC/Features.cs +++ b/DiscImageChef.Decoders/SCSI/MMC/Features.cs @@ -2170,7 +2170,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0000) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0000 decoded = new Feature_0000(); @@ -2204,7 +2204,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0001) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0001 decoded = new Feature_0001(); @@ -2233,7 +2233,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0002) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0002 decoded = new Feature_0002(); @@ -2258,7 +2258,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0003) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0003 decoded = new Feature_0003(); @@ -2293,7 +2293,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0004) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0004 decoded = new Feature_0004(); @@ -2324,7 +2324,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0010) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0010 decoded = new Feature_0010(); @@ -2353,7 +2353,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x001D) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_001D decoded = new Feature_001D(); @@ -2374,7 +2374,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x001E) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_001E decoded = new Feature_001E(); @@ -2403,7 +2403,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x001F) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_001F decoded = new Feature_001F(); @@ -2433,7 +2433,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0020) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0020 decoded = new Feature_0020(); @@ -2463,7 +2463,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0021) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0021 decoded = new Feature_0021(); @@ -2476,7 +2476,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC decoded.DataTypeSupported = (ushort)((feature[4] << 8) + feature[5]); decoded.BUF |= (feature[6] & 0x01) == 0x01; decoded.LinkSizes = new byte[feature[7]]; - if(feature.Length > (feature[7] + 8)) Array.Copy(feature, 8, decoded.LinkSizes, 0, feature[7]); + if(feature.Length > feature[7] + 8) Array.Copy(feature, 8, decoded.LinkSizes, 0, feature[7]); } if(decoded.Version >= 3) @@ -2498,7 +2498,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0022) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0022 decoded = new Feature_0022(); @@ -2519,7 +2519,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0023) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0023 decoded = new Feature_0023(); @@ -2551,7 +2551,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0024) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0024 decoded = new Feature_0024(); @@ -2574,7 +2574,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0025) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0025 decoded = new Feature_0025(); @@ -2603,7 +2603,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0026) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0026 decoded = new Feature_0026(); @@ -2624,7 +2624,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0027) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0027 decoded = new Feature_0027(); @@ -2645,7 +2645,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0028) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0028 decoded = new Feature_0028(); @@ -2674,7 +2674,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0029) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0029 decoded = new Feature_0029(); @@ -2702,7 +2702,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x002A) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_002A decoded = new Feature_002A(); @@ -2731,7 +2731,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x002B) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_002B decoded = new Feature_002B(); @@ -2754,7 +2754,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x002C) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_002C decoded = new Feature_002C(); @@ -2783,7 +2783,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x002D) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_002D decoded = new Feature_002D(); @@ -2819,7 +2819,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x002E) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_002E decoded = new Feature_002E(); @@ -2853,7 +2853,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x002F) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_002F decoded = new Feature_002F(); @@ -2884,7 +2884,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0030) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0030 decoded = new Feature_0030(); @@ -2905,7 +2905,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0031) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0031 decoded = new Feature_0031(); @@ -2928,7 +2928,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0032) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0032 decoded = new Feature_0032(); @@ -2955,7 +2955,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0033) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0033 decoded = new Feature_0033(); @@ -2963,7 +2963,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC decoded.Persistent |= (feature[2] & 0x02) == 0x02; decoded.Version = (byte)((feature[2] & 0x3C) >> 2); - if(feature[7] > 0 && feature.Length > (feature[7] + 8)) + if(feature[7] > 0 && feature.Length > feature[7] + 8) { decoded.LinkSizes = new byte[feature[7]]; Array.Copy(feature, 8, decoded.LinkSizes, 0, feature[7]); @@ -2982,7 +2982,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0035) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0035 decoded = new Feature_0035(); @@ -3003,7 +3003,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0037) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0037 decoded = new Feature_0037(); @@ -3026,7 +3026,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0038) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0038 decoded = new Feature_0038(); @@ -3047,7 +3047,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x003A) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_003A decoded = new Feature_003A(); @@ -3075,7 +3075,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x003B) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_003B decoded = new Feature_003B(); @@ -3098,7 +3098,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0040) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0040 decoded = new Feature_0040(); @@ -3135,7 +3135,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0041) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0041 decoded = new Feature_0041(); @@ -3170,7 +3170,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0042) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0042 decoded = new Feature_0042(); @@ -3191,7 +3191,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0050) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0050 decoded = new Feature_0050(); @@ -3218,7 +3218,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0051) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0051 decoded = new Feature_0051(); @@ -3245,7 +3245,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0080) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0080 decoded = new Feature_0080(); @@ -3268,7 +3268,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0100) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0100 decoded = new Feature_0100(); @@ -3289,7 +3289,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0101) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0101 decoded = new Feature_0101(); @@ -3312,7 +3312,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0102) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0102 decoded = new Feature_0102(); @@ -3340,7 +3340,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0103) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0103 decoded = new Feature_0103(); @@ -3369,7 +3369,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0104) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0104 decoded = new Feature_0104(); @@ -3392,7 +3392,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0105) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0105 decoded = new Feature_0105(); @@ -3419,7 +3419,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0106) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0106 decoded = new Feature_0106(); @@ -3442,7 +3442,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0107) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0107 decoded = new Feature_0107(); @@ -3478,7 +3478,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0108) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0108 decoded = new Feature_0108(); @@ -3506,7 +3506,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0109) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0109 decoded = new Feature_0109(); @@ -3527,7 +3527,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x010A) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_010A decoded = new Feature_010A(); @@ -3556,7 +3556,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x010B) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_010B decoded = new Feature_010B(); @@ -3579,7 +3579,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x010C) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_010C decoded = new Feature_010C(); @@ -3611,7 +3611,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x010D) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_010D decoded = new Feature_010D(); @@ -3648,7 +3648,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x010E) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_010E decoded = new Feature_010E(); @@ -3671,7 +3671,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0110) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0110 decoded = new Feature_0110(); @@ -3692,7 +3692,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0113) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0113 decoded = new Feature_0113(); @@ -3713,7 +3713,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(number != 0x0142) return null; - if((feature[3] + 4) != feature.Length) return null; + if(feature[3] + 4 != feature.Length) return null; Feature_0142 decoded = new Feature_0142(); @@ -5275,14 +5275,14 @@ namespace DiscImageChef.Decoders.SCSI.MMC uint offset = 8; List descLst = new List(); - while((offset + 4) < response.Length) + while(offset + 4 < response.Length) { FeatureDescriptor desc = new FeatureDescriptor(); desc.Code = (ushort)((response[offset + 0] << 8) + response[offset + 1]); desc.Data = new byte[response[offset + 3] + 4]; if(desc.Data.Length + offset > response.Length) desc.Data = new byte[response.Length - offset]; Array.Copy(response, offset, desc.Data, 0, desc.Data.Length); - offset += (uint)(desc.Data.Length); + offset += (uint)desc.Data.Length; descLst.Add(desc); } diff --git a/DiscImageChef.Decoders/SCSI/Modes.cs b/DiscImageChef.Decoders/SCSI/Modes.cs index ada1b5f9..fdb5c96e 100644 --- a/DiscImageChef.Decoders/SCSI/Modes.cs +++ b/DiscImageChef.Decoders/SCSI/Modes.cs @@ -82,13 +82,13 @@ namespace DiscImageChef.Decoders.SCSI if(deviceType == PeripheralDeviceTypes.DirectAccess || deviceType == PeripheralDeviceTypes.MultiMediaDevice) { - header.WriteProtected = ((modeResponse[2] & 0x80) == 0x80); - header.DPOFUA = ((modeResponse[2] & 0x10) == 0x10); + header.WriteProtected = (modeResponse[2] & 0x80) == 0x80; + header.DPOFUA = (modeResponse[2] & 0x10) == 0x10; } if(deviceType == PeripheralDeviceTypes.SequentialAccess) { - header.WriteProtected = ((modeResponse[2] & 0x80) == 0x80); + header.WriteProtected = (modeResponse[2] & 0x80) == 0x80; header.Speed = (byte)(modeResponse[2] & 0x0F); header.BufferedMode = (byte)((modeResponse[2] & 0x70) >> 4); } @@ -98,9 +98,9 @@ namespace DiscImageChef.Decoders.SCSI if(deviceType == PeripheralDeviceTypes.OpticalDevice) { - header.WriteProtected = ((modeResponse[2] & 0x80) == 0x80); - header.EBC = ((modeResponse[2] & 0x01) == 0x01); - header.DPOFUA = ((modeResponse[2] & 0x10) == 0x10); + header.WriteProtected = (modeResponse[2] & 0x80) == 0x80; + header.EBC = (modeResponse[2] & 0x01) == 0x01; + header.DPOFUA = (modeResponse[2] & 0x10) == 0x10; } return header; @@ -2002,13 +2002,13 @@ namespace DiscImageChef.Decoders.SCSI if(deviceType == PeripheralDeviceTypes.DirectAccess || deviceType == PeripheralDeviceTypes.MultiMediaDevice) { - header.WriteProtected = ((modeResponse[3] & 0x80) == 0x80); - header.DPOFUA = ((modeResponse[3] & 0x10) == 0x10); + header.WriteProtected = (modeResponse[3] & 0x80) == 0x80; + header.DPOFUA = (modeResponse[3] & 0x10) == 0x10; } if(deviceType == PeripheralDeviceTypes.SequentialAccess) { - header.WriteProtected = ((modeResponse[3] & 0x80) == 0x80); + header.WriteProtected = (modeResponse[3] & 0x80) == 0x80; header.Speed = (byte)(modeResponse[3] & 0x0F); header.BufferedMode = (byte)((modeResponse[3] & 0x70) >> 4); } @@ -2018,9 +2018,9 @@ namespace DiscImageChef.Decoders.SCSI if(deviceType == PeripheralDeviceTypes.OpticalDevice) { - header.WriteProtected = ((modeResponse[3] & 0x80) == 0x80); - header.EBC = ((modeResponse[3] & 0x01) == 0x01); - header.DPOFUA = ((modeResponse[3] & 0x10) == 0x10); + header.WriteProtected = (modeResponse[3] & 0x80) == 0x80; + header.EBC = (modeResponse[3] & 0x01) == 0x01; + header.DPOFUA = (modeResponse[3] & 0x10) == 0x10; } return header; @@ -3511,7 +3511,7 @@ namespace DiscImageChef.Decoders.SCSI decoded.WritePrecompCylinder = (uint)((pageResponse[6] << 16) + (pageResponse[7] << 8) + pageResponse[8]); decoded.WriteReduceCylinder = (uint)((pageResponse[9] << 16) + (pageResponse[10] << 8) + pageResponse[11]); decoded.DriveStepRate = (ushort)((pageResponse[12] << 8) + pageResponse[13]); - decoded.LandingCylinder = ((pageResponse[14] << 16) + (pageResponse[15] << 8) + pageResponse[16]); + decoded.LandingCylinder = (pageResponse[14] << 16) + (pageResponse[15] << 8) + pageResponse[16]; decoded.RPL = (byte)(pageResponse[17] & 0x03); decoded.RotationalOffset = pageResponse[18]; @@ -5382,7 +5382,7 @@ namespace DiscImageChef.Decoders.SCSI if(page.PS) sb.AppendLine("\tParameters can be saved"); - if((page.Standby && page.StandbyTimer > 0) || (page.Standby_Y && page.StandbyTimer_Y > 0)) + if(page.Standby && page.StandbyTimer > 0 || page.Standby_Y && page.StandbyTimer_Y > 0) { if(page.Standby && page.StandbyTimer > 0) sb.AppendFormat("\tStandby timer Z is set to {0} ms", page.StandbyTimer * 100).AppendLine(); @@ -5391,8 +5391,8 @@ namespace DiscImageChef.Decoders.SCSI } else sb.AppendLine("\tDrive will not enter standy mode"); - if((page.Idle && page.IdleTimer > 0) || (page.Idle_B && page.IdleTimer_B > 0) || - (page.Idle_C && page.IdleTimer_C > 0)) + if(page.Idle && page.IdleTimer > 0 || page.Idle_B && page.IdleTimer_B > 0 || + page.Idle_C && page.IdleTimer_C > 0) { if(page.Idle && page.IdleTimer > 0) sb.AppendFormat("\tIdle timer A is set to {0} ms", page.IdleTimer * 100).AppendLine(); @@ -5468,7 +5468,7 @@ namespace DiscImageChef.Decoders.SCSI if(pageResponse[1] != 0x01) return null; - if(((pageResponse[2] << 8) + pageResponse[3] + 4) != pageResponse.Length) return null; + if((pageResponse[2] << 8) + pageResponse[3] + 4 != pageResponse.Length) return null; if(pageResponse.Length < 32) return null; @@ -5556,7 +5556,7 @@ namespace DiscImageChef.Decoders.SCSI if(pageResponse[1] != 0x01) return null; - if(((pageResponse[2] << 8) + pageResponse[3] + 4) != pageResponse.Length) return null; + if((pageResponse[2] << 8) + pageResponse[3] + 4 != pageResponse.Length) return null; if(pageResponse.Length < 16) return null; @@ -5762,7 +5762,7 @@ namespace DiscImageChef.Decoders.SCSI if(pageResponse[1] != 0x01) return null; - if(((pageResponse[2] << 8) + pageResponse[3] + 4) != pageResponse.Length) return null; + if((pageResponse[2] << 8) + pageResponse[3] + 4 != pageResponse.Length) return null; if(pageResponse.Length < 16) return null; @@ -6327,7 +6327,7 @@ namespace DiscImageChef.Decoders.SCSI if(offset + 3 >= modeResponse.Length) break; pg.PageResponse = new byte[(modeResponse[offset + 2] << 8) + modeResponse[offset + 3] + 4]; - if((pg.PageResponse.Length + offset) > modeResponse.Length) return decoded; + if(pg.PageResponse.Length + offset > modeResponse.Length) return decoded; Array.Copy(modeResponse, offset, pg.PageResponse, 0, pg.PageResponse.Length); pg.Page = (byte)(modeResponse[offset] & 0x3F); @@ -6339,7 +6339,7 @@ namespace DiscImageChef.Decoders.SCSI if(offset + 1 >= modeResponse.Length) break; pg.PageResponse = new byte[modeResponse[offset + 1] + 2]; - if((pg.PageResponse.Length + offset) > modeResponse.Length) return decoded; + if(pg.PageResponse.Length + offset > modeResponse.Length) return decoded; Array.Copy(modeResponse, offset, pg.PageResponse, 0, pg.PageResponse.Length); pg.Page = (byte)(modeResponse[offset] & 0x3F); @@ -6370,7 +6370,7 @@ namespace DiscImageChef.Decoders.SCSI if(longlba) offset = 8 + blkDrLength * 16; else offset = 8 + blkDrLength * 8; - int length = (modeResponse[0] << 8); + int length = modeResponse[0] << 8; length += modeResponse[1]; length += 2; @@ -6398,7 +6398,7 @@ namespace DiscImageChef.Decoders.SCSI { pg.PageResponse = new byte[(modeResponse[offset + 2] << 8) + modeResponse[offset + 3] + 4]; - if((pg.PageResponse.Length + offset) > modeResponse.Length) return decoded; + if(pg.PageResponse.Length + offset > modeResponse.Length) return decoded; Array.Copy(modeResponse, offset, pg.PageResponse, 0, pg.PageResponse.Length); pg.Page = (byte)(modeResponse[offset] & 0x3F); @@ -6409,7 +6409,7 @@ namespace DiscImageChef.Decoders.SCSI { pg.PageResponse = new byte[modeResponse[offset + 1] + 2]; - if((pg.PageResponse.Length + offset) > modeResponse.Length) return decoded; + if(pg.PageResponse.Length + offset > modeResponse.Length) return decoded; Array.Copy(modeResponse, offset, pg.PageResponse, 0, pg.PageResponse.Length); pg.Page = (byte)(modeResponse[offset] & 0x3F); @@ -7019,7 +7019,7 @@ namespace DiscImageChef.Decoders.SCSI decoded.BaudRate = pageResponse[2]; decoded.CmdFwd = (byte)((pageResponse[3] & 0x18) >> 3); decoded.StopBits |= (pageResponse[3] & 0x04) == 0x04; - decoded.CmdFwd = (byte)((pageResponse[3] & 0x03)); + decoded.CmdFwd = (byte)(pageResponse[3] & 0x03); decoded.PortATransportType = pageResponse[4]; decoded.PortAPresentSelectionID = pageResponse[7]; decoded.NextSelectionID = pageResponse[12]; @@ -7314,7 +7314,7 @@ namespace DiscImageChef.Decoders.SCSI decoded.FirmwareUpdateBehaviour = pageResponse[7]; decoded.UOE_C = (byte)((pageResponse[8] & 0x30) >> 4); decoded.UOE_F = (byte)((pageResponse[8] & 0x0C) >> 2); - decoded.UOE_F = ((byte)(pageResponse[8] & 0x03)); + decoded.UOE_F = (byte)(pageResponse[8] & 0x03); return decoded; } diff --git a/DiscImageChef.Decoders/SecureDigital/CSD.cs b/DiscImageChef.Decoders/SecureDigital/CSD.cs index 5fd9faac..6874913c 100644 --- a/DiscImageChef.Decoders/SecureDigital/CSD.cs +++ b/DiscImageChef.Decoders/SecureDigital/CSD.cs @@ -121,7 +121,7 @@ namespace DiscImageChef.Decoders.SecureDigital else csd.Size = (uint)(((response[7] & 0x3F) << 16) + (response[8] << 8) + response[9]); csd.EraseBlockEnable = (response[10] & 0x40) == 0x40; csd.EraseSectorSize = (byte)(((response[10] & 0x3F) << 1) + ((response[11] & 0x80) >> 7)); - csd.WriteProtectGroupSize = ((byte)(response[11] & 0x7F)); + csd.WriteProtectGroupSize = (byte)(response[11] & 0x7F); csd.WriteProtectGroupEnable = (response[12] & 0x80) == 0x80; csd.WriteSpeedFactor = (byte)((response[12] & 0x1C) >> 2); csd.WriteBlockLength = (byte)(((response[12] & 0x03) << 2) + ((response[13] & 0xC0) >> 6)); diff --git a/DiscImageChef.Decoders/Sega/Dreamcast.cs b/DiscImageChef.Decoders/Sega/Dreamcast.cs index 74fbe8ef..7d381c83 100644 --- a/DiscImageChef.Decoders/Sega/Dreamcast.cs +++ b/DiscImageChef.Decoders/Sega/Dreamcast.cs @@ -231,7 +231,7 @@ namespace DiscImageChef.Decoders.Sega if((iPeripherals & 0x08000000) == 0x08000000) IPBinInformation.AppendLine("Game supports Mouse."); if((iPeripherals & 0xEE) != 0) - IPBinInformation.AppendFormat("Game supports unknown peripherals mask {0:X2}", (iPeripherals & 0xEE)); + IPBinInformation.AppendFormat("Game supports unknown peripherals mask {0:X2}", iPeripherals & 0xEE); return IPBinInformation.ToString(); } diff --git a/DiscImageChef.Devices/Command.cs b/DiscImageChef.Devices/Command.cs index 5bb1940f..b93ce978 100644 --- a/DiscImageChef.Devices/Command.cs +++ b/DiscImageChef.Devices/Command.cs @@ -174,12 +174,10 @@ namespace DiscImageChef.Devices { case Interop.PlatformID.Win32NT: { - if(( // Windows XP <= SP1 - Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor == 1 && - (Environment.OSVersion.ServicePack == "Service Pack 1" || - Environment.OSVersion.ServicePack == "")) || ( // Windows 2000 - Environment.OSVersion.Version.Major == 5 && - Environment.OSVersion.Version.Minor == 0)) + if(Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor == 1 && + (Environment.OSVersion.ServicePack == "Service Pack 1" || + Environment.OSVersion.ServicePack == "") || Environment.OSVersion.Version.Major == 5 && + Environment.OSVersion.Version.Minor == 0) return Windows.Command.SendIdeCommand((SafeFileHandle)fd, registers, out errorRegisters, protocol, ref buffer, timeout, out duration, out sense); // Windows NT 4 or earlier, requires special ATA pass thru SCSI. But DiscImageChef cannot run there (or can it?) @@ -224,12 +222,10 @@ namespace DiscImageChef.Devices { case Interop.PlatformID.Win32NT: { - if(( // Windows XP <= SP1 - Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor == 1 && - (Environment.OSVersion.ServicePack == "Service Pack 1" || - Environment.OSVersion.ServicePack == "")) || ( // Windows 2000 - Environment.OSVersion.Version.Major == 5 && - Environment.OSVersion.Version.Minor == 0)) + if(Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor == 1 && + (Environment.OSVersion.ServicePack == "Service Pack 1" || + Environment.OSVersion.ServicePack == "") || Environment.OSVersion.Version.Major == 5 && + Environment.OSVersion.Version.Minor == 0) return Windows.Command.SendIdeCommand((SafeFileHandle)fd, registers, out errorRegisters, protocol, ref buffer, timeout, out duration, out sense); // Windows NT 4 or earlier, requires special ATA pass thru SCSI. But DiscImageChef cannot run there (or can it?) diff --git a/DiscImageChef.Devices/Device/Constructor.cs b/DiscImageChef.Devices/Device/Constructor.cs index 61e4b1b2..888c0401 100644 --- a/DiscImageChef.Devices/Device/Constructor.cs +++ b/DiscImageChef.Devices/Device/Constructor.cs @@ -631,7 +631,7 @@ namespace DiscImageChef.Devices } } - if((scsiSense && (usb || firewire)) || manufacturer == "ATA") + if(scsiSense && (usb || firewire) || manufacturer == "ATA") { bool ataSense = AtaIdentify(out ataBuf, out errorRegisters); if(!ataSense) diff --git a/DiscImageChef.Devices/FreeBSD/Command.cs b/DiscImageChef.Devices/FreeBSD/Command.cs index 3b55be0c..e503d45a 100644 --- a/DiscImageChef.Devices/FreeBSD/Command.cs +++ b/DiscImageChef.Devices/FreeBSD/Command.cs @@ -456,7 +456,7 @@ namespace DiscImageChef.Devices.FreeBSD errorRegisters = new AtaErrorRegistersLBA48(); // 48-bit ATA CAM commands can crash FreeBSD < 9.2-RELEASE - if((System.Environment.Version.Major == 9 && System.Environment.Version.Minor < 2) || + if(System.Environment.Version.Major == 9 && System.Environment.Version.Minor < 2 || System.Environment.Version.Major < 9) return -1; if(buffer == null) return -1; diff --git a/DiscImageChef.Devices/Linux/Command.cs b/DiscImageChef.Devices/Linux/Command.cs index 021bbb0c..c79b0f8e 100644 --- a/DiscImageChef.Devices/Linux/Command.cs +++ b/DiscImageChef.Devices/Linux/Command.cs @@ -164,7 +164,7 @@ namespace DiscImageChef.Devices.Linux int error = SendScsiCommand(fd, cdb, ref buffer, out senseBuffer, timeout, AtaProtocolToScsiDirection(protocol), out duration, out sense); - if(senseBuffer.Length < 22 || (senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C)) return error; + if(senseBuffer.Length < 22 || senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C) return error; errorRegisters.error = senseBuffer[11]; @@ -226,7 +226,7 @@ namespace DiscImageChef.Devices.Linux int error = SendScsiCommand(fd, cdb, ref buffer, out senseBuffer, timeout, AtaProtocolToScsiDirection(protocol), out duration, out sense); - if(senseBuffer.Length < 22 || (senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C)) return error; + if(senseBuffer.Length < 22 || senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C) return error; errorRegisters.error = senseBuffer[11]; @@ -294,7 +294,7 @@ namespace DiscImageChef.Devices.Linux int error = SendScsiCommand(fd, cdb, ref buffer, out senseBuffer, timeout, AtaProtocolToScsiDirection(protocol), out duration, out sense); - if(senseBuffer.Length < 22 || (senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C)) return error; + if(senseBuffer.Length < 22 || senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C) return error; errorRegisters.error = senseBuffer[11]; diff --git a/DiscImageChef.Devices/Windows/Usb.cs b/DiscImageChef.Devices/Windows/Usb.cs index 91b2fce9..83e8ed21 100644 --- a/DiscImageChef.Devices/Windows/Usb.cs +++ b/DiscImageChef.Devices/Windows/Usb.cs @@ -778,7 +778,7 @@ namespace DiscImageChef.Devices.Windows UsbDeviceSpeed speed = (UsbDeviceSpeed)nodeConnection.Speed; port.PortSpeed = speed.ToString(); port.PortIsDeviceConnected = - (nodeConnection.ConnectionStatus == (int)UsbConnectionStatus.DeviceConnected); + nodeConnection.ConnectionStatus == (int)UsbConnectionStatus.DeviceConnected; port.PortIsHub = Convert.ToBoolean(nodeConnection.DeviceIsHub); port.PortDeviceDescriptor = nodeConnection.DeviceDescriptor; @@ -964,7 +964,7 @@ namespace DiscImageChef.Devices.Windows // build a request for configuration descriptor UsbDescriptorRequest dcrRequest = new UsbDescriptorRequest(); dcrRequest.ConnectionIndex = PortPortNumber; - dcrRequest.SetupPacket.wValue = (short)((USB_CONFIGURATION_DESCRIPTOR_TYPE << 8)); + dcrRequest.SetupPacket.wValue = (short)(USB_CONFIGURATION_DESCRIPTOR_TYPE << 8); dcrRequest.SetupPacket.wLength = (short)(nBytes - Marshal.SizeOf(dcrRequest)); dcrRequest.SetupPacket.wIndex = 0; // Geez, I wish C# had a Marshal.MemSet() method diff --git a/DiscImageChef.DiscImages/Alcohol120.cs b/DiscImageChef.DiscImages/Alcohol120.cs index 3a601ea8..081e5b4d 100644 --- a/DiscImageChef.DiscImages/Alcohol120.cs +++ b/DiscImageChef.DiscImages/Alcohol120.cs @@ -562,7 +562,7 @@ namespace DiscImageChef.DiscImages if(!data && !firstdata) ImageInfo.MediaType = MediaType.CDDA; else if(firstaudio && data && sessions.Count > 1 && mode2) ImageInfo.MediaType = MediaType.CDPLUS; - else if((firstdata && audio) || mode2) ImageInfo.MediaType = MediaType.CDROMXA; + else if(firstdata && audio || mode2) ImageInfo.MediaType = MediaType.CDROMXA; else if(!audio) ImageInfo.MediaType = MediaType.CDROM; else ImageInfo.MediaType = MediaType.CD; } @@ -839,8 +839,8 @@ namespace DiscImageChef.DiscImages if(track.point == kvp.Key && alcTrackExtras.TryGetValue(track.point, out extra)) { - if((sectorAddress - kvp.Value) < extra.sectors) - return ReadSectors((sectorAddress - kvp.Value), length, kvp.Key); + if(sectorAddress - kvp.Value < extra.sectors) + return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key); } } } @@ -861,8 +861,8 @@ namespace DiscImageChef.DiscImages if(track.point == kvp.Key && alcTrackExtras.TryGetValue(track.point, out extra)) { - if((sectorAddress - kvp.Value) < extra.sectors) - return ReadSectorsTag((sectorAddress - kvp.Value), length, kvp.Key, tag); + if(sectorAddress - kvp.Value < extra.sectors) + return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag); } } } @@ -1002,7 +1002,7 @@ namespace DiscImageChef.DiscImages case SectorTagType.CdSectorSubchannel: case SectorTagType.CdSectorSubHeader: case SectorTagType.CdSectorSync: break; - case SectorTagType.CdTrackFlags: return new byte[] {((byte)(_track.adrCtl & 0x0F))}; + case SectorTagType.CdTrackFlags: return new byte[] {(byte)(_track.adrCtl & 0x0F)}; default: throw new ArgumentException("Unsupported tag requested", nameof(tag)); } @@ -1323,8 +1323,8 @@ namespace DiscImageChef.DiscImages if(track.point == kvp.Key && alcTrackExtras.TryGetValue(track.point, out extra)) { - if((sectorAddress - kvp.Value) < extra.sectors) - return ReadSectorsLong((sectorAddress - kvp.Value), length, kvp.Key); + if(sectorAddress - kvp.Value < extra.sectors) + return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key); } } } diff --git a/DiscImageChef.DiscImages/AppleDOS.cs b/DiscImageChef.DiscImages/AppleDOS.cs index 41949430..d36d7916 100644 --- a/DiscImageChef.DiscImages/AppleDOS.cs +++ b/DiscImageChef.DiscImages/AppleDOS.cs @@ -107,7 +107,7 @@ namespace DiscImageChef.DiscImages for(int t = 0; t < 35; t++) { for(int s = 0; s < 16; s++) - Array.Copy(tmp, (t * 16 * 256) + (s * 256), deinterleaved, (t * 16 * 256) + (offsets[s] * 256), + Array.Copy(tmp, t * 16 * 256 + s * 256, deinterleaved, t * 16 * 256 + offsets[s] * 256, 256); } diff --git a/DiscImageChef.DiscImages/Apridisk.cs b/DiscImageChef.DiscImages/Apridisk.cs index 9e1b3ab7..180d4c9b 100644 --- a/DiscImageChef.DiscImages/Apridisk.cs +++ b/DiscImageChef.DiscImages/Apridisk.cs @@ -161,7 +161,7 @@ namespace DiscImageChef.DiscImages // Deleted record, just skip it case RecordType.Deleted: DicConsole.DebugWriteLine("Apridisk plugin", "Found deleted record at {0}", stream.Position); - stream.Seek((record.headerSize - recordSize) + record.dataSize, SeekOrigin.Current); + stream.Seek(record.headerSize - recordSize + record.dataSize, SeekOrigin.Current); break; case RecordType.Comment: DicConsole.DebugWriteLine("Apridisk plugin", "Found comment record at {0}", stream.Position); @@ -198,7 +198,7 @@ namespace DiscImageChef.DiscImages if(record.head > totalHeads) totalHeads = record.head; if(record.sector > maxSector) maxSector = record.sector; - stream.Seek((record.headerSize - recordSize) + record.dataSize, SeekOrigin.Current); + stream.Seek(record.headerSize - recordSize + record.dataSize, SeekOrigin.Current); break; default: throw new @@ -255,7 +255,7 @@ namespace DiscImageChef.DiscImages case RecordType.Deleted: case RecordType.Comment: case RecordType.Creator: - stream.Seek((record.headerSize - recordSize) + record.dataSize, SeekOrigin.Current); + stream.Seek(record.headerSize - recordSize + record.dataSize, SeekOrigin.Current); headersizes += record.headerSize + record.dataSize; break; case RecordType.Sector: @@ -454,8 +454,8 @@ namespace DiscImageChef.DiscImages (ushort cylinder, byte head, byte sector) LbaToChs(ulong lba) { ushort cylinder = (ushort)(lba / (ImageInfo.Heads * ImageInfo.SectorsPerTrack)); - byte head = (byte)((lba / ImageInfo.SectorsPerTrack) % ImageInfo.Heads); - byte sector = (byte)((lba % ImageInfo.SectorsPerTrack) + 1); + byte head = (byte)(lba / ImageInfo.SectorsPerTrack % ImageInfo.Heads); + byte sector = (byte)(lba % ImageInfo.SectorsPerTrack + 1); return (cylinder, head, sector); } diff --git a/DiscImageChef.DiscImages/BLU.cs b/DiscImageChef.DiscImages/BLU.cs index 1eec9e07..6d547a15 100644 --- a/DiscImageChef.DiscImages/BLU.cs +++ b/DiscImageChef.DiscImages/BLU.cs @@ -189,7 +189,7 @@ namespace DiscImageChef.DiscImages break; default: ImageInfo.MediaType = MediaType.GENERIC_HDD; - ImageInfo.Cylinders = (uint)((ImageInfo.Sectors / 16) / 63); + ImageInfo.Cylinders = (uint)(ImageInfo.Sectors / 16 / 63); ImageInfo.Heads = 16; ImageInfo.SectorsPerTrack = 63; break; diff --git a/DiscImageChef.DiscImages/BlindWrite4.cs b/DiscImageChef.DiscImages/BlindWrite4.cs index c4849bfc..eb09bd72 100644 --- a/DiscImageChef.DiscImages/BlindWrite4.cs +++ b/DiscImageChef.DiscImages/BlindWrite4.cs @@ -868,7 +868,7 @@ namespace DiscImageChef.DiscImages if(!data && !firstdata) ImageInfo.MediaType = MediaType.CDDA; else if(firstaudio && data && sessions.Count > 1 && mode2) ImageInfo.MediaType = MediaType.CDPLUS; - else if((firstdata && audio) || mode2) ImageInfo.MediaType = MediaType.CDROMXA; + else if(firstdata && audio || mode2) ImageInfo.MediaType = MediaType.CDROMXA; else if(!audio) ImageInfo.MediaType = MediaType.CDROM; else ImageInfo.MediaType = MediaType.CD; @@ -949,8 +949,8 @@ namespace DiscImageChef.DiscImages { if(track.TrackSequence == kvp.Key) { - if((sectorAddress - kvp.Value) < (track.TrackEndSector - track.TrackStartSector + 1)) - return ReadSectors((sectorAddress - kvp.Value), length, kvp.Key); + if(sectorAddress - kvp.Value < track.TrackEndSector - track.TrackStartSector + 1) + return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key); } } } @@ -969,8 +969,8 @@ namespace DiscImageChef.DiscImages { if(track.TrackSequence == kvp.Key) { - if((sectorAddress - kvp.Value) < (track.TrackEndSector - track.TrackStartSector + 1)) - return ReadSectorsTag((sectorAddress - kvp.Value), length, kvp.Key, tag); + if(sectorAddress - kvp.Value < track.TrackEndSector - track.TrackStartSector + 1) + return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag); } } } @@ -997,13 +997,13 @@ namespace DiscImageChef.DiscImages if(_track.TrackSequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); - if(length + sectorAddress > (_track.TrackEndSector - _track.TrackStartSector + 1)) + if(length + sectorAddress > _track.TrackEndSector - _track.TrackStartSector + 1) throw new ArgumentOutOfRangeException(nameof(length), string .Format("Requested more sectors ({0}) than present in track ({1}), won't cross tracks", length + sectorAddress, - (_track.TrackEndSector - _track.TrackStartSector + - 1))); + _track.TrackEndSector - _track.TrackStartSector + + 1)); uint sectorOffset; uint sectorSize; @@ -1083,13 +1083,13 @@ namespace DiscImageChef.DiscImages if(_track.TrackSequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); - if(length + sectorAddress > (_track.TrackEndSector - _track.TrackStartSector + 1)) + if(length + sectorAddress > _track.TrackEndSector - _track.TrackStartSector + 1) throw new ArgumentOutOfRangeException(nameof(length), string .Format("Requested more sectors ({0}) than present in track ({1}), won't cross tracks", length + sectorAddress, - (_track.TrackEndSector - _track.TrackStartSector + - 1))); + _track.TrackEndSector - _track.TrackStartSector + + 1)); uint sectorOffset; uint sectorSize; @@ -1257,8 +1257,8 @@ namespace DiscImageChef.DiscImages { if(track.TrackSequence == kvp.Key) { - if((sectorAddress - kvp.Value) < (track.TrackEndSector - track.TrackStartSector + 1)) - return ReadSectorsLong((sectorAddress - kvp.Value), length, kvp.Key); + if(sectorAddress - kvp.Value < track.TrackEndSector - track.TrackStartSector + 1) + return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key); } } } @@ -1285,13 +1285,13 @@ namespace DiscImageChef.DiscImages if(_track.TrackSequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); - if(length + sectorAddress > (_track.TrackEndSector - _track.TrackStartSector + 1)) + if(length + sectorAddress > _track.TrackEndSector - _track.TrackStartSector + 1) throw new ArgumentOutOfRangeException(nameof(length), string .Format("Requested more sectors ({0}) than present in track ({1}), won't cross tracks", length + sectorAddress, - (_track.TrackEndSector - _track.TrackStartSector + - 1))); + _track.TrackEndSector - _track.TrackStartSector + + 1)); uint sectorOffset; uint sectorSize; diff --git a/DiscImageChef.DiscImages/BlindWrite5.cs b/DiscImageChef.DiscImages/BlindWrite5.cs index 9274a740..0fefad1a 100644 --- a/DiscImageChef.DiscImages/BlindWrite5.cs +++ b/DiscImageChef.DiscImages/BlindWrite5.cs @@ -738,8 +738,8 @@ namespace DiscImageChef.DiscImages long sectorSize = dataFile.Length / dataFile.Sectors; if(sectorSize > 2352) { - if((sectorSize - 2352) == 16) chars.Subchannel = TrackSubchannelType.Q16Interleaved; - else if((sectorSize - 2352) == 96) chars.Subchannel = TrackSubchannelType.PackedInterleaved; + if(sectorSize - 2352 == 16) chars.Subchannel = TrackSubchannelType.Q16Interleaved; + else if(sectorSize - 2352 == 96) chars.Subchannel = TrackSubchannelType.PackedInterleaved; else { DicConsole.ErrorWriteLine("BlindWrite5 found unknown subchannel size: {0}", sectorSize - 2352); @@ -868,13 +868,13 @@ namespace DiscImageChef.DiscImages foreach(DataFileCharacteristics chars in filePaths) { if(trk.startLba >= chars.StartLba && - (trk.startLba + trk.sectors) <= (chars.StartLba + chars.Sectors)) + trk.startLba + trk.sectors <= chars.StartLba + chars.Sectors) { track.TrackFilter = chars.FileFilter; track.TrackFile = chars.FileFilter.GetFilename(); if(trk.startLba >= 0) track.TrackFileOffset = (ulong)((trk.startLba - chars.StartLba) * chars.SectorSize); - else track.TrackFileOffset = (ulong)((trk.startLba * -1) * chars.SectorSize); + else track.TrackFileOffset = (ulong)(trk.startLba * -1 * chars.SectorSize); track.TrackFileType = "BINARY"; if(chars.Subchannel != TrackSubchannelType.None) { @@ -903,7 +903,7 @@ namespace DiscImageChef.DiscImages partition.Description = track.TrackDescription; partition.Size = (track.TrackEndSector - track.TrackStartSector) * (ulong)track.TrackRawBytesPerSector; - partition.Length = (track.TrackEndSector - track.TrackStartSector); + partition.Length = track.TrackEndSector - track.TrackStartSector; partition.Sequence = track.TrackSequence; partition.Offset = offsetBytes; partition.Start = track.TrackStartSector; @@ -1065,7 +1065,7 @@ namespace DiscImageChef.DiscImages if(!data && !firstdata) ImageInfo.MediaType = MediaType.CDDA; else if(firstaudio && data && sessions.Count > 1 && mode2) ImageInfo.MediaType = MediaType.CDPLUS; - else if((firstdata && audio) || mode2) ImageInfo.MediaType = MediaType.CDROMXA; + else if(firstdata && audio || mode2) ImageInfo.MediaType = MediaType.CDROMXA; else if(!audio) ImageInfo.MediaType = MediaType.CDROM; else ImageInfo.MediaType = MediaType.CD; } @@ -1265,8 +1265,8 @@ namespace DiscImageChef.DiscImages { if(track.TrackSequence == kvp.Key) { - if((sectorAddress - kvp.Value) < (track.TrackEndSector - track.TrackStartSector)) - return ReadSectors((sectorAddress - kvp.Value), length, kvp.Key); + if(sectorAddress - kvp.Value < track.TrackEndSector - track.TrackStartSector) + return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key); } } } @@ -1285,8 +1285,8 @@ namespace DiscImageChef.DiscImages { if(track.TrackSequence == kvp.Key) { - if((sectorAddress - kvp.Value) < (track.TrackEndSector - track.TrackStartSector)) - return ReadSectorsTag((sectorAddress - kvp.Value), length, kvp.Key, tag); + if(sectorAddress - kvp.Value < track.TrackEndSector - track.TrackStartSector) + return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag); } } } @@ -1315,7 +1315,7 @@ namespace DiscImageChef.DiscImages if(_track.TrackSequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); - if(length + sectorAddress > (_track.TrackEndSector)) + if(length + sectorAddress > _track.TrackEndSector) throw new ArgumentOutOfRangeException(nameof(length), string .Format("Requested more sectors ({0}) than present in track ({1}), won't cross tracks", @@ -1323,7 +1323,7 @@ namespace DiscImageChef.DiscImages foreach(DataFileCharacteristics _chars in filePaths) { - if((long)sectorAddress >= _chars.StartLba && length < ((ulong)_chars.Sectors - sectorAddress)) + if((long)sectorAddress >= _chars.StartLba && length < (ulong)_chars.Sectors - sectorAddress) { chars = _chars; break; @@ -1442,7 +1442,7 @@ namespace DiscImageChef.DiscImages if(_track.TrackSequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); - if(length + sectorAddress > (_track.TrackEndSector)) + if(length + sectorAddress > _track.TrackEndSector) throw new ArgumentOutOfRangeException(nameof(length), string .Format("Requested more sectors ({0}) than present in track ({1}), won't cross tracks", @@ -1450,7 +1450,7 @@ namespace DiscImageChef.DiscImages foreach(DataFileCharacteristics _chars in filePaths) { - if((long)sectorAddress >= _chars.StartLba && length < ((ulong)_chars.Sectors - sectorAddress)) + if((long)sectorAddress >= _chars.StartLba && length < (ulong)_chars.Sectors - sectorAddress) { chars = _chars; break; @@ -1735,8 +1735,8 @@ namespace DiscImageChef.DiscImages { if(track.TrackSequence == kvp.Key) { - if((sectorAddress - kvp.Value) < (track.TrackEndSector - track.TrackStartSector)) - return ReadSectorsLong((sectorAddress - kvp.Value), length, kvp.Key); + if(sectorAddress - kvp.Value < track.TrackEndSector - track.TrackStartSector) + return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key); } } } @@ -1765,7 +1765,7 @@ namespace DiscImageChef.DiscImages if(_track.TrackSequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); - if(length + sectorAddress > (_track.TrackEndSector)) + if(length + sectorAddress > _track.TrackEndSector) throw new ArgumentOutOfRangeException(nameof(length), string .Format("Requested more sectors ({0}) than present in track ({1}), won't cross tracks", @@ -1773,7 +1773,7 @@ namespace DiscImageChef.DiscImages foreach(DataFileCharacteristics _chars in filePaths) { - if((long)sectorAddress >= _chars.StartLba && length < ((ulong)_chars.Sectors - sectorAddress)) + if((long)sectorAddress >= _chars.StartLba && length < (ulong)_chars.Sectors - sectorAddress) { chars = _chars; break; diff --git a/DiscImageChef.DiscImages/CDRDAO.cs b/DiscImageChef.DiscImages/CDRDAO.cs index fbf4196e..bad6ed75 100644 --- a/DiscImageChef.DiscImages/CDRDAO.cs +++ b/DiscImageChef.DiscImages/CDRDAO.cs @@ -650,7 +650,7 @@ namespace DiscImageChef.DiscImages ulong.Parse(startString[2]); } - currenttrack.Trackfile.Offset += (startSectors * currenttrack.Bps); + currenttrack.Trackfile.Offset += startSectors * currenttrack.Bps; if(matchAudioFile.Groups["length"].Value != "") { @@ -870,7 +870,7 @@ namespace DiscImageChef.DiscImages partition.Name = discimage.Tracks[i].Title; partition.Start = discimage.Tracks[i].StartSector; partition.Size = (discimage.Tracks[i].Sectors - index0Len) * discimage.Tracks[i].Bps; - partition.Length = (discimage.Tracks[i].Sectors - index0Len); + partition.Length = discimage.Tracks[i].Sectors - index0Len; partition.Sequence = partitionSequence; partition.Offset = byteOffset; partition.Type = discimage.Tracks[i].Tracktype; @@ -1078,8 +1078,8 @@ namespace DiscImageChef.DiscImages { if(cdrdaoTrack.Sequence == kvp.Key) { - if((sectorAddress - kvp.Value) < cdrdaoTrack.Sectors) - return ReadSectors((sectorAddress - kvp.Value), length, kvp.Key); + if(sectorAddress - kvp.Value < cdrdaoTrack.Sectors) + return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key); } } } @@ -1099,8 +1099,8 @@ namespace DiscImageChef.DiscImages { if(cdrdaoTrack.Sequence == kvp.Key) { - if((sectorAddress - kvp.Value) < cdrdaoTrack.Sectors) - return ReadSectorsTag((sectorAddress - kvp.Value), length, kvp.Key, tag); + if(sectorAddress - kvp.Value < cdrdaoTrack.Sectors) + return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag); } } } @@ -1412,8 +1412,8 @@ namespace DiscImageChef.DiscImages { if(cdrdaoTrack.Sequence == kvp.Key) { - if((sectorAddress - kvp.Value) < cdrdaoTrack.Sectors) - return ReadSectorsLong((sectorAddress - kvp.Value), length, kvp.Key); + if(sectorAddress - kvp.Value < cdrdaoTrack.Sectors) + return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key); } } } diff --git a/DiscImageChef.DiscImages/CDRWin.cs b/DiscImageChef.DiscImages/CDRWin.cs index a30d2ed8..3fb540ad 100644 --- a/DiscImageChef.DiscImages/CDRWin.cs +++ b/DiscImageChef.DiscImages/CDRWin.cs @@ -619,7 +619,7 @@ namespace DiscImageChef.DiscImages // Check if file exists if(currentfile.Datafilter == null) { - if(datafile[0] == '/' || (datafile[0] == '/' && datafile[1] == '.') + if(datafile[0] == '/' || datafile[0] == '/' && datafile[1] == '.' ) // UNIX absolute path { Regex unixpath = new Regex("^(.+)/([^/]+)$"); @@ -648,9 +648,9 @@ namespace DiscImageChef.DiscImages FeatureUnsupportedImageException(string.Format("File \"{0}\" not found.", matchFile.Groups[1].Value)); } - else if((datafile[1] == ':' && datafile[2] == '\\') || - (datafile[0] == '\\' && datafile[1] == '\\') || - ((datafile[0] == '.' && datafile[1] == '\\'))) // Windows absolute path + else if(datafile[1] == ':' && datafile[2] == '\\' || + datafile[0] == '\\' && datafile[1] == '\\' || + datafile[0] == '.' && datafile[1] == '\\') // Windows absolute path { Regex winpath = new @@ -747,13 +747,13 @@ namespace DiscImageChef.DiscImages int index = int.Parse(matchIndex.Groups[1].Value); ulong offset = CdrWinMsftoLba(matchIndex.Groups[2].Value); - if((index != 0 && index != 1) && currenttrack.Indexes.Count == 0) + if(index != 0 && index != 1 && currenttrack.Indexes.Count == 0) throw new FeatureUnsupportedImageException(string .Format("Found INDEX {0} before INDEX 00 or INDEX 01", index)); - if((index == 0 || (index == 1 && !currenttrack.Indexes.ContainsKey(0)))) + if(index == 0 || index == 1 && !currenttrack.Indexes.ContainsKey(0)) { if((int)(currenttrack.Sequence - 2) >= 0 && offset > 1) { @@ -773,7 +773,7 @@ namespace DiscImageChef.DiscImages } } - if((index == 0 || (index == 1 && !currenttrack.Indexes.ContainsKey(0))) && + if((index == 0 || index == 1 && !currenttrack.Indexes.ContainsKey(0)) && currenttrack.Sequence == 1) { DicConsole.DebugWriteLine("CDRWin plugin", @@ -972,7 +972,7 @@ namespace DiscImageChef.DiscImages else if(cdi) discimage.Disktype = MediaType.CDI; else if(firstaudio && data && discimage.Sessions.Count > 1 && mode2) discimage.Disktype = MediaType.CDPLUS; - else if((firstdata && audio) || mode2) discimage.Disktype = MediaType.CDROMXA; + else if(firstdata && audio || mode2) discimage.Disktype = MediaType.CDROMXA; else if(!audio) discimage.Disktype = MediaType.CDROM; else discimage.Disktype = MediaType.CD; } @@ -1180,7 +1180,7 @@ namespace DiscImageChef.DiscImages partition.Name = discimage.Tracks[i].Title; partition.Start = sectorOffset; partition.Size = (discimage.Tracks[i].Sectors - index0Len) * discimage.Tracks[i].Bps; - partition.Length = (discimage.Tracks[i].Sectors - index0Len); + partition.Length = discimage.Tracks[i].Sectors - index0Len; partition.Sequence = partitionSequence; partition.Offset = byteOffset; partition.Type = discimage.Tracks[i].Tracktype; @@ -1401,8 +1401,8 @@ namespace DiscImageChef.DiscImages { if(cdrwinTrack.Sequence == kvp.Key) { - if((sectorAddress - kvp.Value) < cdrwinTrack.Sectors) - return ReadSectors((sectorAddress - kvp.Value), length, kvp.Key); + if(sectorAddress - kvp.Value < cdrwinTrack.Sectors) + return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key); } } } @@ -1421,8 +1421,8 @@ namespace DiscImageChef.DiscImages { if(cdrwinTrack.Sequence == kvp.Key) { - if((sectorAddress - kvp.Value) < cdrwinTrack.Sectors) - return ReadSectorsTag((sectorAddress - kvp.Value), length, kvp.Key, tag); + if(sectorAddress - kvp.Value < cdrwinTrack.Sectors) + return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag); } } } @@ -1752,8 +1752,8 @@ namespace DiscImageChef.DiscImages { if(cdrwinTrack.Sequence == kvp.Key) { - if((sectorAddress - kvp.Value) < cdrwinTrack.Sectors) - return ReadSectorsLong((sectorAddress - kvp.Value), length, kvp.Key); + if(sectorAddress - kvp.Value < cdrwinTrack.Sectors) + return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key); } } } @@ -2100,7 +2100,7 @@ namespace DiscImageChef.DiscImages second = ulong.Parse(msfElements[1]); frame = ulong.Parse(msfElements[2]); - sectors = (minute * 60 * 75) + (second * 75) + frame; + sectors = minute * 60 * 75 + second * 75 + frame; return sectors; } diff --git a/DiscImageChef.DiscImages/CHD.cs b/DiscImageChef.DiscImages/CHD.cs index 6b7f157b..70838c83 100644 --- a/DiscImageChef.DiscImages/CHD.cs +++ b/DiscImageChef.DiscImages/CHD.cs @@ -660,7 +660,7 @@ namespace DiscImageChef.DiscImages hunkTable = new ulong[hdrV1.totalhunks]; - uint hunkSectorCount = (uint)Math.Ceiling(((double)hdrV1.totalhunks * 8) / 512); + uint hunkSectorCount = (uint)Math.Ceiling((double)hdrV1.totalhunks * 8 / 512); byte[] hunkSectorBytes = new byte[512]; HunkSector hunkSector = new HunkSector(); @@ -676,11 +676,11 @@ namespace DiscImageChef.DiscImages handle.Free(); // This restores the order of elements Array.Reverse(hunkSector.hunkEntry); - if(hunkTable.Length >= (i * 512) / 8 + 512 / 8) - Array.Copy(hunkSector.hunkEntry, 0, hunkTable, (i * 512) / 8, 512 / 8); + if(hunkTable.Length >= i * 512 / 8 + 512 / 8) + Array.Copy(hunkSector.hunkEntry, 0, hunkTable, i * 512 / 8, 512 / 8); else - Array.Copy(hunkSector.hunkEntry, 0, hunkTable, (i * 512) / 8, - hunkTable.Length - (i * 512) / 8); + Array.Copy(hunkSector.hunkEntry, 0, hunkTable, i * 512 / 8, + hunkTable.Length - i * 512 / 8); } DateTime end = DateTime.UtcNow; @@ -733,7 +733,7 @@ namespace DiscImageChef.DiscImages hunkTable = new ulong[hdrV2.totalhunks]; // How many sectors uses the BAT - uint hunkSectorCount = (uint)Math.Ceiling(((double)hdrV2.totalhunks * 8) / 512); + uint hunkSectorCount = (uint)Math.Ceiling((double)hdrV2.totalhunks * 8 / 512); byte[] hunkSectorBytes = new byte[512]; HunkSector hunkSector = new HunkSector(); @@ -749,11 +749,11 @@ namespace DiscImageChef.DiscImages handle.Free(); // This restores the order of elements Array.Reverse(hunkSector.hunkEntry); - if(hunkTable.Length >= (i * 512) / 8 + 512 / 8) - Array.Copy(hunkSector.hunkEntry, 0, hunkTable, (i * 512) / 8, 512 / 8); + if(hunkTable.Length >= i * 512 / 8 + 512 / 8) + Array.Copy(hunkSector.hunkEntry, 0, hunkTable, i * 512 / 8, 512 / 8); else - Array.Copy(hunkSector.hunkEntry, 0, hunkTable, (i * 512) / 8, - hunkTable.Length - (i * 512) / 8); + Array.Copy(hunkSector.hunkEntry, 0, hunkTable, i * 512 / 8, + hunkTable.Length - i * 512 / 8); } DateTime end = DateTime.UtcNow; @@ -910,7 +910,7 @@ namespace DiscImageChef.DiscImages hunkTableSmall = new uint[hdrV5.logicalbytes / hdrV5.hunkbytes]; - uint hunkSectorCount = (uint)Math.Ceiling(((double)hunkTableSmall.Length * 4) / 512); + uint hunkSectorCount = (uint)Math.Ceiling((double)hunkTableSmall.Length * 4 / 512); byte[] hunkSectorBytes = new byte[512]; HunkSectorSmall hunkSector = new HunkSectorSmall(); @@ -929,11 +929,11 @@ namespace DiscImageChef.DiscImages handle.Free(); // This restores the order of elements Array.Reverse(hunkSector.hunkEntry); - if(hunkTableSmall.Length >= (i * 512) / 4 + 512 / 4) - Array.Copy(hunkSector.hunkEntry, 0, hunkTableSmall, (i * 512) / 4, 512 / 4); + if(hunkTableSmall.Length >= i * 512 / 4 + 512 / 4) + Array.Copy(hunkSector.hunkEntry, 0, hunkTableSmall, i * 512 / 4, 512 / 4); else - Array.Copy(hunkSector.hunkEntry, 0, hunkTableSmall, (i * 512) / 4, - hunkTableSmall.Length - (i * 512) / 4); + Array.Copy(hunkSector.hunkEntry, 0, hunkTableSmall, i * 512 / 4, + hunkTableSmall.Length - i * 512 / 4); } DateTime end = DateTime.UtcNow; @@ -1519,7 +1519,7 @@ namespace DiscImageChef.DiscImages ImageInfo.XmlMediaType = XmlMediaType.OpticalDisc; foreach(Track _trk in tracks.Values) - ImageInfo.Sectors += (_trk.TrackEndSector - _trk.TrackStartSector + 1); + ImageInfo.Sectors += _trk.TrackEndSector - _trk.TrackStartSector + 1; } else if(isGdrom) { @@ -1529,7 +1529,7 @@ namespace DiscImageChef.DiscImages ImageInfo.XmlMediaType = XmlMediaType.OpticalDisc; foreach(Track _trk in tracks.Values) - ImageInfo.Sectors += (_trk.TrackEndSector - _trk.TrackStartSector + 1); + ImageInfo.Sectors += _trk.TrackEndSector - _trk.TrackStartSector + 1; } else throw new ImageNotSupportedException("Image does not represent a known media, aborting"); } @@ -1545,7 +1545,7 @@ namespace DiscImageChef.DiscImages partition.Description = _track.TrackDescription; partition.Size = (_track.TrackEndSector - _track.TrackStartSector + 1) * (ulong)_track.TrackRawBytesPerSector; - partition.Length = (_track.TrackEndSector - _track.TrackStartSector + 1); + partition.Length = _track.TrackEndSector - _track.TrackStartSector + 1; partition.Sequence = _track.TrackSequence; partition.Offset = partPos; partition.Start = _track.TrackStartSector; @@ -1657,14 +1657,14 @@ namespace DiscImageChef.DiscImages switch(mapVersion) { case 1: - ulong offset = (hunkTable[hunkNo] & 0x00000FFFFFFFFFFF); + ulong offset = hunkTable[hunkNo] & 0x00000FFFFFFFFFFF; ulong length = hunkTable[hunkNo] >> 44; byte[] compHunk = new byte[length]; imageStream.Seek((long)offset, SeekOrigin.Begin); imageStream.Read(compHunk, 0, compHunk.Length); - if(length == (sectorsPerHunk * ImageInfo.SectorSize)) { hunk = compHunk; } + if(length == sectorsPerHunk * ImageInfo.SectorSize) { hunk = compHunk; } else if((ChdCompression)hdrCompression > ChdCompression.Zlib) throw new ImageNotSupportedException(string.Format("Unsupported compression {0}", (ChdCompression)hdrCompression)); @@ -1706,7 +1706,7 @@ namespace DiscImageChef.DiscImages DeflateStream zStream = new DeflateStream(new MemoryStream(zHunk), CompressionMode.Decompress); hunk = new byte[bytesPerHunk]; - int read = zStream.Read(hunk, 0, (int)(bytesPerHunk)); + int read = zStream.Read(hunk, 0, (int)bytesPerHunk); if(read != bytesPerHunk) throw new IOException(string @@ -1922,7 +1922,7 @@ namespace DiscImageChef.DiscImages } ulong hunkNo = sectorAddress / sectorsPerHunk; - ulong secOff = (sectorAddress * sectorSize) % (sectorsPerHunk * sectorSize); + ulong secOff = sectorAddress * sectorSize % (sectorsPerHunk * sectorSize); byte[] hunk = GetHunk(hunkNo); @@ -2027,7 +2027,7 @@ namespace DiscImageChef.DiscImages sectorSize = (uint)track.TrackRawBytesPerSector; ulong hunkNo = sectorAddress / sectorsPerHunk; - ulong secOff = (sectorAddress * sectorSize) % (sectorsPerHunk * sectorSize); + ulong secOff = sectorAddress * sectorSize % (sectorsPerHunk * sectorSize); byte[] hunk = GetHunk(hunkNo); @@ -2304,7 +2304,7 @@ namespace DiscImageChef.DiscImages sectorSize = (uint)track.TrackRawBytesPerSector; ulong hunkNo = sectorAddress / sectorsPerHunk; - ulong secOff = (sectorAddress * sectorSize) % (sectorsPerHunk * sectorSize); + ulong secOff = sectorAddress * sectorSize % (sectorsPerHunk * sectorSize); byte[] hunk = GetHunk(hunkNo); diff --git a/DiscImageChef.DiscImages/CloneCD.cs b/DiscImageChef.DiscImages/CloneCD.cs index ab782b60..2ab183ab 100644 --- a/DiscImageChef.DiscImages/CloneCD.cs +++ b/DiscImageChef.DiscImages/CloneCD.cs @@ -801,9 +801,9 @@ namespace DiscImageChef.DiscImages Partition partition = new Partition(); partition.Description = track.TrackDescription; - partition.Size = ((track.TrackEndSector - track.TrackStartSector) + 1) * + partition.Size = (track.TrackEndSector - track.TrackStartSector + 1) * (ulong)track.TrackRawBytesPerSector; - partition.Length = (track.TrackEndSector - track.TrackStartSector) + 1; + partition.Length = track.TrackEndSector - track.TrackStartSector + 1; ImageInfo.Sectors += partition.Length; partition.Sequence = track.TrackSequence; partition.Offset = track.TrackFileOffset; @@ -848,7 +848,7 @@ namespace DiscImageChef.DiscImages if(!data && !firstdata) ImageInfo.MediaType = MediaType.CDDA; else if(firstaudio && data && sessions.Count > 1 && mode2) ImageInfo.MediaType = MediaType.CDPLUS; - else if((firstdata && audio) || mode2) ImageInfo.MediaType = MediaType.CDROMXA; + else if(firstdata && audio || mode2) ImageInfo.MediaType = MediaType.CDROMXA; else if(!audio) ImageInfo.MediaType = MediaType.CDROM; else ImageInfo.MediaType = MediaType.CD; @@ -871,7 +871,7 @@ namespace DiscImageChef.DiscImages static ulong GetLba(int hour, int minute, int second, int frame) { - return (ulong)((hour * 60 * 60 * 75) + (minute * 60 * 75) + (second * 75) + frame - 150); + return (ulong)(hour * 60 * 60 * 75 + minute * 60 * 75 + second * 75 + frame - 150); } public override bool ImageHasPartitions() @@ -944,7 +944,7 @@ namespace DiscImageChef.DiscImages if(_track.TrackSequence == kvp.Key) { if(sectorAddress <= _track.TrackEndSector) - return ReadSectors((sectorAddress - kvp.Value), length, kvp.Key); + return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key); } } } @@ -965,7 +965,7 @@ namespace DiscImageChef.DiscImages if(_track.TrackSequence == kvp.Key) { if(sectorAddress <= _track.TrackEndSector) - return ReadSectorsTag((sectorAddress - kvp.Value), length, kvp.Key, tag); + return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag); } } } @@ -993,7 +993,7 @@ namespace DiscImageChef.DiscImages if(_track.TrackSequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); - if((length + sectorAddress) - 1 > _track.TrackEndSector) + if(length + sectorAddress - 1 > _track.TrackEndSector) throw new ArgumentOutOfRangeException(nameof(length), string .Format("Requested more sectors ({0} {2}) than present in track ({1}), won't cross tracks", @@ -1082,7 +1082,7 @@ namespace DiscImageChef.DiscImages if(_track.TrackSequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); - if((length + sectorAddress) - 1 > (_track.TrackEndSector)) + if(length + sectorAddress - 1 > _track.TrackEndSector) throw new ArgumentOutOfRangeException(nameof(length), string .Format("Requested more sectors ({0}) than present in track ({1}), won't cross tracks", @@ -1333,8 +1333,8 @@ namespace DiscImageChef.DiscImages { if(track.TrackSequence == kvp.Key) { - if((sectorAddress - kvp.Value) < ((track.TrackEndSector - track.TrackStartSector) + 1)) - return ReadSectorsLong((sectorAddress - kvp.Value), length, kvp.Key); + if(sectorAddress - kvp.Value < track.TrackEndSector - track.TrackStartSector + 1) + return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key); } } } @@ -1362,7 +1362,7 @@ namespace DiscImageChef.DiscImages if(_track.TrackSequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); - if((length + sectorAddress) - 1 > (_track.TrackEndSector)) + if(length + sectorAddress - 1 > _track.TrackEndSector) throw new ArgumentOutOfRangeException(nameof(length), string .Format("Requested more sectors ({0}) than present in track ({1}), won't cross tracks", diff --git a/DiscImageChef.DiscImages/CopyQM.cs b/DiscImageChef.DiscImages/CopyQM.cs index 6b818681..1ef7f6a1 100644 --- a/DiscImageChef.DiscImages/CopyQM.cs +++ b/DiscImageChef.DiscImages/CopyQM.cs @@ -207,7 +207,7 @@ namespace DiscImageChef.DiscImages ushort magic = BitConverter.ToUInt16(hdr, 0); - if(magic != COPYQM_MAGIC || hdr[0x02] != COPYQM_MARK || (133 + hdr[0x6F]) >= stream.Length) return false; + if(magic != COPYQM_MAGIC || hdr[0x02] != COPYQM_MARK || 133 + hdr[0x6F] >= stream.Length) return false; return true; } @@ -277,7 +277,7 @@ namespace DiscImageChef.DiscImages byte[] repeatedArray = new byte[runLength * -1]; ArrayHelpers.ArrayFill(repeatedArray, repeatedByte); - for(int i = 0; i < (runLength * -1); i++) + for(int i = 0; i < runLength * -1; i++) { decodedImage.WriteByte(repeatedByte); calculatedDataCrc = copyQmCrcTable[(repeatedByte ^ calculatedDataCrc) & 0x3F] ^ @@ -297,9 +297,9 @@ namespace DiscImageChef.DiscImages } // In case there is omitted data - long sectors = (header.sectorsPerTrack) * header.heads * header.totalCylinders; + long sectors = header.sectorsPerTrack * header.heads * header.totalCylinders; - long fillingLen = (sectors * header.sectorSize) - decodedImage.Length; + long fillingLen = sectors * header.sectorSize - decodedImage.Length; if(fillingLen > 0) { @@ -320,7 +320,7 @@ namespace DiscImageChef.DiscImages headerChecksumOk = ((-1 * sum) & 0xFF) == header.headerChecksum; DicConsole.DebugWriteLine("CopyQM plugin", "Calculated header checksum = 0x{0:X2}, {1}", - ((-1 * sum) & 0xFF), headerChecksumOk); + (-1 * sum) & 0xFF, headerChecksumOk); DicConsole.DebugWriteLine("CopyQM plugin", "Calculated data CRC = 0x{0:X8}, {1}", calculatedDataCrc, calculatedDataCrc == header.crc); @@ -456,7 +456,7 @@ namespace DiscImageChef.DiscImages public override bool? VerifyMediaImage() { - return (calculatedDataCrc == header.crc) && headerChecksumOk; + return calculatedDataCrc == header.crc && headerChecksumOk; } public override bool ImageHasPartitions() diff --git a/DiscImageChef.DiscImages/DART.cs b/DiscImageChef.DiscImages/DART.cs index 0a001152..1c4db99b 100644 --- a/DiscImageChef.DiscImages/DART.cs +++ b/DiscImageChef.DiscImages/DART.cs @@ -81,7 +81,7 @@ namespace DiscImageChef.DiscImages const int TAG_SECTOR_SIZE = 12; const int DATA_SIZE = SECTORS_PER_BLOCK * SECTOR_SIZE; const int TAG_SIZE = SECTORS_PER_BLOCK * TAG_SECTOR_SIZE; - const int BUFFER_SIZE = (SECTORS_PER_BLOCK * SECTOR_SIZE) + (SECTORS_PER_BLOCK * TAG_SECTOR_SIZE); + const int BUFFER_SIZE = SECTORS_PER_BLOCK * SECTOR_SIZE + SECTORS_PER_BLOCK * TAG_SECTOR_SIZE; #endregion #region Internal Structures @@ -142,7 +142,7 @@ namespace DiscImageChef.DiscImages if(header.srcCmp > COMPRESS_NONE) return false; - int expectedMaxSize = 84 + (header.srcSize * 2 * 524); + int expectedMaxSize = 84 + header.srcSize * 2 * 524; switch(header.srcType) { @@ -195,7 +195,7 @@ namespace DiscImageChef.DiscImages if(header.srcCmp > COMPRESS_NONE) return false; - int expectedMaxSize = 84 + (header.srcSize * 2 * 524); + int expectedMaxSize = 84 + header.srcSize * 2 * 524; switch(header.srcType) { @@ -488,9 +488,9 @@ namespace DiscImageChef.DiscImages for(uint i = 0; i < length; i++) { - Array.Copy(data, i * (ImageInfo.SectorSize), buffer, i * (ImageInfo.SectorSize + TAG_SECTOR_SIZE), + Array.Copy(data, i * ImageInfo.SectorSize, buffer, i * (ImageInfo.SectorSize + TAG_SECTOR_SIZE), ImageInfo.SectorSize); - Array.Copy(tags, i * (TAG_SECTOR_SIZE), buffer, + Array.Copy(tags, i * TAG_SECTOR_SIZE, buffer, i * (ImageInfo.SectorSize + TAG_SECTOR_SIZE) + ImageInfo.SectorSize, TAG_SECTOR_SIZE); } diff --git a/DiscImageChef.DiscImages/DiscJuggler.cs b/DiscImageChef.DiscImages/DiscJuggler.cs index 7a545e98..9e846207 100644 --- a/DiscImageChef.DiscImages/DiscJuggler.cs +++ b/DiscImageChef.DiscImages/DiscJuggler.cs @@ -622,7 +622,7 @@ namespace DiscImageChef.DiscImages if(!data && !firstdata) ImageInfo.MediaType = MediaType.CDDA; else if(firstaudio && data && sessions.Count > 1 && mode2) ImageInfo.MediaType = MediaType.CDPLUS; - else if((firstdata && audio) || mode2) ImageInfo.MediaType = MediaType.CDROMXA; + else if(firstdata && audio || mode2) ImageInfo.MediaType = MediaType.CDROMXA; else if(!audio) ImageInfo.MediaType = MediaType.CDROM; else ImageInfo.MediaType = MediaType.CD; } @@ -712,7 +712,7 @@ namespace DiscImageChef.DiscImages if(_track.TrackSequence == kvp.Key) { if(sectorAddress < _track.TrackEndSector) - return ReadSectors((sectorAddress - kvp.Value), length, kvp.Key); + return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key); } } } @@ -733,7 +733,7 @@ namespace DiscImageChef.DiscImages if(_track.TrackSequence == kvp.Key) { if(sectorAddress < _track.TrackEndSector) - return ReadSectorsTag((sectorAddress - kvp.Value), length, kvp.Key, tag); + return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag); } } } @@ -761,7 +761,7 @@ namespace DiscImageChef.DiscImages if(_track.TrackSequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); - if(length + sectorAddress > (_track.TrackEndSector)) + if(length + sectorAddress > _track.TrackEndSector) throw new ArgumentOutOfRangeException(nameof(length), string .Format("Requested more sectors ({0}) than present in track ({1}), won't cross tracks", @@ -863,7 +863,7 @@ namespace DiscImageChef.DiscImages if(_track.TrackSequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); - if(length + sectorAddress > (_track.TrackEndSector)) + if(length + sectorAddress > _track.TrackEndSector) throw new ArgumentOutOfRangeException(nameof(length), string .Format("Requested more sectors ({0}) than present in track ({1}), won't cross tracks", @@ -1080,8 +1080,8 @@ namespace DiscImageChef.DiscImages { if(track.TrackSequence == kvp.Key) { - if((sectorAddress - kvp.Value) < (track.TrackEndSector - track.TrackStartSector)) - return ReadSectorsLong((sectorAddress - kvp.Value), length, kvp.Key); + if(sectorAddress - kvp.Value < track.TrackEndSector - track.TrackStartSector) + return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key); } } } @@ -1109,7 +1109,7 @@ namespace DiscImageChef.DiscImages if(_track.TrackSequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); - if(length + sectorAddress > (_track.TrackEndSector)) + if(length + sectorAddress > _track.TrackEndSector) throw new ArgumentOutOfRangeException(nameof(length), string .Format("Requested more sectors ({0}) than present in track ({1}), won't cross tracks", diff --git a/DiscImageChef.DiscImages/DiskCopy42.cs b/DiscImageChef.DiscImages/DiskCopy42.cs index 8d379884..9476286d 100644 --- a/DiscImageChef.DiscImages/DiskCopy42.cs +++ b/DiscImageChef.DiscImages/DiskCopy42.cs @@ -402,22 +402,22 @@ namespace DiscImageChef.DiscImages twiggy = true; Stream datastream = imageFilter.GetDataForkStream(); - datastream.Seek((dataOffset), SeekOrigin.Begin); + datastream.Seek(dataOffset, SeekOrigin.Begin); datastream.Read(data, 0, (int)header.DataSize); Stream tagstream = imageFilter.GetDataForkStream(); - tagstream.Seek((tagOffset), SeekOrigin.Begin); + tagstream.Seek(tagOffset, SeekOrigin.Begin); tagstream.Read(tags, 0, (int)header.TagSize); - ushort mfsMagic = BigEndianBitConverter.ToUInt16(data, (int)((data.Length / 2) + 0x400)); - ushort mfsAllBlocks = BigEndianBitConverter.ToUInt16(data, (int)((data.Length / 2) + 0x412)); + ushort mfsMagic = BigEndianBitConverter.ToUInt16(data, (int)(data.Length / 2 + 0x400)); + ushort mfsAllBlocks = BigEndianBitConverter.ToUInt16(data, (int)(data.Length / 2 + 0x412)); // Detect a Macintosh Twiggy if(mfsMagic == 0xD2D7 && mfsAllBlocks == 422) { DicConsole.DebugWriteLine("DC42 plugin", "Macintosh Twiggy detected, reversing disk sides"); - Array.Copy(data, (header.DataSize / 2), twiggyCache, 0, header.DataSize / 2); - Array.Copy(tags, (header.TagSize / 2), twiggyCacheTags, 0, header.TagSize / 2); + Array.Copy(data, header.DataSize / 2, twiggyCache, 0, header.DataSize / 2); + Array.Copy(tags, header.TagSize / 2, twiggyCacheTags, 0, header.TagSize / 2); Array.Copy(data, 0, twiggyCache, header.DataSize / 2, header.DataSize / 2); Array.Copy(tags, 0, twiggyCacheTags, header.TagSize / 2, header.TagSize / 2); } @@ -588,7 +588,7 @@ namespace DiscImageChef.DiscImages ImageInfo.SectorsPerTrack = 16; break; default: - ImageInfo.Cylinders = (uint)((ImageInfo.Sectors / 16) / 63); + ImageInfo.Cylinders = (uint)(ImageInfo.Sectors / 16 / 63); ImageInfo.Heads = 16; ImageInfo.SectorsPerTrack = 63; break; @@ -638,7 +638,7 @@ namespace DiscImageChef.DiscImages DicConsole.DebugWriteLine("DC42 plugin", "Reading data"); Stream datastream = dc42ImageFilter.GetDataForkStream(); - datastream.Seek((dataOffset), SeekOrigin.Begin); + datastream.Seek(dataOffset, SeekOrigin.Begin); datastream.Read(data, 0, (int)header.DataSize); DicConsole.DebugWriteLine("DC42 plugin", "Calculating data checksum"); @@ -650,7 +650,7 @@ namespace DiscImageChef.DiscImages { DicConsole.DebugWriteLine("DC42 plugin", "Reading tags"); Stream tagstream = dc42ImageFilter.GetDataForkStream(); - tagstream.Seek((tagOffset), SeekOrigin.Begin); + tagstream.Seek(tagOffset, SeekOrigin.Begin); tagstream.Read(tags, 0, (int)header.TagSize); DicConsole.DebugWriteLine("DC42 plugin", "Calculating tag checksum"); @@ -762,9 +762,9 @@ namespace DiscImageChef.DiscImages for(uint i = 0; i < length; i++) { - Array.Copy(data, i * (ImageInfo.SectorSize), buffer, i * (ImageInfo.SectorSize + bptag), + Array.Copy(data, i * ImageInfo.SectorSize, buffer, i * (ImageInfo.SectorSize + bptag), ImageInfo.SectorSize); - Array.Copy(tags, i * (bptag), buffer, i * (ImageInfo.SectorSize + bptag) + ImageInfo.SectorSize, bptag); + Array.Copy(tags, i * bptag, buffer, i * (ImageInfo.SectorSize + bptag) + ImageInfo.SectorSize, bptag); } return buffer; diff --git a/DiscImageChef.DiscImages/DriDiskCopy.cs b/DiscImageChef.DiscImages/DriDiskCopy.cs index 7a9a8d27..86587b82 100644 --- a/DiscImageChef.DiscImages/DriDiskCopy.cs +++ b/DiscImageChef.DiscImages/DriDiskCopy.cs @@ -211,7 +211,7 @@ namespace DiscImageChef.DiscImages if(tmpFooter.bpb.sptrack * tmpFooter.bpb.cylinders * tmpFooter.bpb.heads != tmpFooter.bpb.sectors) return false; - if((tmpFooter.bpb.sectors * tmpFooter.bpb.bps) + Marshal.SizeOf(tmpFooter) != stream.Length) + if(tmpFooter.bpb.sectors * tmpFooter.bpb.bps + Marshal.SizeOf(tmpFooter) != stream.Length) return false; return true; @@ -242,7 +242,7 @@ namespace DiscImageChef.DiscImages if(footer.bpb.sptrack * footer.bpb.cylinders * footer.bpb.heads != footer.bpb.sectors) return false; - if((footer.bpb.sectors * footer.bpb.bps) + Marshal.SizeOf(footer) != stream.Length) return false; + if(footer.bpb.sectors * footer.bpb.bps + Marshal.SizeOf(footer) != stream.Length) return false; ImageInfo.Cylinders = footer.bpb.cylinders; ImageInfo.Heads = footer.bpb.heads; diff --git a/DiscImageChef.DiscImages/GDI.cs b/DiscImageChef.DiscImages/GDI.cs index 2c6dbb9a..2d7716ab 100644 --- a/DiscImageChef.DiscImages/GDI.cs +++ b/DiscImageChef.DiscImages/GDI.cs @@ -257,23 +257,23 @@ namespace DiscImageChef.DiscImages .Trim(new[] {'"'}))); currentTrack.Trackfile = currentTrack.Trackfilter.GetFilename(); - if((currentTrack.StartSector - currentStart) > 0) + if(currentTrack.StartSector - currentStart > 0) { if(currentTrack.StartSector == 45000) { highDensity = true; offsetmap.Add(0, currentStart); - densitySeparationSectors = (currentTrack.StartSector - currentStart); + densitySeparationSectors = currentTrack.StartSector - currentStart; currentStart = currentTrack.StartSector; } else { - currentTrack.Pregap = (currentTrack.StartSector - currentStart); - currentTrack.StartSector -= (currentTrack.StartSector - currentStart); + currentTrack.Pregap = currentTrack.StartSector - currentStart; + currentTrack.StartSector -= currentTrack.StartSector - currentStart; } } - if(((currentTrack.Trackfilter.GetDataForkLength() - currentTrack.Offset) % currentTrack.Bps) != + if((currentTrack.Trackfilter.GetDataForkLength() - currentTrack.Offset) % currentTrack.Bps != 0) throw new ImageNotSupportedException("Track size not a multiple of sector size"); currentTrack.Sectors = @@ -309,7 +309,7 @@ namespace DiscImageChef.DiscImages if(_sessions[s].StartSector > trk.StartSector) _sessions[s].StartSector = trk.StartSector; - if(_sessions[s].EndSector < (trk.Sectors + trk.StartSector - 1)) + if(_sessions[s].EndSector < trk.Sectors + trk.StartSector - 1) _sessions[s].EndSector = trk.Sectors + trk.StartSector - 1; } } @@ -330,7 +330,7 @@ namespace DiscImageChef.DiscImages if(_sessions[s].StartSector > trk.StartSector) _sessions[s].StartSector = trk.StartSector; - if(_sessions[s].EndSector < (trk.Sectors + trk.StartSector - 1)) + if(_sessions[s].EndSector < trk.Sectors + trk.StartSector - 1) _sessions[s].EndSector = trk.Sectors + trk.StartSector - 1; } } @@ -506,8 +506,8 @@ namespace DiscImageChef.DiscImages { if(gdiTrack.Sequence == kvp.Key) { - if((sectorAddress - kvp.Value) < gdiTrack.Sectors) - return ReadSectors((sectorAddress - kvp.Value), length, kvp.Key); + if(sectorAddress - kvp.Value < gdiTrack.Sectors) + return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key); } } } @@ -515,8 +515,8 @@ namespace DiscImageChef.DiscImages ulong transitionStart; offsetmap.TryGetValue(0, out transitionStart); - if(sectorAddress >= transitionStart && sectorAddress < (densitySeparationSectors + transitionStart)) - return ReadSectors((sectorAddress - transitionStart), length, 0); + if(sectorAddress >= transitionStart && sectorAddress < densitySeparationSectors + transitionStart) + return ReadSectors(sectorAddress - transitionStart, length, 0); throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); } @@ -531,8 +531,8 @@ namespace DiscImageChef.DiscImages { if(gdiTrack.Sequence == kvp.Key) { - if((sectorAddress - kvp.Value) < gdiTrack.Sectors) - return ReadSectorsTag((sectorAddress - kvp.Value), length, kvp.Key, tag); + if(sectorAddress - kvp.Value < gdiTrack.Sectors) + return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag); } } } @@ -540,8 +540,8 @@ namespace DiscImageChef.DiscImages ulong transitionStart; offsetmap.TryGetValue(0, out transitionStart); - if(sectorAddress >= transitionStart && sectorAddress < (densitySeparationSectors + transitionStart)) - return ReadSectorsTag((sectorAddress - transitionStart), length, 0, tag); + if(sectorAddress >= transitionStart && sectorAddress < densitySeparationSectors + transitionStart) + return ReadSectorsTag(sectorAddress - transitionStart, length, 0, tag); throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); } @@ -550,7 +550,7 @@ namespace DiscImageChef.DiscImages { if(track == 0) { - if((sectorAddress + length) > densitySeparationSectors) + if(sectorAddress + length > densitySeparationSectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks"); @@ -573,7 +573,7 @@ namespace DiscImageChef.DiscImages if(_track.Sequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); - if((sectorAddress + length) > _track.Sectors) + if(sectorAddress + length > _track.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks"); @@ -658,7 +658,7 @@ namespace DiscImageChef.DiscImages { if(track == 0) { - if((sectorAddress + length) > densitySeparationSectors) + if(sectorAddress + length > densitySeparationSectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks"); @@ -838,8 +838,8 @@ namespace DiscImageChef.DiscImages { if(gdiTrack.Sequence == kvp.Key) { - if((sectorAddress - kvp.Value) < gdiTrack.Sectors) - return ReadSectorsLong((sectorAddress - kvp.Value), length, kvp.Key); + if(sectorAddress - kvp.Value < gdiTrack.Sectors) + return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key); } } } @@ -852,7 +852,7 @@ namespace DiscImageChef.DiscImages { if(track == 0) { - if((sectorAddress + length) > densitySeparationSectors) + if(sectorAddress + length > densitySeparationSectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks"); @@ -875,7 +875,7 @@ namespace DiscImageChef.DiscImages if(_track.Sequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); - if((sectorAddress + length) > _track.Sectors) + if(sectorAddress + length > _track.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks"); diff --git a/DiscImageChef.DiscImages/HDCopy.cs b/DiscImageChef.DiscImages/HDCopy.cs index 305450fe..8ebbfa87 100644 --- a/DiscImageChef.DiscImages/HDCopy.cs +++ b/DiscImageChef.DiscImages/HDCopy.cs @@ -215,12 +215,12 @@ namespace DiscImageChef.DiscImages * We know the image is from a DOS floppy disk, so assume * some sane cylinder and sectors-per-track count. */ - if((fheader.sectorsPerTrack < 8) || (fheader.sectorsPerTrack > 40)) return false; + if(fheader.sectorsPerTrack < 8 || fheader.sectorsPerTrack > 40) return false; - if((fheader.lastCylinder < 37) || (fheader.lastCylinder >= 82)) return false; + if(fheader.lastCylinder < 37 || fheader.lastCylinder >= 82) return false; // Validate the trackmap. First two tracks need to be present - if((fheader.trackMap[0] != 1) || (fheader.trackMap[1] != 1)) return false; + if(fheader.trackMap[0] != 1 || fheader.trackMap[1] != 1) return false; // all other tracks must be either present (=1) or absent (=0) for(int i = 0; i < 2 * 82; i++) { if(fheader.trackMap[i] > 1) return false; } @@ -375,7 +375,7 @@ namespace DiscImageChef.DiscImages { foreach(MediaTypeTableEntry ent in mediaTypes) { - if((ent.Tracks == ImageInfo.Cylinders) && (ent.SectorsPerTrack == ImageInfo.SectorsPerTrack)) + if(ent.Tracks == ImageInfo.Cylinders && ent.SectorsPerTrack == ImageInfo.SectorsPerTrack) return ent.MediaType; } diff --git a/DiscImageChef.DiscImages/NDIF.cs b/DiscImageChef.DiscImages/NDIF.cs index f5e61ea2..300b244f 100644 --- a/DiscImageChef.DiscImages/NDIF.cs +++ b/DiscImageChef.DiscImages/NDIF.cs @@ -325,19 +325,19 @@ namespace DiscImageChef.DiscImages bChnk.sector += (uint)ImageInfo.Sectors; // TODO: Handle compressed chunks - if((bChnk.type == CHUNK_TYPE_KENCODE)) + if(bChnk.type == CHUNK_TYPE_KENCODE) throw new ImageNotSupportedException("Chunks compressed with KenCode are not yet supported."); - if((bChnk.type == CHUNK_TYPE_RLE)) + if(bChnk.type == CHUNK_TYPE_RLE) throw new ImageNotSupportedException("Chunks compressed with RLE are not yet supported."); - if((bChnk.type == CHUNK_TYPE_LZH)) + if(bChnk.type == CHUNK_TYPE_LZH) throw new ImageNotSupportedException("Chunks compressed with LZH are not yet supported."); - if((bChnk.type == CHUNK_TYPE_STUFFIT)) + if(bChnk.type == CHUNK_TYPE_STUFFIT) throw new ImageNotSupportedException("Chunks compressed with StuffIt! are not yet supported."); // TODO: Handle compressed chunks - if((bChnk.type > CHUNK_TYPE_COPY && bChnk.type < CHUNK_TYPE_KENCODE) || - (bChnk.type > CHUNK_TYPE_ADC && bChnk.type < CHUNK_TYPE_STUFFIT) || - (bChnk.type > CHUNK_TYPE_STUFFIT && bChnk.type < CHUNK_TYPE_END) || + if(bChnk.type > CHUNK_TYPE_COPY && bChnk.type < CHUNK_TYPE_KENCODE || + bChnk.type > CHUNK_TYPE_ADC && bChnk.type < CHUNK_TYPE_STUFFIT || + bChnk.type > CHUNK_TYPE_STUFFIT && bChnk.type < CHUNK_TYPE_END || bChnk.type == 1) throw new ImageNotSupportedException(string.Format("Unsupported chunk type 0x{0:X8} found", bChnk.type)); @@ -458,7 +458,7 @@ namespace DiscImageChef.DiscImages break; default: ImageInfo.MediaType = MediaType.GENERIC_HDD; - ImageInfo.Cylinders = (uint)((ImageInfo.Sectors / 16) / 63); + ImageInfo.Cylinders = (uint)(ImageInfo.Sectors / 16 / 63); ImageInfo.Heads = 16; ImageInfo.SectorsPerTrack = 63; break; diff --git a/DiscImageChef.DiscImages/Nero.cs b/DiscImageChef.DiscImages/Nero.cs index 8cd5de9b..6f23dccc 100644 --- a/DiscImageChef.DiscImages/Nero.cs +++ b/DiscImageChef.DiscImages/Nero.cs @@ -1009,20 +1009,20 @@ namespace DiscImageChef.DiscImages entry.Second = tmpbuffer[6]; entry.Frame = tmpbuffer[7]; - DicConsole.DebugWriteLine("Nero plugin", "Cuesheet entry {0}", (i / 8) + 1); - DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Mode = {1:X2}", (i / 8) + 1, + DicConsole.DebugWriteLine("Nero plugin", "Cuesheet entry {0}", i / 8 + 1); + DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Mode = {1:X2}", i / 8 + 1, entry.Mode); DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].TrackNumber = {1:X2}", - (i / 8) + 1, entry.TrackNumber); + i / 8 + 1, entry.TrackNumber); DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].IndexNumber = {1:X2}", - (i / 8) + 1, entry.IndexNumber); - DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Dummy = {1:X4}", (i / 8) + 1, + i / 8 + 1, entry.IndexNumber); + DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Dummy = {1:X4}", i / 8 + 1, entry.Dummy); - DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Minute = {1:X2}", (i / 8) + 1, + DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Minute = {1:X2}", i / 8 + 1, entry.Minute); - DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Second = {1:X2}", (i / 8) + 1, + DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Second = {1:X2}", i / 8 + 1, entry.Second); - DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Frame = {1:X2}", (i / 8) + 1, + DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Frame = {1:X2}", i / 8 + 1, entry.Frame); neroCuesheetV1.Entries.Add(entry); @@ -1051,16 +1051,16 @@ namespace DiscImageChef.DiscImages entry.Dummy = tmpbuffer[3]; entry.LbaStart = BigEndianBitConverter.ToInt32(tmpbuffer, 4); - DicConsole.DebugWriteLine("Nero plugin", "Cuesheet entry {0}", (i / 8) + 1); - DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Mode = 0x{1:X2}", (i / 8) + 1, + DicConsole.DebugWriteLine("Nero plugin", "Cuesheet entry {0}", i / 8 + 1); + DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Mode = 0x{1:X2}", i / 8 + 1, entry.Mode); DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].TrackNumber = {1:X2}", - (i / 8) + 1, entry.TrackNumber); + i / 8 + 1, entry.TrackNumber); DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].IndexNumber = {1:X2}", - (i / 8) + 1, entry.IndexNumber); - DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Dummy = {1:X2}", (i / 8) + 1, + i / 8 + 1, entry.IndexNumber); + DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Dummy = {1:X2}", i / 8 + 1, entry.Dummy); - DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].LBAStart = {1}", (i / 8) + 1, + DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].LBAStart = {1}", i / 8 + 1, entry.LbaStart); neroCuesheetV2.Entries.Add(entry); @@ -1105,7 +1105,7 @@ namespace DiscImageChef.DiscImages upc = neroDaov1.Upc; tmpbuffer = new byte[30]; - for(int i = 0; i < (neroDaov1.ChunkSizeBe - 22); i += 30) + for(int i = 0; i < neroDaov1.ChunkSizeBe - 22; i += 30) { NeroV1DaoEntry entry = new NeroV1DaoEntry(); imageStream.Read(tmpbuffer, 0, 30); @@ -1118,21 +1118,21 @@ namespace DiscImageChef.DiscImages entry.Index1 = BigEndianBitConverter.ToUInt32(tmpbuffer, 22); entry.EndOfTrack = BigEndianBitConverter.ToUInt32(tmpbuffer, 26); - DicConsole.DebugWriteLine("Nero plugin", "Disc-At-Once entry {0}", (i / 32) + 1); - DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].ISRC = \"{1}\"", (i / 32) + 1, + DicConsole.DebugWriteLine("Nero plugin", "Disc-At-Once entry {0}", i / 32 + 1); + DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].ISRC = \"{1}\"", i / 32 + 1, StringHandlers.CToString(entry.Isrc)); DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].SectorSize = {1}", - (i / 32) + 1, entry.SectorSize); + i / 32 + 1, entry.SectorSize); DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Mode = {1} (0x{2:X4})", - (i / 32) + 1, (DaoMode)entry.Mode, entry.Mode); + i / 32 + 1, (DaoMode)entry.Mode, entry.Mode); DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Unknown = 0x{1:X4}", - (i / 32) + 1, entry.Unknown); - DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Index0 = {1}", (i / 32) + 1, + i / 32 + 1, entry.Unknown); + DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Index0 = {1}", i / 32 + 1, entry.Index0); - DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Index1 = {1}", (i / 32) + 1, + DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Index1 = {1}", i / 32 + 1, entry.Index1); DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].EndOfTrack = {1}", - (i / 32) + 1, entry.EndOfTrack); + i / 32 + 1, entry.EndOfTrack); neroDaov1.Tracks.Add(entry); @@ -1199,7 +1199,7 @@ namespace DiscImageChef.DiscImages DicConsole.DebugWriteLine("Nero plugin", "neroDAOV2.LastTrack = {0}", neroDaov2.LastTrack); tmpbuffer = new byte[42]; - for(int i = 0; i < (neroDaov2.ChunkSizeBe - 22); i += 42) + for(int i = 0; i < neroDaov2.ChunkSizeBe - 22; i += 42) { NeroV2DaoEntry entry = new NeroV2DaoEntry(); imageStream.Read(tmpbuffer, 0, 42); @@ -1212,21 +1212,21 @@ namespace DiscImageChef.DiscImages entry.Index1 = BigEndianBitConverter.ToUInt64(tmpbuffer, 26); entry.EndOfTrack = BigEndianBitConverter.ToUInt64(tmpbuffer, 34); - DicConsole.DebugWriteLine("Nero plugin", "Disc-At-Once entry {0}", (i / 32) + 1); - DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].ISRC = \"{1}\"", (i / 32) + 1, + DicConsole.DebugWriteLine("Nero plugin", "Disc-At-Once entry {0}", i / 32 + 1); + DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].ISRC = \"{1}\"", i / 32 + 1, StringHandlers.CToString(entry.Isrc)); DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].SectorSize = {1}", - (i / 32) + 1, entry.SectorSize); + i / 32 + 1, entry.SectorSize); DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Mode = {1} (0x{2:X4})", - (i / 32) + 1, (DaoMode)entry.Mode, entry.Mode); + i / 32 + 1, (DaoMode)entry.Mode, entry.Mode); DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Unknown = {1:X2}", - (i / 32) + 1, entry.Unknown); - DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Index0 = {1}", (i / 32) + 1, + i / 32 + 1, entry.Unknown); + DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Index0 = {1}", i / 32 + 1, entry.Index0); - DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Index1 = {1}", (i / 32) + 1, + DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Index1 = {1}", i / 32 + 1, entry.Index1); DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].EndOfTrack = {1}", - (i / 32) + 1, entry.EndOfTrack); + i / 32 + 1, entry.EndOfTrack); neroDaov2.Tracks.Add(entry); @@ -1268,7 +1268,7 @@ namespace DiscImageChef.DiscImages neroCdtxt.Packs = new List(); byte[] tmpbuffer = new byte[18]; - for(int i = 0; i < (neroCdtxt.ChunkSize); i += 18) + for(int i = 0; i < neroCdtxt.ChunkSize; i += 18) { NeroCdTextPack entry = new NeroCdTextPack(); imageStream.Read(tmpbuffer, 0, 18); @@ -1281,18 +1281,18 @@ namespace DiscImageChef.DiscImages Array.Copy(tmpbuffer, 4, entry.Text, 0, 12); entry.Crc = BigEndianBitConverter.ToUInt16(tmpbuffer, 16); - DicConsole.DebugWriteLine("Nero plugin", "CD-TEXT entry {0}", (i / 18) + 1); + DicConsole.DebugWriteLine("Nero plugin", "CD-TEXT entry {0}", i / 18 + 1); DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].PackType = 0x{1:X2}", - (i / 18) + 1, entry.PackType); + i / 18 + 1, entry.PackType); DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].TrackNumber = 0x{1:X2}", - (i / 18) + 1, entry.TrackNumber); + i / 18 + 1, entry.TrackNumber); DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].PackNumber = 0x{1:X2}", - (i / 18) + 1, entry.PackNumber); + i / 18 + 1, entry.PackNumber); DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].BlockNumber = 0x{1:X2}", - (i / 18) + 1, entry.BlockNumber); - DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Text = \"{1}\"", (i / 18) + 1, + i / 18 + 1, entry.BlockNumber); + DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Text = \"{1}\"", i / 18 + 1, StringHandlers.CToString(entry.Text)); - DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].CRC = 0x{1:X4}", (i / 18) + 1, + DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].CRC = 0x{1:X4}", i / 18 + 1, entry.Crc); neroCdtxt.Packs.Add(entry); @@ -1311,7 +1311,7 @@ namespace DiscImageChef.DiscImages neroTaov1.Tracks = new List(); byte[] tmpbuffer = new byte[20]; - for(int i = 0; i < (neroTaov1.ChunkSize); i += 20) + for(int i = 0; i < neroTaov1.ChunkSize; i += 20) { NeroV1TaoEntry entry = new NeroV1TaoEntry(); imageStream.Read(tmpbuffer, 0, 20); @@ -1322,17 +1322,17 @@ namespace DiscImageChef.DiscImages entry.StartLba = BigEndianBitConverter.ToUInt32(tmpbuffer, 12); entry.Unknown = BigEndianBitConverter.ToUInt32(tmpbuffer, 16); - DicConsole.DebugWriteLine("Nero plugin", "Track-at-Once entry {0}", (i / 20) + 1); - DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Offset = {1}", (i / 20) + 1, + DicConsole.DebugWriteLine("Nero plugin", "Track-at-Once entry {0}", i / 20 + 1); + DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Offset = {1}", i / 20 + 1, entry.Offset); DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Length = {1} bytes", - (i / 20) + 1, entry.Length); + i / 20 + 1, entry.Length); DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Mode = {1} (0x{2:X4})", - (i / 20) + 1, (DaoMode)entry.Mode, entry.Mode); - DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].StartLBA = {1}", (i / 20) + 1, + i / 20 + 1, (DaoMode)entry.Mode, entry.Mode); + DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].StartLBA = {1}", i / 20 + 1, entry.StartLba); DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Unknown = 0x{1:X4}", - (i / 20) + 1, entry.Unknown); + i / 20 + 1, entry.Unknown); neroTaov1.Tracks.Add(entry); @@ -1372,7 +1372,7 @@ namespace DiscImageChef.DiscImages neroTaov2.Tracks = new List(); byte[] tmpbuffer = new byte[32]; - for(int i = 0; i < (neroTaov2.ChunkSize); i += 32) + for(int i = 0; i < neroTaov2.ChunkSize; i += 32) { NeroV2TaoEntry entry = new NeroV2TaoEntry(); imageStream.Read(tmpbuffer, 0, 32); @@ -1384,18 +1384,18 @@ namespace DiscImageChef.DiscImages entry.Unknown = BigEndianBitConverter.ToUInt32(tmpbuffer, 24); entry.Sectors = BigEndianBitConverter.ToUInt32(tmpbuffer, 28); - DicConsole.DebugWriteLine("Nero plugin", "Track-at-Once entry {0}", (i / 32) + 1); - DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Offset = {1}", (i / 32) + 1, + DicConsole.DebugWriteLine("Nero plugin", "Track-at-Once entry {0}", i / 32 + 1); + DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Offset = {1}", i / 32 + 1, entry.Offset); DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Length = {1} bytes", - (i / 32) + 1, entry.Length); + i / 32 + 1, entry.Length); DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Mode = {1} (0x{2:X4})", - (i / 32) + 1, (DaoMode)entry.Mode, entry.Mode); - DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].StartLBA = {1}", (i / 32) + 1, + i / 32 + 1, (DaoMode)entry.Mode, entry.Mode); + DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].StartLBA = {1}", i / 32 + 1, entry.StartLba); DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Unknown = 0x{1:X4}", - (i / 32) + 1, entry.Unknown); - DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Sectors = {1}", (i / 32) + 1, + i / 32 + 1, entry.Unknown); + DicConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Sectors = {1}", i / 32 + 1, entry.Sectors); neroTaov2.Tracks.Add(entry); @@ -1594,7 +1594,7 @@ namespace DiscImageChef.DiscImages _track.Indexes.Add(0, neroTrack.Index0 / neroTrack.SectorSize); _track.Indexes.Add(1, neroTrack.Index1 / neroTrack.SectorSize); _track.TrackDescription = StringHandlers.CToString(neroTrack.Isrc); - _track.TrackEndSector = (neroTrack.Length / neroTrack.SectorSize) + neroTrack.StartLba - 1; + _track.TrackEndSector = neroTrack.Length / neroTrack.SectorSize + neroTrack.StartLba - 1; _track.TrackPregap = (neroTrack.Index1 - neroTrack.Index0) / neroTrack.SectorSize; _track.TrackSequence = neroTrack.Sequence; _track.TrackSession = currentsession; @@ -1716,13 +1716,13 @@ namespace DiscImageChef.DiscImages partition = new Partition(); partition.Description = string.Format("Track {0} Index 1", _track.TrackSequence); - partition.Size = (neroTrack.EndOfTrack - neroTrack.Index1); + partition.Size = neroTrack.EndOfTrack - neroTrack.Index1; partition.Name = StringHandlers.CToString(neroTrack.Isrc); partition.Length = partition.Size / neroTrack.SectorSize; partition.Sequence = partitionSequence; partition.Offset = partitionStartByte; partition.Start = neroTrack.StartLba + - ((neroTrack.Index1 - neroTrack.Index0) / neroTrack.SectorSize); + (neroTrack.Index1 - neroTrack.Index0) / neroTrack.SectorSize; partition.Type = NeroTrackModeToTrackType((DaoMode)neroTrack.Mode).ToString(); imagePartitions.Add(partition); partitionSequence++; @@ -1747,12 +1747,10 @@ namespace DiscImageChef.DiscImages (DaoMode)neroTracks.ElementAt(i).Value.Mode == DaoMode.AudioSub); // First track is data - firstdata |= i == 0 && ((DaoMode)neroTracks.ElementAt(i).Value.Mode != DaoMode.Audio && - (DaoMode)neroTracks.ElementAt(i).Value.Mode != DaoMode.AudioSub); + firstdata |= i == 0 && (DaoMode)neroTracks.ElementAt(i).Value.Mode != DaoMode.Audio && (DaoMode)neroTracks.ElementAt(i).Value.Mode != DaoMode.AudioSub; // Any non first track is data - data |= i != 0 && ((DaoMode)neroTracks.ElementAt(i).Value.Mode != DaoMode.Audio && - (DaoMode)neroTracks.ElementAt(i).Value.Mode != DaoMode.AudioSub); + data |= i != 0 && (DaoMode)neroTracks.ElementAt(i).Value.Mode != DaoMode.Audio && (DaoMode)neroTracks.ElementAt(i).Value.Mode != DaoMode.AudioSub; // Any non first track is audio audio |= i != 0 && ((DaoMode)neroTracks.ElementAt(i).Value.Mode == DaoMode.Audio || @@ -1772,7 +1770,7 @@ namespace DiscImageChef.DiscImages if(!data && !firstdata) ImageInfo.MediaType = MediaType.CDDA; else if(firstaudio && data && imageSessions.Count > 1 && mode2) ImageInfo.MediaType = MediaType.CDPLUS; - else if((firstdata && audio) || mode2) ImageInfo.MediaType = MediaType.CDROMXA; + else if(firstdata && audio || mode2) ImageInfo.MediaType = MediaType.CDROMXA; else if(!audio) ImageInfo.MediaType = MediaType.CDROM; else ImageInfo.MediaType = MediaType.CD; } @@ -1851,8 +1849,8 @@ namespace DiscImageChef.DiscImages { if(_track.TrackSequence == kvp.Key) { - if((sectorAddress - kvp.Value) < (_track.TrackEndSector - _track.TrackStartSector)) - return ReadSectors((sectorAddress - kvp.Value), length, kvp.Key); + if(sectorAddress - kvp.Value < _track.TrackEndSector - _track.TrackStartSector) + return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key); } } } @@ -1872,8 +1870,8 @@ namespace DiscImageChef.DiscImages { if(_track.TrackSequence == kvp.Key) { - if((sectorAddress - kvp.Value) < (_track.TrackEndSector - _track.TrackStartSector)) - return ReadSectorsTag((sectorAddress - kvp.Value), length, kvp.Key, tag); + if(sectorAddress - kvp.Value < _track.TrackEndSector - _track.TrackStartSector) + return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag); } } } @@ -2237,8 +2235,8 @@ namespace DiscImageChef.DiscImages { if(_track.TrackSequence == kvp.Key) { - if((sectorAddress - kvp.Value) < (_track.TrackEndSector - _track.TrackStartSector)) - return ReadSectorsLong((sectorAddress - kvp.Value), length, kvp.Key); + if(sectorAddress - kvp.Value < _track.TrackEndSector - _track.TrackStartSector) + return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key); } } } diff --git a/DiscImageChef.DiscImages/Parallels.cs b/DiscImageChef.DiscImages/Parallels.cs index cd48602e..3ddbe48d 100644 --- a/DiscImageChef.DiscImages/Parallels.cs +++ b/DiscImageChef.DiscImages/Parallels.cs @@ -208,7 +208,7 @@ namespace DiscImageChef.DiscImages clusterBytes = pHdr.cluster_size * 512; if(pHdr.data_off > 0) dataOffset = pHdr.data_off * 512; - else dataOffset = ((stream.Position / clusterBytes) + (stream.Position % clusterBytes)) * clusterBytes; + else dataOffset = (stream.Position / clusterBytes + stream.Position % clusterBytes) * clusterBytes; sectorCache = new Dictionary(); @@ -224,7 +224,7 @@ namespace DiscImageChef.DiscImages ImageInfo.ImageSize = pHdr.sectors * 512; ImageInfo.Cylinders = pHdr.cylinders; ImageInfo.Heads = pHdr.heads; - ImageInfo.SectorsPerTrack = (uint)((ImageInfo.Sectors / ImageInfo.Cylinders) / ImageInfo.Heads); + ImageInfo.SectorsPerTrack = (uint)(ImageInfo.Sectors / ImageInfo.Cylinders / ImageInfo.Heads); imageStream = stream; return true; diff --git a/DiscImageChef.DiscImages/QCOW.cs b/DiscImageChef.DiscImages/QCOW.cs index f4403f62..e2bbdcc5 100644 --- a/DiscImageChef.DiscImages/QCOW.cs +++ b/DiscImageChef.DiscImages/QCOW.cs @@ -289,7 +289,7 @@ namespace DiscImageChef.DiscImages ImageInfo.MediaType = MediaType.GENERIC_HDD; ImageInfo.ImageSize = qHdr.size; - ImageInfo.Cylinders = (uint)((ImageInfo.Sectors / 16) / 63); + ImageInfo.Cylinders = (uint)(ImageInfo.Sectors / 16 / 63); ImageInfo.Heads = 16; ImageInfo.SectorsPerTrack = 63; @@ -355,7 +355,7 @@ namespace DiscImageChef.DiscImages compSizeMask = (ulong)(1 << qHdr.cluster_bits) - 1; compSizeMask <<= 63 - qHdr.cluster_bits; - offMask = (~compSizeMask) ^ QCOW_COMPRESSED; + offMask = ~compSizeMask ^ QCOW_COMPRESSED; ulong realOff = offset & offMask; ulong compSize = (offset & compSizeMask) >> (63 - qHdr.cluster_bits); diff --git a/DiscImageChef.DiscImages/QCOW2.cs b/DiscImageChef.DiscImages/QCOW2.cs index 96b737c1..146e5742 100644 --- a/DiscImageChef.DiscImages/QCOW2.cs +++ b/DiscImageChef.DiscImages/QCOW2.cs @@ -336,7 +336,7 @@ namespace DiscImageChef.DiscImages ImageInfo.ImageSize = qHdr.size; ImageInfo.ImageVersion = string.Format("{0}", qHdr.version); - ImageInfo.Cylinders = (uint)((ImageInfo.Sectors / 16) / 63); + ImageInfo.Cylinders = (uint)(ImageInfo.Sectors / 16 / 63); ImageInfo.Heads = 16; ImageInfo.SectorsPerTrack = 63; @@ -402,8 +402,8 @@ namespace DiscImageChef.DiscImages compSizeMask = (ulong)(1 << (int)(qHdr.cluster_bits - 8)) - 1; byte countbits = (byte)(qHdr.cluster_bits - 8); - compSizeMask <<= (62 - countbits); - offMask = (~compSizeMask) & QCOW_FLAGS_MASK; + compSizeMask <<= 62 - countbits; + offMask = ~compSizeMask & QCOW_FLAGS_MASK; ulong realOff = offset & offMask; ulong compSize = (((offset & compSizeMask) >> (62 - countbits)) + 1) * 512; diff --git a/DiscImageChef.DiscImages/QED.cs b/DiscImageChef.DiscImages/QED.cs index 260bf354..51ca4a7a 100644 --- a/DiscImageChef.DiscImages/QED.cs +++ b/DiscImageChef.DiscImages/QED.cs @@ -242,7 +242,7 @@ namespace DiscImageChef.DiscImages throw new NotImplementedException("Differencing images not yet supported"); clusterSectors = qHdr.cluster_size / 512; - tableSize = (qHdr.cluster_size * qHdr.table_size) / 8; + tableSize = qHdr.cluster_size * qHdr.table_size / 8; DicConsole.DebugWriteLine("QED plugin", "qHdr.clusterSectors = {0}", clusterSectors); DicConsole.DebugWriteLine("QED plugin", "qHdr.tableSize = {0}", tableSize); @@ -280,7 +280,7 @@ namespace DiscImageChef.DiscImages DicConsole.DebugWriteLine("QED plugin", "qHdr.l2Mask = {0:X}", l2Mask); DicConsole.DebugWriteLine("QED plugin", "qHdr.sectorMask = {0:X}", sectorMask); - maxL2TableCache = MAX_CACHE_SIZE / (tableSize); + maxL2TableCache = MAX_CACHE_SIZE / tableSize; maxClusterCache = MAX_CACHE_SIZE / qHdr.cluster_size; imageStream = stream; @@ -298,7 +298,7 @@ namespace DiscImageChef.DiscImages ImageInfo.MediaType = MediaType.GENERIC_HDD; ImageInfo.ImageSize = qHdr.image_size; - ImageInfo.Cylinders = (uint)((ImageInfo.Sectors / 16) / 63); + ImageInfo.Cylinders = (uint)(ImageInfo.Sectors / 16 / 63); ImageInfo.Heads = 16; ImageInfo.SectorsPerTrack = 63; @@ -468,9 +468,9 @@ namespace DiscImageChef.DiscImages bool IsPowerOfTwo(uint x) { - while(((x & 1) == 0) && x > 1) x >>= 1; + while((x & 1) == 0 && x > 1) x >>= 1; - return (x == 1); + return x == 1; } static int Ctz32(uint val) diff --git a/DiscImageChef.DiscImages/RsIde.cs b/DiscImageChef.DiscImages/RsIde.cs index 2232ef10..b8d743e1 100644 --- a/DiscImageChef.DiscImages/RsIde.cs +++ b/DiscImageChef.DiscImages/RsIde.cs @@ -154,7 +154,7 @@ namespace DiscImageChef.DiscImages if(ImageInfo.Cylinders == 0 || ImageInfo.Heads == 0 || ImageInfo.SectorsPerTrack == 0) { - ImageInfo.Cylinders = (uint)((ImageInfo.Sectors / 16) / 63); + ImageInfo.Cylinders = (uint)(ImageInfo.Sectors / 16 / 63); ImageInfo.Heads = 16; ImageInfo.SectorsPerTrack = 63; } diff --git a/DiscImageChef.DiscImages/SaveDskF.cs b/DiscImageChef.DiscImages/SaveDskF.cs index fe4a1fbe..ce66ef40 100644 --- a/DiscImageChef.DiscImages/SaveDskF.cs +++ b/DiscImageChef.DiscImages/SaveDskF.cs @@ -207,7 +207,7 @@ namespace DiscImageChef.DiscImages while(b >= 0); // In case there is omitted data - sectors = (header.sectorsPerTrack) * header.heads * header.cylinders; + sectors = header.sectorsPerTrack * header.heads * header.cylinders; DicConsole.DebugWriteLine("SaveDskF plugin", "Calculated checksum = 0x{0:X8}, {1}", calculatedChk, calculatedChk == header.checksum); diff --git a/DiscImageChef.DiscImages/T98.cs b/DiscImageChef.DiscImages/T98.cs index 2b4e1dc3..8002d6bf 100644 --- a/DiscImageChef.DiscImages/T98.cs +++ b/DiscImageChef.DiscImages/T98.cs @@ -90,7 +90,7 @@ namespace DiscImageChef.DiscImages // This format is expanding, so length can be smaller // Just grow it, I won't risk false positives... - return stream.Length == (cylinders * 8 * 33 * 256) + 256; + return stream.Length == cylinders * 8 * 33 * 256 + 256; } public override bool OpenImage(Filter imageFilter) @@ -113,7 +113,7 @@ namespace DiscImageChef.DiscImages ImageInfo.ImageCreationTime = imageFilter.GetCreationTime(); ImageInfo.ImageLastModificationTime = imageFilter.GetLastWriteTime(); ImageInfo.ImageName = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - ImageInfo.Sectors = (ulong)((stream.Length / 256) - 1); + ImageInfo.Sectors = (ulong)(stream.Length / 256 - 1); ImageInfo.XmlMediaType = XmlMediaType.BlockMedia; ImageInfo.SectorSize = 256; ImageInfo.Cylinders = (uint)cylinders; diff --git a/DiscImageChef.DiscImages/TeleDisk.cs b/DiscImageChef.DiscImages/TeleDisk.cs index b18354be..fbba4e6c 100644 --- a/DiscImageChef.DiscImages/TeleDisk.cs +++ b/DiscImageChef.DiscImages/TeleDisk.cs @@ -642,8 +642,8 @@ namespace DiscImageChef.DiscImages DicConsole.DebugWriteLine("TeleDisk plugin", "\t\tSector CRC (plus headers): 0x{0:X2}", teleDiskSector.Crc); - uint lba = (uint)((teleDiskSector.Cylinder * header.Sides * ImageInfo.SectorsPerTrack) + - (teleDiskSector.Head * ImageInfo.SectorsPerTrack) + (teleDiskSector.SectorNumber - 1)); + uint lba = (uint)(teleDiskSector.Cylinder * header.Sides * ImageInfo.SectorsPerTrack + + teleDiskSector.Head * ImageInfo.SectorsPerTrack + (teleDiskSector.SectorNumber - 1)); if((teleDiskSector.Flags & FLAGS_SECTOR_DATALESS) != FLAGS_SECTOR_DATALESS && (teleDiskSector.Flags & FLAGS_SECTOR_SKIPPED) != FLAGS_SECTOR_SKIPPED) { @@ -807,8 +807,8 @@ namespace DiscImageChef.DiscImages (ushort cylinder, byte head, byte sector) LbaToChs(ulong lba) { ushort cylinder = (ushort)(lba / (ImageInfo.Heads * ImageInfo.SectorsPerTrack)); - byte head = (byte)((lba / ImageInfo.SectorsPerTrack) % ImageInfo.Heads); - byte sector = (byte)((lba % ImageInfo.SectorsPerTrack) + 1); + byte head = (byte)(lba / ImageInfo.SectorsPerTrack % ImageInfo.Heads); + byte sector = (byte)(lba % ImageInfo.SectorsPerTrack + 1); return (cylinder, head, sector); } @@ -1001,7 +1001,7 @@ namespace DiscImageChef.DiscImages { length = encodedData[ins + 1]; Array.Copy(encodedData, ins + 2, decodedData, outs, length); - ins += (2 + length); + ins += 2 + length; outs += length; } else @@ -1013,7 +1013,7 @@ namespace DiscImageChef.DiscImages piece = new byte[length * run]; ArrayHelpers.ArrayFill(piece, part); Array.Copy(piece, 0, decodedData, outs, piece.Length); - ins += (2 + length); + ins += 2 + length; outs += piece.Length; } } @@ -1347,10 +1347,10 @@ namespace DiscImageChef.DiscImages /* Huffman coding parameters */ - const int N_CHAR = (256 - THRESHOLD + F); + const int N_CHAR = 256 - THRESHOLD + F; /* character code (= 0..N_CHAR-1) */ - const int T = (N_CHAR * 2 - 1); /* Size of table */ - const int R = (T - 1); /* root position */ + const int T = N_CHAR * 2 - 1; /* Size of table */ + const int R = T - 1; /* root position */ const int MAX_FREQ = 0x8000; /* update when cumulative frequency */ /* reaches to this value */ @@ -1442,7 +1442,7 @@ namespace DiscImageChef.DiscImages { tdctl.Ibufndx = 0; tdctl.Ibufcnt = (ushort)data_read(out tdctl.Inbuf, BUFSZ); - if(tdctl.Ibufcnt <= 0) return (-1); + if(tdctl.Ibufcnt <= 0) return -1; } while(getlen <= 8) @@ -1452,31 +1452,31 @@ namespace DiscImageChef.DiscImages getlen += 8; } - return (0); + return 0; } int GetBit() /* get one bit */ { short i; - if(next_word() < 0) return (-1); + if(next_word() < 0) return -1; i = (short)getbuf; getbuf <<= 1; getlen--; - if(i < 0) return (1); - else return (0); + if(i < 0) return 1; + else return 0; } int GetByte() /* get a byte */ { ushort i; - if(next_word() != 0) return (-1); + if(next_word() != 0) return -1; i = getbuf; getbuf <<= 8; getlen -= 8; i = (ushort)(i >> 8); - return ((int)i); + return (int)i; } /* initialize freq tree */ @@ -1602,7 +1602,7 @@ namespace DiscImageChef.DiscImages */ while(c < T) { - if((ret = GetBit()) < 0) return (-1); + if((ret = GetBit()) < 0) return -1; c += (ushort)ret; c = (ushort)son[c]; @@ -1619,7 +1619,7 @@ namespace DiscImageChef.DiscImages ushort i, j, c; /* decode upper 6 bits from given table */ - if((bit = (short)GetByte()) < 0) return (-1); + if((bit = (short)GetByte()) < 0) return -1; i = (ushort)bit; c = (ushort)(d_code[i] << 6); @@ -1629,7 +1629,7 @@ namespace DiscImageChef.DiscImages j -= 2; while(j-- > 0) { - if((bit = (short)GetBit()) < 0) return (-1); + if((bit = (short)GetBit()) < 0) return -1; i = (ushort)((i << 1) + bit); } @@ -1666,18 +1666,18 @@ namespace DiscImageChef.DiscImages { if(tdctl.Bufcnt == 0) { - if((c = DecodeChar()) < 0) return (count); // fatal error + if((c = DecodeChar()) < 0) return count; // fatal error if(c < 256) { buf[count] = (byte)c; text_buf[tdctl.R++] = (byte)c; - tdctl.R &= (N - 1); + tdctl.R &= N - 1; count++; } else { - if((pos = DecodePosition()) < 0) return (count); // fatal error + if((pos = DecodePosition()) < 0) return count; // fatal error tdctl.Bufpos = (ushort)((tdctl.R - pos - 1) & (N - 1)); tdctl.Bufcnt = (ushort)(c - 255 + THRESHOLD); @@ -1693,7 +1693,7 @@ namespace DiscImageChef.DiscImages buf[count] = (byte)c; tdctl.Bufndx++; text_buf[tdctl.R++] = (byte)c; - tdctl.R &= (N - 1); + tdctl.R &= N - 1; count++; } // reset bufcnt after copy string from text_buf[] @@ -1701,7 +1701,7 @@ namespace DiscImageChef.DiscImages } } - return (count); // count == len, success + return count; // count == len, success } #endregion LZH decompression from MAME } diff --git a/DiscImageChef.DiscImages/UDIF.cs b/DiscImageChef.DiscImages/UDIF.cs index f20d5482..3f490e3e 100644 --- a/DiscImageChef.DiscImages/UDIF.cs +++ b/DiscImageChef.DiscImages/UDIF.cs @@ -465,18 +465,18 @@ namespace DiscImageChef.DiscImages if(bChnk.type == CHUNK_TYPE_COMMNT) continue; // TODO: Handle compressed chunks - if((bChnk.type == CHUNK_TYPE_KENCODE)) + if(bChnk.type == CHUNK_TYPE_KENCODE) throw new ImageNotSupportedException("Chunks compressed with KenCode are not yet supported."); - if((bChnk.type == CHUNK_TYPE_RLE)) + if(bChnk.type == CHUNK_TYPE_RLE) throw new ImageNotSupportedException("Chunks compressed with RLE are not yet supported."); - if((bChnk.type == CHUNK_TYPE_LZH)) + if(bChnk.type == CHUNK_TYPE_LZH) throw new ImageNotSupportedException("Chunks compressed with LZH are not yet supported."); - if((bChnk.type == CHUNK_TYPE_LZFSE)) + if(bChnk.type == CHUNK_TYPE_LZFSE) throw new ImageNotSupportedException("Chunks compressed with lzfse are not yet supported."); - if((bChnk.type > CHUNK_TYPE_NOCOPY && bChnk.type < CHUNK_TYPE_COMMNT) || - (bChnk.type > CHUNK_TYPE_LZFSE && bChnk.type < CHUNK_TYPE_END)) + if(bChnk.type > CHUNK_TYPE_NOCOPY && bChnk.type < CHUNK_TYPE_COMMNT || + bChnk.type > CHUNK_TYPE_LZFSE && bChnk.type < CHUNK_TYPE_END) throw new ImageNotSupportedException(string.Format("Unsupported chunk type 0x{0:X8} found", bChnk.type)); @@ -499,7 +499,7 @@ namespace DiscImageChef.DiscImages ImageInfo.ImageSize = ImageInfo.Sectors * SECTOR_SIZE; ImageInfo.ImageVersion = string.Format("{0}", footer.version); - ImageInfo.Cylinders = (uint)((ImageInfo.Sectors / 16) / 63); + ImageInfo.Cylinders = (uint)(ImageInfo.Sectors / 16 / 63); ImageInfo.Heads = 16; ImageInfo.SectorsPerTrack = 63; diff --git a/DiscImageChef.DiscImages/UkvFdi.cs b/DiscImageChef.DiscImages/UkvFdi.cs index 6d4e56de..23d6c9d5 100644 --- a/DiscImageChef.DiscImages/UkvFdi.cs +++ b/DiscImageChef.DiscImages/UkvFdi.cs @@ -375,8 +375,8 @@ namespace DiscImageChef.DiscImages (ushort cylinder, byte head, byte sector) LbaToChs(ulong lba) { ushort cylinder = (ushort)(lba / (ImageInfo.Heads * ImageInfo.SectorsPerTrack)); - byte head = (byte)((lba / ImageInfo.SectorsPerTrack) % ImageInfo.Heads); - byte sector = (byte)((lba % ImageInfo.SectorsPerTrack) + 1); + byte head = (byte)(lba / ImageInfo.SectorsPerTrack % ImageInfo.Heads); + byte sector = (byte)(lba % ImageInfo.SectorsPerTrack + 1); return (cylinder, head, sector); } diff --git a/DiscImageChef.DiscImages/VDI.cs b/DiscImageChef.DiscImages/VDI.cs index e073dd8b..6231f2e1 100644 --- a/DiscImageChef.DiscImages/VDI.cs +++ b/DiscImageChef.DiscImages/VDI.cs @@ -248,15 +248,15 @@ namespace DiscImageChef.DiscImages if(sectorCache.TryGetValue(sectorAddress, out sector)) return sector; - ulong index = (sectorAddress * vHdr.sectorSize) / vHdr.blockSize; - ulong secOff = (sectorAddress * vHdr.sectorSize) % vHdr.blockSize; + ulong index = sectorAddress * vHdr.sectorSize / vHdr.blockSize; + ulong secOff = sectorAddress * vHdr.sectorSize % vHdr.blockSize; uint ibmOff = ibm[index]; ulong imageOff; if(ibmOff == VDI_EMPTY) return new byte[vHdr.sectorSize]; - imageOff = vHdr.offsetData + (ibmOff * vHdr.blockSize); + imageOff = vHdr.offsetData + ibmOff * vHdr.blockSize; byte[] cluster = new byte[vHdr.blockSize]; imageStream.Seek((long)imageOff, SeekOrigin.Begin); diff --git a/DiscImageChef.DiscImages/VHD.cs b/DiscImageChef.DiscImages/VHD.cs index b0febca7..a767f5dc 100644 --- a/DiscImageChef.DiscImages/VHD.cs +++ b/DiscImageChef.DiscImages/VHD.cs @@ -394,7 +394,7 @@ namespace DiscImageChef.DiscImages byte[] headerCookieBytes = new byte[8]; byte[] footerCookieBytes = new byte[8]; - if((imageStream.Length % 2) == 0) imageStream.Seek(-512, SeekOrigin.End); + if(imageStream.Length % 2 == 0) imageStream.Seek(-512, SeekOrigin.End); else imageStream.Seek(-511, SeekOrigin.End); imageStream.Read(footerCookieBytes, 0, 8); @@ -405,7 +405,7 @@ namespace DiscImageChef.DiscImages headerCookie = BigEndianBitConverter.ToUInt64(headerCookieBytes, 0); footerCookie = BigEndianBitConverter.ToUInt64(footerCookieBytes, 0); - return (headerCookie == IMAGE_COOKIE || footerCookie == IMAGE_COOKIE); + return headerCookie == IMAGE_COOKIE || footerCookie == IMAGE_COOKIE; } public override bool OpenImage(Filter imageFilter) @@ -417,7 +417,7 @@ namespace DiscImageChef.DiscImages imageStream.Seek(0, SeekOrigin.Begin); imageStream.Read(header, 0, 512); - if((imageStream.Length % 2) == 0) + if(imageStream.Length % 2 == 0) { footer = new byte[512]; imageStream.Seek(-512, SeekOrigin.End); @@ -488,7 +488,7 @@ namespace DiscImageChef.DiscImages thisFooter.UniqueId = BigEndianBitConverter.ToGuid(usableHeader, 0x44); thisFooter.SavedState = usableHeader[0x54]; thisFooter.Reserved = new byte[usableHeader.Length - 0x55]; - Array.Copy(usableHeader, 0x55, thisFooter.Reserved, 0, (usableHeader.Length - 0x55)); + Array.Copy(usableHeader, 0x55, thisFooter.Reserved, 0, usableHeader.Length - 0x55); thisDateTime = new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc); thisDateTime = thisDateTime.AddSeconds(thisFooter.Timestamp); @@ -517,7 +517,7 @@ namespace DiscImageChef.DiscImages DicConsole.DebugWriteLine("VirtualPC plugin", "footer.currentSize = {0}", thisFooter.CurrentSize); DicConsole.DebugWriteLine("VirtualPC plugin", "footer.diskGeometry = 0x{0:X8} (C/H/S: {1}/{2}/{3})", thisFooter.DiskGeometry, (thisFooter.DiskGeometry & 0xFFFF0000) >> 16, - (thisFooter.DiskGeometry & 0xFF00) >> 8, (thisFooter.DiskGeometry & 0xFF)); + (thisFooter.DiskGeometry & 0xFF00) >> 8, thisFooter.DiskGeometry & 0xFF); DicConsole.DebugWriteLine("VirtualPC plugin", "footer.diskType = 0x{0:X8}", thisFooter.DiskType); DicConsole.DebugWriteLine("VirtualPC plugin", "footer.checksum = 0x{0:X8}", thisFooter.Checksum); DicConsole.DebugWriteLine("VirtualPC plugin", "footer.uniqueId = {0}", thisFooter.UniqueId); @@ -544,7 +544,7 @@ namespace DiscImageChef.DiscImages { ImageInfo.ImageApplicationVersion = string.Format("{0}.{1:D2}", (thisFooter.CreatorVersion & 0xFFFF0000) >> 16, - (thisFooter.CreatorVersion & 0x0000FFFF)); + thisFooter.CreatorVersion & 0x0000FFFF); switch(thisFooter.CreatorHostOs) { case CREATOR_MACINTOSH: @@ -657,7 +657,7 @@ namespace DiscImageChef.DiscImages ImageInfo.Cylinders = (thisFooter.DiskGeometry & 0xFFFF0000) >> 16; ImageInfo.Heads = (thisFooter.DiskGeometry & 0xFF00) >> 8; - ImageInfo.SectorsPerTrack = (thisFooter.DiskGeometry & 0xFF); + ImageInfo.SectorsPerTrack = thisFooter.DiskGeometry & 0xFF; if(thisFooter.DiskType == TYPE_DYNAMIC || thisFooter.DiskType == TYPE_DIFFERENCING) { @@ -782,7 +782,7 @@ namespace DiscImageChef.DiscImages */ // How many sectors uses the BAT - uint batSectorCount = (uint)Math.Ceiling(((double)thisDynamic.MaxTableEntries * 4) / 512); + uint batSectorCount = (uint)Math.Ceiling((double)thisDynamic.MaxTableEntries * 4 / 512); byte[] batSectorBytes = new byte[512]; BatSector batSector = new BatSector(); @@ -799,11 +799,11 @@ namespace DiscImageChef.DiscImages handle.Free(); // This restores the order of elements Array.Reverse(batSector.blockPointer); - if(blockAllocationTable.Length >= (i * 512) / 4 + 512 / 4) - Array.Copy(batSector.blockPointer, 0, blockAllocationTable, (i * 512) / 4, 512 / 4); + if(blockAllocationTable.Length >= i * 512 / 4 + 512 / 4) + Array.Copy(batSector.blockPointer, 0, blockAllocationTable, i * 512 / 4, 512 / 4); else - Array.Copy(batSector.blockPointer, 0, blockAllocationTable, (i * 512) / 4, - blockAllocationTable.Length - (i * 512) / 4); + Array.Copy(batSector.blockPointer, 0, blockAllocationTable, i * 512 / 4, + blockAllocationTable.Length - i * 512 / 4); } DateTime endTime = DateTime.UtcNow; @@ -817,13 +817,11 @@ namespace DiscImageChef.DiscImages */ // Get the roundest number of sectors needed to store the block bitmap - bitmapSize = (uint)Math.Ceiling(( - // How many sectors do a block store - ((double)thisDynamic.BlockSize / 512) - // 1 bit per sector on the bitmap - / 8 - // and aligned to 512 byte boundary - / 512)); + bitmapSize = (uint)Math.Ceiling((double)thisDynamic.BlockSize / 512 + // 1 bit per sector on the bitmap + / 8 + // and aligned to 512 byte boundary + / 512); DicConsole.DebugWriteLine("VirtualPC plugin", "Bitmap is {0} sectors", bitmapSize); } @@ -1095,7 +1093,7 @@ namespace DiscImageChef.DiscImages uint sectorOffset = blockAllocationTable[blockNumber] + bitmapSize + sectorInBlock; thisStream = thisFilter.GetDataForkStream(); - thisStream.Seek((sectorOffset * 512), SeekOrigin.Begin); + thisStream.Seek(sectorOffset * 512, SeekOrigin.Begin); thisStream.Read(data, 0, 512); return data; @@ -1141,7 +1139,7 @@ namespace DiscImageChef.DiscImages // Sector number inside of block uint sectorInBlock = (uint)(sectorAddress % (thisDynamic.BlockSize / 512)); // How many sectors before reaching end of block - uint remainingInBlock = (thisDynamic.BlockSize / 512) - sectorInBlock; + uint remainingInBlock = thisDynamic.BlockSize / 512 - sectorInBlock; // Data that can be read in this block byte[] prefix; @@ -1167,7 +1165,7 @@ namespace DiscImageChef.DiscImages if(sectorOffset != 0xFFFFFFFF) { thisStream = thisFilter.GetDataForkStream(); - thisStream.Seek((sectorOffset * 512), SeekOrigin.Begin); + thisStream.Seek(sectorOffset * 512, SeekOrigin.Begin); thisStream.Read(prefix, 0, (int)(512 * sectorsToReadHere)); } // If it is unallocated, just fill with zeroes diff --git a/DiscImageChef.DiscImages/VHDX.cs b/DiscImageChef.DiscImages/VHDX.cs index 2a810037..a9bd7176 100644 --- a/DiscImageChef.DiscImages/VHDX.cs +++ b/DiscImageChef.DiscImages/VHDX.cs @@ -649,20 +649,20 @@ namespace DiscImageChef.DiscImages hasParent = true; } - chunkRatio = (long)((Math.Pow(2, 23) * logicalSectorSize) / vFileParms.blockSize); + chunkRatio = (long)(Math.Pow(2, 23) * logicalSectorSize / vFileParms.blockSize); dataBlocks = virtualDiskSize / vFileParms.blockSize; - if((virtualDiskSize % vFileParms.blockSize) > 0) dataBlocks++; + if(virtualDiskSize % vFileParms.blockSize > 0) dataBlocks++; long batEntries; if(hasParent) { long sectorBitmapBlocks = (long)dataBlocks / chunkRatio; - if((dataBlocks % (ulong)chunkRatio) > 0) sectorBitmapBlocks++; + if(dataBlocks % (ulong)chunkRatio > 0) sectorBitmapBlocks++; sectorBitmapPointers = new ulong[sectorBitmapBlocks]; batEntries = sectorBitmapBlocks * (chunkRatio - 1); } - else batEntries = (long)(dataBlocks + ((dataBlocks - 1) / (ulong)chunkRatio)); + else batEntries = (long)(dataBlocks + (dataBlocks - 1) / (ulong)chunkRatio); DicConsole.DebugWriteLine("VHDX plugin", "Reading BAT"); @@ -739,7 +739,7 @@ namespace DiscImageChef.DiscImages // TODO: Separate image application from version, need several samples. - ImageInfo.Cylinders = (uint)((ImageInfo.Sectors / 16) / 63); + ImageInfo.Cylinders = (uint)(ImageInfo.Sectors / 16 / 63); ImageInfo.Heads = 16; ImageInfo.SectorsPerTrack = 63; @@ -754,7 +754,7 @@ namespace DiscImageChef.DiscImages if(index > sectorBitmap.LongLength) return false; - return ((sectorBitmap[index] & val) == val); + return (sectorBitmap[index] & val) == val; } public override bool ImageHasPartitions() @@ -832,8 +832,8 @@ namespace DiscImageChef.DiscImages if(sectorCache.TryGetValue(sectorAddress, out sector)) return sector; - ulong index = (sectorAddress * logicalSectorSize) / vFileParms.blockSize; - ulong secOff = (sectorAddress * logicalSectorSize) % vFileParms.blockSize; + ulong index = sectorAddress * logicalSectorSize / vFileParms.blockSize; + ulong secOff = sectorAddress * logicalSectorSize % vFileParms.blockSize; ulong blkPtr = blockAllocationTable[index]; ulong blkFlags = blkPtr & BAT_FLAGS_MASK; @@ -859,7 +859,7 @@ namespace DiscImageChef.DiscImages if(!blockCache.TryGetValue(blkPtr & BAT_FILE_OFFSET_MASK, out block)) { block = new byte[vFileParms.blockSize]; - imageStream.Seek((long)((blkPtr & BAT_FILE_OFFSET_MASK)), SeekOrigin.Begin); + imageStream.Seek((long)(blkPtr & BAT_FILE_OFFSET_MASK), SeekOrigin.Begin); imageStream.Read(block, 0, block.Length); if(blockCache.Count >= maxBlockCache) blockCache.Clear(); diff --git a/DiscImageChef.DiscImages/VMware.cs b/DiscImageChef.DiscImages/VMware.cs index 37bfb559..f57ffa21 100644 --- a/DiscImageChef.DiscImages/VMware.cs +++ b/DiscImageChef.DiscImages/VMware.cs @@ -703,7 +703,7 @@ namespace DiscImageChef.DiscImages } else if(!matchedCyls || !matchedHds || !matchedSpt) { - ImageInfo.Cylinders = (uint)((ImageInfo.Sectors / 16) / 63); + ImageInfo.Cylinders = (uint)(ImageInfo.Sectors / 16 / 63); ImageInfo.Heads = 16; ImageInfo.SectorsPerTrack = 63; } @@ -766,7 +766,7 @@ namespace DiscImageChef.DiscImages } ulong index = sectorAddress / grainSize; - ulong secOff = (sectorAddress % grainSize) * SECTOR_SIZE; + ulong secOff = sectorAddress % grainSize * SECTOR_SIZE; uint grainOff = gTable[index]; @@ -788,7 +788,7 @@ namespace DiscImageChef.DiscImages { grain = new byte[SECTOR_SIZE * grainSize]; dataStream = currentExtent.Filter.GetDataForkStream(); - dataStream.Seek((long)(((grainOff - extentStartSector) * SECTOR_SIZE)), SeekOrigin.Begin); + dataStream.Seek((long)((grainOff - extentStartSector) * SECTOR_SIZE), SeekOrigin.Begin); dataStream.Read(grain, 0, grain.Length); if(grainCache.Count >= maxCachedGrains) grainCache.Clear(); diff --git a/DiscImageChef.DiscImages/ZZZRawImage.cs b/DiscImageChef.DiscImages/ZZZRawImage.cs index e549d3c7..7fe3951d 100644 --- a/DiscImageChef.DiscImages/ZZZRawImage.cs +++ b/DiscImageChef.DiscImages/ZZZRawImage.cs @@ -78,7 +78,7 @@ namespace DiscImageChef.DiscImages public override bool IdentifyImage(Filter imageFilter) { // Check if file is not multiple of 512 - if((imageFilter.GetDataForkLength() % 512) != 0) + if(imageFilter.GetDataForkLength() % 512 != 0) { extension = Path.GetExtension(imageFilter.GetFilename()).ToLower(); @@ -123,7 +123,7 @@ namespace DiscImageChef.DiscImages stream.Seek(0, SeekOrigin.Begin); extension = Path.GetExtension(imageFilter.GetFilename()).ToLower(); - if(extension == ".iso" && (imageFilter.GetDataForkLength() % 2048) == 0) ImageInfo.SectorSize = 2048; + if(extension == ".iso" && imageFilter.GetDataForkLength() % 2048 == 0) ImageInfo.SectorSize = 2048; else if(extension == ".d81" && imageFilter.GetDataForkLength() == 819200) ImageInfo.SectorSize = 256; else if((extension == ".adf" || extension == ".adl" || extension == ".ssd" || extension == ".dsd") && (imageFilter.GetDataForkLength() == 163840 || imageFilter.GetDataForkLength() == 327680 || @@ -639,7 +639,7 @@ namespace DiscImageChef.DiscImages ImageInfo.SectorsPerTrack = 32; break; default: - ImageInfo.Cylinders = (uint)((ImageInfo.Sectors / 16) / 63); + ImageInfo.Cylinders = (uint)(ImageInfo.Sectors / 16 / 63); ImageInfo.Heads = 16; ImageInfo.SectorsPerTrack = 63; break; diff --git a/DiscImageChef.Filesystems/Acorn.cs b/DiscImageChef.Filesystems/Acorn.cs index 06e8bd74..e49e8fb0 100644 --- a/DiscImageChef.Filesystems/Acorn.cs +++ b/DiscImageChef.Filesystems/Acorn.cs @@ -334,8 +334,8 @@ namespace DiscImageChef.Filesystems oldRoot.tail.checkByte); DicConsole.DebugWriteLine("ADFS Plugin", "dirChk at 0x200 = {0}", dirChk); - if((oldRoot.header.magic == oldDirMagic && oldRoot.tail.magic == oldDirMagic) || - (oldRoot.header.magic == newDirMagic && oldRoot.tail.magic == newDirMagic)) return true; + if(oldRoot.header.magic == oldDirMagic && oldRoot.tail.magic == oldDirMagic || + oldRoot.header.magic == newDirMagic && oldRoot.tail.magic == newDirMagic) return true; // RISC OS says the old directory can't be in the new location, hard disks created by RISC OS 3.10 do that... sbSector = newDirectoryLocation / imagePlugin.ImageInfo.SectorSize; @@ -361,8 +361,8 @@ namespace DiscImageChef.Filesystems oldRoot.tail.checkByte); DicConsole.DebugWriteLine("ADFS Plugin", "dirChk at 0x400 = {0}", dirChk); - if((oldRoot.header.magic == oldDirMagic && oldRoot.tail.magic == oldDirMagic) || - (oldRoot.header.magic == newDirMagic && oldRoot.tail.magic == newDirMagic)) return true; + if(oldRoot.header.magic == oldDirMagic && oldRoot.tail.magic == oldDirMagic || + oldRoot.header.magic == newDirMagic && oldRoot.tail.magic == newDirMagic) return true; } } @@ -382,7 +382,7 @@ namespace DiscImageChef.Filesystems byte[] bootSector = imagePlugin.ReadSectors(sbSector + partition.Start, sectorsToRead); int bootChk = 0; - for(int i = 0; i < 0x1FF; i++) bootChk = ((bootChk & 0xFF) + (bootChk >> 8) + bootSector[i]); + for(int i = 0; i < 0x1FF; i++) bootChk = (bootChk & 0xFF) + (bootChk >> 8) + bootSector[i]; DicConsole.DebugWriteLine("ADFS Plugin", "bootChk = {0}", bootChk); DicConsole.DebugWriteLine("ADFS Plugin", "bBlock.checksum = {0}", bootSector[0x1FF]); @@ -412,9 +412,9 @@ namespace DiscImageChef.Filesystems if(drSb.log2secsize < 8 || drSb.log2secsize > 10) return false; - if(drSb.idlen < (drSb.log2secsize + 3) || drSb.idlen > 19) return false; + if(drSb.idlen < drSb.log2secsize + 3 || drSb.idlen > 19) return false; - if((drSb.disc_size_high >> drSb.log2secsize) != 0) return false; + if(drSb.disc_size_high >> drSb.log2secsize != 0) return false; if(!ArrayHelpers.ArrayIsNullOrEmpty(drSb.reserved)) return false; @@ -422,7 +422,7 @@ namespace DiscImageChef.Filesystems bytes *= 0x100000000; bytes += drSb.disc_size; - if(bytes > (imagePlugin.GetSectors() * imagePlugin.GetSectorSize())) return false; + if(bytes > imagePlugin.GetSectors() * imagePlugin.GetSectorSize()) return false; return true; } @@ -593,7 +593,7 @@ namespace DiscImageChef.Filesystems byte[] bootSector = imagePlugin.ReadSectors(sbSector + partition.Start, sectorsToRead); int bootChk = 0; - for(int i = 0; i < 0x1FF; i++) bootChk = ((bootChk & 0xFF) + (bootChk >> 8) + bootSector[i]); + for(int i = 0; i < 0x1FF; i++) bootChk = (bootChk & 0xFF) + (bootChk >> 8) + bootSector[i]; DicConsole.DebugWriteLine("ADFS Plugin", "bootChk = {0}", bootChk); DicConsole.DebugWriteLine("ADFS Plugin", "bBlock.checksum = {0}", bootSector[0x1FF]); @@ -639,9 +639,9 @@ namespace DiscImageChef.Filesystems if(drSb.log2secsize < 8 || drSb.log2secsize > 10) return; - if(drSb.idlen < (drSb.log2secsize + 3) || drSb.idlen > 19) return; + if(drSb.idlen < drSb.log2secsize + 3 || drSb.idlen > 19) return; - if((drSb.disc_size_high >> drSb.log2secsize) != 0) return; + if(drSb.disc_size_high >> drSb.log2secsize != 0) return; if(!ArrayHelpers.ArrayIsNullOrEmpty(drSb.reserved)) return; @@ -653,7 +653,7 @@ namespace DiscImageChef.Filesystems zones *= 0x100000000; zones += drSb.nzones; - if(bytes > (imagePlugin.GetSectors() * imagePlugin.GetSectorSize())) return; + if(bytes > imagePlugin.GetSectors() * imagePlugin.GetSectorSize()) return; xmlFSType = new Schemas.FileSystemType(); @@ -687,7 +687,7 @@ namespace DiscImageChef.Filesystems xmlFSType.Bootable |= drSb.bootoption != 0; // Or not? xmlFSType.Clusters = (long)(bytes / (ulong)(1 << drSb.log2secsize)); - xmlFSType.ClusterSize = (1 << drSb.log2secsize); + xmlFSType.ClusterSize = 1 << drSb.log2secsize; xmlFSType.Type = "Acorn Advanced Disc Filing System"; } @@ -803,7 +803,7 @@ namespace DiscImageChef.Filesystems /* Don't add the check byte when calculating its value */ - sum_vector0 += (sum_vector3 >> 8); + sum_vector0 += sum_vector3 >> 8; sum_vector1 += map_base[rover + 1] + (sum_vector0 >> 8); sum_vector2 += map_base[rover + 2] + (sum_vector1 >> 8); sum_vector3 += map_base[rover + 3] + (sum_vector2 >> 8); @@ -824,7 +824,7 @@ namespace DiscImageChef.Filesystems uint carry = sum & 0x1FFF; sum >>= 13; sum ^= data[i]; - sum += (carry << 19); + sum += carry << 19; } return (byte)(((sum & 0xFF000000) >> 24) ^ ((sum & 0xFF0000) >> 16) ^ ((sum & 0xFF00) >> 8) ^ (sum & 0xFF)); diff --git a/DiscImageChef.Filesystems/AmigaDOS.cs b/DiscImageChef.Filesystems/AmigaDOS.cs index a3b9bd46..543df094 100644 --- a/DiscImageChef.Filesystems/AmigaDOS.cs +++ b/DiscImageChef.Filesystems/AmigaDOS.cs @@ -252,10 +252,10 @@ namespace DiscImageChef.Filesystems ulong[] root_ptrs = { - b_root_ptr + partition.Start, ((partition.End - partition.Start) + 1) / 2 + partition.Start - 2, - ((partition.End - partition.Start) + 1) / 2 + partition.Start - 1, - ((partition.End - partition.Start) + 1) / 2 + partition.Start, - ((partition.End - partition.Start) + 1) / 2 + partition.Start + 4 + b_root_ptr + partition.Start, (partition.End - partition.Start + 1) / 2 + partition.Start - 2, + (partition.End - partition.Start + 1) / 2 + partition.Start - 1, + (partition.End - partition.Start + 1) / 2 + partition.Start, + (partition.End - partition.Start + 1) / 2 + partition.Start + 4 }; RootBlock rblk = new RootBlock(); @@ -333,10 +333,10 @@ namespace DiscImageChef.Filesystems ulong[] root_ptrs = { - b_root_ptr + partition.Start, ((partition.End - partition.Start) + 1) / 2 + partition.Start - 2, - ((partition.End - partition.Start) + 1) / 2 + partition.Start - 1, - ((partition.End - partition.Start) + 1) / 2 + partition.Start, - ((partition.End - partition.Start) + 1) / 2 + partition.Start + 4 + b_root_ptr + partition.Start, (partition.End - partition.Start + 1) / 2 + partition.Start - 2, + (partition.End - partition.Start + 1) / 2 + partition.Start - 1, + (partition.End - partition.Start + 1) / 2 + partition.Start, + (partition.End - partition.Start + 1) / 2 + partition.Start + 4 }; RootBlock rootBlk = new RootBlock(); @@ -458,7 +458,7 @@ namespace DiscImageChef.Filesystems if((bootBlk.diskType & 0xFF) == 4 || (bootBlk.diskType & 0xFF) == 5) sbInformation.AppendFormat("Directory cache starts at block {0}", rootBlk.extension).AppendLine(); - long blocks = (long)((((partition.End - partition.Start) + 1) * imagePlugin.ImageInfo.SectorSize) / + long blocks = (long)((partition.End - partition.Start + 1) * imagePlugin.ImageInfo.SectorSize / blockSize); sbInformation.AppendFormat("Volume block size is {0} bytes", blockSize).AppendLine(); diff --git a/DiscImageChef.Filesystems/AppleDOS/Dir.cs b/DiscImageChef.Filesystems/AppleDOS/Dir.cs index bdcad526..86714251 100644 --- a/DiscImageChef.Filesystems/AppleDOS/Dir.cs +++ b/DiscImageChef.Filesystems/AppleDOS/Dir.cs @@ -80,7 +80,7 @@ namespace DiscImageChef.Filesystems.AppleDOS Errno ReadCatalog() { MemoryStream catalogMs = new MemoryStream(); - ulong lba = (ulong)((vtoc.catalogTrack * sectorsPerTrack) + vtoc.catalogSector); + ulong lba = (ulong)(vtoc.catalogTrack * sectorsPerTrack + vtoc.catalogSector); totalFileEntries = 0; catalogCache = new Dictionary(); fileTypeCache = new Dictionary(); @@ -131,7 +131,7 @@ namespace DiscImageChef.Filesystems.AppleDOS } } - lba = (ulong)((catSector.trackOfNext * sectorsPerTrack) + catSector.sectorOfNext); + lba = (ulong)(catSector.trackOfNext * sectorsPerTrack + catSector.sectorOfNext); if(lba > device.ImageInfo.Sectors) break; } diff --git a/DiscImageChef.Filesystems/AppleDOS/File.cs b/DiscImageChef.Filesystems/AppleDOS/File.cs index a2f00d94..4cfee1c9 100644 --- a/DiscImageChef.Filesystems/AppleDOS/File.cs +++ b/DiscImageChef.Filesystems/AppleDOS/File.cs @@ -173,7 +173,7 @@ namespace DiscImageChef.Filesystems.AppleDOS if(!catalogCache.TryGetValue(filename, out ts)) return Errno.NoSuchFile; - ulong lba = (ulong)((((ts & 0xFF00) >> 8) * sectorsPerTrack) + (ts & 0xFF)); + ulong lba = (ulong)(((ts & 0xFF00) >> 8) * sectorsPerTrack + (ts & 0xFF)); MemoryStream fileMs = new MemoryStream(); MemoryStream tsListMs = new MemoryStream(); ushort expectedBlock = 0; @@ -204,7 +204,7 @@ namespace DiscImageChef.Filesystems.AppleDOS track2UsedByFiles |= entry.track == 2; usedSectors++; - ulong blockLba = (ulong)((entry.track * sectorsPerTrack) + entry.sector); + ulong blockLba = (ulong)(entry.track * sectorsPerTrack + entry.sector); if(blockLba == 0) break; byte[] fileBlock = device.ReadSector(blockLba); @@ -212,7 +212,7 @@ namespace DiscImageChef.Filesystems.AppleDOS expectedBlock++; } - lba = (ulong)((tsSector.nextListTrack * sectorsPerTrack) + tsSector.nextListSector); + lba = (ulong)(tsSector.nextListTrack * sectorsPerTrack + tsSector.nextListSector); } if(fileCache.ContainsKey(filename)) fileCache.Remove(filename); diff --git a/DiscImageChef.Filesystems/AppleHFS.cs b/DiscImageChef.Filesystems/AppleHFS.cs index 76d9d492..83e837ab 100644 --- a/DiscImageChef.Filesystems/AppleHFS.cs +++ b/DiscImageChef.Filesystems/AppleHFS.cs @@ -80,7 +80,7 @@ namespace DiscImageChef.Filesystems public override bool Identify(DiscImages.ImagePlugin imagePlugin, Partition partition) { - if((2 + partition.Start) >= partition.End) return false; + if(2 + partition.Start >= partition.End) return false; byte[] mdb_sector; ushort drSigWord; @@ -282,8 +282,7 @@ namespace DiscImageChef.Filesystems xmlFSType.BackupDate = DateHandlers.MacToDateTime(MDB.drVolBkUp); xmlFSType.BackupDateSpecified = true; } - xmlFSType.Bootable = BB.signature == HFSBB_MAGIC || - (MDB.drFndrInfo0 != 0 || MDB.drFndrInfo3 != 0 || MDB.drFndrInfo5 != 0); + xmlFSType.Bootable = BB.signature == HFSBB_MAGIC || MDB.drFndrInfo0 != 0 || MDB.drFndrInfo3 != 0 || MDB.drFndrInfo5 != 0; xmlFSType.Clusters = MDB.drNmAlBlks; xmlFSType.ClusterSize = (int)MDB.drAlBlkSiz; if(MDB.drCrDate > 0) diff --git a/DiscImageChef.Filesystems/AppleHFSPlus.cs b/DiscImageChef.Filesystems/AppleHFSPlus.cs index b8647f66..d32cdb43 100644 --- a/DiscImageChef.Filesystems/AppleHFSPlus.cs +++ b/DiscImageChef.Filesystems/AppleHFSPlus.cs @@ -77,7 +77,7 @@ namespace DiscImageChef.Filesystems public override bool Identify(DiscImages.ImagePlugin imagePlugin, Partition partition) { - if((2 + partition.Start) >= partition.End) return false; + if(2 + partition.Start >= partition.End) return false; ushort drSigWord; ushort xdrStABNt; @@ -109,7 +109,7 @@ namespace DiscImageChef.Filesystems drAlBlSt = BigEndianBitConverter .ToUInt16(vh_sector, 0x41C); // Start of allocated blocks (in 512-byte/block) - hfsp_offset = (ulong)(((drAlBlSt * 512) + (xdrStABNt * drAlBlkSiz)) / imagePlugin.GetSectorSize()); + hfsp_offset = (ulong)((drAlBlSt * 512 + xdrStABNt * drAlBlkSiz) / imagePlugin.GetSectorSize()); } else { hfsp_offset = 0; } } @@ -160,7 +160,7 @@ namespace DiscImageChef.Filesystems drAlBlSt = BigEndianBitConverter .ToUInt16(vh_sector, 0x41C); // Start of allocated blocks (in 512-byte/block) - hfsp_offset = (ulong)(((drAlBlSt * 512) + (xdrStABNt * drAlBlkSiz)) / imagePlugin.GetSectorSize()); + hfsp_offset = (ulong)((drAlBlSt * 512 + xdrStABNt * drAlBlkSiz) / imagePlugin.GetSectorSize()); wrapped = true; } else @@ -251,7 +251,7 @@ namespace DiscImageChef.Filesystems xmlFSType.BackupDate = DateHandlers.MacToDateTime(HPVH.backupDate); xmlFSType.BackupDateSpecified = true; } - xmlFSType.Bootable |= (HPVH.drFndrInfo0 != 0 || HPVH.drFndrInfo3 != 0 || HPVH.drFndrInfo5 != 0); + xmlFSType.Bootable |= HPVH.drFndrInfo0 != 0 || HPVH.drFndrInfo3 != 0 || HPVH.drFndrInfo5 != 0; xmlFSType.Clusters = HPVH.totalBlocks; xmlFSType.ClusterSize = (int)HPVH.blockSize; if(HPVH.createDate > 0) diff --git a/DiscImageChef.Filesystems/AppleMFS/Dir.cs b/DiscImageChef.Filesystems/AppleMFS/Dir.cs index 7f1aa4d6..a1fd7713 100644 --- a/DiscImageChef.Filesystems/AppleMFS/Dir.cs +++ b/DiscImageChef.Filesystems/AppleMFS/Dir.cs @@ -119,10 +119,10 @@ namespace DiscImageChef.Filesystems.AppleMFS StringHandlers.PascalToString(entry.flNam, CurrentEncoding)); } - offset += (50 + entry.flNam.Length); + offset += 50 + entry.flNam.Length; // "Entries are always an integral number of words" - if((offset % 2) != 0) offset++; + if(offset % 2 != 0) offset++; // TODO: "Entries don't cross logical block boundaries" } diff --git a/DiscImageChef.Filesystems/AppleMFS/File.cs b/DiscImageChef.Filesystems/AppleMFS/File.cs index 361023f3..5276ef56 100644 --- a/DiscImageChef.Filesystems/AppleMFS/File.cs +++ b/DiscImageChef.Filesystems/AppleMFS/File.cs @@ -55,7 +55,7 @@ namespace DiscImageChef.Filesystems.AppleMFS if(!idToEntry.TryGetValue(fileID, out entry)) return Errno.NoSuchFile; - if(fileBlock > (entry.flPyLen / volMDB.drAlBlkSiz)) return Errno.InvalidArgument; + if(fileBlock > entry.flPyLen / volMDB.drAlBlkSiz) return Errno.InvalidArgument; uint nextBlock = entry.flStBlk; long relBlock = 0; @@ -64,7 +64,7 @@ namespace DiscImageChef.Filesystems.AppleMFS { if(relBlock == fileBlock) { - deviceBlock = ((nextBlock - 2) * sectorsPerBlock) + volMDB.drAlBlSt + (long)partitionStart; + deviceBlock = (nextBlock - 2) * sectorsPerBlock + volMDB.drAlBlSt + (long)partitionStart; return Errno.NoError; } @@ -174,23 +174,23 @@ namespace DiscImageChef.Filesystems.AppleMFS if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0) { - stat.Blocks = (directoryBlocks.Length / stat.BlockSize) + - (directoryBlocks.Length % stat.BlockSize); + stat.Blocks = directoryBlocks.Length / stat.BlockSize + + directoryBlocks.Length % stat.BlockSize; stat.Length = directoryBlocks.Length; } else if(string.Compare(path, "$Bitmap", StringComparison.InvariantCulture) == 0) { - stat.Blocks = (blockMapBytes.Length / stat.BlockSize) + (blockMapBytes.Length % stat.BlockSize); + stat.Blocks = blockMapBytes.Length / stat.BlockSize + blockMapBytes.Length % stat.BlockSize; stat.Length = blockMapBytes.Length; } else if(string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 && bootBlocks != null) { - stat.Blocks = (bootBlocks.Length / stat.BlockSize) + (bootBlocks.Length % stat.BlockSize); + stat.Blocks = bootBlocks.Length / stat.BlockSize + bootBlocks.Length % stat.BlockSize; stat.Length = bootBlocks.Length; } else if(string.Compare(path, "$MDB", StringComparison.InvariantCulture) == 0) { - stat.Blocks = (mdbBlocks.Length / stat.BlockSize) + (mdbBlocks.Length % stat.BlockSize); + stat.Blocks = mdbBlocks.Length / stat.BlockSize + mdbBlocks.Length % stat.BlockSize; stat.Length = mdbBlocks.Length; } else return Errno.InvalidArgument; diff --git a/DiscImageChef.Filesystems/AppleMFS/Info.cs b/DiscImageChef.Filesystems/AppleMFS/Info.cs index b4f00ecb..39c9a956 100644 --- a/DiscImageChef.Filesystems/AppleMFS/Info.cs +++ b/DiscImageChef.Filesystems/AppleMFS/Info.cs @@ -43,7 +43,7 @@ namespace DiscImageChef.Filesystems.AppleMFS { ushort drSigWord; - if((2 + partition.Start) >= partition.End) return false; + if(2 + partition.Start >= partition.End) return false; byte[] mdb_sector = imagePlugin.ReadSector(2 + partition.Start); diff --git a/DiscImageChef.Filesystems/AppleMFS/Super.cs b/DiscImageChef.Filesystems/AppleMFS/Super.cs index 6f1ac099..9d09c895 100644 --- a/DiscImageChef.Filesystems/AppleMFS/Super.cs +++ b/DiscImageChef.Filesystems/AppleMFS/Super.cs @@ -70,11 +70,11 @@ namespace DiscImageChef.Filesystems.AppleMFS volMDB.drVN = StringHandlers.PascalToString(variable_size, CurrentEncoding); directoryBlocks = device.ReadSectors(volMDB.drDirSt + partitionStart, volMDB.drBlLen); - int bytesInBlockMap = ((volMDB.drNmAlBlks * 12) / 8) + ((volMDB.drNmAlBlks * 12) % 8); + int bytesInBlockMap = volMDB.drNmAlBlks * 12 / 8 + volMDB.drNmAlBlks * 12 % 8; int bytesBeforeBlockMap = 64; int bytesInWholeMDB = bytesInBlockMap + bytesBeforeBlockMap; - int sectorsInWholeMDB = (bytesInWholeMDB / (int)device.ImageInfo.SectorSize) + - (bytesInWholeMDB % (int)device.ImageInfo.SectorSize); + int sectorsInWholeMDB = bytesInWholeMDB / (int)device.ImageInfo.SectorSize + + bytesInWholeMDB % (int)device.ImageInfo.SectorSize; byte[] wholeMDB = device.ReadSectors(partitionStart + 2, (uint)sectorsInWholeMDB); blockMapBytes = new byte[bytesInBlockMap]; Array.Copy(wholeMDB, bytesBeforeBlockMap, blockMapBytes, 0, blockMapBytes.Length); @@ -100,7 +100,7 @@ namespace DiscImageChef.Filesystems.AppleMFS if(i + 5 < blockMap.Length) blockMap[i + 4] = (tmp2 & 0xFFF0) >> 4; if(i + 6 < blockMap.Length) blockMap[i + 5] = ((tmp2 & 0xF) << 8) + ((tmp3 & 0xFF000000) >> 24); if(i + 7 < blockMap.Length) blockMap[i + 6] = (tmp3 & 0xFFF000) >> 12; - if(i + 8 < blockMap.Length) blockMap[i + 7] = (tmp3 & 0xFFF); + if(i + 8 < blockMap.Length) blockMap[i + 7] = tmp3 & 0xFFF; offset += 12; } diff --git a/DiscImageChef.Filesystems/AtheOS.cs b/DiscImageChef.Filesystems/AtheOS.cs index 6326ccf7..504e39fb 100644 --- a/DiscImageChef.Filesystems/AtheOS.cs +++ b/DiscImageChef.Filesystems/AtheOS.cs @@ -80,7 +80,7 @@ namespace DiscImageChef.Filesystems if(imagePlugin.GetSectorSize() < AFS_SUPERBLOCK_SIZE) run = AFS_SUPERBLOCK_SIZE / imagePlugin.GetSectorSize(); - if((sector + partition.Start) >= partition.End) return false; + if(sector + partition.Start >= partition.End) return false; uint magic; diff --git a/DiscImageChef.Filesystems/BFS.cs b/DiscImageChef.Filesystems/BFS.cs index 30d82633..7ed65c11 100644 --- a/DiscImageChef.Filesystems/BFS.cs +++ b/DiscImageChef.Filesystems/BFS.cs @@ -78,7 +78,7 @@ namespace DiscImageChef.Filesystems public override bool Identify(DiscImages.ImagePlugin imagePlugin, Partition partition) { - if((2 + partition.Start) >= partition.End) return false; + if(2 + partition.Start >= partition.End) return false; uint magic; uint magic_be; @@ -166,7 +166,7 @@ namespace DiscImageChef.Filesystems if(besb.magic1 != BEFS_MAGIC1 || besb.fs_byte_order != BEFS_ENDIAN || besb.magic2 != BEFS_MAGIC2 || besb.magic3 != BEFS_MAGIC3 || besb.root_dir_len != 1 || besb.indices_len != 1 || - (1 << (int)besb.block_shift) != besb.block_size) + 1 << (int)besb.block_shift != besb.block_size) { sb.AppendLine("Superblock seems corrupt, following information may be incorrect"); sb.AppendFormat("Magic 1: 0x{0:X8} (Should be 0x42465331)", besb.magic1).AppendLine(); diff --git a/DiscImageChef.Filesystems/BTRFS.cs b/DiscImageChef.Filesystems/BTRFS.cs index 2811d878..6e43ed38 100644 --- a/DiscImageChef.Filesystems/BTRFS.cs +++ b/DiscImageChef.Filesystems/BTRFS.cs @@ -132,7 +132,7 @@ namespace DiscImageChef.Filesystems ulong sbSectorOff = 0x10000 / imagePlugin.GetSectorSize(); uint sbSectorSize = 0x1000 / imagePlugin.GetSectorSize(); - if((sbSectorOff + partition.Start) >= partition.End) return false; + if(sbSectorOff + partition.Start >= partition.End) return false; byte[] sector = imagePlugin.ReadSectors(sbSectorOff + partition.Start, sbSectorSize); SuperBlock btrfsSb; diff --git a/DiscImageChef.Filesystems/CPM/Dir.cs b/DiscImageChef.Filesystems/CPM/Dir.cs index 9aa0477c..bf41b5c4 100644 --- a/DiscImageChef.Filesystems/CPM/Dir.cs +++ b/DiscImageChef.Filesystems/CPM/Dir.cs @@ -110,7 +110,7 @@ namespace DiscImageChef.Filesystems.CPM else if(entry.statusUser == 0x21) { if(directory[off + 1] == 0x00) { thirdPartyTimestamps = true; } - else standardTimestamps |= (directory[off + 21] == 0x00 && directory[off + 31] == 0x00); + else standardTimestamps |= directory[off + 21] == 0x00 && directory[off + 31] == 0x00; } } diff --git a/DiscImageChef.Filesystems/CPM/Info.cs b/DiscImageChef.Filesystems/CPM/Info.cs index 599d758f..cb32ef8d 100644 --- a/DiscImageChef.Filesystems/CPM/Info.cs +++ b/DiscImageChef.Filesystems/CPM/Info.cs @@ -194,9 +194,9 @@ namespace DiscImageChef.Filesystems.CPM Marshal.FreeHGlobal(amsPtr); // Check that format byte and sidedness indicate the same number of sizes - if((amsSb.format == 0 && (amsSb.sidedness & 0x02) == 0) || - (amsSb.format == 2 && (amsSb.sidedness & 0x02) == 1) || - (amsSb.format == 2 && (amsSb.sidedness & 0x02) == 2)) + if(amsSb.format == 0 && (amsSb.sidedness & 0x02) == 0 || + amsSb.format == 2 && (amsSb.sidedness & 0x02) == 1 || + amsSb.format == 2 && (amsSb.sidedness & 0x02) == 2) { // Calculate device limits sides = (ulong)(amsSb.format == 0 ? 1 : 2); @@ -207,7 +207,7 @@ namespace DiscImageChef.Filesystems.CPM if(sectorSize == imagePlugin.GetSectorSize() && sectorCount == imagePlugin.GetSectors()) { cpmFound = true; - firstDirectorySector = (ulong)((amsSb.off * amsSb.spt)); + firstDirectorySector = (ulong)(amsSb.off * amsSb.spt); // Build a DiscParameterBlock dpb = new DiscParameterBlock(); @@ -233,7 +233,7 @@ namespace DiscImageChef.Filesystems.CPM for(int i = 0; i < dpb.psh; i++) dpb.phm += (byte)Math.Pow(2, i); dpb.spt = (ushort)(amsSb.spt * (sectorSize / 128)); - uint directoryLength = (uint)((((ulong)dpb.drm + 1) * 32) / sectorSize); + uint directoryLength = (uint)(((ulong)dpb.drm + 1) * 32 / sectorSize); directory = imagePlugin.ReadSectors(firstDirectorySector + partition.Start, directoryLength); @@ -314,7 +314,7 @@ namespace DiscImageChef.Filesystems.CPM sectorsInPartition + partition.Start <= partition.End) { cpmFound = true; - firstDirectorySector = (ulong)((hddSb.off * hddSb.sectorsPerTrack)); + firstDirectorySector = (ulong)(hddSb.off * hddSb.sectorsPerTrack); // Build a DiscParameterBlock dpb = new DiscParameterBlock(); @@ -330,7 +330,7 @@ namespace DiscImageChef.Filesystems.CPM dpb.phm = 0; // Needed? dpb.psh = 0; // Needed? dpb.spt = hddSb.spt; - uint directoryLength = (uint)((((ulong)dpb.drm + 1) * 32) / sectorSize); + uint directoryLength = (uint)(((ulong)dpb.drm + 1) * 32 / sectorSize); directory = imagePlugin.ReadSectors(firstDirectorySector + partition.Start, directoryLength); DicConsole.DebugWriteLine("CP/M Plugin", "Found CP/M-86 hard disk superblock."); @@ -760,7 +760,7 @@ namespace DiscImageChef.Filesystems.CPM if(cpmFound) { - uint directoryLength = (uint)((((ulong)dpb.drm + 1) * 32) / imagePlugin.GetSectorSize()); + uint directoryLength = (uint)(((ulong)dpb.drm + 1) * 32 / imagePlugin.GetSectorSize()); directory = imagePlugin.ReadSectors(firstDirectorySector86 + partition.Start, directoryLength); DicConsole.DebugWriteLine("CP/M Plugin", "Found CP/M-86 floppy identifier."); } @@ -799,7 +799,7 @@ namespace DiscImageChef.Filesystems.CPM if(def.sofs != 0) offset = (ulong)def.sofs; else offset = (ulong)(def.ofs * def.sectorsPerTrack); - int dirLen = ((def.drm + 1) * 32) / def.bytesPerSector; + int dirLen = (def.drm + 1) * 32 / def.bytesPerSector; if(def.sides == 1) { @@ -819,7 +819,7 @@ namespace DiscImageChef.Filesystems.CPM // Skip first track (first side) for(int m = 0; m < def.side2.sectorIds.Length; m++) sectorMask[m + def.side1.sectorIds.Length] = - (def.side2.sectorIds[m] - def.side2.sectorIds[0]) + + def.side2.sectorIds[m] - def.side2.sectorIds[0] + def.side1.sectorIds.Length; } // Head changes after whole side @@ -831,7 +831,7 @@ namespace DiscImageChef.Filesystems.CPM // Skip first track (first side) and first track (second side) for(int m = 0; m < def.side1.sectorIds.Length; m++) sectorMask[m + def.side1.sectorIds.Length] = - (def.side1.sectorIds[m] - def.side1.sectorIds[0]) + + def.side1.sectorIds[m] - def.side1.sectorIds[0] + def.side1.sectorIds.Length + def.side2.sectorIds.Length; } // TODO: Implement COLUMBIA ordering @@ -865,7 +865,7 @@ namespace DiscImageChef.Filesystems.CPM { byte[] dirSector = imagePlugin.ReadSector((ulong)((int)offset + (int)partition.Start + - (p / sectorMask.Length) * sectorMask.Length + + p / sectorMask.Length * sectorMask.Length + sectorMask[p % sectorMask.Length])); ms.Write(dirSector, 0, dirSector.Length); } @@ -942,7 +942,7 @@ namespace DiscImageChef.Filesystems.CPM break; } - dpb.spt = (ushort)((def.sectorsPerTrack * def.bytesPerSector) / 128); + dpb.spt = (ushort)(def.sectorsPerTrack * def.bytesPerSector / 128); cpmFound = true; workingDefinition = def; @@ -985,7 +985,7 @@ namespace DiscImageChef.Filesystems.CPM sb.AppendFormat("Identified as {0}", workingDefinition.comment).AppendLine(); sb.AppendFormat("Volume block is {0} bytes", 128 << dpb.bsh).AppendLine(); if(dpb.dsm > 0) - sb.AppendFormat("Volume contains {0} blocks ({1} bytes)", dpb.dsm, (dpb.dsm) * (128 << dpb.bsh)) + sb.AppendFormat("Volume contains {0} blocks ({1} bytes)", dpb.dsm, dpb.dsm * (128 << dpb.bsh)) .AppendLine(); sb.AppendFormat("Volume contains {0} directory entries", dpb.drm + 1).AppendLine(); if(workingDefinition.sofs > 0) @@ -1051,7 +1051,7 @@ namespace DiscImageChef.Filesystems.CPM sb.AppendFormat("Volume updated on {0}", DateHandlers.CPMToDateTime(labelUpdateDate)).AppendLine(); xmlFSType = new Schemas.FileSystemType(); - xmlFSType.Bootable |= (workingDefinition.sofs > 0 || workingDefinition.ofs > 0); + xmlFSType.Bootable |= workingDefinition.sofs > 0 || workingDefinition.ofs > 0; xmlFSType.ClusterSize = 128 << dpb.bsh; if(dpb.dsm > 0) xmlFSType.Clusters = dpb.dsm; else xmlFSType.Clusters = (long)(partition.End - partition.Start); diff --git a/DiscImageChef.Filesystems/CPM/Super.cs b/DiscImageChef.Filesystems/CPM/Super.cs index 63b6cedc..6a98d6f5 100644 --- a/DiscImageChef.Filesystems/CPM/Super.cs +++ b/DiscImageChef.Filesystems/CPM/Super.cs @@ -73,7 +73,7 @@ namespace DiscImageChef.Filesystems.CPM // Skip first track (first side) for(int m = 0; m < workingDefinition.side2.sectorIds.Length; m++) sectorMask[m + workingDefinition.side1.sectorIds.Length] = - (workingDefinition.side2.sectorIds[m] - workingDefinition.side2.sectorIds[0]) + + workingDefinition.side2.sectorIds[m] - workingDefinition.side2.sectorIds[0] + workingDefinition.side1.sectorIds.Length; } // Head changes after whole side @@ -85,7 +85,7 @@ namespace DiscImageChef.Filesystems.CPM // Skip first track (first side) and first track (second side) for(int m = 0; m < workingDefinition.side1.sectorIds.Length; m++) sectorMask[m + workingDefinition.side1.sectorIds.Length] = - (workingDefinition.side1.sectorIds[m] - workingDefinition.side1.sectorIds[0]) + + workingDefinition.side1.sectorIds[m] - workingDefinition.side1.sectorIds[0] + workingDefinition.side1.sectorIds.Length + workingDefinition.side2.sectorIds.Length; // TODO: Implement CYLINDERS ordering @@ -128,7 +128,7 @@ namespace DiscImageChef.Filesystems.CPM for(int p = 0; p <= (int)(partition.End - partition.Start); p++) { byte[] readSector = - device.ReadSector((ulong)((int)partition.Start + (p / sectorMask.Length) * sectorMask.Length + + device.ReadSector((ulong)((int)partition.Start + p / sectorMask.Length * sectorMask.Length + sectorMask[p % sectorMask.Length])); if(workingDefinition.complement) { @@ -156,7 +156,7 @@ namespace DiscImageChef.Filesystems.CPM // May it happen? Just in case, CP/M blocks are smaller than physical sectors if(sector.Length > blockSize) { - for(int i = 0; i < (sector.Length / blockSize); i++) + for(int i = 0; i < sector.Length / blockSize; i++) { byte[] tmp = new byte[blockSize]; Array.Copy(sector, blockSize * i, tmp, 0, blockSize); @@ -183,7 +183,7 @@ namespace DiscImageChef.Filesystems.CPM DicConsole.DebugWriteLine("CP/M Plugin", "Reading directory."); int dirOff; - int dirSectors = ((dpb.drm + 1) * 32) / workingDefinition.bytesPerSector; + int dirSectors = (dpb.drm + 1) * 32 / workingDefinition.bytesPerSector; if(workingDefinition.sofs > 0) dirOff = workingDefinition.sofs; else dirOff = workingDefinition.ofs * workingDefinition.sectorsPerTrack; @@ -235,7 +235,7 @@ namespace DiscImageChef.Filesystems.CPM bool rdOnly = (entry.filename[0] & 0x80) == 0x80 || (entry.extension[0] & 0x80) == 0x80; bool system = (entry.filename[1] & 0x80) == 0x80 || (entry.extension[2] & 0x80) == 0x80; //bool backed = (entry.filename[3] & 0x80) == 0x80 || (entry.extension[3] & 0x80) == 0x80; - int user = (entry.statusUser & 0x0F); + int user = entry.statusUser & 0x0F; bool validEntry = true; @@ -259,7 +259,7 @@ namespace DiscImageChef.Filesystems.CPM if(user > 0) filename = string.Format("{0:X1}:{1}", user, filename); if(!string.IsNullOrEmpty(extension)) filename = filename + "." + extension; - int entryNo = ((32 * entry.extentCounter) + entry.extentCounterHigh) / (dpb.exm + 1); + int entryNo = (32 * entry.extentCounter + entry.extentCounterHigh) / (dpb.exm + 1); List blocks; Dictionary> extentBlocks; FileEntryInfo fInfo; @@ -332,7 +332,7 @@ namespace DiscImageChef.Filesystems.CPM bool rdOnly = (entry.filename[0] & 0x80) == 0x80 || (entry.extension[0] & 0x80) == 0x80; bool system = (entry.filename[1] & 0x80) == 0x80 || (entry.extension[2] & 0x80) == 0x80; //bool backed = (entry.filename[3] & 0x80) == 0x80 || (entry.extension[3] & 0x80) == 0x80; - int user = (entry.statusUser & 0x0F); + int user = entry.statusUser & 0x0F; bool validEntry = true; @@ -356,7 +356,7 @@ namespace DiscImageChef.Filesystems.CPM if(user > 0) filename = string.Format("{0:X1}:{1}", user, filename); if(!string.IsNullOrEmpty(extension)) filename = filename + "." + extension; - int entryNo = ((32 * entry.extentCounterHigh) + entry.extentCounter) / (dpb.exm + 1); + int entryNo = (32 * entry.extentCounterHigh + entry.extentCounter) / (dpb.exm + 1); List blocks; Dictionary> extentBlocks; FileEntryInfo fInfo; @@ -427,7 +427,7 @@ namespace DiscImageChef.Filesystems.CPM entry = (PasswordEntry)Marshal.PtrToStructure(dirPtr, typeof(PasswordEntry)); Marshal.FreeHGlobal(dirPtr); - int user = (entry.userNumber & 0x0F); + int user = entry.userNumber & 0x0F; for(int i = 0; i < 8; i++) entry.filename[i] &= 0x7F; for(int i = 0; i < 3; i++) entry.extension[i] &= 0x7F; diff --git a/DiscImageChef.Filesystems/FAT.cs b/DiscImageChef.Filesystems/FAT.cs index 56238e08..88f70c35 100644 --- a/DiscImageChef.Filesystems/FAT.cs +++ b/DiscImageChef.Filesystems/FAT.cs @@ -69,7 +69,7 @@ namespace DiscImageChef.Filesystems public override bool Identify(DiscImages.ImagePlugin imagePlugin, Partition partition) { - if((2 + partition.Start) >= partition.End) return false; + if(2 + partition.Start >= partition.End) return false; ushort bps; byte spc; @@ -202,31 +202,31 @@ namespace DiscImageChef.Filesystems if(bits_in_bps == 1 && correct_spc && fats_no <= 2 && sectors == 0 && fat_sectors == 0 && fat32_signature == 0x28) return big_sectors == 0 - ? huge_sectors <= (partition.End - partition.Start) + 1 - : big_sectors <= (partition.End - partition.Start) + 1; + ? huge_sectors <= partition.End - partition.Start + 1 + : big_sectors <= partition.End - partition.Start + 1; // MSX-DOS FAT12 if(bits_in_bps == 1 && correct_spc && fats_no <= 2 && root_entries > 0 && - sectors <= (partition.End - partition.Start) + 1 && fat_sectors > 0 && + sectors <= partition.End - partition.Start + 1 && fat_sectors > 0 && msx_string == "VOL_ID") return true; // EBPB if(bits_in_bps == 1 && correct_spc && fats_no <= 2 && root_entries > 0 && fat_sectors > 0 && (bpb_signature == 0x28 || bpb_signature == 0x29)) return sectors == 0 - ? big_sectors <= (partition.End - partition.Start) + 1 - : sectors <= (partition.End - partition.Start) + 1; + ? big_sectors <= partition.End - partition.Start + 1 + : sectors <= partition.End - partition.Start + 1; // BPB - if(bits_in_bps == 1 && correct_spc && reserved_secs < (partition.End - partition.Start) && fats_no <= 2 && + if(bits_in_bps == 1 && correct_spc && reserved_secs < partition.End - partition.Start && fats_no <= 2 && root_entries > 0 && fat_sectors > 0) return sectors == 0 - ? big_sectors <= (partition.End - partition.Start) + 1 - : sectors <= (partition.End - partition.Start) + 1; + ? big_sectors <= partition.End - partition.Start + 1 + : sectors <= partition.End - partition.Start + 1; // Apricot BPB if(bits_in_apricot_bps == 1 && apricot_correct_spc && - apricot_reserved_secs < (partition.End - partition.Start) && apricot_fats_no <= 2 && + apricot_reserved_secs < partition.End - partition.Start && apricot_fats_no <= 2 && apricot_root_entries > 0 && apricot_fat_sectors > 0 && - apricot_sectors <= (partition.End - partition.Start) + 1 && apricot_partitions == 0) return true; + apricot_sectors <= partition.End - partition.Start + 1 && apricot_partitions == 0) return true; // All FAT12 without BPB can only be used on floppies, without partitions. if(partition.Start != 0) return false; @@ -258,7 +258,7 @@ namespace DiscImageChef.Filesystems { for(int c = 0; c < 11; c++) { - if((root_dir[c + e] < 0x20 && root_dir[c + e] != 0x00 && root_dir[c + e] != 0x05) || + if(root_dir[c + e] < 0x20 && root_dir[c + e] != 0x00 && root_dir[c + e] != 0x05 || root_dir[c + e] == 0xFF || root_dir[c + e] == 0x2E) { valid_root_dir = false; @@ -474,11 +474,11 @@ namespace DiscImageChef.Filesystems { DicConsole.DebugWriteLine("FAT plugin", "Using short FAT32 BPB"); useShortFAT32 = shortFat32BPB.big_sectors == 0 - ? shortFat32BPB.huge_sectors <= (partition.End - partition.Start) + 1 - : shortFat32BPB.big_sectors <= (partition.End - partition.Start) + 1; + ? shortFat32BPB.huge_sectors <= partition.End - partition.Start + 1 + : shortFat32BPB.big_sectors <= partition.End - partition.Start + 1; } else if(bits_in_bps_msx == 1 && correct_spc_msx && msxBPB.fats_no <= 2 && msxBPB.root_ent > 0 && - msxBPB.sectors <= (partition.End - partition.Start) + 1 && msxBPB.spfat > 0 && + msxBPB.sectors <= partition.End - partition.Start + 1 && msxBPB.spfat > 0 && Encoding.ASCII.GetString(msxBPB.vol_id) == "VOL_ID") { DicConsole.DebugWriteLine("FAT plugin", "Using MSX BPB"); @@ -486,7 +486,7 @@ namespace DiscImageChef.Filesystems } else if(bits_in_bps_apricot == 1 && correct_spc_apricot && ApricotBPB.mainBPB.fats_no <= 2 && ApricotBPB.mainBPB.root_ent > 0 && - ApricotBPB.mainBPB.sectors <= (partition.End - partition.Start) + 1 && + ApricotBPB.mainBPB.sectors <= partition.End - partition.Start + 1 && ApricotBPB.mainBPB.spfat > 0 && ApricotBPB.partitionCount == 0) { DicConsole.DebugWriteLine("FAT plugin", "Using Apricot BPB"); @@ -497,7 +497,7 @@ namespace DiscImageChef.Filesystems { if(EBPB.sectors == 0) { - if(EBPB.big_sectors <= (partition.End - partition.Start) + 1) + if(EBPB.big_sectors <= partition.End - partition.Start + 1) { if(EBPB.signature == 0x29 || andos_oem_correct) { @@ -511,7 +511,7 @@ namespace DiscImageChef.Filesystems } } } - else if(EBPB.sectors <= (partition.End - partition.Start) + 1) + else if(EBPB.sectors <= partition.End - partition.Start + 1) { if(EBPB.signature == 0x29 || andos_oem_correct) { @@ -526,19 +526,19 @@ namespace DiscImageChef.Filesystems } } else if(bits_in_bps_dos33 == 1 && correct_spc_dos33 && - dos33BPB.rsectors < (partition.End - partition.Start) && dos33BPB.fats_no <= 2 && + dos33BPB.rsectors < partition.End - partition.Start && dos33BPB.fats_no <= 2 && dos33BPB.root_ent > 0 && dos33BPB.spfat > 0) { if(dos33BPB.sectors == 0 && dos33BPB.hsectors <= partition.Start && dos33BPB.big_sectors > 0 && - dos33BPB.big_sectors <= (partition.End - partition.Start) + 1) + dos33BPB.big_sectors <= partition.End - partition.Start + 1) { DicConsole.DebugWriteLine("FAT plugin", "Using DOS 3.3 BPB"); useDOS33BPB = true; } else if(dos33BPB.big_sectors == 0 && dos33BPB.hsectors <= partition.Start && dos33BPB.sectors > 0 && - dos33BPB.sectors <= (partition.End - partition.Start) + 1) + dos33BPB.sectors <= partition.End - partition.Start + 1) { - if(atariBPB.jump[0] == 0x60 || (atariBPB.jump[0] == 0xE9 && atariBPB.jump[1] == 0x00) && + if(atariBPB.jump[0] == 0x60 || atariBPB.jump[0] == 0xE9 && atariBPB.jump[1] == 0x00 && Encoding.ASCII.GetString(dos33BPB.oem_name) != "NEXT ") { DicConsole.DebugWriteLine("FAT plugin", "Using Atari BPB"); @@ -560,7 +560,7 @@ namespace DiscImageChef.Filesystems } else if(dos30BPB.sptrk > 0 && dos30BPB.sptrk < 64 && dos30BPB.heads > 0 && dos30BPB.heads < 256) { - if(atariBPB.jump[0] == 0x60 || (atariBPB.jump[0] == 0xE9 && atariBPB.jump[1] == 0x00) && + if(atariBPB.jump[0] == 0x60 || atariBPB.jump[0] == 0xE9 && atariBPB.jump[1] == 0x00 && Encoding.ASCII.GetString(dos33BPB.oem_name) != "NEXT ") { DicConsole.DebugWriteLine("FAT plugin", "Using Atari BPB"); @@ -574,7 +574,7 @@ namespace DiscImageChef.Filesystems } else { - if(atariBPB.jump[0] == 0x60 || (atariBPB.jump[0] == 0xE9 && atariBPB.jump[1] == 0x00) && + if(atariBPB.jump[0] == 0x60 || atariBPB.jump[0] == 0xE9 && atariBPB.jump[1] == 0x00 && Encoding.ASCII.GetString(dos33BPB.oem_name) != "NEXT ") { DicConsole.DebugWriteLine("FAT plugin", "Using Atari BPB"); @@ -636,7 +636,7 @@ namespace DiscImageChef.Filesystems { for(int c = 0; c < 11; c++) { - if((root_dir[c + e] < 0x20 && root_dir[c + e] != 0x00 && root_dir[c + e] != 0x05) || + if(root_dir[c + e] < 0x20 && root_dir[c + e] != 0x00 && root_dir[c + e] != 0x05 || root_dir[c + e] == 0xFF || root_dir[c + e] == 0x2E) { valid_root_dir = false; @@ -836,7 +836,7 @@ namespace DiscImageChef.Filesystems } // This assumes a bootable sector will jump somewhere or disable interrupts in x86 code - xmlFSType.Bootable |= (bpb_sector[0] == 0xFA || (bpb_sector[0] == 0xEB && bpb_sector[1] <= 0x7F)); + xmlFSType.Bootable |= bpb_sector[0] == 0xFA || bpb_sector[0] == 0xEB && bpb_sector[1] <= 0x7F; fakeBPB.boot_code = bpb_sector; } else if(useShortFAT32 || useLongFAT32) @@ -931,8 +931,8 @@ namespace DiscImageChef.Filesystems // Check that jumps to a correct boot code position and has boot signature set. // This will mean that the volume will boot, even if just to say "this is not bootable change disk"...... - xmlFSType.Bootable |= (Fat32BPB.jump[0] == 0xEB && Fat32BPB.jump[1] > 0x58 && Fat32BPB.jump[1] < 0x80 && - Fat32BPB.boot_signature == 0xAA55); + xmlFSType.Bootable |= Fat32BPB.jump[0] == 0xEB && Fat32BPB.jump[1] > 0x58 && Fat32BPB.jump[1] < 0x80 && + Fat32BPB.boot_signature == 0xAA55; sectors_per_real_sector = Fat32BPB.bps / imagePlugin.ImageInfo.SectorSize; // First root directory sector @@ -1308,14 +1308,14 @@ namespace DiscImageChef.Filesystems // Check that jumps to a correct boot code position and has boot signature set. // This will mean that the volume will boot, even if just to say "this is not bootable change disk"...... if(xmlFSType.Bootable == false && fakeBPB.jump != null) - xmlFSType.Bootable |= (fakeBPB.jump[0] == 0xEB && fakeBPB.jump[1] > 0x58 && - fakeBPB.jump[1] < 0x80 && fakeBPB.boot_signature == 0xAA55); + xmlFSType.Bootable |= fakeBPB.jump[0] == 0xEB && fakeBPB.jump[1] > 0x58 && + fakeBPB.jump[1] < 0x80 && fakeBPB.boot_signature == 0xAA55; sectors_per_real_sector = fakeBPB.bps / imagePlugin.ImageInfo.SectorSize; // First root directory sector root_directory_sector = (ulong)(fakeBPB.spfat * fakeBPB.fats_no + fakeBPB.rsectors) * sectors_per_real_sector; - sectors_for_root_directory = (uint)((fakeBPB.root_ent * 32) / imagePlugin.ImageInfo.SectorSize); + sectors_for_root_directory = (uint)(fakeBPB.root_ent * 32 / imagePlugin.ImageInfo.SectorSize); } if(extraInfo != null) sb.Append(extraInfo); diff --git a/DiscImageChef.Filesystems/FFS.cs b/DiscImageChef.Filesystems/FFS.cs index b16a3795..02afe9d5 100644 --- a/DiscImageChef.Filesystems/FFS.cs +++ b/DiscImageChef.Filesystems/FFS.cs @@ -69,7 +69,7 @@ namespace DiscImageChef.Filesystems public override bool Identify(DiscImages.ImagePlugin imagePlugin, Partition partition) { - if((2 + partition.Start) >= partition.End) return false; + if(2 + partition.Start >= partition.End) return false; uint magic; uint sb_size_in_sectors; @@ -88,7 +88,7 @@ namespace DiscImageChef.Filesystems foreach(ulong loc in locations) { - if(partition.End > (partition.Start + loc + sb_size_in_sectors)) + if(partition.End > partition.Start + loc + sb_size_in_sectors) { ufs_sb_sectors = imagePlugin.ReadSectors(partition.Start + loc, sb_size_in_sectors); magic = BitConverter.ToUInt32(ufs_sb_sectors, 0x055C); @@ -133,7 +133,7 @@ namespace DiscImageChef.Filesystems foreach(ulong loc in locations) { - if(partition.End > (partition.Start + loc + sb_size_in_sectors)) + if(partition.End > partition.Start + loc + sb_size_in_sectors) { ufs_sb_sectors = imagePlugin.ReadSectors(partition.Start + loc, sb_size_in_sectors); magic = BitConverter.ToUInt32(ufs_sb_sectors, 0x055C); @@ -204,10 +204,10 @@ namespace DiscImageChef.Filesystems Marshal.FreeHGlobal(sbPtr); UFSSuperBlock bs_sfu = BigEndianMarshal.ByteArrayToStructureBigEndian(ufs_sb_sectors); - if((bs_sfu.fs_magic == UFS_MAGIC && ufs_sb.fs_magic == UFS_CIGAM) || - (bs_sfu.fs_magic == UFS_MAGIC_BW && ufs_sb.fs_magic == UFS_CIGAM_BW) || - (bs_sfu.fs_magic == UFS2_MAGIC && ufs_sb.fs_magic == UFS2_CIGAM) || - (bs_sfu.fs_magic == UFS_BAD_MAGIC && ufs_sb.fs_magic == UFS_BAD_CIGAM)) + if(bs_sfu.fs_magic == UFS_MAGIC && ufs_sb.fs_magic == UFS_CIGAM || + bs_sfu.fs_magic == UFS_MAGIC_BW && ufs_sb.fs_magic == UFS_CIGAM_BW || + bs_sfu.fs_magic == UFS2_MAGIC && ufs_sb.fs_magic == UFS2_CIGAM || + bs_sfu.fs_magic == UFS_BAD_MAGIC && ufs_sb.fs_magic == UFS_BAD_CIGAM) { ufs_sb = bs_sfu; ufs_sb.fs_old_cstotal.cs_nbfree = Swapping.Swap(ufs_sb.fs_old_cstotal.cs_nbfree); diff --git a/DiscImageChef.Filesystems/Fossil.cs b/DiscImageChef.Filesystems/Fossil.cs index 529bd1f9..dadf93c9 100644 --- a/DiscImageChef.Filesystems/Fossil.cs +++ b/DiscImageChef.Filesystems/Fossil.cs @@ -190,7 +190,7 @@ namespace DiscImageChef.Filesystems sb.AppendFormat("Data starts at block {0}", hdr.data).AppendLine(); sb.AppendFormat("Volume has {0} blocks", hdr.end).AppendLine(); - ulong sbLocation = (hdr.super * (hdr.blockSize / imagePlugin.GetSectorSize())) + partition.Start; + ulong sbLocation = hdr.super * (hdr.blockSize / imagePlugin.GetSectorSize()) + partition.Start; xmlFSType = new Schemas.FileSystemType { diff --git a/DiscImageChef.Filesystems/HAMMER.cs b/DiscImageChef.Filesystems/HAMMER.cs index c53420cc..ee6562a6 100644 --- a/DiscImageChef.Filesystems/HAMMER.cs +++ b/DiscImageChef.Filesystems/HAMMER.cs @@ -77,7 +77,7 @@ namespace DiscImageChef.Filesystems if(HAMMER_VOLHDR_SIZE % imagePlugin.GetSectorSize() > 0) run++; - if((run + partition.Start) >= partition.End) return false; + if(run + partition.Start >= partition.End) return false; ulong magic; diff --git a/DiscImageChef.Filesystems/HPFS.cs b/DiscImageChef.Filesystems/HPFS.cs index d44d2230..31450064 100644 --- a/DiscImageChef.Filesystems/HPFS.cs +++ b/DiscImageChef.Filesystems/HPFS.cs @@ -67,7 +67,7 @@ namespace DiscImageChef.Filesystems public override bool Identify(DiscImages.ImagePlugin imagePlugin, Partition partition) { - if((16 + partition.Start) >= partition.End) return false; + if(16 + partition.Start >= partition.End) return false; uint magic1, magic2; diff --git a/DiscImageChef.Filesystems/ISO9660/Info.cs b/DiscImageChef.Filesystems/ISO9660/Info.cs index e06bfeb9..6d4f4e62 100644 --- a/DiscImageChef.Filesystems/ISO9660/Info.cs +++ b/DiscImageChef.Filesystems/ISO9660/Info.cs @@ -49,7 +49,7 @@ namespace DiscImageChef.Filesystems.ISO9660 if(imagePlugin.GetSectorSize() < 2048) return false; // ISO9660 Primary Volume Descriptor starts at sector 16, so that's minimal size. - if(partition.End <= (16 + partition.Start)) return false; + if(partition.End <= 16 + partition.Start) return false; // Read to Volume Descriptor byte[] vd_sector = imagePlugin.ReadSector(16 + partition.Start); @@ -389,7 +389,7 @@ namespace DiscImageChef.Filesystems.ISO9660 ziso |= nextSignature == ziso_Magic; Amiga |= nextSignature == Amiga_Magic; AAIP |= nextSignature == AAIP_Magic || - (nextSignature == AAIP_OldMagic && sa[sa_off + 3] == 1 && sa[sa_off + 2] >= 9); + nextSignature == AAIP_OldMagic && sa[sa_off + 3] == 1 && sa[sa_off + 2] >= 9; sa_off += sa[sa_off + 2]; @@ -446,7 +446,7 @@ namespace DiscImageChef.Filesystems.ISO9660 ziso |= nextSignature == ziso_Magic; Amiga |= nextSignature == Amiga_Magic; AAIP |= nextSignature == AAIP_Magic || - (nextSignature == AAIP_OldMagic && ca_data[ca_off + 3] == 1 && ca_data[ca_off + 2] >= 9); + nextSignature == AAIP_OldMagic && ca_data[ca_off + 3] == 1 && ca_data[ca_off + 2] >= 9; ca_off += ca_data[ca_off + 2]; } diff --git a/DiscImageChef.Filesystems/LisaFS/Dir.cs b/DiscImageChef.Filesystems/LisaFS/Dir.cs index 5a5f4529..9651e0ab 100644 --- a/DiscImageChef.Filesystems/LisaFS/Dir.cs +++ b/DiscImageChef.Filesystems/LisaFS/Dir.cs @@ -227,7 +227,7 @@ namespace DiscImageChef.Filesystems.LisaFS int offset = 0; // Traverse all entries - while((offset + 64) <= buf.Length) + while(offset + 64 <= buf.Length) { // Catalog block header if(buf[offset + 0x24] == 0x08) offset += 78; diff --git a/DiscImageChef.Filesystems/LisaFS/Extent.cs b/DiscImageChef.Filesystems/LisaFS/Extent.cs index 1e36599e..84f0373c 100644 --- a/DiscImageChef.Filesystems/LisaFS/Extent.cs +++ b/DiscImageChef.Filesystems/LisaFS/Extent.cs @@ -57,7 +57,7 @@ namespace DiscImageChef.Filesystems.LisaFS if(!mounted) return Errno.AccessDenied; - if(fileId < 4 || (fileId == 4 && (mddf.fsversion != LisaFSv2 && mddf.fsversion != LisaFSv1))) + if(fileId < 4 || fileId == 4 && mddf.fsversion != LisaFSv2 && mddf.fsversion != LisaFSv1) return Errno.InvalidArgument; if(extentCache.TryGetValue(fileId, out file)) return Errno.NoError; @@ -98,7 +98,7 @@ namespace DiscImageChef.Filesystems.LisaFS // Checks that the sector tag indicates its the Extents File we are searching for DecodeTag(device.ReadSectorTag(ptr, SectorTagType.AppleSectorTag), out extTag); - if(extTag.fileID == ((short)(-1 * fileId))) + if(extTag.fileID == (short)(-1 * fileId)) { byte[] sector; diff --git a/DiscImageChef.Filesystems/LisaFS/File.cs b/DiscImageChef.Filesystems/LisaFS/File.cs index 3573a21e..459a31d2 100644 --- a/DiscImageChef.Filesystems/LisaFS/File.cs +++ b/DiscImageChef.Filesystems/LisaFS/File.cs @@ -348,7 +348,7 @@ namespace DiscImageChef.Filesystems.LisaFS tags &= debug; - if(fileId < 4 || (fileId == 4 && (mddf.fsversion != LisaFSv2 && mddf.fsversion != LisaFSv1))) + if(fileId < 4 || fileId == 4 && mddf.fsversion != LisaFSv2 && mddf.fsversion != LisaFSv1) return Errno.InvalidArgument; if(!tags && fileCache.TryGetValue(fileId, out buf)) return Errno.NoError; @@ -371,10 +371,10 @@ namespace DiscImageChef.Filesystems.LisaFS byte[] sector; if(!tags) - sector = device.ReadSectors(((ulong)file.extents[i].start + mddf.mddf_block + volumePrefix), + sector = device.ReadSectors((ulong)file.extents[i].start + mddf.mddf_block + volumePrefix, (uint)file.extents[i].length); else - sector = device.ReadSectorsTag(((ulong)file.extents[i].start + mddf.mddf_block + volumePrefix), + sector = device.ReadSectorsTag((ulong)file.extents[i].start + mddf.mddf_block + volumePrefix, (uint)file.extents[i].length, SectorTagType.AppleSectorTag); Array.Copy(sector, 0, temp, offset, sector.Length); diff --git a/DiscImageChef.Filesystems/Locus.cs b/DiscImageChef.Filesystems/Locus.cs index 578b12d9..2c431d86 100644 --- a/DiscImageChef.Filesystems/Locus.cs +++ b/DiscImageChef.Filesystems/Locus.cs @@ -221,8 +221,8 @@ namespace DiscImageChef.Filesystems { Locus_Superblock LocusSb = new Locus_Superblock(); - uint sbSize = (uint)((Marshal.SizeOf(LocusSb)) / imagePlugin.GetSectorSize()); - if((Marshal.SizeOf(LocusSb)) % imagePlugin.GetSectorSize() != 0) sbSize++; + uint sbSize = (uint)(Marshal.SizeOf(LocusSb) / imagePlugin.GetSectorSize()); + if(Marshal.SizeOf(LocusSb) % imagePlugin.GetSectorSize() != 0) sbSize++; if(partition.Start + location + sbSize >= imagePlugin.GetSectors()) break; @@ -254,8 +254,8 @@ namespace DiscImageChef.Filesystems for(ulong location = 0; location <= 8; location++) { - uint sbSize = (uint)((Marshal.SizeOf(LocusSb)) / imagePlugin.GetSectorSize()); - if((Marshal.SizeOf(LocusSb)) % imagePlugin.GetSectorSize() != 0) sbSize++; + uint sbSize = (uint)(Marshal.SizeOf(LocusSb) / imagePlugin.GetSectorSize()); + if(Marshal.SizeOf(LocusSb) % imagePlugin.GetSectorSize() != 0) sbSize++; sector = imagePlugin.ReadSectors(partition.Start + location, sbSize); if(sector.Length < Marshal.SizeOf(LocusSb)) return; diff --git a/DiscImageChef.Filesystems/MicroDOS.cs b/DiscImageChef.Filesystems/MicroDOS.cs index b3c4ac13..8968d3c1 100644 --- a/DiscImageChef.Filesystems/MicroDOS.cs +++ b/DiscImageChef.Filesystems/MicroDOS.cs @@ -70,7 +70,7 @@ namespace DiscImageChef.Filesystems public override bool Identify(DiscImages.ImagePlugin imagePlugin, Partition partition) { - if((1 + partition.Start) >= partition.End) return false; + if(1 + partition.Start >= partition.End) return false; if(imagePlugin.GetSectorSize() < 512) return false; diff --git a/DiscImageChef.Filesystems/MinixFS.cs b/DiscImageChef.Filesystems/MinixFS.cs index ba44c5b9..8601255c 100644 --- a/DiscImageChef.Filesystems/MinixFS.cs +++ b/DiscImageChef.Filesystems/MinixFS.cs @@ -97,7 +97,7 @@ namespace DiscImageChef.Filesystems offset = 0x400; } - if((sector + partition.Start) >= partition.End) return false; + if(sector + partition.Start >= partition.End) return false; ushort magic; byte[] minix_sb_sector = imagePlugin.ReadSector(sector + partition.Start); @@ -164,7 +164,7 @@ namespace DiscImageChef.Filesystems magic == MINIX_MAGIC || magic == MINIX_CIGAM) { filenamesize = 60; - littleEndian = (magic != MINIX3_CIGAM || magic == MINIX2_CIGAM || magic == MINIX_CIGAM); + littleEndian = magic != MINIX3_CIGAM || magic == MINIX2_CIGAM || magic == MINIX_CIGAM; if(magic == MINIX3_MAGIC || magic == MINIX3_CIGAM) { diff --git a/DiscImageChef.Filesystems/NTFS.cs b/DiscImageChef.Filesystems/NTFS.cs index 6c8fc2fc..fd53b5a9 100644 --- a/DiscImageChef.Filesystems/NTFS.cs +++ b/DiscImageChef.Filesystems/NTFS.cs @@ -65,7 +65,7 @@ namespace DiscImageChef.Filesystems public override bool Identify(DiscImages.ImagePlugin imagePlugin, Partition partition) { - if((2 + partition.Start) >= partition.End) return false; + if(2 + partition.Start >= partition.End) return false; byte[] eigth_bytes = new byte[8]; byte fats_no; diff --git a/DiscImageChef.Filesystems/Nintendo.cs b/DiscImageChef.Filesystems/Nintendo.cs index b48728e8..d87908dd 100644 --- a/DiscImageChef.Filesystems/Nintendo.cs +++ b/DiscImageChef.Filesystems/Nintendo.cs @@ -67,11 +67,11 @@ namespace DiscImageChef.Filesystems { if(partition.Start != 0) return false; - if((imagePlugin.GetSectors() * imagePlugin.GetSectorSize()) < 0x50000) return false; + if(imagePlugin.GetSectors() * imagePlugin.GetSectorSize() < 0x50000) return false; BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian; - byte[] header = imagePlugin.ReadSectors(0, (0x50000 / imagePlugin.GetSectorSize())); + byte[] header = imagePlugin.ReadSectors(0, 0x50000 / imagePlugin.GetSectorSize()); uint magicGC = BigEndianBitConverter.ToUInt32(header, 0x1C); uint magicWii = BigEndianBitConverter.ToUInt32(header, 0x18); @@ -91,7 +91,7 @@ namespace DiscImageChef.Filesystems NintendoFields fields = new NintendoFields(); BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian; - byte[] header = imagePlugin.ReadSectors(0, (0x50000 / imagePlugin.GetSectorSize())); + byte[] header = imagePlugin.ReadSectors(0, 0x50000 / imagePlugin.GetSectorSize()); bool wii = false; @@ -140,7 +140,7 @@ namespace DiscImageChef.Filesystems for(int i = 0; i < fields.firstPartitions.Length; i++) { - if((offset1 + i * 8 + 8) < 0x50000) + if(offset1 + i * 8 + 8 < 0x50000) { fields.firstPartitions[i].offset = BigEndianBitConverter.ToUInt32(header, (int)(offset1 + i * 8 + 0)) << 2; @@ -151,7 +151,7 @@ namespace DiscImageChef.Filesystems for(int i = 0; i < fields.secondPartitions.Length; i++) { - if((offset1 + i * 8 + 8) < 0x50000) + if(offset1 + i * 8 + 8 < 0x50000) { fields.firstPartitions[i].offset = BigEndianBitConverter.ToUInt32(header, (int)(offset2 + i * 8 + 0)) << 2; @@ -162,7 +162,7 @@ namespace DiscImageChef.Filesystems for(int i = 0; i < fields.thirdPartitions.Length; i++) { - if((offset1 + i * 8 + 8) < 0x50000) + if(offset1 + i * 8 + 8 < 0x50000) { fields.firstPartitions[i].offset = BigEndianBitConverter.ToUInt32(header, (int)(offset3 + i * 8 + 0)) << 2; @@ -173,7 +173,7 @@ namespace DiscImageChef.Filesystems for(int i = 0; i < fields.fourthPartitions.Length; i++) { - if((offset1 + i * 8 + 8) < 0x50000) + if(offset1 + i * 8 + 8 < 0x50000) { fields.firstPartitions[i].offset = BigEndianBitConverter.ToUInt32(header, (int)(offset4 + i * 8 + 0)) << 2; @@ -317,7 +317,7 @@ namespace DiscImageChef.Filesystems information = sbInformation.ToString(); xmlFSType.Bootable = true; - xmlFSType.Clusters = (long)((imagePlugin.GetSectors() * imagePlugin.GetSectorSize()) / 2048); + xmlFSType.Clusters = (long)(imagePlugin.GetSectors() * imagePlugin.GetSectorSize() / 2048); xmlFSType.ClusterSize = 2048; if(wii) xmlFSType.Type = "Nintendo Wii filesystem"; else xmlFSType.Type = "Nintendo Gamecube filesystem"; diff --git a/DiscImageChef.Filesystems/ODS.cs b/DiscImageChef.Filesystems/ODS.cs index d9df0d1e..25eacdc1 100644 --- a/DiscImageChef.Filesystems/ODS.cs +++ b/DiscImageChef.Filesystems/ODS.cs @@ -75,7 +75,7 @@ namespace DiscImageChef.Filesystems public override bool Identify(DiscImages.ImagePlugin imagePlugin, Partition partition) { - if((2 + partition.Start) >= partition.End) return false; + if(2 + partition.Start >= partition.End) return false; if(imagePlugin.GetSectorSize() < 512) return false; @@ -247,7 +247,7 @@ namespace DiscImageChef.Filesystems { Type = "FILES-11", ClusterSize = homeblock.cluster * 512, - Clusters = (long)(partition.Size) / (homeblock.cluster * 512), + Clusters = (long)partition.Size / (homeblock.cluster * 512), VolumeName = StringHandlers.SpacePaddedToString(homeblock.volname, CurrentEncoding), VolumeSerial = string.Format("{0:X8}", homeblock.serialnum) }; diff --git a/DiscImageChef.Filesystems/Opera.cs b/DiscImageChef.Filesystems/Opera.cs index a91546f9..2e93f834 100644 --- a/DiscImageChef.Filesystems/Opera.cs +++ b/DiscImageChef.Filesystems/Opera.cs @@ -65,7 +65,7 @@ namespace DiscImageChef.Filesystems public override bool Identify(DiscImages.ImagePlugin imagePlugin, Partition partition) { - if((2 + partition.Start) >= partition.End) return false; + if(2 + partition.Start >= partition.End) return false; byte[] sb_sector = imagePlugin.ReadSector(0 + partition.Start); diff --git a/DiscImageChef.Filesystems/PCEngine.cs b/DiscImageChef.Filesystems/PCEngine.cs index 25216273..a91a1faf 100644 --- a/DiscImageChef.Filesystems/PCEngine.cs +++ b/DiscImageChef.Filesystems/PCEngine.cs @@ -64,7 +64,7 @@ namespace DiscImageChef.Filesystems public override bool Identify(DiscImages.ImagePlugin imagePlugin, Partition partition) { - if((2 + partition.Start) >= partition.End) return false; + if(2 + partition.Start >= partition.End) return false; byte[] system_descriptor = new byte[23]; byte[] sector = imagePlugin.ReadSector(1 + partition.Start); diff --git a/DiscImageChef.Filesystems/ProDOS.cs b/DiscImageChef.Filesystems/ProDOS.cs index c09aee28..129d9ad8 100644 --- a/DiscImageChef.Filesystems/ProDOS.cs +++ b/DiscImageChef.Filesystems/ProDOS.cs @@ -152,8 +152,8 @@ namespace DiscImageChef.Filesystems if(APMFromHDDOnCD) total_blocks /= 4; DicConsole.DebugWriteLine("ProDOS plugin", "{0} <= ({1} - {2} + 1)? {3}", total_blocks, partition.End, - partition.Start, total_blocks <= (partition.End - partition.Start + 1)); - return total_blocks <= (partition.End - partition.Start + 1); + partition.Start, total_blocks <= partition.End - partition.Start + 1); + return total_blocks <= partition.End - partition.Start + 1; } public override void GetInformation(DiscImages.ImagePlugin imagePlugin, Partition partition, @@ -305,7 +305,7 @@ namespace DiscImageChef.Filesystems xmlFSType.Files = rootDirectoryKeyBlock.header.file_count; xmlFSType.FilesSpecified = true; xmlFSType.Clusters = rootDirectoryKeyBlock.header.total_blocks; - xmlFSType.ClusterSize = (int)(((partition.End - partition.Start) + 1) * imagePlugin.ImageInfo.SectorSize / + xmlFSType.ClusterSize = (int)((partition.End - partition.Start + 1) * imagePlugin.ImageInfo.SectorSize / (ulong)xmlFSType.Clusters); xmlFSType.Type = "ProDOS"; diff --git a/DiscImageChef.Filesystems/QNX4.cs b/DiscImageChef.Filesystems/QNX4.cs index 5f9679d6..049365c5 100644 --- a/DiscImageChef.Filesystems/QNX4.cs +++ b/DiscImageChef.Filesystems/QNX4.cs @@ -261,7 +261,7 @@ namespace DiscImageChef.Filesystems ModificationDate = DateHandlers.UNIXUnsignedToDateTime(qnxSb.rootDir.di_mtime), ModificationDateSpecified = true }; - xmlFSType.Bootable |= (qnxSb.boot.di_size != 0 || qnxSb.altBoot.di_size != 0); + xmlFSType.Bootable |= qnxSb.boot.di_size != 0 || qnxSb.altBoot.di_size != 0; } public override Errno Mount() diff --git a/DiscImageChef.Filesystems/RT11.cs b/DiscImageChef.Filesystems/RT11.cs index 12869fac..105fb894 100644 --- a/DiscImageChef.Filesystems/RT11.cs +++ b/DiscImageChef.Filesystems/RT11.cs @@ -67,7 +67,7 @@ namespace DiscImageChef.Filesystems public override bool Identify(DiscImages.ImagePlugin imagePlugin, Partition partition) { - if((1 + partition.Start) >= partition.End) return false; + if(1 + partition.Start >= partition.End) return false; if(imagePlugin.GetSectorSize() < 512) return false; diff --git a/DiscImageChef.Filesystems/Reiser4.cs b/DiscImageChef.Filesystems/Reiser4.cs index e9682393..30a8b417 100644 --- a/DiscImageChef.Filesystems/Reiser4.cs +++ b/DiscImageChef.Filesystems/Reiser4.cs @@ -141,7 +141,7 @@ namespace DiscImageChef.Filesystems xmlFSType.Type = "Reiser 4 filesystem"; xmlFSType.ClusterSize = reiserSb.blocksize; xmlFSType.Clusters = - (long)(((partition.End - partition.Start) * imagePlugin.GetSectorSize()) / reiserSb.blocksize); + (long)((partition.End - partition.Start) * imagePlugin.GetSectorSize() / reiserSb.blocksize); xmlFSType.VolumeName = StringHandlers.CToString(reiserSb.label, CurrentEncoding); xmlFSType.VolumeSerial = reiserSb.uuid.ToString(); } diff --git a/DiscImageChef.Filesystems/SolarFS.cs b/DiscImageChef.Filesystems/SolarFS.cs index d0d33d99..f3b37e65 100644 --- a/DiscImageChef.Filesystems/SolarFS.cs +++ b/DiscImageChef.Filesystems/SolarFS.cs @@ -66,7 +66,7 @@ namespace DiscImageChef.Filesystems public override bool Identify(DiscImages.ImagePlugin imagePlugin, Partition partition) { - if((2 + partition.Start) >= partition.End) return false; + if(2 + partition.Start >= partition.End) return false; byte signature; /// 0x29 string fs_type; // "SOL_FS " diff --git a/DiscImageChef.Filesystems/Squash.cs b/DiscImageChef.Filesystems/Squash.cs index e761817d..56a684ab 100644 --- a/DiscImageChef.Filesystems/Squash.cs +++ b/DiscImageChef.Filesystems/Squash.cs @@ -179,7 +179,7 @@ namespace DiscImageChef.Filesystems xmlFSType.Type = "Squash file system"; xmlFSType.CreationDate = DateHandlers.UNIXUnsignedToDateTime(sqSb.mkfs_time); xmlFSType.CreationDateSpecified = true; - xmlFSType.Clusters = (long)(((partition.End - partition.Start + 1) * imagePlugin.ImageInfo.SectorSize) / + xmlFSType.Clusters = (long)((partition.End - partition.Start + 1) * imagePlugin.ImageInfo.SectorSize / sqSb.block_size); xmlFSType.ClusterSize = (int)sqSb.block_size; xmlFSType.Files = sqSb.inodes; diff --git a/DiscImageChef.Filesystems/SysV.cs b/DiscImageChef.Filesystems/SysV.cs index 0613f317..68b22fac 100644 --- a/DiscImageChef.Filesystems/SysV.cs +++ b/DiscImageChef.Filesystems/SysV.cs @@ -83,7 +83,7 @@ namespace DiscImageChef.Filesystems public override bool Identify(DiscImages.ImagePlugin imagePlugin, Partition partition) { - if((2 + partition.Start) >= partition.End) return false; + if(2 + partition.Start >= partition.End) return false; uint magic; string s_fname, s_fpack; @@ -117,7 +117,7 @@ namespace DiscImageChef.Filesystems sb_size_in_sectors = (byte)(0x400 / imagePlugin.GetSectorSize()); else sb_size_in_sectors = 1; // If not a single sector can store it - if(partition.End <= (partition.Start + 4 * (ulong)sb_size_in_sectors + sb_size_in_sectors) + if(partition.End <= partition.Start + 4 * (ulong)sb_size_in_sectors + sb_size_in_sectors ) // Device must be bigger than SB location + SB size + offset return false; @@ -157,8 +157,8 @@ namespace DiscImageChef.Filesystems Array.Copy(sb_sector, 0x1EA, coherent_string, 0, 6); // Coherent UNIX s_fpack location s_fpack = StringHandlers.CToString(coherent_string, CurrentEncoding); - if((s_fname == COH_FNAME && s_fpack == COH_FPACK) || (s_fname == COH_XXXXX && s_fpack == COH_XXXXX) || - (s_fname == COH_XXXXS && s_fpack == COH_XXXXN)) return true; + if(s_fname == COH_FNAME && s_fpack == COH_FPACK || s_fname == COH_XXXXX && s_fpack == COH_XXXXX || + s_fname == COH_XXXXS && s_fpack == COH_XXXXN) return true; // Now try to identify 7th edition s_fsize = BitConverter.ToUInt32(sb_sector, 0x002); // 7th edition's s_fsize @@ -181,8 +181,8 @@ namespace DiscImageChef.Filesystems { if(s_fsize < V7_MAXSIZE && s_nfree < V7_NICFREE && s_ninode < V7_NICINOD) { - if((s_fsize * 1024) == ((partition.End - partition.Start) * imagePlugin.GetSectorSize()) || - (s_fsize * 512) == ((partition.End - partition.Start) * imagePlugin.GetSectorSize())) + if(s_fsize * 1024 == (partition.End - partition.Start) * imagePlugin.GetSectorSize() || + s_fsize * 512 == (partition.End - partition.Start) * imagePlugin.GetSectorSize()) return true; } } @@ -303,8 +303,8 @@ namespace DiscImageChef.Filesystems Array.Copy(sb_sector, 0x1EA, coherent_string, 0, 6); // Coherent UNIX s_fpack location s_fpack = StringHandlers.CToString(coherent_string, CurrentEncoding); - if((s_fname == COH_FNAME && s_fpack == COH_FPACK) || (s_fname == COH_XXXXX && s_fpack == COH_XXXXX) || - (s_fname == COH_XXXXS && s_fpack == COH_XXXXN)) + if(s_fname == COH_FNAME && s_fpack == COH_FPACK || s_fname == COH_XXXXX && s_fpack == COH_XXXXX || + s_fname == COH_XXXXS && s_fpack == COH_XXXXN) { BigEndianBitConverter.IsLittleEndian = true; // Coherent is in PDP endianness, use helper for that coherent = true; @@ -333,8 +333,8 @@ namespace DiscImageChef.Filesystems { if(s_fsize < V7_MAXSIZE && s_nfree < V7_NICFREE && s_ninode < V7_NICINOD) { - if((s_fsize * 1024) == ((partition.End - partition.Start) * imagePlugin.GetSectorSize()) || - (s_fsize * 512) == ((partition.End - partition.Start) * imagePlugin.GetSectorSize())) + if(s_fsize * 1024 == (partition.End - partition.Start) * imagePlugin.GetSectorSize() || + s_fsize * 512 == (partition.End - partition.Start) * imagePlugin.GetSectorSize()) { sys7th = true; BigEndianBitConverter.IsLittleEndian = true; @@ -591,7 +591,7 @@ namespace DiscImageChef.Filesystems sb.AppendFormat("Volume name: {0}", sysv_sb.s_fname).AppendLine(); xmlFSType.VolumeName = sysv_sb.s_fname; sb.AppendFormat("Pack name: {0}", sysv_sb.s_fpack).AppendLine(); - if(sysv_sb.s_state == (0x7C269D38 - sysv_sb.s_time)) sb.AppendLine("Volume is clean"); + if(sysv_sb.s_state == 0x7C269D38 - sysv_sb.s_time) sb.AppendLine("Volume is clean"); else { sb.AppendLine("Volume is dirty"); diff --git a/DiscImageChef.Filesystems/UCSDPascal/File.cs b/DiscImageChef.Filesystems/UCSDPascal/File.cs index 3af65303..42146f59 100644 --- a/DiscImageChef.Filesystems/UCSDPascal/File.cs +++ b/DiscImageChef.Filesystems/UCSDPascal/File.cs @@ -129,12 +129,12 @@ namespace DiscImageChef.Filesystems.UCSDPascal if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0) { - stat.Blocks = (catalogBlocks.Length / stat.BlockSize) + (catalogBlocks.Length % stat.BlockSize); + stat.Blocks = catalogBlocks.Length / stat.BlockSize + catalogBlocks.Length % stat.BlockSize; stat.Length = catalogBlocks.Length; } else { - stat.Blocks = (bootBlocks.Length / stat.BlockSize) + (catalogBlocks.Length % stat.BlockSize); + stat.Blocks = bootBlocks.Length / stat.BlockSize + catalogBlocks.Length % stat.BlockSize; stat.Length = bootBlocks.Length; } diff --git a/DiscImageChef.Filesystems/UCSDPascal/Super.cs b/DiscImageChef.Filesystems/UCSDPascal/Super.cs index 8bd1ae6d..eda1fe67 100644 --- a/DiscImageChef.Filesystems/UCSDPascal/Super.cs +++ b/DiscImageChef.Filesystems/UCSDPascal/Super.cs @@ -66,8 +66,8 @@ namespace DiscImageChef.Filesystems.UCSDPascal if(mountedVolEntry.firstBlock != 0 || mountedVolEntry.lastBlock <= mountedVolEntry.firstBlock || (ulong)mountedVolEntry.lastBlock > device.GetSectors() - 2 || - (mountedVolEntry.entryType != PascalFileKind.Volume && - mountedVolEntry.entryType != PascalFileKind.Secure) || mountedVolEntry.volumeName[0] > 7 || + mountedVolEntry.entryType != PascalFileKind.Volume && + mountedVolEntry.entryType != PascalFileKind.Secure || mountedVolEntry.volumeName[0] > 7 || mountedVolEntry.blocks < 0 || (ulong)mountedVolEntry.blocks != device.GetSectors() || mountedVolEntry.files < 0) return Errno.InvalidArgument; @@ -125,7 +125,7 @@ namespace DiscImageChef.Filesystems.UCSDPascal stat.Type = "UCSD Pascal"; stat.FreeBlocks = mountedVolEntry.blocks - (mountedVolEntry.lastBlock - mountedVolEntry.firstBlock); - foreach(PascalFileEntry entry in fileEntries) stat.FreeBlocks -= (entry.lastBlock - entry.firstBlock); + foreach(PascalFileEntry entry in fileEntries) stat.FreeBlocks -= entry.lastBlock - entry.firstBlock; return Errno.NotImplemented; } diff --git a/DiscImageChef.Filesystems/UDF.cs b/DiscImageChef.Filesystems/UDF.cs index b46737bc..02e4eaab 100644 --- a/DiscImageChef.Filesystems/UDF.cs +++ b/DiscImageChef.Filesystems/UDF.cs @@ -280,7 +280,7 @@ namespace DiscImageChef.Filesystems if(anchor.tag.tagIdentifier == TagIdentifier.AnchorVolumeDescriptorPointer && anchor.tag.tagLocation == position && - (anchor.mainVolumeDescriptorSequenceExtent.location + partition.Start) < partition.End) + anchor.mainVolumeDescriptorSequenceExtent.location + partition.Start < partition.End) { anchorFound = true; break; @@ -347,7 +347,7 @@ namespace DiscImageChef.Filesystems if(anchor.tag.tagIdentifier == TagIdentifier.AnchorVolumeDescriptorPointer && anchor.tag.tagLocation == position && - (anchor.mainVolumeDescriptorSequenceExtent.location + partition.Start) < partition.End) break; + anchor.mainVolumeDescriptorSequenceExtent.location + partition.Start < partition.End) break; } ulong count = 0; @@ -457,7 +457,7 @@ namespace DiscImageChef.Filesystems xmlFSType.ApplicationIdentifier = CurrentEncoding .GetString(pvd.implementationIdentifier.identifier).TrimEnd(new char[] {'\u0000'}); xmlFSType.ClusterSize = (int)lvd.logicalBlockSize; - xmlFSType.Clusters = (long)(((partition.End - partition.Start + 1) * imagePlugin.ImageInfo.SectorSize) / + xmlFSType.Clusters = (long)((partition.End - partition.Start + 1) * imagePlugin.ImageInfo.SectorSize / (ulong)xmlFSType.ClusterSize); xmlFSType.ModificationDate = ECMAToDateTime(lvid.recordingDateTime); xmlFSType.ModificationDateSpecified = true; diff --git a/DiscImageChef.Filesystems/UNICOS.cs b/DiscImageChef.Filesystems/UNICOS.cs index 187bcd57..50d2af0f 100644 --- a/DiscImageChef.Filesystems/UNICOS.cs +++ b/DiscImageChef.Filesystems/UNICOS.cs @@ -161,8 +161,8 @@ namespace DiscImageChef.Filesystems UNICOS_Superblock unicosSb = new UNICOS_Superblock(); - uint sbSize = (uint)((Marshal.SizeOf(unicosSb)) / imagePlugin.GetSectorSize()); - if((Marshal.SizeOf(unicosSb)) % imagePlugin.GetSectorSize() != 0) sbSize++; + uint sbSize = (uint)(Marshal.SizeOf(unicosSb) / imagePlugin.GetSectorSize()); + if(Marshal.SizeOf(unicosSb) % imagePlugin.GetSectorSize() != 0) sbSize++; byte[] sector = imagePlugin.ReadSectors(partition.Start, sbSize); if(sector.Length < Marshal.SizeOf(unicosSb)) return false; @@ -183,8 +183,8 @@ namespace DiscImageChef.Filesystems UNICOS_Superblock unicosSb = new UNICOS_Superblock(); - uint sbSize = (uint)((Marshal.SizeOf(unicosSb)) / imagePlugin.GetSectorSize()); - if((Marshal.SizeOf(unicosSb)) % imagePlugin.GetSectorSize() != 0) sbSize++; + uint sbSize = (uint)(Marshal.SizeOf(unicosSb) / imagePlugin.GetSectorSize()); + if(Marshal.SizeOf(unicosSb) % imagePlugin.GetSectorSize() != 0) sbSize++; byte[] sector = imagePlugin.ReadSectors(partition.Start, sbSize); if(sector.Length < Marshal.SizeOf(unicosSb)) return; diff --git a/DiscImageChef.Filesystems/UNIXBFS.cs b/DiscImageChef.Filesystems/UNIXBFS.cs index 4b1957e6..a0026b89 100644 --- a/DiscImageChef.Filesystems/UNIXBFS.cs +++ b/DiscImageChef.Filesystems/UNIXBFS.cs @@ -68,7 +68,7 @@ namespace DiscImageChef.Filesystems public override bool Identify(DiscImages.ImagePlugin imagePlugin, Partition partition) { - if((2 + partition.Start) >= partition.End) return false; + if(2 + partition.Start >= partition.End) return false; uint magic; diff --git a/DiscImageChef.Filesystems/ZFS.cs b/DiscImageChef.Filesystems/ZFS.cs index 134245be..9c32b483 100644 --- a/DiscImageChef.Filesystems/ZFS.cs +++ b/DiscImageChef.Filesystems/ZFS.cs @@ -359,7 +359,7 @@ namespace DiscImageChef.Filesystems offset += 4; nameLength = BigEndianBitConverter.ToUInt32(nvlist, offset); offset += 4; - if(nameLength % 4 > 0) nameLength += 4 - (nameLength % 4); + if(nameLength % 4 > 0) nameLength += 4 - nameLength % 4; nameBytes = new byte[nameLength]; Array.Copy(nvlist, offset, nameBytes, 0, nameLength); item.name = StringHandlers.CToString(nameBytes); @@ -395,7 +395,7 @@ namespace DiscImageChef.Filesystems else { uint temp = BigEndianBitConverter.ToUInt32(nvlist, offset); - item.value = (temp > 0); + item.value = temp > 0; offset += 4; } diff --git a/DiscImageChef.Filesystems/dump.cs b/DiscImageChef.Filesystems/dump.cs index 23fe7c30..b99e772f 100644 --- a/DiscImageChef.Filesystems/dump.cs +++ b/DiscImageChef.Filesystems/dump.cs @@ -240,8 +240,8 @@ namespace DiscImageChef.Filesystems spcl_aix aixHdr = new spcl_aix(); s_spcl newHdr = new s_spcl(); - uint sbSize = (uint)((Marshal.SizeOf(newHdr)) / imagePlugin.GetSectorSize()); - if((Marshal.SizeOf(newHdr)) % imagePlugin.GetSectorSize() != 0) sbSize++; + uint sbSize = (uint)(Marshal.SizeOf(newHdr) / imagePlugin.GetSectorSize()); + if(Marshal.SizeOf(newHdr) % imagePlugin.GetSectorSize() != 0) sbSize++; byte[] sector = imagePlugin.ReadSectors(partition.Start, sbSize); if(sector.Length < Marshal.SizeOf(newHdr)) return false; @@ -282,8 +282,8 @@ namespace DiscImageChef.Filesystems spcl_aix aixHdr = new spcl_aix(); s_spcl newHdr = new s_spcl(); - uint sbSize = (uint)((Marshal.SizeOf(newHdr)) / imagePlugin.GetSectorSize()); - if((Marshal.SizeOf(newHdr)) % imagePlugin.GetSectorSize() != 0) sbSize++; + uint sbSize = (uint)(Marshal.SizeOf(newHdr) / imagePlugin.GetSectorSize()); + if(Marshal.SizeOf(newHdr) % imagePlugin.GetSectorSize() != 0) sbSize++; byte[] sector = imagePlugin.ReadSectors(partition.Start, sbSize); if(sector.Length < Marshal.SizeOf(newHdr)) return; diff --git a/DiscImageChef.Filesystems/exFAT.cs b/DiscImageChef.Filesystems/exFAT.cs index bcd2649a..486278a5 100644 --- a/DiscImageChef.Filesystems/exFAT.cs +++ b/DiscImageChef.Filesystems/exFAT.cs @@ -68,7 +68,7 @@ namespace DiscImageChef.Filesystems public override bool Identify(ImagePlugin imagePlugin, Partition partition) { - if((12 + partition.Start) >= partition.End) return false; + if(12 + partition.Start >= partition.End) return false; byte[] vbrSector = imagePlugin.ReadSector(0 + partition.Start); if(vbrSector.Length < 512) return false; @@ -122,7 +122,7 @@ namespace DiscImageChef.Filesystems sb.AppendFormat("Cluster heap starts at sector {0}, contains {1} clusters and is {2}% used", vbr.clusterHeapOffset, vbr.clusterHeapLength, vbr.heapUsage).AppendLine(); sb.AppendFormat("Root directory starts at cluster {0}", vbr.rootDirectoryCluster).AppendLine(); - sb.AppendFormat("Filesystem revision is {0}.{1:D2}", (vbr.revision & 0xFF00) >> 8, (vbr.revision & 0xFF)) + sb.AppendFormat("Filesystem revision is {0}.{1:D2}", (vbr.revision & 0xFF00) >> 8, vbr.revision & 0xFF) .AppendLine(); sb.AppendFormat("Volume serial number: {0:X8}", vbr.volumeSerial).AppendLine(); sb.AppendFormat("BIOS drive is {0:X2}h", vbr.drive).AppendLine(); diff --git a/DiscImageChef.Filesystems/ext2FS.cs b/DiscImageChef.Filesystems/ext2FS.cs index a33af76b..0fa8b01e 100644 --- a/DiscImageChef.Filesystems/ext2FS.cs +++ b/DiscImageChef.Filesystems/ext2FS.cs @@ -71,7 +71,7 @@ namespace DiscImageChef.Filesystems ulong sbSector = sbPos / imagePlugin.GetSectorSize(); uint sbOff = sbPos % imagePlugin.GetSectorSize(); - if((sbSector + partition.Start) >= partition.End) return false; + if(sbSector + partition.Start >= partition.End) return false; int sb_size_in_bytes = Marshal.SizeOf(typeof(ext2FSSuperBlock)); uint sb_size_in_sectors = (uint)(sb_size_in_bytes / imagePlugin.GetSectorSize()); diff --git a/DiscImageChef.Filesystems/extFS.cs b/DiscImageChef.Filesystems/extFS.cs index 82753abf..76d4c0e6 100644 --- a/DiscImageChef.Filesystems/extFS.cs +++ b/DiscImageChef.Filesystems/extFS.cs @@ -72,7 +72,7 @@ namespace DiscImageChef.Filesystems ulong sbSector = sbPos / imagePlugin.GetSectorSize(); uint sbOff = sbPos % imagePlugin.GetSectorSize(); - if((sbSector + partition.Start) >= partition.End) return false; + if(sbSector + partition.Start >= partition.End) return false; byte[] sb_sector = imagePlugin.ReadSector(sbSector + partition.Start); byte[] sb = new byte[512]; @@ -95,7 +95,7 @@ namespace DiscImageChef.Filesystems ulong sbSector = sbPos / imagePlugin.GetSectorSize(); uint sbOff = sbPos % imagePlugin.GetSectorSize(); - if((sbSector + partition.Start) >= partition.End) return; + if(sbSector + partition.Start >= partition.End) return; byte[] sblock = imagePlugin.ReadSector(sbSector + partition.Start); byte[] sb_sector = new byte[512]; diff --git a/DiscImageChef.Filters/MacBinary.cs b/DiscImageChef.Filters/MacBinary.cs index 50141e1a..4cd08058 100644 --- a/DiscImageChef.Filters/MacBinary.cs +++ b/DiscImageChef.Filters/MacBinary.cs @@ -274,10 +274,10 @@ namespace DiscImageChef.Filters Array.Copy(buffer, 0, hdr_b, 0, 128); header = BigEndianMarshal.ByteArrayToStructureBigEndian(hdr_b); - return header.magic == MacBinaryMagic || (header.version == 0 && header.filename[0] > 0 && - header.filename[0] < 64 && header.zero1 == 0 && - header.zero2 == 0 && header.reserved == 0 && - (header.dataLength > 0 || header.resourceLength > 0)); + return header.magic == MacBinaryMagic || header.version == 0 && header.filename[0] > 0 && + header.filename[0] < 64 && header.zero1 == 0 && + header.zero2 == 0 && header.reserved == 0 && + (header.dataLength > 0 || header.resourceLength > 0); } public override bool Identify(Stream stream) @@ -289,10 +289,10 @@ namespace DiscImageChef.Filters stream.Read(hdr_b, 0, 128); header = BigEndianMarshal.ByteArrayToStructureBigEndian(hdr_b); - return header.magic == MacBinaryMagic || (header.version == 0 && header.filename[0] > 0 && - header.filename[0] < 64 && header.zero1 == 0 && - header.zero2 == 0 && header.reserved == 0 && - (header.dataLength > 0 || header.resourceLength > 0)); + return header.magic == MacBinaryMagic || header.version == 0 && header.filename[0] > 0 && + header.filename[0] < 64 && header.zero1 == 0 && + header.zero2 == 0 && header.reserved == 0 && + (header.dataLength > 0 || header.resourceLength > 0); } public override bool Identify(string path) @@ -305,10 +305,10 @@ namespace DiscImageChef.Filters header = BigEndianMarshal.ByteArrayToStructureBigEndian(hdr_b); fstream.Close(); - return header.magic == MacBinaryMagic || (header.version == 0 && header.filename[0] > 0 && - header.filename[0] < 64 && header.zero1 == 0 && - header.zero2 == 0 && header.reserved == 0 && - (header.dataLength > 0 || header.resourceLength > 0)); + return header.magic == MacBinaryMagic || header.version == 0 && header.filename[0] > 0 && + header.filename[0] < 64 && header.zero1 == 0 && + header.zero2 == 0 && header.reserved == 0 && + (header.dataLength > 0 || header.resourceLength > 0); } public override bool IsOpened() diff --git a/DiscImageChef.Filters/PCExchange.cs b/DiscImageChef.Filters/PCExchange.cs index 59c2f232..26ad5f68 100644 --- a/DiscImageChef.Filters/PCExchange.cs +++ b/DiscImageChef.Filters/PCExchange.cs @@ -224,8 +224,8 @@ namespace DiscImageChef.Filters byte[] tmpDosExt_b = new byte[3]; Array.Copy(datEntry.dosName, 0, tmpDosName_b, 0, 8); Array.Copy(datEntry.dosName, 8, tmpDosExt_b, 0, 3); - string dosName = (Encoding.ASCII.GetString(tmpDosName_b).Trim() + "." + - Encoding.ASCII.GetString(tmpDosExt_b).Trim()); + string dosName = Encoding.ASCII.GetString(tmpDosName_b).Trim() + "." + + Encoding.ASCII.GetString(tmpDosExt_b).Trim(); string dosNameLow = dosName.ToLower(CultureInfo.CurrentCulture); if(baseFilename == macName || baseFilename == dosName || baseFilename == dosNameLow) @@ -280,8 +280,8 @@ namespace DiscImageChef.Filters byte[] tmpDosExt_b = new byte[3]; Array.Copy(datEntry.dosName, 0, tmpDosName_b, 0, 8); Array.Copy(datEntry.dosName, 8, tmpDosExt_b, 0, 3); - string dosName = (Encoding.ASCII.GetString(tmpDosName_b).Trim() + "." + - Encoding.ASCII.GetString(tmpDosExt_b).Trim()); + string dosName = Encoding.ASCII.GetString(tmpDosName_b).Trim() + "." + + Encoding.ASCII.GetString(tmpDosExt_b).Trim(); string dosNameLow = dosName.ToLower(CultureInfo.CurrentCulture); if(baseFilename == macName || baseFilename == dosName || baseFilename == dosNameLow) diff --git a/DiscImageChef.Helpers/DateHandlers.cs b/DiscImageChef.Helpers/DateHandlers.cs index 87160d81..a13c5ffd 100644 --- a/DiscImageChef.Helpers/DateHandlers.cs +++ b/DiscImageChef.Helpers/DateHandlers.cs @@ -173,7 +173,7 @@ namespace DiscImageChef { int year = ((dateRecord & 0xFE00) >> 9) + 1900; int day = (dateRecord & 0x01F0) >> 4; - int month = (dateRecord & 0x000F); + int month = dateRecord & 0x000F; DicConsole.DebugWriteLine("UCSDPascalToDateTime handler", "dateRecord = 0x{0:X4}, year = {1}, month = {2}, day = {3}", dateRecord, year, @@ -252,7 +252,7 @@ namespace DiscImageChef public static DateTime OS9ToDateTime(byte[] date) { - if(date == null || (date.Length != 3 && date.Length != 5)) return DateTime.MinValue; + if(date == null || date.Length != 3 && date.Length != 5) return DateTime.MinValue; DateTime os9date; @@ -278,7 +278,7 @@ namespace DiscImageChef { try { - int iyear = ((year >> 4) * 10 + (year & 0xF)); + int iyear = (year >> 4) * 10 + (year & 0xF); int imonth = (month >> 4) * 10 + (month & 0xF); int iday = (day >> 4) * 10 + (day & 0xF); int iminute = (minute >> 4) * 10 + (minute & 0xF); diff --git a/DiscImageChef.Helpers/StringHandlers.cs b/DiscImageChef.Helpers/StringHandlers.cs index 09e42989..c6ccc887 100644 --- a/DiscImageChef.Helpers/StringHandlers.cs +++ b/DiscImageChef.Helpers/StringHandlers.cs @@ -65,7 +65,7 @@ namespace DiscImageChef { if(twoBytes) { - if((i + 1) < CString.Length && CString[i + 1] == 0) + if(i + 1 < CString.Length && CString[i + 1] == 0) { len++; break; diff --git a/DiscImageChef.Interop/DetectOS.cs b/DiscImageChef.Interop/DetectOS.cs index 095d1b7a..d8137a4c 100644 --- a/DiscImageChef.Interop/DetectOS.cs +++ b/DiscImageChef.Interop/DetectOS.cs @@ -83,7 +83,7 @@ namespace DiscImageChef.Interop { if((int)Environment.OSVersion.Platform < 4 || (int)Environment.OSVersion.Platform == 5) { - return (PlatformID)((int)Environment.OSVersion.Platform); + return (PlatformID)(int)Environment.OSVersion.Platform; } utsname unixname; @@ -210,7 +210,7 @@ namespace DiscImageChef.Interop Environment.OSVersion.Version.Minor); case PlatformID.Win32NT: // From Windows 8.1 the reported version is simply falsified... - if((Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Major >= 2) || + if(Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Major >= 2 || Environment.OSVersion.Version.Major > 6) return FileVersionInfo .GetVersionInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), diff --git a/DiscImageChef.Partitions/Acorn.cs b/DiscImageChef.Partitions/Acorn.cs index ee5685fc..25ca10d6 100644 --- a/DiscImageChef.Partitions/Acorn.cs +++ b/DiscImageChef.Partitions/Acorn.cs @@ -79,7 +79,7 @@ namespace DiscImageChef.Partitions Marshal.FreeHGlobal(bbPtr); int checksum = 0; - for(int i = 0; i < 0x1FF; i++) checksum = ((checksum & 0xFF) + (checksum >> 8) + sector[i]); + for(int i = 0; i < 0x1FF; i++) checksum = (checksum & 0xFF) + (checksum >> 8) + sector[i]; int heads = bootBlock.discRecord.heads + ((bootBlock.discRecord.lowsector >> 6) & 1); int secCyl = bootBlock.discRecord.spt * heads; diff --git a/DiscImageChef.Partitions/AppleMap.cs b/DiscImageChef.Partitions/AppleMap.cs index edbb0f8f..5c51ef17 100644 --- a/DiscImageChef.Partitions/AppleMap.cs +++ b/DiscImageChef.Partitions/AppleMap.cs @@ -117,14 +117,14 @@ namespace DiscImageChef.Partitions CommonTypes.Partition part = new CommonTypes.Partition() { Size = (ulong)(ddm.sbMap[i].ddSize * 512), - Length = (ulong)((ddm.sbMap[i].ddSize * 512) / sector_size), + Length = (ulong)(ddm.sbMap[i].ddSize * 512 / sector_size), Sequence = sequence, Offset = ddm.sbMap[i].ddBlock * sector_size, Start = ddm.sbMap[i].ddBlock + sectorOffset, Type = "Apple_Driver" }; - if((ddm.sbMap[i].ddSize * 512) % sector_size > 0) part.Length++; + if(ddm.sbMap[i].ddSize * 512 % sector_size > 0) part.Length++; partitions.Add(part); @@ -163,10 +163,10 @@ namespace DiscImageChef.Partitions CommonTypes.Partition part = new CommonTypes.Partition { Size = old_entry.pdStart * ddm.sbBlockSize, - Length = (old_entry.pdStart * ddm.sbBlockSize) / sector_size, + Length = old_entry.pdStart * ddm.sbBlockSize / sector_size, Sequence = sequence, Offset = old_entry.pdSize * ddm.sbBlockSize, - Start = (old_entry.pdSize * ddm.sbBlockSize) / sector_size, + Start = old_entry.pdSize * ddm.sbBlockSize / sector_size, Scheme = Name }; @@ -200,7 +200,7 @@ namespace DiscImageChef.Partitions entry_size = 512; entry_count = entry.entries; skip_ddm = 512; - sectors_to_read = (((entry_count + 1) * 512) / sector_size) + 1; + sectors_to_read = (entry_count + 1) * 512 / sector_size + 1; } else { @@ -291,8 +291,8 @@ namespace DiscImageChef.Partitions Name = StringHandlers.CToString(entry.name), Offset = entry.start * entry_size, Size = entry.sectors * entry_size, - Start = ((entry.start * entry_size) / sector_size) + sectorOffset, - Length = (entry.sectors * entry_size) / sector_size, + Start = entry.start * entry_size / sector_size + sectorOffset, + Length = entry.sectors * entry_size / sector_size, Scheme = Name }; sb.AppendLine("Partition flags:"); @@ -306,7 +306,7 @@ namespace DiscImageChef.Partitions if(flags.HasFlag(AppleMapFlags.Bootable)) { sb.AppendFormat("First boot sector: {0}", - (entry.first_boot_block * entry_size) / sector_size).AppendLine(); + entry.first_boot_block * entry_size / sector_size).AppendLine(); sb.AppendFormat("Boot is {0} bytes.", entry.boot_size).AppendLine(); sb.AppendFormat("Boot load address: 0x{0:X8}", entry.load_address).AppendLine(); sb.AppendFormat("Boot entry point: 0x{0:X8}", entry.entry_point).AppendLine(); diff --git a/DiscImageChef.Partitions/Atari.cs b/DiscImageChef.Partitions/Atari.cs index 859fa001..8d65b391 100644 --- a/DiscImageChef.Partitions/Atari.cs +++ b/DiscImageChef.Partitions/Atari.cs @@ -109,7 +109,7 @@ namespace DiscImageChef.Partitions DicConsole.DebugWriteLine("Atari partition plugin", "table.icdEntries[{0}].flag = 0x{1:X2}", i, (table.icdEntries[i].type & 0xFF000000) >> 24); DicConsole.DebugWriteLine("Atari partition plugin", "table.icdEntries[{0}].type = 0x{1:X6}", i, - (table.icdEntries[i].type & 0x00FFFFFF)); + table.icdEntries[i].type & 0x00FFFFFF); DicConsole.DebugWriteLine("Atari partition plugin", "table.icdEntries[{0}].start = {1}", i, table.icdEntries[i].start); DicConsole.DebugWriteLine("Atari partition plugin", "table.icdEntries[{0}].length = {1}", i, @@ -123,7 +123,7 @@ namespace DiscImageChef.Partitions DicConsole.DebugWriteLine("Atari partition plugin", "table.entries[{0}].flag = 0x{1:X2}", i, (table.entries[i].type & 0xFF000000) >> 24); DicConsole.DebugWriteLine("Atari partition plugin", "table.entries[{0}].type = 0x{1:X6}", i, - (table.entries[i].type & 0x00FFFFFF)); + table.entries[i].type & 0x00FFFFFF); DicConsole.DebugWriteLine("Atari partition plugin", "table.entries[{0}].start = {1}", i, table.entries[i].start); DicConsole.DebugWriteLine("Atari partition plugin", "table.entries[{0}].length = {1}", i, @@ -148,7 +148,7 @@ namespace DiscImageChef.Partitions if(table.entries[i].start <= imagePlugin.GetSectors()) { - if((table.entries[i].start + table.entries[i].length) > imagePlugin.GetSectors()) + if(table.entries[i].start + table.entries[i].length > imagePlugin.GetSectors()) DicConsole.DebugWriteLine("Atari partition plugin", "WARNING: End of partition goes beyond device size"); @@ -242,7 +242,7 @@ namespace DiscImageChef.Partitions validTable = true; if(extendedTable.entries[j].start <= imagePlugin.GetSectors()) { - if((extendedTable.entries[j].start + extendedTable.entries[j].length) > + if(extendedTable.entries[j].start + extendedTable.entries[j].length > imagePlugin.GetSectors()) DicConsole.DebugWriteLine("Atari partition plugin", "WARNING: End of partition goes beyond device size"); @@ -324,7 +324,7 @@ namespace DiscImageChef.Partitions { if(table.icdEntries[i].start <= imagePlugin.GetSectors()) { - if((table.icdEntries[i].start + table.icdEntries[i].length) > imagePlugin.GetSectors()) + if(table.icdEntries[i].start + table.icdEntries[i].length > imagePlugin.GetSectors()) DicConsole.DebugWriteLine("Atari partition plugin", "WARNING: End of partition goes beyond device size"); diff --git a/DiscImageChef.Partitions/BSD.cs b/DiscImageChef.Partitions/BSD.cs index 96d2db13..7735c48b 100644 --- a/DiscImageChef.Partitions/BSD.cs +++ b/DiscImageChef.Partitions/BSD.cs @@ -80,8 +80,8 @@ namespace DiscImageChef.Partitions DicConsole.DebugWriteLine("BSD plugin", "dl.magic on sector {0} at offset {1} = 0x{2:X8} (expected 0x{3:X8})", location + sectorOffset, offset, dl.d_magic, DISKMAGIC); - if((dl.d_magic == DISKMAGIC && dl.d_magic2 == DISKMAGIC) || - (dl.d_magic == DISKCIGAM && dl.d_magic2 == DISKCIGAM)) + if(dl.d_magic == DISKMAGIC && dl.d_magic2 == DISKMAGIC || + dl.d_magic == DISKCIGAM && dl.d_magic2 == DISKCIGAM) { found = true; break; @@ -143,10 +143,10 @@ namespace DiscImageChef.Partitions dl.d_partitions[i].p_fstype, fsTypeToString(dl.d_partitions[i].p_fstype)); Partition part = new Partition { - Start = ((dl.d_partitions[i].p_offset * dl.d_secsize) / imagePlugin.GetSectorSize()), - Offset = (dl.d_partitions[i].p_offset * dl.d_secsize), - Length = (dl.d_partitions[i].p_size * dl.d_secsize) / imagePlugin.GetSectorSize(), - Size = (dl.d_partitions[i].p_size * dl.d_secsize), + Start = dl.d_partitions[i].p_offset * dl.d_secsize / imagePlugin.GetSectorSize(), + Offset = dl.d_partitions[i].p_offset * dl.d_secsize, + Length = dl.d_partitions[i].p_size * dl.d_secsize / imagePlugin.GetSectorSize(), + Size = dl.d_partitions[i].p_size * dl.d_secsize, Type = fsTypeToString(dl.d_partitions[i].p_fstype), Sequence = counter, Scheme = Name @@ -159,7 +159,7 @@ namespace DiscImageChef.Partitions if(addSectorOffset) { part.Start += sectorOffset; - part.Offset += (sectorOffset * imagePlugin.GetSectorSize()); + part.Offset += sectorOffset * imagePlugin.GetSectorSize(); } DicConsole.DebugWriteLine("BSD plugin", "part.start = {0}", part.Start); DicConsole.DebugWriteLine("BSD plugin", "Adding it..."); diff --git a/DiscImageChef.Partitions/DragonFlyBSD.cs b/DiscImageChef.Partitions/DragonFlyBSD.cs index 5e213585..5346c9c9 100644 --- a/DiscImageChef.Partitions/DragonFlyBSD.cs +++ b/DiscImageChef.Partitions/DragonFlyBSD.cs @@ -73,16 +73,16 @@ namespace DiscImageChef.Partitions { Partition part = new Partition { - Start = (entry.p_boffset / imagePlugin.GetSectorSize()) + sectorOffset, - Offset = entry.p_boffset + (sectorOffset * imagePlugin.GetSectorSize()), + Start = entry.p_boffset / imagePlugin.GetSectorSize() + sectorOffset, + Offset = entry.p_boffset + sectorOffset * imagePlugin.GetSectorSize(), Size = entry.p_bsize, - Length = (entry.p_bsize / imagePlugin.GetSectorSize()), + Length = entry.p_bsize / imagePlugin.GetSectorSize(), Name = entry.p_stor_uuid.ToString(), Sequence = counter, Scheme = Name }; - if((entry.p_bsize % imagePlugin.GetSectorSize()) > 0) part.Length++; + if(entry.p_bsize % imagePlugin.GetSectorSize() > 0) part.Length++; if((BSD.fsType)entry.p_fstype == BSD.fsType.Other) part.Type = entry.p_type_uuid.ToString(); else part.Type = BSD.fsTypeToString((BSD.fsType)entry.p_fstype); diff --git a/DiscImageChef.Partitions/GPT.cs b/DiscImageChef.Partitions/GPT.cs index af7f831f..352f07b0 100644 --- a/DiscImageChef.Partitions/GPT.cs +++ b/DiscImageChef.Partitions/GPT.cs @@ -124,11 +124,11 @@ namespace DiscImageChef.Partitions sectorSize = imagePlugin.GetSectorSize(); } - uint totalEntriesSectors = (hdr.entries * hdr.entriesSize) / imagePlugin.GetSectorSize(); - if((hdr.entries * hdr.entriesSize) % imagePlugin.GetSectorSize() > 0) totalEntriesSectors++; + uint totalEntriesSectors = hdr.entries * hdr.entriesSize / imagePlugin.GetSectorSize(); + if(hdr.entries * hdr.entriesSize % imagePlugin.GetSectorSize() > 0) totalEntriesSectors++; byte[] temp = imagePlugin.ReadSectors(hdr.entryLBA / divisor, totalEntriesSectors + modulo); - byte[] entriesBytes = new byte[temp.Length - (modulo * 512)]; + byte[] entriesBytes = new byte[temp.Length - modulo * 512]; Array.Copy(temp, modulo * 512, entriesBytes, 0, entriesBytes.Length); List entries = new List(); @@ -163,8 +163,8 @@ namespace DiscImageChef.Partitions DicConsole.DebugWriteLine("GPT Plugin", "entry.attributes = 0x{0:X16}", entry.attributes); DicConsole.DebugWriteLine("GPT Plugin", "entry.name = {0}", entry.name); - if((entry.startLBA / divisor) > imagePlugin.GetSectors() || - (entry.endLBA / divisor) > imagePlugin.GetSectors()) return false; + if(entry.startLBA / divisor > imagePlugin.GetSectors() || + entry.endLBA / divisor > imagePlugin.GetSectors()) return false; CommonTypes.Partition part = new CommonTypes.Partition { diff --git a/DiscImageChef.Partitions/MBR.cs b/DiscImageChef.Partitions/MBR.cs index 3e30b7bc..af63fd09 100644 --- a/DiscImageChef.Partitions/MBR.cs +++ b/DiscImageChef.Partitions/MBR.cs @@ -285,7 +285,7 @@ namespace DiscImageChef.Partitions imagePlugin.ImageInfo.Heads, imagePlugin.ImageInfo.SectorsPerTrack) - ext_start; } - ext_minix |= (ebr_entry.type == 0x81 || ebr_entry.type == 0x80); + ext_minix |= ebr_entry.type == 0x81 || ebr_entry.type == 0x80; // For optical media ext_start /= divider; @@ -345,7 +345,7 @@ namespace DiscImageChef.Partitions DicConsole.DebugWriteLine("MBR plugin", "next_start {0}", next_start); processing_extended &= next_start != 0; - processing_extended &= (next_start <= imagePlugin.GetSectors()); + processing_extended &= next_start <= imagePlugin.GetSectors(); lba_start = next_start; } } diff --git a/DiscImageChef.Partitions/NeXT.cs b/DiscImageChef.Partitions/NeXT.cs index 98ea1f2d..beb5604c 100644 --- a/DiscImageChef.Partitions/NeXT.cs +++ b/DiscImageChef.Partitions/NeXT.cs @@ -179,9 +179,9 @@ namespace DiscImageChef.Partitions Type = StringHandlers.CToString(label.dl_dt.d_partitions[i].p_type), Sequence = (ulong)i, Name = StringHandlers.CToString(label.dl_dt.d_partitions[i].p_mountpt), - Length = (ulong)((label.dl_dt.d_partitions[i].p_size * label.dl_dt.d_secsize) / sector_size), - Start = (ulong)(((label.dl_dt.d_partitions[i].p_base + label.dl_dt.d_front) * - label.dl_dt.d_secsize) / sector_size), + Length = (ulong)(label.dl_dt.d_partitions[i].p_size * label.dl_dt.d_secsize / sector_size), + Start = (ulong)((label.dl_dt.d_partitions[i].p_base + label.dl_dt.d_front) * + label.dl_dt.d_secsize / sector_size), Scheme = Name }; diff --git a/DiscImageChef.Partitions/Plan9.cs b/DiscImageChef.Partitions/Plan9.cs index 135e2fb3..d8bbedbe 100644 --- a/DiscImageChef.Partitions/Plan9.cs +++ b/DiscImageChef.Partitions/Plan9.cs @@ -72,11 +72,11 @@ namespace DiscImageChef.Partitions Partition _part = new Partition { - Length = (end - start) + 1, + Length = end - start + 1, Offset = (start + sectorOffset) * imagePlugin.GetSectorSize(), Scheme = Name, Sequence = (ulong)partitions.Count, - Size = ((end - start) + 1) * imagePlugin.GetSectorSize(), + Size = (end - start + 1) * imagePlugin.GetSectorSize(), Start = start + sectorOffset, Type = tokens[1] }; diff --git a/DiscImageChef.Partitions/SGI.cs b/DiscImageChef.Partitions/SGI.cs index c8f7e1a4..22d543c4 100644 --- a/DiscImageChef.Partitions/SGI.cs +++ b/DiscImageChef.Partitions/SGI.cs @@ -117,11 +117,11 @@ namespace DiscImageChef.Partitions Partition part = new Partition { Start = - (dvh.partitions[i].first_block * dvh.device_params.dp_secbytes) / imagePlugin.GetSectorSize(), - Offset = (dvh.partitions[i].first_block * dvh.device_params.dp_secbytes), + dvh.partitions[i].first_block * dvh.device_params.dp_secbytes / imagePlugin.GetSectorSize(), + Offset = dvh.partitions[i].first_block * dvh.device_params.dp_secbytes, Length = - (dvh.partitions[i].num_blocks * dvh.device_params.dp_secbytes) / imagePlugin.GetSectorSize(), - Size = (dvh.partitions[i].num_blocks * dvh.device_params.dp_secbytes), + dvh.partitions[i].num_blocks * dvh.device_params.dp_secbytes / imagePlugin.GetSectorSize(), + Size = dvh.partitions[i].num_blocks * dvh.device_params.dp_secbytes, Type = TypeToString(dvh.partitions[i].type), Sequence = counter, Scheme = Name diff --git a/DiscImageChef.Partitions/Sun.cs b/DiscImageChef.Partitions/Sun.cs index 50ffd852..9fe63674 100644 --- a/DiscImageChef.Partitions/Sun.cs +++ b/DiscImageChef.Partitions/Sun.cs @@ -61,7 +61,7 @@ namespace DiscImageChef.Partitions const int LEN_DKL_PAD = DK_LABEL_SIZE - (LEN_DKL_ASCII + NDKMAP * 8 + 14 * 2); /// Size of padding in Solaris disk label with 8 partitions const int LEN_DKL_PAD8 = DK_LABEL_SIZE - (LEN_DKL_ASCII + 136 + // sizeof(dk_vtoc8) - (NDKMAP * 8) + 14 * 2 + 2 * 2); + NDKMAP * 8 + 14 * 2 + 2 * 2); const int LEN_DKL_PAD16 = DK_LABEL_SIZE - (456 + // sizeof(dk_vtoc16) 4 * 4 + 12 * 2 + 2 * 2); @@ -197,12 +197,12 @@ namespace DiscImageChef.Partitions CommonTypes.Partition part = new CommonTypes.Partition { Size = (ulong)dkl.dkl_map[i].dkl_nblk * DK_LABEL_SIZE, - Length = (ulong)((dkl.dkl_map[i].dkl_nblk * DK_LABEL_SIZE) / imagePlugin.GetSectorSize()), + Length = (ulong)(dkl.dkl_map[i].dkl_nblk * DK_LABEL_SIZE / imagePlugin.GetSectorSize()), Sequence = (ulong)i, Offset = ((ulong)dkl.dkl_map[i].dkl_cylno * sectorsPerCylinder + sectorOffset) * DK_LABEL_SIZE, - Start = (((ulong)dkl.dkl_map[i].dkl_cylno * sectorsPerCylinder + sectorOffset) * - DK_LABEL_SIZE) / imagePlugin.GetSectorSize(), + Start = ((ulong)dkl.dkl_map[i].dkl_cylno * sectorsPerCylinder + sectorOffset) * + DK_LABEL_SIZE / imagePlugin.GetSectorSize(), Type = "SunOS partition", Scheme = Name }; @@ -265,13 +265,13 @@ namespace DiscImageChef.Partitions { Description = SunFlagsToString(dkl8.dkl_vtoc.v_part[i].p_flag), Size = (ulong)dkl8.dkl_map[i].dkl_nblk * DK_LABEL_SIZE, - Length = (ulong)((dkl8.dkl_map[i].dkl_nblk * DK_LABEL_SIZE) / imagePlugin.GetSectorSize()), + Length = (ulong)(dkl8.dkl_map[i].dkl_nblk * DK_LABEL_SIZE / imagePlugin.GetSectorSize()), Sequence = (ulong)i, Offset = ((ulong)dkl8.dkl_map[i].dkl_cylno * sectorsPerCylinder + sectorOffset) * DK_LABEL_SIZE, Start = - (((ulong)dkl8.dkl_map[i].dkl_cylno * sectorsPerCylinder + sectorOffset) * - DK_LABEL_SIZE) / imagePlugin.GetSectorSize(), + ((ulong)dkl8.dkl_map[i].dkl_cylno * sectorsPerCylinder + sectorOffset) * + DK_LABEL_SIZE / imagePlugin.GetSectorSize(), Type = SunIdToString(dkl8.dkl_vtoc.v_part[i].p_tag), Scheme = Name }; @@ -336,13 +336,13 @@ namespace DiscImageChef.Partitions Description = SunFlagsToString(dkl16.dkl_vtoc.v_part[i].p_flag), Size = (ulong)dkl16.dkl_vtoc.v_part[i].p_size * dkl16.dkl_vtoc.v_sectorsz, Length = - (ulong)((dkl16.dkl_vtoc.v_part[i].p_size * dkl16.dkl_vtoc.v_sectorsz) / + (ulong)(dkl16.dkl_vtoc.v_part[i].p_size * dkl16.dkl_vtoc.v_sectorsz / imagePlugin.GetSectorSize()), Sequence = (ulong)i, Offset = ((ulong)dkl16.dkl_vtoc.v_part[i].p_start + sectorOffset) * dkl16.dkl_vtoc.v_sectorsz, Start = - (((ulong)dkl16.dkl_vtoc.v_part[i].p_start + sectorOffset) * dkl16.dkl_vtoc.v_sectorsz) / + ((ulong)dkl16.dkl_vtoc.v_part[i].p_start + sectorOffset) * dkl16.dkl_vtoc.v_sectorsz / imagePlugin.GetSectorSize(), Type = SunIdToString(dkl16.dkl_vtoc.v_part[i].p_tag), Scheme = Name diff --git a/DiscImageChef.Partitions/VTOC.cs b/DiscImageChef.Partitions/VTOC.cs index 9da3a714..068e5f70 100644 --- a/DiscImageChef.Partitions/VTOC.cs +++ b/DiscImageChef.Partitions/VTOC.cs @@ -337,7 +337,7 @@ namespace DiscImageChef.Partitions { Partition part = new Partition { - Start = ((ulong)(parts[i].p_start * bps) / imagePlugin.GetSectorSize()), + Start = (ulong)(parts[i].p_start * bps) / imagePlugin.GetSectorSize(), Length = (ulong)(parts[i].p_size * bps) / imagePlugin.GetSectorSize(), Offset = (ulong)(parts[i].p_start * bps), Size = (ulong)(parts[i].p_size * bps), diff --git a/DiscImageChef.Partitions/XENIX.cs b/DiscImageChef.Partitions/XENIX.cs index a425b93f..d531da8b 100644 --- a/DiscImageChef.Partitions/XENIX.cs +++ b/DiscImageChef.Partitions/XENIX.cs @@ -80,12 +80,12 @@ namespace DiscImageChef.Partitions Partition part = new Partition { Start = - ((ulong)((xnxtbl.p[i].p_off + XENIX_OFFSET) * XENIX_BSIZE) / imagePlugin.GetSectorSize()) + + (ulong)((xnxtbl.p[i].p_off + XENIX_OFFSET) * XENIX_BSIZE) / imagePlugin.GetSectorSize() + sectorOffset, Length = (ulong)(xnxtbl.p[i].p_size * XENIX_BSIZE) / imagePlugin.GetSectorSize(), Offset = (ulong)((xnxtbl.p[i].p_off + XENIX_OFFSET) * XENIX_BSIZE) + - (imagePlugin.GetSectorSize() * sectorOffset), + imagePlugin.GetSectorSize() * sectorOffset, Size = (ulong)(xnxtbl.p[i].p_size * XENIX_BSIZE), Sequence = (ulong)i, Type = "XENIX", diff --git a/DiscImageChef.Server/App_Start/Ata.cs b/DiscImageChef.Server/App_Start/Ata.cs index 6a309fc0..fcbe4ba8 100644 --- a/DiscImageChef.Server/App_Start/Ata.cs +++ b/DiscImageChef.Server/App_Start/Ata.cs @@ -548,19 +548,19 @@ namespace DiscImageChef.Server.App_Start { case 1: ataOneValue.Add(string.Format("{0} KiB of single ported single sector buffer", - (ataReport.BufferSize * logicalsectorsize) / 1024)); + ataReport.BufferSize * logicalsectorsize / 1024)); break; case 2: ataOneValue.Add(string.Format("{0} KiB of dual ported multi sector buffer", - (ataReport.BufferSize * logicalsectorsize) / 1024)); + ataReport.BufferSize * logicalsectorsize / 1024)); break; case 3: ataOneValue.Add(string.Format("{0} KiB of dual ported multi sector buffer with read caching", - (ataReport.BufferSize * logicalsectorsize) / 1024)); + ataReport.BufferSize * logicalsectorsize / 1024)); break; default: ataOneValue.Add(string.Format("{0} KiB of unknown type {1} buffer", - (ataReport.BufferSize * logicalsectorsize) / 1024, + ataReport.BufferSize * logicalsectorsize / 1024, ataReport.BufferType)); break; } @@ -842,8 +842,8 @@ namespace DiscImageChef.Server.App_Start ataReport.ServiceBusyClear)); } - if(ataReport.TransportMajorVersionSpecified && (((ataReport.TransportMajorVersion & 0xF000) >> 12) == 0x1 || - ((ataReport.TransportMajorVersion & 0xF000) >> 12) == 0xE)) + if(ataReport.TransportMajorVersionSpecified && ((ataReport.TransportMajorVersion & 0xF000) >> 12 == 0x1 || + (ataReport.TransportMajorVersion & 0xF000) >> 12 == 0xE)) { if(!ataReport.SATACapabilities.HasFlag(SATACapabilitiesBit.Clear)) { @@ -974,7 +974,7 @@ namespace DiscImageChef.Server.App_Start ataOneValue.Add("CompactFlash power mode 1 is disabled"); ataOneValue.Add(string.Format("CompactFlash device uses a maximum of {0} mA", - (ataReport.CFAPowerMode & 0x0FFF))); + ataReport.CFAPowerMode & 0x0FFF)); } } @@ -1429,8 +1429,8 @@ namespace DiscImageChef.Server.App_Start ataOneValue.Add("Trusted Computing feature set is supported"); } - if(ataReport.TransportMajorVersionSpecified && (((ataReport.TransportMajorVersion & 0xF000) >> 12) == 0x1 || - ((ataReport.TransportMajorVersion & 0xF000) >> 12) == 0xE)) + if(ataReport.TransportMajorVersionSpecified && ((ataReport.TransportMajorVersion & 0xF000) >> 12 == 0x1 || + (ataReport.TransportMajorVersion & 0xF000) >> 12 == 0xE)) { if(ataReport.SATACapabilitiesSpecified) { @@ -1655,7 +1655,7 @@ namespace DiscImageChef.Server.App_Start if(ataReport.ReadCapabilities.BlockSizeSpecified && ataReport.ReadCapabilities.PhysicalBlockSizeSpecified && - (ataReport.ReadCapabilities.BlockSize != ataReport.ReadCapabilities.PhysicalBlockSize) && + ataReport.ReadCapabilities.BlockSize != ataReport.ReadCapabilities.PhysicalBlockSize && (ataReport.ReadCapabilities.LogicalAlignment & 0x8000) == 0x0000 && (ataReport.ReadCapabilities.LogicalAlignment & 0x4000) == 0x4000) { @@ -1685,7 +1685,7 @@ namespace DiscImageChef.Server.App_Start ataTwoValue.Add("Device size in CHS mode", string.Format("{0} bytes, {1} Mb, {2:F2} MiB", (ulong)currentSectors * logicalsectorsize, - ((ulong)currentSectors * logicalsectorsize) / 1000 / 1000, + (ulong)currentSectors * logicalsectorsize / 1000 / 1000, (double)((ulong)currentSectors * logicalsectorsize) / 1024 / 1024)); } @@ -1702,7 +1702,7 @@ namespace DiscImageChef.Server.App_Start ataTwoValue.Add("Device size in CHS mode", string.Format("{0} bytes, {1} Mb, {2:F2} MiB", (ulong)currentSectors * logicalsectorsize, - ((ulong)currentSectors * logicalsectorsize) / 1000 / 1000, + (ulong)currentSectors * logicalsectorsize / 1000 / 1000, (double)((ulong)currentSectors * logicalsectorsize) / 1024 / 1024)); } @@ -1712,26 +1712,26 @@ namespace DiscImageChef.Server.App_Start ataTwoValue.Add("Sectors addressable in sectors in 28-bit LBA mode", string.Format("{0}", ataReport.ReadCapabilities.LBASectors)); - if((((ulong)ataReport.ReadCapabilities.LBASectors * logicalsectorsize) / 1024 / 1024) > 1000000) + if((ulong)ataReport.ReadCapabilities.LBASectors * logicalsectorsize / 1024 / 1024 > 1000000) { ataTwoValue.Add("Device size in 28-bit LBA mode", string.Format("{0} bytes, {1} Tb, {2:F2} TiB", (ulong)ataReport.ReadCapabilities.LBASectors * logicalsectorsize, - ((ulong)ataReport.ReadCapabilities.LBASectors * - logicalsectorsize) / 1000 / 1000 / 1000 / 1000, + (ulong)ataReport.ReadCapabilities.LBASectors * + logicalsectorsize / 1000 / 1000 / 1000 / 1000, (double)((ulong)ataReport.ReadCapabilities.LBASectors * logicalsectorsize) / 1024 / 1024 / 1024 / 1024)); } - else if((((ulong)ataReport.ReadCapabilities.LBASectors * logicalsectorsize) / 1024 / 1024) > + else if((ulong)ataReport.ReadCapabilities.LBASectors * logicalsectorsize / 1024 / 1024 > 1000) { ataTwoValue.Add("Device size in 28-bit LBA mode", string.Format("{0} bytes, {1} Gb, {2:F2} GiB", (ulong)ataReport.ReadCapabilities.LBASectors * logicalsectorsize, - ((ulong)ataReport.ReadCapabilities.LBASectors * - logicalsectorsize) / 1000 / 1000 / 1000, + (ulong)ataReport.ReadCapabilities.LBASectors * + logicalsectorsize / 1000 / 1000 / 1000, (double)((ulong)ataReport.ReadCapabilities.LBASectors * logicalsectorsize) / 1024 / 1024 / 1024)); } @@ -1741,8 +1741,8 @@ namespace DiscImageChef.Server.App_Start string.Format("{0} bytes, {1} Mb, {2:F2} MiB", (ulong)ataReport.ReadCapabilities.LBASectors * logicalsectorsize, - ((ulong)ataReport.ReadCapabilities.LBASectors * - logicalsectorsize) / 1000 / 1000, + (ulong)ataReport.ReadCapabilities.LBASectors * + logicalsectorsize / 1000 / 1000, (double)((ulong)ataReport.ReadCapabilities.LBASectors * logicalsectorsize) / 1024 / 1024)); } @@ -1753,23 +1753,23 @@ namespace DiscImageChef.Server.App_Start ataTwoValue.Add("Sectors addressable in sectors in 48-bit LBA mode", string.Format("{0}", ataReport.ReadCapabilities.LBA48Sectors)); - if(((ataReport.ReadCapabilities.LBA48Sectors * logicalsectorsize) / 1024 / 1024) > 1000000) + if(ataReport.ReadCapabilities.LBA48Sectors * logicalsectorsize / 1024 / 1024 > 1000000) { ataTwoValue.Add("Device size in 48-bit LBA mode", string.Format("{0} bytes, {1} Tb, {2:F2} TiB", ataReport.ReadCapabilities.LBA48Sectors * logicalsectorsize, - (ataReport.ReadCapabilities.LBA48Sectors * - logicalsectorsize) / 1000 / 1000 / 1000 / 1000, + ataReport.ReadCapabilities.LBA48Sectors * + logicalsectorsize / 1000 / 1000 / 1000 / 1000, (double)(ataReport.ReadCapabilities.LBA48Sectors * logicalsectorsize) / 1024 / 1024 / 1024 / 1024)); } - else if(((ataReport.ReadCapabilities.LBA48Sectors * logicalsectorsize) / 1024 / 1024) > 1000) + else if(ataReport.ReadCapabilities.LBA48Sectors * logicalsectorsize / 1024 / 1024 > 1000) { ataTwoValue.Add("Device size in 48-bit LBA mode", string.Format("{0} bytes, {1} Gb, {2:F2} GiB", ataReport.ReadCapabilities.LBA48Sectors * logicalsectorsize, - (ataReport.ReadCapabilities.LBA48Sectors * - logicalsectorsize) / 1000 / 1000 / 1000, + ataReport.ReadCapabilities.LBA48Sectors * + logicalsectorsize / 1000 / 1000 / 1000, (double)(ataReport.ReadCapabilities.LBA48Sectors * logicalsectorsize) / 1024 / 1024 / 1024)); } @@ -1778,8 +1778,8 @@ namespace DiscImageChef.Server.App_Start ataTwoValue.Add("Device size in 48-bit LBA mode", string.Format("{0} bytes, {1} Mb, {2:F2} MiB", ataReport.ReadCapabilities.LBA48Sectors * logicalsectorsize, - (ataReport.ReadCapabilities.LBA48Sectors * - logicalsectorsize) / 1000 / 1000, + ataReport.ReadCapabilities.LBA48Sectors * + logicalsectorsize / 1000 / 1000, (double)(ataReport.ReadCapabilities.LBA48Sectors * logicalsectorsize) / 1024 / 1024)); } diff --git a/DiscImageChef.Server/App_Start/TestedMedia.cs b/DiscImageChef.Server/App_Start/TestedMedia.cs index 7fd4d694..ab6bd1ac 100644 --- a/DiscImageChef.Server/App_Start/TestedMedia.cs +++ b/DiscImageChef.Server/App_Start/TestedMedia.cs @@ -75,20 +75,20 @@ namespace DiscImageChef.Server.App_Start mediaOneValue.Add(string.Format("Medium has {0} blocks of {1} bytes each", testedMedia.Blocks, testedMedia.BlockSize)); - if(((testedMedia.Blocks * testedMedia.BlockSize) / 1024 / 1024) > 1000000) + if(testedMedia.Blocks * testedMedia.BlockSize / 1024 / 1024 > 1000000) { mediaOneValue.Add(string.Format("Medium size: {0} bytes, {1} Tb, {2:F2} TiB", testedMedia.Blocks * testedMedia.BlockSize, - (testedMedia.Blocks * testedMedia.BlockSize) / 1000 / 1000 / + testedMedia.Blocks * testedMedia.BlockSize / 1000 / 1000 / 1000 / 1000, (double)(testedMedia.Blocks * testedMedia.BlockSize) / 1024 / 1024 / 1024 / 1024)); } - else if(((testedMedia.Blocks * testedMedia.BlockSize) / 1024 / 1024) > 1000) + else if(testedMedia.Blocks * testedMedia.BlockSize / 1024 / 1024 > 1000) { mediaOneValue.Add(string.Format("Medium size: {0} bytes, {1} Gb, {2:F2} GiB", testedMedia.Blocks * testedMedia.BlockSize, - (testedMedia.Blocks * testedMedia.BlockSize) / 1000 / 1000 / + testedMedia.Blocks * testedMedia.BlockSize / 1000 / 1000 / 1000, (double)(testedMedia.Blocks * testedMedia.BlockSize) / 1024 / 1024 / 1024)); @@ -97,7 +97,7 @@ namespace DiscImageChef.Server.App_Start { mediaOneValue.Add(string.Format("Medium size: {0} bytes, {1} Mb, {2:F2} MiB", testedMedia.Blocks * testedMedia.BlockSize, - (testedMedia.Blocks * testedMedia.BlockSize) / 1000 / 1000, + testedMedia.Blocks * testedMedia.BlockSize / 1000 / 1000, (double)(testedMedia.Blocks * testedMedia.BlockSize) / 1024 / 1024)); } @@ -118,7 +118,7 @@ namespace DiscImageChef.Server.App_Start testedMedia.CHS.Sectors, currentSectors)); mediaOneValue.Add(string.Format("Medium size in CHS mode: {0} bytes, {1} Mb, {2:F2} MiB", (ulong)currentSectors * testedMedia.BlockSize, - ((ulong)currentSectors * testedMedia.BlockSize) / 1000 / 1000, + (ulong)currentSectors * testedMedia.BlockSize / 1000 / 1000, (double)((ulong)currentSectors * testedMedia.BlockSize) / 1024 / 1024)); } @@ -131,7 +131,7 @@ namespace DiscImageChef.Server.App_Start mediaOneValue.Add(string.Format("Sectors addressable in CHS mode: {0}", currentSectors)); mediaOneValue.Add(string.Format("Medium size in CHS mode: {0} bytes, {1} Mb, {2:F2} MiB", (ulong)currentSectors * testedMedia.BlockSize, - ((ulong)currentSectors * testedMedia.BlockSize) / 1000 / 1000, + (ulong)currentSectors * testedMedia.BlockSize / 1000 / 1000, (double)((ulong)currentSectors * testedMedia.BlockSize) / 1024 / 1024)); } @@ -141,20 +141,20 @@ namespace DiscImageChef.Server.App_Start mediaOneValue.Add(string.Format("Sectors addressable in sectors in 28-bit LBA mode: {0}", testedMedia.LBASectors)); - if((((ulong)testedMedia.LBASectors * testedMedia.BlockSize) / 1024 / 1024) > 1000000) + if((ulong)testedMedia.LBASectors * testedMedia.BlockSize / 1024 / 1024 > 1000000) { mediaOneValue.Add(string.Format("Medium size in 28-bit LBA mode: {0} bytes, {1} Tb, {2:F2} TiB", (ulong)testedMedia.LBASectors * testedMedia.BlockSize, - ((ulong)testedMedia.LBASectors * testedMedia.BlockSize) / 1000 / + (ulong)testedMedia.LBASectors * testedMedia.BlockSize / 1000 / 1000 / 1000 / 1000, (double)((ulong)testedMedia.LBASectors * testedMedia.BlockSize) / 1024 / 1024 / 1024 / 1024)); } - else if((((ulong)testedMedia.LBASectors * testedMedia.BlockSize) / 1024 / 1024) > 1000) + else if((ulong)testedMedia.LBASectors * testedMedia.BlockSize / 1024 / 1024 > 1000) { mediaOneValue.Add(string.Format("Medium size in 28-bit LBA mode: {0} bytes, {1} Gb, {2:F2} GiB", (ulong)testedMedia.LBASectors * testedMedia.BlockSize, - ((ulong)testedMedia.LBASectors * testedMedia.BlockSize) / 1000 / + (ulong)testedMedia.LBASectors * testedMedia.BlockSize / 1000 / 1000 / 1000, (double)((ulong)testedMedia.LBASectors * testedMedia.BlockSize) / 1024 / 1024 / 1024)); @@ -163,7 +163,7 @@ namespace DiscImageChef.Server.App_Start { mediaOneValue.Add(string.Format("Medium size in 28-bit LBA mode: {0} bytes, {1} Mb, {2:F2} MiB", (ulong)testedMedia.LBASectors * testedMedia.BlockSize, - ((ulong)testedMedia.LBASectors * testedMedia.BlockSize) / 1000 / + (ulong)testedMedia.LBASectors * testedMedia.BlockSize / 1000 / 1000, (double)((ulong)testedMedia.LBASectors * testedMedia.BlockSize) / 1024 / 1024)); @@ -175,20 +175,20 @@ namespace DiscImageChef.Server.App_Start mediaOneValue.Add(string.Format("Sectors addressable in sectors in 48-bit LBA mode: {0}", testedMedia.LBA48Sectors)); - if(((testedMedia.LBA48Sectors * testedMedia.BlockSize) / 1024 / 1024) > 1000000) + if(testedMedia.LBA48Sectors * testedMedia.BlockSize / 1024 / 1024 > 1000000) { mediaOneValue.Add(string.Format("Medium size in 48-bit LBA mode: {0} bytes, {1} Tb, {2:F2} TiB", testedMedia.LBA48Sectors * testedMedia.BlockSize, - (testedMedia.LBA48Sectors * testedMedia.BlockSize) / 1000 / + testedMedia.LBA48Sectors * testedMedia.BlockSize / 1000 / 1000 / 1000 / 1000, (double)(testedMedia.LBA48Sectors * testedMedia.BlockSize) / 1024 / 1024 / 1024 / 1024)); } - else if(((testedMedia.LBA48Sectors * testedMedia.BlockSize) / 1024 / 1024) > 1000) + else if(testedMedia.LBA48Sectors * testedMedia.BlockSize / 1024 / 1024 > 1000) { mediaOneValue.Add(string.Format("Medium size in 48-bit LBA mode: {0} bytes, {1} Gb, {2:F2} GiB", testedMedia.LBA48Sectors * testedMedia.BlockSize, - (testedMedia.LBA48Sectors * testedMedia.BlockSize) / 1000 / + testedMedia.LBA48Sectors * testedMedia.BlockSize / 1000 / 1000 / 1000, (double)(testedMedia.LBA48Sectors * testedMedia.BlockSize) / 1024 / 1024 / 1024)); @@ -197,7 +197,7 @@ namespace DiscImageChef.Server.App_Start { mediaOneValue.Add(string.Format("Medium size in 48-bit LBA mode: {0} bytes, {1} Mb, {2:F2} MiB", testedMedia.LBA48Sectors * testedMedia.BlockSize, - (testedMedia.LBA48Sectors * testedMedia.BlockSize) / 1000 / + testedMedia.LBA48Sectors * testedMedia.BlockSize / 1000 / 1000, (double)(testedMedia.LBA48Sectors * testedMedia.BlockSize) / 1024 / 1024)); @@ -212,7 +212,7 @@ namespace DiscImageChef.Server.App_Start } if(testedMedia.BlockSizeSpecified && testedMedia.PhysicalBlockSizeSpecified && - (testedMedia.BlockSize != testedMedia.PhysicalBlockSize) && + testedMedia.BlockSize != testedMedia.PhysicalBlockSize && (testedMedia.LogicalAlignment & 0x8000) == 0x0000 && (testedMedia.LogicalAlignment & 0x4000) == 0x4000) { diff --git a/DiscImageChef.Server/ViewReport.aspx.cs b/DiscImageChef.Server/ViewReport.aspx.cs index a06509c2..1b037726 100644 --- a/DiscImageChef.Server/ViewReport.aspx.cs +++ b/DiscImageChef.Server/ViewReport.aspx.cs @@ -395,28 +395,28 @@ namespace DiscImageChef.Server report.SCSI.ReadCapabilities.Blocks, report.SCSI.ReadCapabilities.BlockSize)); - if(((report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize) / 1024 / - 1024) > 1000000) + if(report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize / 1024 / + 1024 > 1000000) { scsiOneValue.Add(string.Format("Device size: {0} bytes, {1} Tb, {2:F2} TiB", report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize, - (report.SCSI.ReadCapabilities.Blocks * - report.SCSI.ReadCapabilities.BlockSize) / 1000 / 1000 / + report.SCSI.ReadCapabilities.Blocks * + report.SCSI.ReadCapabilities.BlockSize / 1000 / 1000 / 1000 / 1000, (double)(report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize) / 1024 / 1024 / 1024 / 1024)); } else if( - ((report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize) / 1024 / - 1024) > 1000) + report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize / 1024 / + 1024 > 1000) { scsiOneValue.Add(string.Format("Device size: {0} bytes, {1} Gb, {2:F2} GiB", report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize, - (report.SCSI.ReadCapabilities.Blocks * - report.SCSI.ReadCapabilities.BlockSize) / 1000 / 1000 / + report.SCSI.ReadCapabilities.Blocks * + report.SCSI.ReadCapabilities.BlockSize / 1000 / 1000 / 1000, (double)(report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize) / 1024 / @@ -427,8 +427,8 @@ namespace DiscImageChef.Server scsiOneValue.Add(string.Format("Device size: {0} bytes, {1} Mb, {2:F2} MiB", report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize, - (report.SCSI.ReadCapabilities.Blocks * - report.SCSI.ReadCapabilities.BlockSize) / 1000 / 1000, + report.SCSI.ReadCapabilities.Blocks * + report.SCSI.ReadCapabilities.BlockSize / 1000 / 1000, (double)(report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize) / 1024 / 1024)); diff --git a/DiscImageChef.Tests.Devices/DecodeATARegisters.cs b/DiscImageChef.Tests.Devices/DecodeATARegisters.cs index b72e61a9..1dac4df4 100644 --- a/DiscImageChef.Tests.Devices/DecodeATARegisters.cs +++ b/DiscImageChef.Tests.Devices/DecodeATARegisters.cs @@ -72,7 +72,7 @@ namespace DiscImageChef.Tests.Devices sb.AppendFormat("Status: {0}", DecodeATAStatus(registers.status)).AppendLine(); sb.AppendFormat("Error: {0}", DecodeATAStatus(registers.error)).AppendLine(); sb.AppendFormat("Device: {0}", (registers.deviceHead >> 4) & 0x01).AppendLine(); - sb.AppendFormat("Cylinder: {0}", (registers.cylinderHigh) << 8 + registers.cylinderLow).AppendLine(); + sb.AppendFormat("Cylinder: {0}", registers.cylinderHigh << 8 + registers.cylinderLow).AppendLine(); sb.AppendFormat("Head: {0}", registers.deviceHead & 0xF).AppendLine(); sb.AppendFormat("Sector: {0}", registers.sector).AppendLine(); sb.AppendFormat("Count: {0}", registers.sectorCount).AppendLine(); @@ -105,8 +105,8 @@ namespace DiscImageChef.Tests.Devices sb.AppendFormat("Error: {0}", DecodeATAStatus(registers.error)).AppendLine(); sb.AppendFormat("Device: {0}", (registers.deviceHead >> 4) & 0x01).AppendLine(); sb.AppendFormat("LBA: {0}", - ((ulong)(registers.deviceHead & 0xF) * (ulong)0x100000000000) + - (registers.lbaHigh * (ulong)0x100000000L) + (ulong)(registers.lbaMid << 16) + + (ulong)(registers.deviceHead & 0xF) * (ulong)0x100000000000 + + registers.lbaHigh * (ulong)0x100000000L + (ulong)(registers.lbaMid << 16) + registers.lbaLow); sb.AppendFormat("Count: {0}", registers.sectorCount).AppendLine(); sb.AppendFormat("LBA?: {0}", Convert.ToBoolean(registers.deviceHead & 0x40)).AppendLine(); diff --git a/DiscImageChef.Tests/Images/2MG.cs b/DiscImageChef.Tests/Images/2MG.cs index e42ecf20..53238ccb 100644 --- a/DiscImageChef.Tests/Images/2MG.cs +++ b/DiscImageChef.Tests/Images/2MG.cs @@ -85,7 +85,7 @@ namespace DiscImageChef.Tests.Images { byte[] sector; - if((image.ImageInfo.Sectors - doneSectors) >= sectorsToRead) + if(image.ImageInfo.Sectors - doneSectors >= sectorsToRead) { sector = image.ReadSectors(doneSectors, sectorsToRead); doneSectors += sectorsToRead; @@ -93,7 +93,7 @@ namespace DiscImageChef.Tests.Images else { sector = image.ReadSectors(doneSectors, (uint)(image.ImageInfo.Sectors - doneSectors)); - doneSectors += (image.ImageInfo.Sectors - doneSectors); + doneSectors += image.ImageInfo.Sectors - doneSectors; } ctx.Update(sector); diff --git a/DiscImageChef.Tests/Images/Anex86.cs b/DiscImageChef.Tests/Images/Anex86.cs index 78bb71bf..842c3ce4 100644 --- a/DiscImageChef.Tests/Images/Anex86.cs +++ b/DiscImageChef.Tests/Images/Anex86.cs @@ -89,7 +89,7 @@ namespace DiscImageChef.Tests.Images { byte[] sector; - if((image.ImageInfo.Sectors - doneSectors) >= sectorsToRead) + if(image.ImageInfo.Sectors - doneSectors >= sectorsToRead) { sector = image.ReadSectors(doneSectors, sectorsToRead); doneSectors += sectorsToRead; @@ -97,7 +97,7 @@ namespace DiscImageChef.Tests.Images else { sector = image.ReadSectors(doneSectors, (uint)(image.ImageInfo.Sectors - doneSectors)); - doneSectors += (image.ImageInfo.Sectors - doneSectors); + doneSectors += image.ImageInfo.Sectors - doneSectors; } ctx.Update(sector); diff --git a/DiscImageChef.Tests/Images/CisCopy.cs b/DiscImageChef.Tests/Images/CisCopy.cs index 20373ccd..d44fbd3c 100644 --- a/DiscImageChef.Tests/Images/CisCopy.cs +++ b/DiscImageChef.Tests/Images/CisCopy.cs @@ -103,7 +103,7 @@ namespace DiscImageChef.Tests.Images { byte[] sector; - if((image.ImageInfo.Sectors - doneSectors) >= sectorsToRead) + if(image.ImageInfo.Sectors - doneSectors >= sectorsToRead) { sector = image.ReadSectors(doneSectors, sectorsToRead); doneSectors += sectorsToRead; @@ -111,7 +111,7 @@ namespace DiscImageChef.Tests.Images else { sector = image.ReadSectors(doneSectors, (uint)(image.ImageInfo.Sectors - doneSectors)); - doneSectors += (image.ImageInfo.Sectors - doneSectors); + doneSectors += image.ImageInfo.Sectors - doneSectors; } ctx.Update(sector); diff --git a/DiscImageChef.Tests/Images/CopyQM.cs b/DiscImageChef.Tests/Images/CopyQM.cs index 049f5af4..8b73e770 100644 --- a/DiscImageChef.Tests/Images/CopyQM.cs +++ b/DiscImageChef.Tests/Images/CopyQM.cs @@ -87,7 +87,7 @@ namespace DiscImageChef.Tests.Images { byte[] sector; - if((image.ImageInfo.Sectors - doneSectors) >= sectorsToRead) + if(image.ImageInfo.Sectors - doneSectors >= sectorsToRead) { sector = image.ReadSectors(doneSectors, sectorsToRead); doneSectors += sectorsToRead; @@ -95,7 +95,7 @@ namespace DiscImageChef.Tests.Images else { sector = image.ReadSectors(doneSectors, (uint)(image.ImageInfo.Sectors - doneSectors)); - doneSectors += (image.ImageInfo.Sectors - doneSectors); + doneSectors += image.ImageInfo.Sectors - doneSectors; } ctx.Update(sector); diff --git a/DiscImageChef.Tests/Images/D88.cs b/DiscImageChef.Tests/Images/D88.cs index 2912f044..0aa4d584 100644 --- a/DiscImageChef.Tests/Images/D88.cs +++ b/DiscImageChef.Tests/Images/D88.cs @@ -105,7 +105,7 @@ namespace DiscImageChef.Tests.Images { byte[] sector; - if((image.ImageInfo.Sectors - doneSectors) >= sectorsToRead) + if(image.ImageInfo.Sectors - doneSectors >= sectorsToRead) { sector = image.ReadSectors(doneSectors, sectorsToRead); doneSectors += sectorsToRead; @@ -113,7 +113,7 @@ namespace DiscImageChef.Tests.Images else { sector = image.ReadSectors(doneSectors, (uint)(image.ImageInfo.Sectors - doneSectors)); - doneSectors += (image.ImageInfo.Sectors - doneSectors); + doneSectors += image.ImageInfo.Sectors - doneSectors; } ctx.Update(sector); diff --git a/DiscImageChef.Tests/Images/DART.cs b/DiscImageChef.Tests/Images/DART.cs index 49fe0c98..986fbb4e 100644 --- a/DiscImageChef.Tests/Images/DART.cs +++ b/DiscImageChef.Tests/Images/DART.cs @@ -86,7 +86,7 @@ namespace DiscImageChef.Tests.Images { byte[] sector; - if((image.ImageInfo.Sectors - doneSectors) >= sectorsToRead) + if(image.ImageInfo.Sectors - doneSectors >= sectorsToRead) { sector = image.ReadSectors(doneSectors, sectorsToRead); doneSectors += sectorsToRead; @@ -94,7 +94,7 @@ namespace DiscImageChef.Tests.Images else { sector = image.ReadSectors(doneSectors, (uint)(image.ImageInfo.Sectors - doneSectors)); - doneSectors += (image.ImageInfo.Sectors - doneSectors); + doneSectors += image.ImageInfo.Sectors - doneSectors; } ctx.Update(sector); diff --git a/DiscImageChef.Tests/Images/DiskCopy42.cs b/DiscImageChef.Tests/Images/DiskCopy42.cs index 14372cd0..94d48b51 100644 --- a/DiscImageChef.Tests/Images/DiskCopy42.cs +++ b/DiscImageChef.Tests/Images/DiskCopy42.cs @@ -106,7 +106,7 @@ namespace DiscImageChef.Tests.Images { byte[] sector; - if((image.ImageInfo.Sectors - doneSectors) >= sectorsToRead) + if(image.ImageInfo.Sectors - doneSectors >= sectorsToRead) { sector = image.ReadSectors(doneSectors, sectorsToRead); doneSectors += sectorsToRead; @@ -114,7 +114,7 @@ namespace DiscImageChef.Tests.Images else { sector = image.ReadSectors(doneSectors, (uint)(image.ImageInfo.Sectors - doneSectors)); - doneSectors += (image.ImageInfo.Sectors - doneSectors); + doneSectors += image.ImageInfo.Sectors - doneSectors; } ctx.Update(sector); diff --git a/DiscImageChef/Commands/Checksum.cs b/DiscImageChef/Commands/Checksum.cs index 4e2d79bf..6c8f6671 100644 --- a/DiscImageChef/Commands/Checksum.cs +++ b/DiscImageChef/Commands/Checksum.cs @@ -114,7 +114,7 @@ namespace DiscImageChef.Commands List inputTracks = inputFormat.GetTracks(); foreach(Track currentTrack in inputTracks) { - if((currentTrack.TrackStartSector - previousTrackEnd) != 0 && options.WholeDisc) + if(currentTrack.TrackStartSector - previousTrackEnd != 0 && options.WholeDisc) { for(ulong i = previousTrackEnd + 1; i < currentTrack.TrackStartSector; i++) { @@ -141,7 +141,7 @@ namespace DiscImageChef.Commands { byte[] sector; - if((sectors - doneSectors) >= SECTORS_TO_READ) + if(sectors - doneSectors >= SECTORS_TO_READ) { sector = inputFormat.ReadSectors(doneSectors, SECTORS_TO_READ, currentTrack.TrackSequence); @@ -155,7 +155,7 @@ namespace DiscImageChef.Commands currentTrack.TrackSequence); DicConsole.Write("\rHashings sectors {0} to {2} of track {1}", doneSectors, currentTrack.TrackSequence, doneSectors + (sectors - doneSectors)); - doneSectors += (sectors - doneSectors); + doneSectors += sectors - doneSectors; } if(options.WholeDisc) mediaChecksum.Update(sector); @@ -175,7 +175,7 @@ namespace DiscImageChef.Commands previousTrackEnd = currentTrack.TrackEndSector; } - if((inputFormat.GetSectors() - previousTrackEnd) != 0 && options.WholeDisc) + if(inputFormat.GetSectors() - previousTrackEnd != 0 && options.WholeDisc) { for(ulong i = previousTrackEnd + 1; i < inputFormat.GetSectors(); i++) { @@ -210,7 +210,7 @@ namespace DiscImageChef.Commands { byte[] sector; - if((sectors - doneSectors) >= SECTORS_TO_READ) + if(sectors - doneSectors >= SECTORS_TO_READ) { sector = inputFormat.ReadSectors(doneSectors, SECTORS_TO_READ); DicConsole.Write("\rHashings sectors {0} to {1}", doneSectors, doneSectors + SECTORS_TO_READ); @@ -221,7 +221,7 @@ namespace DiscImageChef.Commands sector = inputFormat.ReadSectors(doneSectors, (uint)(sectors - doneSectors)); DicConsole.Write("\rHashings sectors {0} to {1}", doneSectors, doneSectors + (sectors - doneSectors)); - doneSectors += (sectors - doneSectors); + doneSectors += sectors - doneSectors; } mediaChecksum.Update(sector); diff --git a/DiscImageChef/Commands/DeviceInfo.cs b/DiscImageChef/Commands/DeviceInfo.cs index cf51c1d0..94cfbcdc 100644 --- a/DiscImageChef/Commands/DeviceInfo.cs +++ b/DiscImageChef/Commands/DeviceInfo.cs @@ -224,7 +224,7 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("Media card is write protected"); ushort specificData = - (ushort)((errorRegisters.cylinderHigh * 0x100) + errorRegisters.cylinderLow); + (ushort)(errorRegisters.cylinderHigh * 0x100 + errorRegisters.cylinderLow); if(specificData != 0) DicConsole.WriteLine("Card specific data: 0x{0:X4}", specificData); } @@ -1319,18 +1319,18 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("Drive has loaded a total of {0} discs", discs); DicConsole .WriteLine("Drive has spent {0} hours, {1} minutes and {2} seconds reading CDs", - cdReadTime / 3600, (cdReadTime / 60) % 60, cdReadTime % 60); + cdReadTime / 3600, cdReadTime / 60 % 60, cdReadTime % 60); DicConsole .WriteLine("Drive has spent {0} hours, {1} minutes and {2} seconds writing CDs", - cdWriteTime / 3600, (cdWriteTime / 60) % 60, cdWriteTime % 60); + cdWriteTime / 3600, cdWriteTime / 60 % 60, cdWriteTime % 60); if(plxtDvd) { DicConsole .WriteLine("Drive has spent {0} hours, {1} minutes and {2} seconds reading DVDs", - dvdReadTime / 3600, (dvdReadTime / 60) % 60, dvdReadTime % 60); + dvdReadTime / 3600, dvdReadTime / 60 % 60, dvdReadTime % 60); DicConsole .WriteLine("Drive has spent {0} hours, {1} minutes and {2} seconds writing DVDs", - dvdWriteTime / 3600, (dvdWriteTime / 60) % 60, dvdWriteTime % 60); + dvdWriteTime / 3600, dvdWriteTime / 60 % 60, dvdWriteTime % 60); } } diff --git a/DiscImageChef/Commands/MediaInfo.cs b/DiscImageChef/Commands/MediaInfo.cs index fe600648..720b34e1 100644 --- a/DiscImageChef/Commands/MediaInfo.cs +++ b/DiscImageChef/Commands/MediaInfo.cs @@ -237,8 +237,8 @@ namespace DiscImageChef.Commands { DataFile.WriteTo("Media-Info command", outputPrefix, "_readcapacity.bin", "SCSI READ CAPACITY", cmdBuf); - blocks = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + (cmdBuf[3])); - blockSize = (uint)((cmdBuf[5] << 24) + (cmdBuf[5] << 16) + (cmdBuf[6] << 8) + (cmdBuf[7])); + blocks = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]); + blockSize = (uint)((cmdBuf[5] << 24) + (cmdBuf[5] << 16) + (cmdBuf[6] << 8) + cmdBuf[7]); } if(sense || blocks == 0xFFFFFFFF) @@ -264,7 +264,7 @@ namespace DiscImageChef.Commands Array.Copy(cmdBuf, 0, temp, 0, 8); Array.Reverse(temp); blocks = BitConverter.ToUInt64(temp, 0); - blockSize = (uint)((cmdBuf[5] << 24) + (cmdBuf[5] << 16) + (cmdBuf[6] << 8) + (cmdBuf[7])); + blockSize = (uint)((cmdBuf[5] << 24) + (cmdBuf[5] << 16) + (cmdBuf[6] << 8) + cmdBuf[7]); } } @@ -1234,7 +1234,7 @@ namespace DiscImageChef.Commands } #region Xbox - if((dskType == MediaType.XGD || dskType == MediaType.XGD2 || dskType == MediaType.XGD3)) + if(dskType == MediaType.XGD || dskType == MediaType.XGD2 || dskType == MediaType.XGD3) { // We need to get INQUIRY to know if it is a Kreon drive byte[] inqBuffer; @@ -1275,7 +1275,7 @@ namespace DiscImageChef.Commands return; } - totalSize = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + (cmdBuf[3])); + totalSize = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]); sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, MmcDiscStructureFormat.PhysicalInformation, 0, 0, out duration); if(sense) @@ -1306,7 +1306,7 @@ namespace DiscImageChef.Commands return; } - gameSize = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + (cmdBuf[3])) + 1; + gameSize = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]) + 1; DicConsole.DebugWriteLine("Dump-media command", "Game partition total size: {0} sectors", gameSize); @@ -1326,7 +1326,7 @@ namespace DiscImageChef.Commands return; } - totalSize = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + (cmdBuf[3])); + totalSize = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]); sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, MmcDiscStructureFormat.PhysicalInformation, 0, 0, out duration); if(sense)