From c1287c00cf4f1ec5ad59d1ed5bd6d149ca2ffcf6 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Tue, 17 Aug 2021 14:27:19 +0100 Subject: [PATCH] Remove redundant parentheses. --- Aaru.Checksums | 2 +- Aaru.CommonTypes | 2 +- Aaru.Compression/TeleDiskLzh.cs | 6 +- .../Devices/Dumping/CompactDisc/LeadOuts.cs | 4 +- Aaru.Core/Logging/SubchannelLog.cs | 6 +- Aaru.Core/Media/Info/CompactDisc.cs | 16 ++--- Aaru.Core/Partitions.cs | 2 +- Aaru.Core/Sidecar/BlockTape.cs | 2 +- Aaru.Decoders | 2 +- Aaru.Filesystems/AmigaDOS.cs | 18 +++--- Aaru.Filesystems/AppleMFS/Super.cs | 4 +- Aaru.Filesystems/CPM/Info.cs | 18 +++--- Aaru.Filesystems/ECMA67.cs | 2 +- Aaru.Filesystems/FATX/Info.cs | 2 +- Aaru.Filesystems/FATX/Super.cs | 22 +++---- Aaru.Filesystems/ISO9660/File.cs | 2 +- Aaru.Filesystems/ISO9660/Info.cs | 4 +- Aaru.Filesystems/ISO9660/Mode2.cs | 4 +- Aaru.Filesystems/ISO9660/Xattr.cs | 2 +- Aaru.Filesystems/Nintendo.cs | 2 +- Aaru.Filesystems/PCEngine.cs | 2 +- Aaru.Filesystems/Reiser4.cs | 2 +- Aaru.Filesystems/Squash.cs | 2 +- Aaru.Filesystems/UNIXBFS.cs | 2 +- Aaru.Filesystems/VMfs.cs | 2 +- Aaru.Filesystems/ext2FS.cs | 2 +- Aaru.Filesystems/extFS.cs | 4 +- Aaru.Filters/AppleDouble.cs | 2 +- Aaru.Filters/AppleSingle.cs | 12 ++-- Aaru.Filters/MacBinary.cs | 12 ++-- Aaru.Gui/Controls/BlockMap.cs | 8 +-- .../Windows/ImageChecksumViewModel.cs | 2 +- .../Windows/ImageConvertViewModel.cs | 4 +- Aaru.Images/AaruFormat/CdEcc.cs | 6 +- Aaru.Images/Apridisk/Helpers.cs | 4 +- Aaru.Images/Apridisk/Read.cs | 6 +- Aaru.Images/CDRDAO/Helpers.cs | 2 +- Aaru.Images/CDRDAO/Write.cs | 12 ++-- Aaru.Images/CHD/Read.cs | 60 +++++++++---------- Aaru.Images/CloneCD/Helpers.cs | 6 +- Aaru.Images/DiscFerret/Read.cs | 4 +- Aaru.Images/DiskDupe/Helpers.cs | 2 +- Aaru.Images/GDI/Properties.cs | 2 +- Aaru.Images/GDI/Read.cs | 10 ++-- Aaru.Images/QCOW/Read.cs | 2 +- Aaru.Images/QED/Read.cs | 4 +- Aaru.Images/QED/Write.cs | 6 +- Aaru.Images/TeleDisk/Helpers.cs | 4 +- Aaru.Images/UkvFdi/Helpers.cs | 4 +- Aaru.Images/VHDX/Read.cs | 6 +- Aaru.Images/VMware/Read.cs | 4 +- Aaru.Partitions/AppleMap.cs | 22 +++---- Aaru.Partitions/BSD.cs | 8 +-- Aaru.Partitions/GPT.cs | 8 +-- Aaru.Partitions/NeXT.cs | 6 +- Aaru.Partitions/Plan9.cs | 4 +- Aaru.Partitions/RDB.cs | 4 +- Aaru.Partitions/SGI.cs | 4 +- Aaru.Partitions/Sun.cs | 18 +++--- Aaru.Tests.Devices/SCSI_MMC/GdRom.cs | 2 +- Aaru/Commands/Image/Checksum.cs | 4 +- 61 files changed, 201 insertions(+), 201 deletions(-) diff --git a/Aaru.Checksums b/Aaru.Checksums index 8ca59cbcd..e28d38c8a 160000 --- a/Aaru.Checksums +++ b/Aaru.Checksums @@ -1 +1 @@ -Subproject commit 8ca59cbcd0a4a9a2740ea11531937bc26965d4b2 +Subproject commit e28d38c8ae2c8d179851ec1989af76cbcd4fdeb3 diff --git a/Aaru.CommonTypes b/Aaru.CommonTypes index fb6e3cf36..c63d5a5f4 160000 --- a/Aaru.CommonTypes +++ b/Aaru.CommonTypes @@ -1 +1 @@ -Subproject commit fb6e3cf36116dac98001f505c131c64ac59e481c +Subproject commit c63d5a5f4419b9732dfc300704385922f6717074 diff --git a/Aaru.Compression/TeleDiskLzh.cs b/Aaru.Compression/TeleDiskLzh.cs index a64893185..19d218f24 100644 --- a/Aaru.Compression/TeleDiskLzh.cs +++ b/Aaru.Compression/TeleDiskLzh.cs @@ -68,7 +68,7 @@ namespace Aaru.Compression /* 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 ROOT = T - 1; /* root position */ @@ -129,7 +129,7 @@ namespace Aaru.Compression /* pointing children nodes (son[], son[] + 1)*/ readonly short[] _son = new short[T]; - readonly byte[] _textBuf = new byte[(N + F) - 1]; + readonly byte[] _textBuf = new byte[N + F - 1]; ushort _getbuf; byte _getlen; @@ -196,7 +196,7 @@ namespace Aaru.Compression return count; // fatal error _tdctl.Bufpos = (ushort)((_tdctl.R - pos - 1) & (N - 1)); - _tdctl.Bufcnt = (ushort)((c - 255) + THRESHOLD); + _tdctl.Bufcnt = (ushort)(c - 255 + THRESHOLD); _tdctl.Bufndx = 0; } } diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/LeadOuts.cs b/Aaru.Core/Devices/Dumping/CompactDisc/LeadOuts.cs index b9c8c2f04..02b027d62 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/LeadOuts.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/LeadOuts.cs @@ -207,7 +207,7 @@ namespace Aaru.Core.Devices.Dumping ibgLog.Write(i, 0); } - double newSpeed = ((double)blockSize * _maximumReadable) / 1048576 / (cmdDuration / 1000); + double newSpeed = (double)blockSize * _maximumReadable / 1048576 / (cmdDuration / 1000); if(!double.IsInfinity(newSpeed)) currentSpeed = newSpeed; @@ -376,7 +376,7 @@ namespace Aaru.Core.Devices.Dumping ibgLog.Write(i, 0); } - double newSpeed = ((double)blockSize * _maximumReadable) / 1048576 / (cmdDuration / 1000); + double newSpeed = (double)blockSize * _maximumReadable / 1048576 / (cmdDuration / 1000); if(!double.IsInfinity(newSpeed)) currentSpeed = newSpeed; diff --git a/Aaru.Core/Logging/SubchannelLog.cs b/Aaru.Core/Logging/SubchannelLog.cs index c242b002d..c14595c76 100644 --- a/Aaru.Core/Logging/SubchannelLog.cs +++ b/Aaru.Core/Logging/SubchannelLog.cs @@ -314,9 +314,9 @@ namespace Aaru.Core.Logging /// Message to log public void WriteMessageWithPosition(long lba, string message) { - long minute = (lba + 150) / 4500; - long second = ((lba + 150) % 4500) / 75; - long frame = (lba + 150) % 4500 % 75; + long minute = (lba + 150) / 4500; + long second = (lba + 150) % 4500 / 75; + long frame = (lba + 150) % 4500 % 75; string area = lba < 0 ? "Lead-In" : "Program"; _logSw.WriteLine($"{minute:D2}:{second:D2}:{frame:D2} - LBA {lba,6}: {area} area, {message}"); diff --git a/Aaru.Core/Media/Info/CompactDisc.cs b/Aaru.Core/Media/Info/CompactDisc.cs index 3a510a69f..4b83a5bbd 100644 --- a/Aaru.Core/Media/Info/CompactDisc.cs +++ b/Aaru.Core/Media/Info/CompactDisc.cs @@ -131,12 +131,12 @@ namespace Aaru.Core.Media.Info frame = cmdBuf[i + 14]; // Convert to binary - minute = ((minute / 16) * 10) + (minute & 0x0F); - second = ((second / 16) * 10) + (second & 0x0F); - frame = ((frame / 16) * 10) + (frame & 0x0F); + minute = (minute / 16 * 10) + (minute & 0x0F); + second = (second / 16 * 10) + (second & 0x0F); + frame = (frame / 16 * 10) + (frame & 0x0F); // Calculate the first found LBA - lba = ((minute * 60 * 75) + (second * 75) + frame) - 150; + lba = (minute * 60 * 75) + (second * 75) + frame - 150; // Calculate the difference between the found LBA and the requested one diff = (int)wantedLba - lba; @@ -191,12 +191,12 @@ namespace Aaru.Core.Media.Info frame = cmdBuf[i + 14]; // Convert to binary - minute = ((minute / 16) * 10) + (minute & 0x0F); - second = ((second / 16) * 10) + (second & 0x0F); - frame = ((frame / 16) * 10) + (frame & 0x0F); + minute = (minute / 16 * 10) + (minute & 0x0F); + second = (second / 16 * 10) + (second & 0x0F); + frame = (frame / 16 * 10) + (frame & 0x0F); // Calculate the first found LBA - lba = ((minute * 60 * 75) + (second * 75) + frame) - 150; + lba = (minute * 60 * 75) + (second * 75) + frame - 150; // Calculate the difference between the found LBA and the requested one diff = (int)wantedLba - lba; diff --git a/Aaru.Core/Partitions.cs b/Aaru.Core/Partitions.cs index 69c27f970..ed746731d 100644 --- a/Aaru.Core/Partitions.cs +++ b/Aaru.Core/Partitions.cs @@ -161,7 +161,7 @@ namespace Aaru.Core Select(tapeFile => new Partition { Start = tapeFile.FirstBlock, - Length = (tapeFile.LastBlock - tapeFile.FirstBlock) + 1, + Length = tapeFile.LastBlock - tapeFile.FirstBlock + 1, Sequence = tapeFile.File })); } diff --git a/Aaru.Core/Sidecar/BlockTape.cs b/Aaru.Core/Sidecar/BlockTape.cs index 11b8ea1f4..0653bfc01 100644 --- a/Aaru.Core/Sidecar/BlockTape.cs +++ b/Aaru.Core/Sidecar/BlockTape.cs @@ -157,7 +157,7 @@ namespace Aaru.Core tapeWorker.Update(sector); } - tapeFile.EndBlock = (tapeFile.StartBlock + sectors) - 1; + tapeFile.EndBlock = tapeFile.StartBlock + sectors - 1; currentBlock += sectors; totalSize += (ulong)_fs.Length; tapeFile.Checksums = fileWorker.End().ToArray(); diff --git a/Aaru.Decoders b/Aaru.Decoders index f7fa22672..e9e427d50 160000 --- a/Aaru.Decoders +++ b/Aaru.Decoders @@ -1 +1 @@ -Subproject commit f7fa226727375a8e093d8252d95f4a02c4b45cf0 +Subproject commit e9e427d50bb7ec58ade0640702767bbb3f7ead02 diff --git a/Aaru.Filesystems/AmigaDOS.cs b/Aaru.Filesystems/AmigaDOS.cs index 65a06437b..0c190ef7e 100644 --- a/Aaru.Filesystems/AmigaDOS.cs +++ b/Aaru.Filesystems/AmigaDOS.cs @@ -116,10 +116,10 @@ namespace Aaru.Filesystems ulong[] rootPtrs = { - bRootPtr + 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 + bRootPtr + 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 }; var rblk = new RootBlock(); @@ -201,10 +201,10 @@ namespace Aaru.Filesystems ulong[] rootPtrs = { - bRootPtr + 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 + bRootPtr + 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 }; var rootBlk = new RootBlock(); @@ -342,7 +342,7 @@ namespace Aaru.Filesystems (bootBlk.diskType & 0xFF) == 5) sbInformation.AppendFormat("Directory cache starts at block {0}", rootBlk.extension).AppendLine(); - ulong blocks = (((partition.End - partition.Start) + 1) * imagePlugin.Info.SectorSize) / blockSize; + ulong blocks = (partition.End - partition.Start + 1) * imagePlugin.Info.SectorSize / blockSize; sbInformation.AppendFormat("Volume block size is {0} bytes", blockSize).AppendLine(); sbInformation.AppendFormat("Volume has {0} blocks", blocks).AppendLine(); diff --git a/Aaru.Filesystems/AppleMFS/Super.cs b/Aaru.Filesystems/AppleMFS/Super.cs index c970936c9..3fb80e878 100644 --- a/Aaru.Filesystems/AppleMFS/Super.cs +++ b/Aaru.Filesystems/AppleMFS/Super.cs @@ -88,8 +88,8 @@ namespace Aaru.Filesystems _volMdb.drVN = StringHandlers.PascalToString(variableSize, Encoding); _directoryBlocks = _device.ReadSectors(_volMdb.drDirSt + _partitionStart, _volMdb.drBlLen); - int bytesInBlockMap = ((_volMdb.drNmAlBlks * 12) / 8) + ((_volMdb.drNmAlBlks * 12) % 8); - int bytesInWholeMdb = bytesInBlockMap + BYTES_BEFORE_BLOCK_MAP; + int bytesInBlockMap = (_volMdb.drNmAlBlks * 12 / 8) + (_volMdb.drNmAlBlks * 12 % 8); + int bytesInWholeMdb = bytesInBlockMap + BYTES_BEFORE_BLOCK_MAP; int sectorsInWholeMdb = (bytesInWholeMdb / (int)_device.Info.SectorSize) + (bytesInWholeMdb % (int)_device.Info.SectorSize); diff --git a/Aaru.Filesystems/CPM/Info.cs b/Aaru.Filesystems/CPM/Info.cs index db3ec921f..0dcf0a6f8 100644 --- a/Aaru.Filesystems/CPM/Info.cs +++ b/Aaru.Filesystems/CPM/Info.cs @@ -234,8 +234,8 @@ namespace Aaru.Filesystems 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); + _dpb.spt = (ushort)(amsSb.spt * (sectorSize / 128)); + uint directoryLength = (uint)(((ulong)_dpb.drm + 1) * 32 / sectorSize); directory = imagePlugin.ReadSectors(firstDirectorySector + partition.Start, directoryLength); @@ -361,7 +361,7 @@ namespace Aaru.Filesystems 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); @@ -884,7 +884,7 @@ namespace Aaru.Filesystems if(_cpmFound) { - uint directoryLength = (uint)((((ulong)_dpb.drm + 1) * 32) / imagePlugin.Info.SectorSize); + uint directoryLength = (uint)(((ulong)_dpb.drm + 1) * 32 / imagePlugin.Info.SectorSize); directory = imagePlugin.ReadSectors(firstDirectorySector86 + partition.Start, directoryLength); AaruConsole.DebugWriteLine("CP/M Plugin", "Found CP/M-86 floppy identifier."); } @@ -929,7 +929,7 @@ namespace Aaru.Filesystems 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) { @@ -951,7 +951,7 @@ namespace Aaru.Filesystems // 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; } @@ -965,7 +965,7 @@ namespace Aaru.Filesystems // 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; } @@ -1005,7 +1005,7 @@ namespace Aaru.Filesystems { 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); @@ -1044,7 +1044,7 @@ namespace Aaru.Filesystems dsm = (ushort)def.dsm, exm = (byte)def.exm, off = (ushort)def.ofs, - spt = (ushort)((def.sectorsPerTrack * def.bytesPerSector) / 128) + spt = (ushort)(def.sectorsPerTrack * def.bytesPerSector / 128) }; switch(def.bytesPerSector) diff --git a/Aaru.Filesystems/ECMA67.cs b/Aaru.Filesystems/ECMA67.cs index f72a323de..805f26d32 100644 --- a/Aaru.Filesystems/ECMA67.cs +++ b/Aaru.Filesystems/ECMA67.cs @@ -102,7 +102,7 @@ namespace Aaru.Filesystems { Type = "ECMA-67", ClusterSize = 256, - Clusters = (partition.End - partition.Start) + 1, + Clusters = partition.End - partition.Start + 1, VolumeName = Encoding.ASCII.GetString(vol.volumeIdentifier) }; diff --git a/Aaru.Filesystems/FATX/Info.cs b/Aaru.Filesystems/FATX/Info.cs index d4c6d16bd..e976086a8 100644 --- a/Aaru.Filesystems/FATX/Info.cs +++ b/Aaru.Filesystems/FATX/Info.cs @@ -111,7 +111,7 @@ namespace Aaru.Filesystems VolumeSerial = $"{fatxSb.id:X8}" }; - XmlFsType.Clusters = (((partition.End - partition.Start) + 1) * imagePlugin.Info.SectorSize) / + XmlFsType.Clusters = (partition.End - partition.Start + 1) * imagePlugin.Info.SectorSize / XmlFsType.ClusterSize; } } diff --git a/Aaru.Filesystems/FATX/Super.cs b/Aaru.Filesystems/FATX/Super.cs index aeaa5554e..7cfdfb568 100644 --- a/Aaru.Filesystems/FATX/Super.cs +++ b/Aaru.Filesystems/FATX/Super.cs @@ -98,7 +98,7 @@ namespace Aaru.Filesystems VolumeSerial = $"{_superblock.id:X8}" }; - XmlFsType.Clusters = (((partition.End - partition.Start) + 1) * imagePlugin.Info.SectorSize) / + XmlFsType.Clusters = (partition.End - partition.Start + 1) * imagePlugin.Info.SectorSize / XmlFsType.ClusterSize; _statfs = new FileSystemInfo @@ -135,17 +135,17 @@ namespace Aaru.Filesystems { AaruConsole.DebugWriteLine("Xbox FAT plugin", "Reading FAT32"); - fatSize = (uint)(((_statfs.Blocks + 1) * sizeof(uint)) / imagePlugin.Info.SectorSize); + fatSize = (uint)((_statfs.Blocks + 1) * sizeof(uint) / imagePlugin.Info.SectorSize); - if((uint)(((_statfs.Blocks + 1) * sizeof(uint)) % imagePlugin.Info.SectorSize) > 0) + if((uint)((_statfs.Blocks + 1) * sizeof(uint) % imagePlugin.Info.SectorSize) > 0) fatSize++; - long fatClusters = (fatSize * imagePlugin.Info.SectorSize) / 4096; + long fatClusters = fatSize * imagePlugin.Info.SectorSize / 4096; - if((fatSize * imagePlugin.Info.SectorSize) % 4096 > 0) + if(fatSize * imagePlugin.Info.SectorSize % 4096 > 0) fatClusters++; - fatSize = (uint)((fatClusters * 4096) / imagePlugin.Info.SectorSize); + fatSize = (uint)(fatClusters * 4096 / imagePlugin.Info.SectorSize); AaruConsole.DebugWriteLine("Xbox FAT plugin", "FAT is {0} sectors", fatSize); @@ -167,17 +167,17 @@ namespace Aaru.Filesystems { AaruConsole.DebugWriteLine("Xbox FAT plugin", "Reading FAT16"); - fatSize = (uint)(((_statfs.Blocks + 1) * sizeof(ushort)) / imagePlugin.Info.SectorSize); + fatSize = (uint)((_statfs.Blocks + 1) * sizeof(ushort) / imagePlugin.Info.SectorSize); - if((uint)(((_statfs.Blocks + 1) * sizeof(ushort)) % imagePlugin.Info.SectorSize) > 0) + if((uint)((_statfs.Blocks + 1) * sizeof(ushort) % imagePlugin.Info.SectorSize) > 0) fatSize++; - long fatClusters = (fatSize * imagePlugin.Info.SectorSize) / 4096; + long fatClusters = fatSize * imagePlugin.Info.SectorSize / 4096; - if((fatSize * imagePlugin.Info.SectorSize) % 4096 > 0) + if(fatSize * imagePlugin.Info.SectorSize % 4096 > 0) fatClusters++; - fatSize = (uint)((fatClusters * 4096) / imagePlugin.Info.SectorSize); + fatSize = (uint)(fatClusters * 4096 / imagePlugin.Info.SectorSize); AaruConsole.DebugWriteLine("Xbox FAT plugin", "FAT is {0} sectors", fatSize); diff --git a/Aaru.Filesystems/ISO9660/File.cs b/Aaru.Filesystems/ISO9660/File.cs index b7c96f779..4b60d8928 100644 --- a/Aaru.Filesystems/ISO9660/File.cs +++ b/Aaru.Filesystems/ISO9660/File.cs @@ -581,7 +581,7 @@ namespace Aaru.Filesystems try { byte[] fullSector = - _image.ReadSectorTag(((extents[i].extent + currentExtentSector) * _blockSize) / 2048, + _image.ReadSectorTag((extents[i].extent + currentExtentSector) * _blockSize / 2048, SectorTagType.CdSectorSubHeader); ms.Write(fullSector, copy ? 0 : 4, 4); diff --git a/Aaru.Filesystems/ISO9660/Info.cs b/Aaru.Filesystems/ISO9660/Info.cs index cd845b4b5..5806b37a5 100644 --- a/Aaru.Filesystems/ISO9660/Info.cs +++ b/Aaru.Filesystems/ISO9660/Info.cs @@ -697,7 +697,7 @@ namespace Aaru.Filesystems initialEntry.sector_count); byte[] bootImage = - (initialEntry.load_rba + partition.Start + initialEntry.sector_count) - 1 <= partition.End + initialEntry.load_rba + partition.Start + initialEntry.sector_count - 1 <= partition.End ? imagePlugin.ReadSectors(initialEntry.load_rba + partition.Start, initialEntry.sector_count) : null; @@ -790,7 +790,7 @@ namespace Aaru.Filesystems if(sectionEntry.bootable == ElToritoIndicator.Bootable) { bootImage = - (sectionEntry.load_rba + partition.Start + sectionEntry.sector_count) - 1 <= + sectionEntry.load_rba + partition.Start + sectionEntry.sector_count - 1 <= partition.End ? imagePlugin.ReadSectors(sectionEntry.load_rba + partition.Start, sectionEntry.sector_count) : null; diff --git a/Aaru.Filesystems/ISO9660/Mode2.cs b/Aaru.Filesystems/ISO9660/Mode2.cs index 7cde82c49..7b2e5e1e7 100644 --- a/Aaru.Filesystems/ISO9660/Mode2.cs +++ b/Aaru.Filesystems/ISO9660/Mode2.cs @@ -50,9 +50,9 @@ namespace Aaru.Filesystems if(_blockSize % 2048 > 0) sectorCount++; - realSector = (sector * _blockSize) / 2048; + realSector = sector * _blockSize / 2048; - ulong offset = (sector * _blockSize) % 2048; + ulong offset = sector * _blockSize % 2048; byte[] data; diff --git a/Aaru.Filesystems/ISO9660/Xattr.cs b/Aaru.Filesystems/ISO9660/Xattr.cs index e584fdee2..2636966b5 100644 --- a/Aaru.Filesystems/ISO9660/Xattr.cs +++ b/Aaru.Filesystems/ISO9660/Xattr.cs @@ -87,7 +87,7 @@ namespace Aaru.Filesystems // TODO: No more exceptions try { - byte[] sector = _image.ReadSectorLong((entry.Extents[0].extent * _blockSize) / 2048); + byte[] sector = _image.ReadSectorLong(entry.Extents[0].extent * _blockSize / 2048); if(sector[15] != 2) return Errno.NoError; diff --git a/Aaru.Filesystems/Nintendo.cs b/Aaru.Filesystems/Nintendo.cs index 59eda1489..26f48f946 100644 --- a/Aaru.Filesystems/Nintendo.cs +++ b/Aaru.Filesystems/Nintendo.cs @@ -330,7 +330,7 @@ namespace Aaru.Filesystems information = sbInformation.ToString(); XmlFsType.Bootable = true; - XmlFsType.Clusters = (imagePlugin.Info.Sectors * imagePlugin.Info.SectorSize) / 2048; + XmlFsType.Clusters = imagePlugin.Info.Sectors * imagePlugin.Info.SectorSize / 2048; XmlFsType.ClusterSize = 2048; XmlFsType.Type = wii ? "Nintendo Wii filesystem" : "Nintendo Gamecube filesystem"; XmlFsType.VolumeName = fields.Title; diff --git a/Aaru.Filesystems/PCEngine.cs b/Aaru.Filesystems/PCEngine.cs index 61bae5c17..3746fcfbc 100644 --- a/Aaru.Filesystems/PCEngine.cs +++ b/Aaru.Filesystems/PCEngine.cs @@ -79,7 +79,7 @@ namespace Aaru.Filesystems XmlFsType = new FileSystemType { Type = "PC Engine filesystem", - Clusters = (((partition.End - partition.Start) + 1) / imagePlugin.Info.SectorSize) * 2048, + Clusters = (partition.End - partition.Start + 1) / imagePlugin.Info.SectorSize * 2048, ClusterSize = 2048 }; } diff --git a/Aaru.Filesystems/Reiser4.cs b/Aaru.Filesystems/Reiser4.cs index dec5fc87c..1bbc95174 100644 --- a/Aaru.Filesystems/Reiser4.cs +++ b/Aaru.Filesystems/Reiser4.cs @@ -139,7 +139,7 @@ namespace Aaru.Filesystems { Type = "Reiser 4 filesystem", ClusterSize = reiserSb.blocksize, - Clusters = ((partition.End - partition.Start) * imagePlugin.Info.SectorSize) / reiserSb.blocksize, + Clusters = (partition.End - partition.Start) * imagePlugin.Info.SectorSize / reiserSb.blocksize, VolumeName = StringHandlers.CToString(reiserSb.label, Encoding), VolumeSerial = reiserSb.uuid.ToString() }; diff --git a/Aaru.Filesystems/Squash.cs b/Aaru.Filesystems/Squash.cs index 14f1b8023..c7188ead1 100644 --- a/Aaru.Filesystems/Squash.cs +++ b/Aaru.Filesystems/Squash.cs @@ -152,7 +152,7 @@ namespace Aaru.Filesystems Type = "Squash file system", CreationDate = DateHandlers.UnixUnsignedToDateTime(sqSb.mkfs_time), CreationDateSpecified = true, - Clusters = (((partition.End - partition.Start) + 1) * imagePlugin.Info.SectorSize) / sqSb.block_size, + Clusters = (partition.End - partition.Start + 1) * imagePlugin.Info.SectorSize / sqSb.block_size, ClusterSize = sqSb.block_size, Files = sqSb.inodes, FilesSpecified = true, diff --git a/Aaru.Filesystems/UNIXBFS.cs b/Aaru.Filesystems/UNIXBFS.cs index abc7aa7fa..037ce4b63 100644 --- a/Aaru.Filesystems/UNIXBFS.cs +++ b/Aaru.Filesystems/UNIXBFS.cs @@ -121,7 +121,7 @@ namespace Aaru.Filesystems Type = "BFS", VolumeName = bfsSb.s_volume, ClusterSize = imagePlugin.Info.SectorSize, - Clusters = (partition.End - partition.Start) + 1 + Clusters = partition.End - partition.Start + 1 }; information = sb.ToString(); diff --git a/Aaru.Filesystems/VMfs.cs b/Aaru.Filesystems/VMfs.cs index b73803bbc..5c5971815 100644 --- a/Aaru.Filesystems/VMfs.cs +++ b/Aaru.Filesystems/VMfs.cs @@ -126,7 +126,7 @@ namespace Aaru.Filesystems CreationDateSpecified = true, ModificationDate = DateHandlers.UnixUnsignedToDateTime(mtimeSecs, mtimeNanoSecs), ModificationDateSpecified = true, - Clusters = (volInfo.size * 256) / imagePlugin.Info.SectorSize, + Clusters = volInfo.size * 256 / imagePlugin.Info.SectorSize, ClusterSize = imagePlugin.Info.SectorSize, VolumeSerial = volInfo.uuid.ToString() }; diff --git a/Aaru.Filesystems/ext2FS.cs b/Aaru.Filesystems/ext2FS.cs index 4b1ebd959..2738e6331 100644 --- a/Aaru.Filesystems/ext2FS.cs +++ b/Aaru.Filesystems/ext2FS.cs @@ -518,7 +518,7 @@ namespace Aaru.Filesystems XmlFsType.FreeClustersSpecified = true; sb.AppendFormat("{0} inodes with {1} free inodes ({2}%)", supblk.inodes, supblk.free_inodes, - (supblk.free_inodes * 100) / supblk.inodes).AppendLine(); + supblk.free_inodes * 100 / supblk.inodes).AppendLine(); if(supblk.first_inode > 0) sb.AppendFormat("First inode is {0}", supblk.first_inode).AppendLine(); diff --git a/Aaru.Filesystems/extFS.cs b/Aaru.Filesystems/extFS.cs index 8e09b0a74..16fdc0b3e 100644 --- a/Aaru.Filesystems/extFS.cs +++ b/Aaru.Filesystems/extFS.cs @@ -127,7 +127,7 @@ namespace Aaru.Filesystems sb.AppendFormat("{0} free blocks ({1} bytes)", extSb.freecountblk, extSb.freecountblk * 1024); sb.AppendFormat("{0} inodes on volume, {1} free ({2}%)", extSb.inodes, extSb.freecountind, - (extSb.freecountind * 100) / extSb.inodes); + extSb.freecountind * 100 / extSb.inodes); sb.AppendFormat("First free inode is {0}", extSb.firstfreeind); sb.AppendFormat("First free block is {0}", extSb.firstfreeblk); @@ -141,7 +141,7 @@ namespace Aaru.Filesystems FreeClusters = extSb.freecountblk, FreeClustersSpecified = true, ClusterSize = 1024, - Clusters = (((partition.End - partition.Start) + 1) * imagePlugin.Info.SectorSize) / 1024 + Clusters = (partition.End - partition.Start + 1) * imagePlugin.Info.SectorSize / 1024 }; information = sb.ToString(); diff --git a/Aaru.Filters/AppleDouble.cs b/Aaru.Filters/AppleDouble.cs index b96b4a347..df4de5083 100644 --- a/Aaru.Filters/AppleDouble.cs +++ b/Aaru.Filters/AppleDouble.cs @@ -129,7 +129,7 @@ namespace Aaru.Filters return null; return new OffsetStream(_headerPath, FileMode.Open, FileAccess.Read, _rsrcFork.offset, - (_rsrcFork.offset + _rsrcFork.length) - 1); + _rsrcFork.offset + _rsrcFork.length - 1); } /// diff --git a/Aaru.Filters/AppleSingle.cs b/Aaru.Filters/AppleSingle.cs index ee878c295..a91d61aee 100644 --- a/Aaru.Filters/AppleSingle.cs +++ b/Aaru.Filters/AppleSingle.cs @@ -117,14 +117,14 @@ namespace Aaru.Filters return null; if(_isBytes) - return new OffsetStream(_bytes, _dataFork.offset, (_dataFork.offset + _dataFork.length) - 1); + return new OffsetStream(_bytes, _dataFork.offset, _dataFork.offset + _dataFork.length - 1); if(_isStream) - return new OffsetStream(_stream, _dataFork.offset, (_dataFork.offset + _dataFork.length) - 1); + return new OffsetStream(_stream, _dataFork.offset, _dataFork.offset + _dataFork.length - 1); if(_isPath) return new OffsetStream(_basePath, FileMode.Open, FileAccess.Read, _dataFork.offset, - (_dataFork.offset + _dataFork.length) - 1); + _dataFork.offset + _dataFork.length - 1); return null; } @@ -154,14 +154,14 @@ namespace Aaru.Filters return null; if(_isBytes) - return new OffsetStream(_bytes, _rsrcFork.offset, (_rsrcFork.offset + _rsrcFork.length) - 1); + return new OffsetStream(_bytes, _rsrcFork.offset, _rsrcFork.offset + _rsrcFork.length - 1); if(_isStream) - return new OffsetStream(_stream, _rsrcFork.offset, (_rsrcFork.offset + _rsrcFork.length) - 1); + return new OffsetStream(_stream, _rsrcFork.offset, _rsrcFork.offset + _rsrcFork.length - 1); if(_isPath) return new OffsetStream(_basePath, FileMode.Open, FileAccess.Read, _rsrcFork.offset, - (_rsrcFork.offset + _rsrcFork.length) - 1); + _rsrcFork.offset + _rsrcFork.length - 1); return null; } diff --git a/Aaru.Filters/MacBinary.cs b/Aaru.Filters/MacBinary.cs index 2a9542673..da480f1e9 100644 --- a/Aaru.Filters/MacBinary.cs +++ b/Aaru.Filters/MacBinary.cs @@ -90,14 +90,14 @@ namespace Aaru.Filters return null; if(_isBytes) - return new OffsetStream(_bytes, _dataForkOff, (_dataForkOff + _header.dataLength) - 1); + return new OffsetStream(_bytes, _dataForkOff, _dataForkOff + _header.dataLength - 1); if(_isStream) - return new OffsetStream(_stream, _dataForkOff, (_dataForkOff + _header.dataLength) - 1); + return new OffsetStream(_stream, _dataForkOff, _dataForkOff + _header.dataLength - 1); if(_isPath) return new OffsetStream(_basePath, FileMode.Open, FileAccess.Read, _dataForkOff, - (_dataForkOff + _header.dataLength) - 1); + _dataForkOff + _header.dataLength - 1); return null; } @@ -127,14 +127,14 @@ namespace Aaru.Filters return null; if(_isBytes) - return new OffsetStream(_bytes, _rsrcForkOff, (_rsrcForkOff + _header.resourceLength) - 1); + return new OffsetStream(_bytes, _rsrcForkOff, _rsrcForkOff + _header.resourceLength - 1); if(_isStream) - return new OffsetStream(_stream, _rsrcForkOff, (_rsrcForkOff + _header.resourceLength) - 1); + return new OffsetStream(_stream, _rsrcForkOff, _rsrcForkOff + _header.resourceLength - 1); if(_isPath) return new OffsetStream(_basePath, FileMode.Open, FileAccess.Read, _rsrcForkOff, - (_rsrcForkOff + _header.resourceLength) - 1); + _rsrcForkOff + _header.resourceLength - 1); return null; } diff --git a/Aaru.Gui/Controls/BlockMap.cs b/Aaru.Gui/Controls/BlockMap.cs index fd616d69e..77ba24591 100644 --- a/Aaru.Gui/Controls/BlockMap.cs +++ b/Aaru.Gui/Controls/BlockMap.cs @@ -170,7 +170,7 @@ namespace Aaru.Gui.Controls { case nameof(Blocks): if(_maxBlocks == 0) - _maxBlocks = (ulong)((Width / _blockSize) * (Height / _blockSize)); + _maxBlocks = (ulong)(Width / _blockSize * (Height / _blockSize)); if(Blocks > _maxBlocks) { @@ -225,7 +225,7 @@ namespace Aaru.Gui.Controls if((int?)_bitmap?.Size.Height != (int)Height || (int?)_bitmap?.Size.Width != (int)Width) { - _maxBlocks = (ulong)((Width / _blockSize) * (Height / _blockSize)); + _maxBlocks = (ulong)(Width / _blockSize * (Height / _blockSize)); CreateBitmap(); } @@ -398,7 +398,7 @@ namespace Aaru.Gui.Controls void CreateBitmap() { if(_maxBlocks == 0) - _maxBlocks = (ulong)((Width / _blockSize) * (Height / _blockSize)); + _maxBlocks = (ulong)(Width / _blockSize * (Height / _blockSize)); _bitmap?.Dispose(); @@ -423,7 +423,7 @@ namespace Aaru.Gui.Controls { for(ulong x = 0; x < Width; x += _blockSize) { - ulong currentBlockValue = ((y * clustersPerRow) / _blockSize) + (x / _blockSize); + ulong currentBlockValue = (y * clustersPerRow / _blockSize) + (x / _blockSize); if(currentBlockValue >= _maxBlocks || currentBlockValue >= Blocks) diff --git a/Aaru.Gui/ViewModels/Windows/ImageChecksumViewModel.cs b/Aaru.Gui/ViewModels/Windows/ImageChecksumViewModel.cs index d9ab987a1..a5123078d 100644 --- a/Aaru.Gui/ViewModels/Windows/ImageChecksumViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/ImageChecksumViewModel.cs @@ -485,7 +485,7 @@ namespace Aaru.Gui.ViewModels.Windows if(ChecksumTracksChecked) trackChecksum = new Checksum(enabledChecksums); - ulong sectors = (currentTrack.TrackEndSector - currentTrack.TrackStartSector) + 1; + ulong sectors = currentTrack.TrackEndSector - currentTrack.TrackStartSector + 1; ulong doneSectors = 0; while(doneSectors < sectors) diff --git a/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs b/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs index be051c534..e3e9b9e39 100644 --- a/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs @@ -1192,7 +1192,7 @@ namespace Aaru.Gui.ViewModels.Windows foreach(Track track in tracks.TakeWhile(track => !_cancel)) { doneSectors = 0; - ulong trackSectors = (track.TrackEndSector - track.TrackStartSector) + 1; + ulong trackSectors = track.TrackEndSector - track.TrackStartSector + 1; await Dispatcher.UIThread.InvokeAsync(() => { @@ -1313,7 +1313,7 @@ namespace Aaru.Gui.ViewModels.Windows foreach(Track track in tracks.TakeWhile(track => !_cancel)) { doneSectors = 0; - ulong trackSectors = (track.TrackEndSector - track.TrackStartSector) + 1; + ulong trackSectors = track.TrackEndSector - track.TrackStartSector + 1; byte[] sector; bool result; diff --git a/Aaru.Images/AaruFormat/CdEcc.cs b/Aaru.Images/AaruFormat/CdEcc.cs index 5be55dc02..dbb9a79a7 100644 --- a/Aaru.Images/AaruFormat/CdEcc.cs +++ b/Aaru.Images/AaruFormat/CdEcc.cs @@ -151,7 +151,7 @@ namespace Aaru.DiscImages for(minor = 0; minor < minorCount; minor++) { - byte temp = idx < 4 ? address[idx + addressOffset] : data[(idx + dataOffset) - 4]; + byte temp = idx < 4 ? address[idx + addressOffset] : data[idx + dataOffset - 4]; idx += minorInc; if(idx >= size) @@ -187,7 +187,7 @@ namespace Aaru.DiscImages for(minor = 0; minor < minorCount; minor++) { - byte temp = idx < 4 ? address[idx + addressOffset] : data[(idx + dataOffset) - 4]; + byte temp = idx < 4 ? address[idx + addressOffset] : data[idx + dataOffset - 4]; idx += minorInc; if(idx >= size) @@ -212,7 +212,7 @@ namespace Aaru.DiscImages } static (byte minute, byte second, byte frame) LbaToMsf(long pos) => - ((byte)((pos + 150) / 75 / 60), (byte)(((pos + 150) / 75) % 60), (byte)((pos + 150) % 75)); + ((byte)((pos + 150) / 75 / 60), (byte)((pos + 150) / 75 % 60), (byte)((pos + 150) % 75)); void ReconstructPrefix(ref byte[] sector, // must point to a full 2352-byte sector TrackType type, long lba) diff --git a/Aaru.Images/Apridisk/Helpers.cs b/Aaru.Images/Apridisk/Helpers.cs index 72ae30819..a9cada08d 100644 --- a/Aaru.Images/Apridisk/Helpers.cs +++ b/Aaru.Images/Apridisk/Helpers.cs @@ -37,8 +37,8 @@ namespace Aaru.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/Aaru.Images/Apridisk/Read.cs b/Aaru.Images/Apridisk/Read.cs index 62bcb39ff..0a3a01e9b 100644 --- a/Aaru.Images/Apridisk/Read.cs +++ b/Aaru.Images/Apridisk/Read.cs @@ -70,7 +70,7 @@ namespace Aaru.DiscImages // Deleted record, just skip it case RecordType.Deleted: AaruConsole.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: @@ -112,7 +112,7 @@ namespace Aaru.DiscImages 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: @@ -170,7 +170,7 @@ namespace Aaru.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; diff --git a/Aaru.Images/CDRDAO/Helpers.cs b/Aaru.Images/CDRDAO/Helpers.cs index 410824c9e..28edcd682 100644 --- a/Aaru.Images/CDRDAO/Helpers.cs +++ b/Aaru.Images/CDRDAO/Helpers.cs @@ -86,7 +86,7 @@ namespace Aaru.DiscImages } static (byte minute, byte second, byte frame) LbaToMsf(ulong sector) => - ((byte)(sector / 75 / 60), (byte)((sector / 75) % 60), (byte)(sector % 75)); + ((byte)(sector / 75 / 60), (byte)(sector / 75 % 60), (byte)(sector % 75)); static string GetTrackMode(Track track) { diff --git a/Aaru.Images/CDRDAO/Write.cs b/Aaru.Images/CDRDAO/Write.cs index 625f1e9eb..75b6a90f0 100644 --- a/Aaru.Images/CDRDAO/Write.cs +++ b/Aaru.Images/CDRDAO/Write.cs @@ -429,7 +429,7 @@ namespace Aaru.DiscImages for(uint i = 0; i < length; i++) { trackStream. - Seek((long)(track.TrackFileOffset + (((i + sectorAddress) - track.TrackStartSector) * (ulong)(track.TrackRawBytesPerSector + subchannelSize))), + Seek((long)(track.TrackFileOffset + ((i + sectorAddress - track.TrackStartSector) * (ulong)(track.TrackRawBytesPerSector + subchannelSize))), SeekOrigin.Begin); trackStream.Write(data, (int)(i * track.TrackRawBytesPerSector), track.TrackRawBytesPerSector); @@ -484,10 +484,10 @@ namespace Aaru.DiscImages _writingTracks.Add(newTrack); currentOffset += (ulong)newTrack.TrackRawBytesPerSector * - ((newTrack.TrackEndSector - newTrack.TrackStartSector) + 1); + (newTrack.TrackEndSector - newTrack.TrackStartSector + 1); if(track.TrackSubchannelType != TrackSubchannelType.None) - currentOffset += 96 * ((newTrack.TrackEndSector - newTrack.TrackStartSector) + 1); + currentOffset += 96 * (newTrack.TrackEndSector - newTrack.TrackStartSector + 1); } _writingStreams = new Dictionary(); @@ -606,12 +606,12 @@ namespace Aaru.DiscImages _descriptorStream.WriteLine("ISRC {0}", isrc); (byte minute, byte second, byte frame) msf = - LbaToMsf((track.TrackEndSector - track.TrackStartSector) + 1); + LbaToMsf(track.TrackEndSector - track.TrackStartSector + 1); _descriptorStream.WriteLine("DATAFILE \"{0}\" #{1} {2:D2}:{3:D2}:{4:D2} // length in bytes: {5}", Path.GetFileName(track.TrackFile), track.TrackFileOffset, msf.minute, msf.second, msf.frame, - ((track.TrackEndSector - track.TrackStartSector) + 1) * + (track.TrackEndSector - track.TrackStartSector + 1) * (ulong)(track.TrackRawBytesPerSector + (track.TrackSubchannelType != TrackSubchannelType.None ? 96 : 0))); @@ -791,7 +791,7 @@ namespace Aaru.DiscImages for(uint i = 0; i < length; i++) { trackStream. - Seek((long)(track.TrackFileOffset + (((i + sectorAddress) - track.TrackStartSector) * (ulong)(track.TrackRawBytesPerSector + 96))) + track.TrackRawBytesPerSector, + Seek((long)(track.TrackFileOffset + ((i + sectorAddress - track.TrackStartSector) * (ulong)(track.TrackRawBytesPerSector + 96))) + track.TrackRawBytesPerSector, SeekOrigin.Begin); trackStream.Write(data, (int)(i * 96), 96); diff --git a/Aaru.Images/CHD/Read.cs b/Aaru.Images/CHD/Read.cs index 09550ca1e..2081ff77e 100644 --- a/Aaru.Images/CHD/Read.cs +++ b/Aaru.Images/CHD/Read.cs @@ -109,7 +109,7 @@ namespace Aaru.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]; @@ -124,11 +124,11 @@ namespace Aaru.DiscImages // 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; @@ -186,7 +186,7 @@ namespace Aaru.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]; @@ -201,11 +201,11 @@ namespace Aaru.DiscImages // 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; @@ -387,7 +387,7 @@ namespace Aaru.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]; @@ -406,11 +406,11 @@ namespace Aaru.DiscImages // 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; @@ -590,8 +590,8 @@ namespace Aaru.DiscImages ImageNotSupportedException($"Unsupported subchannel type {chdTrack.type}"); } - aaruTrack.TrackDescription = $"Track {i + 1}"; - aaruTrack.TrackEndSector = (currentSector + chdTrack.frames) - 1; + aaruTrack.TrackDescription = $"Track {i + 1}"; + aaruTrack.TrackEndSector = currentSector + chdTrack.frames - 1; aaruTrack.TrackFile = imageFilter.GetFilename(); aaruTrack.TrackFileType = "BINARY"; aaruTrack.TrackFilter = imageFilter; @@ -717,7 +717,7 @@ namespace Aaru.DiscImages } aaruTrack.TrackDescription = $"Track {trackNo}"; - aaruTrack.TrackEndSector = (currentSector + frames) - 1; + aaruTrack.TrackEndSector = currentSector + frames - 1; aaruTrack.TrackFile = imageFilter.GetFilename(); aaruTrack.TrackFileType = "BINARY"; aaruTrack.TrackFilter = imageFilter; @@ -856,7 +856,7 @@ namespace Aaru.DiscImages } aaruTrack.TrackDescription = $"Track {trackNo}"; - aaruTrack.TrackEndSector = (currentSector + frames) - 1; + aaruTrack.TrackEndSector = currentSector + frames - 1; aaruTrack.TrackFile = imageFilter.GetFilename(); aaruTrack.TrackFileType = "BINARY"; aaruTrack.TrackFilter = imageFilter; @@ -1013,7 +1013,7 @@ namespace Aaru.DiscImages } aaruTrack.TrackDescription = $"Track {trackNo}"; - aaruTrack.TrackEndSector = (currentSector + frames) - 1; + aaruTrack.TrackEndSector = currentSector + frames - 1; aaruTrack.TrackFile = imageFilter.GetFilename(); aaruTrack.TrackFileType = "BINARY"; aaruTrack.TrackFilter = imageFilter; @@ -1113,7 +1113,7 @@ namespace Aaru.DiscImages _imageInfo.XmlMediaType = XmlMediaType.OpticalDisc; foreach(Track aaruTrack in _tracks.Values) - _imageInfo.Sectors += (aaruTrack.TrackEndSector - aaruTrack.TrackStartSector) + 1; + _imageInfo.Sectors += aaruTrack.TrackEndSector - aaruTrack.TrackStartSector + 1; } else if(_isGdrom) { @@ -1123,7 +1123,7 @@ namespace Aaru.DiscImages _imageInfo.XmlMediaType = XmlMediaType.OpticalDisc; foreach(Track aaruTrack in _tracks.Values) - _imageInfo.Sectors += (aaruTrack.TrackEndSector - aaruTrack.TrackStartSector) + 1; + _imageInfo.Sectors += aaruTrack.TrackEndSector - aaruTrack.TrackStartSector + 1; } else throw new ImageNotSupportedException("Image does not represent a known media, aborting"); @@ -1140,9 +1140,9 @@ namespace Aaru.DiscImages var partition = new Partition { Description = aaruTrack.TrackDescription, - Size = ((aaruTrack.TrackEndSector - (ulong)aaruTrack.Indexes[1]) + 1) * + Size = (aaruTrack.TrackEndSector - (ulong)aaruTrack.Indexes[1] + 1) * (ulong)aaruTrack.TrackRawBytesPerSector, - Length = (aaruTrack.TrackEndSector - (ulong)aaruTrack.Indexes[1]) + 1, + Length = aaruTrack.TrackEndSector - (ulong)aaruTrack.Indexes[1] + 1, Sequence = aaruTrack.TrackSequence, Offset = partPos, Start = (ulong)aaruTrack.Indexes[1], @@ -1263,8 +1263,8 @@ namespace Aaru.DiscImages sectorSize = (uint)track.TrackRawBytesPerSector; } - ulong hunkNo = sectorAddress / _sectorsPerHunk; - ulong secOff = (sectorAddress * sectorSize) % (_sectorsPerHunk * sectorSize); + ulong hunkNo = sectorAddress / _sectorsPerHunk; + ulong secOff = sectorAddress * sectorSize % (_sectorsPerHunk * sectorSize); byte[] hunk = GetHunk(hunkNo); @@ -1389,8 +1389,8 @@ namespace Aaru.DiscImages track = GetTrack(sectorAddress); sectorSize = (uint)track.TrackRawBytesPerSector; - ulong hunkNo = sectorAddress / _sectorsPerHunk; - ulong secOff = (sectorAddress * sectorSize) % (_sectorsPerHunk * sectorSize); + ulong hunkNo = sectorAddress / _sectorsPerHunk; + ulong secOff = sectorAddress * sectorSize % (_sectorsPerHunk * sectorSize); byte[] hunk = GetHunk(hunkNo); @@ -1687,8 +1687,8 @@ namespace Aaru.DiscImages track = GetTrack(sectorAddress); uint sectorSize = (uint)track.TrackRawBytesPerSector; - ulong hunkNo = sectorAddress / _sectorsPerHunk; - ulong secOff = (sectorAddress * sectorSize) % (_sectorsPerHunk * sectorSize); + ulong hunkNo = sectorAddress / _sectorsPerHunk; + ulong secOff = sectorAddress * sectorSize % (_sectorsPerHunk * sectorSize); byte[] hunk = GetHunk(hunkNo); diff --git a/Aaru.Images/CloneCD/Helpers.cs b/Aaru.Images/CloneCD/Helpers.cs index 6eeb05c22..90aa77859 100644 --- a/Aaru.Images/CloneCD/Helpers.cs +++ b/Aaru.Images/CloneCD/Helpers.cs @@ -35,12 +35,12 @@ namespace Aaru.DiscImages public sealed partial class CloneCd { static ulong GetLba(int minute, int second, int frame) => - (ulong)(((minute * 60 * 75) + (second * 75) + frame) - 150); + (ulong)((minute * 60 * 75) + (second * 75) + frame - 150); static long MsfToLba((byte minute, byte second, byte frame) msf) => - ((msf.minute * 60 * 75) + (msf.second * 75) + msf.frame) - 150; + (msf.minute * 60 * 75) + (msf.second * 75) + msf.frame - 150; static (byte minute, byte second, byte frame) LbaToMsf(ulong sector) => - ((byte)((sector + 150) / 75 / 60), (byte)(((sector + 150) / 75) % 60), (byte)((sector + 150) % 75)); + ((byte)((sector + 150) / 75 / 60), (byte)((sector + 150) / 75 % 60), (byte)((sector + 150) % 75)); } } \ No newline at end of file diff --git a/Aaru.Images/DiscFerret/Read.cs b/Aaru.Images/DiscFerret/Read.cs index b23a0f48a..292784633 100644 --- a/Aaru.Images/DiscFerret/Read.cs +++ b/Aaru.Images/DiscFerret/Read.cs @@ -94,7 +94,7 @@ namespace Aaru.DiscImages lastCylinder = blockHeader.cylinder; lastHead = 0; TrackOffsets.Add(t, offset); - TrackLengths.Add(t, (thisOffset - offset) + 1); + TrackLengths.Add(t, thisOffset - offset + 1); offset = thisOffset; t++; } @@ -103,7 +103,7 @@ namespace Aaru.DiscImages { lastHead = blockHeader.head; TrackOffsets.Add(t, offset); - TrackLengths.Add(t, (thisOffset - offset) + 1); + TrackLengths.Add(t, thisOffset - offset + 1); offset = thisOffset; t++; } diff --git a/Aaru.Images/DiskDupe/Helpers.cs b/Aaru.Images/DiskDupe/Helpers.cs index 7e1e15a6f..e172899a7 100644 --- a/Aaru.Images/DiskDupe/Helpers.cs +++ b/Aaru.Images/DiskDupe/Helpers.cs @@ -63,7 +63,7 @@ namespace Aaru.DiscImages // read and check disk type byte fHeader.diskType = (byte)stream.ReadByte(); - if ((fHeader.diskType < 1) || (fHeader.diskType > 4)) + if (fHeader.diskType < 1 || fHeader.diskType > 4) return false; // seek to start of the trackmap diff --git a/Aaru.Images/GDI/Properties.cs b/Aaru.Images/GDI/Properties.cs index 6c7c68493..64483de43 100644 --- a/Aaru.Images/GDI/Properties.cs +++ b/Aaru.Images/GDI/Properties.cs @@ -82,7 +82,7 @@ namespace Aaru.DiscImages TrackSubchannelType = TrackSubchannelType.None }; - track.TrackEndSector = (track.TrackStartSector + gdiTrack.Sectors) - 1; + track.TrackEndSector = track.TrackStartSector + gdiTrack.Sectors - 1; tracks.Add(track); } diff --git a/Aaru.Images/GDI/Read.cs b/Aaru.Images/GDI/Read.cs index 14eb37c5e..9b36ff844 100644 --- a/Aaru.Images/GDI/Read.cs +++ b/Aaru.Images/GDI/Read.cs @@ -169,8 +169,8 @@ namespace Aaru.DiscImages if(sessions[s].StartSector > trk.StartSector) sessions[s].StartSector = trk.StartSector; - if(sessions[s].EndSector < (trk.Sectors + trk.StartSector) - 1) - 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; } } else @@ -190,8 +190,8 @@ namespace Aaru.DiscImages if(sessions[s].StartSector > trk.StartSector) sessions[s].StartSector = trk.StartSector; - if(sessions[s].EndSector < (trk.Sectors + trk.StartSector) - 1) - 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; } } @@ -888,7 +888,7 @@ namespace Aaru.DiscImages TrackSubchannelType = TrackSubchannelType.None }; - track.TrackEndSector = (track.TrackStartSector + gdiTrack.Sectors) - 1; + track.TrackEndSector = track.TrackStartSector + gdiTrack.Sectors - 1; tracks.Add(track); } diff --git a/Aaru.Images/QCOW/Read.cs b/Aaru.Images/QCOW/Read.cs index b44264199..19493e418 100644 --- a/Aaru.Images/QCOW/Read.cs +++ b/Aaru.Images/QCOW/Read.cs @@ -101,7 +101,7 @@ namespace Aaru.DiscImages _clusterSize = 1 << _qHdr.cluster_bits; _clusterSectors = 1 << (_qHdr.cluster_bits - 9); - _l1Size = (uint)(((_qHdr.size + (ulong)(1 << shift)) - 1) >> shift); + _l1Size = (uint)((_qHdr.size + (ulong)(1 << shift) - 1) >> shift); _l2Size = 1 << _qHdr.l2_bits; AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.clusterSize = {0}", _clusterSize); diff --git a/Aaru.Images/QED/Read.cs b/Aaru.Images/QED/Read.cs index 2df753ac9..69e06ec36 100644 --- a/Aaru.Images/QED/Read.cs +++ b/Aaru.Images/QED/Read.cs @@ -95,8 +95,8 @@ namespace Aaru.DiscImages if((_qHdr.features & QED_FEATURE_BACKING_FILE) == QED_FEATURE_BACKING_FILE) throw new NotImplementedException("Differencing images not yet supported"); - _clusterSectors = _qHdr.cluster_size / 512; - _tableSize = (_qHdr.cluster_size * _qHdr.table_size) / 8; + _clusterSectors = _qHdr.cluster_size / 512; + _tableSize = _qHdr.cluster_size * _qHdr.table_size / 8; AaruConsole.DebugWriteLine("QED plugin", "qHdr.clusterSectors = {0}", _clusterSectors); AaruConsole.DebugWriteLine("QED plugin", "qHdr.tableSize = {0}", _tableSize); diff --git a/Aaru.Images/QED/Write.cs b/Aaru.Images/QED/Write.cs index 3c035caec..8a8c46776 100644 --- a/Aaru.Images/QED/Write.cs +++ b/Aaru.Images/QED/Write.cs @@ -65,7 +65,7 @@ namespace Aaru.DiscImages } // TODO: Correct this calculation - if((sectors * sectorSize) / DEFAULT_CLUSTER_SIZE > uint.MaxValue) + if(sectors * sectorSize / DEFAULT_CLUSTER_SIZE > uint.MaxValue) { ErrorMessage = "Too many sectors for selected cluster size"; @@ -100,8 +100,8 @@ namespace Aaru.DiscImages image_size = sectors * sectorSize }; - _clusterSectors = _qHdr.cluster_size / 512; - _tableSize = (_qHdr.cluster_size * _qHdr.table_size) / 8; + _clusterSectors = _qHdr.cluster_size / 512; + _tableSize = _qHdr.cluster_size * _qHdr.table_size / 8; _l1Table = new ulong[_tableSize]; _l1Mask = 0; diff --git a/Aaru.Images/TeleDisk/Helpers.cs b/Aaru.Images/TeleDisk/Helpers.cs index 38fa7ee06..6b2d512fb 100644 --- a/Aaru.Images/TeleDisk/Helpers.cs +++ b/Aaru.Images/TeleDisk/Helpers.cs @@ -43,8 +43,8 @@ namespace Aaru.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/Aaru.Images/UkvFdi/Helpers.cs b/Aaru.Images/UkvFdi/Helpers.cs index 73b679bc8..980dfdd49 100644 --- a/Aaru.Images/UkvFdi/Helpers.cs +++ b/Aaru.Images/UkvFdi/Helpers.cs @@ -37,8 +37,8 @@ namespace Aaru.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/Aaru.Images/VHDX/Read.cs b/Aaru.Images/VHDX/Read.cs index 5d8bbf063..2a51323ab 100644 --- a/Aaru.Images/VHDX/Read.cs +++ b/Aaru.Images/VHDX/Read.cs @@ -323,7 +323,7 @@ namespace Aaru.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) @@ -439,8 +439,8 @@ namespace Aaru.DiscImages if(_sectorCache.TryGetValue(sectorAddress, out byte[] 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; diff --git a/Aaru.Images/VMware/Read.cs b/Aaru.Images/VMware/Read.cs index 74fd57989..af0cc12e7 100644 --- a/Aaru.Images/VMware/Read.cs +++ b/Aaru.Images/VMware/Read.cs @@ -582,8 +582,8 @@ namespace Aaru.DiscImages return sector; } - ulong index = sectorAddress / _grainSize; - ulong secOff = (sectorAddress % _grainSize) * SECTOR_SIZE; + ulong index = sectorAddress / _grainSize; + ulong secOff = sectorAddress % _grainSize * SECTOR_SIZE; uint grainOff = _gTable[index]; diff --git a/Aaru.Partitions/AppleMap.cs b/Aaru.Partitions/AppleMap.cs index df97aa2fa..26c54c08c 100644 --- a/Aaru.Partitions/AppleMap.cs +++ b/Aaru.Partitions/AppleMap.cs @@ -135,15 +135,15 @@ namespace Aaru.Partitions var part = new Partition { - Size = (ulong)(ddm.sbMap[i].ddSize * 512), - Length = (ulong)((ddm.sbMap[i].ddSize * 512) / sectorSize), + Size = (ulong)(ddm.sbMap[i].ddSize * 512), + Length = (ulong)(ddm.sbMap[i].ddSize * 512 / sectorSize), Sequence = sequence, Offset = ddm.sbMap[i].ddBlock * sectorSize, Start = ddm.sbMap[i].ddBlock + sectorOffset, Type = "Apple_Driver" }; - if((ddm.sbMap[i].ddSize * 512) % sectorSize > 0) + if(ddm.sbMap[i].ddSize * 512 % sectorSize > 0) part.Length++; partitions.Add(part); @@ -188,11 +188,11 @@ namespace Aaru.Partitions var part = new Partition { - Size = oldEntry.pdStart * ddm.sbBlockSize, - Length = (oldEntry.pdStart * ddm.sbBlockSize) / sectorSize, + Size = oldEntry.pdStart * ddm.sbBlockSize, + Length = oldEntry.pdStart * ddm.sbBlockSize / sectorSize, Sequence = sequence, - Offset = oldEntry.pdSize * ddm.sbBlockSize, - Start = (oldEntry.pdSize * ddm.sbBlockSize) / sectorSize, + Offset = oldEntry.pdSize * ddm.sbBlockSize, + Start = oldEntry.pdSize * ddm.sbBlockSize / sectorSize, Scheme = Name, Type = oldEntry.pdFSID == HFS_MAGIC_OLD ? "Apple_HFS" : $"0x{oldEntry.pdFSID:X8}" }; @@ -225,7 +225,7 @@ namespace Aaru.Partitions entrySize = 512; entryCount = entry.entries; skipDdm = 512; - sectorsToRead = (((entryCount + 1) * 512) / sectorSize) + 1; + sectorsToRead = ((entryCount + 1) * 512 / sectorSize) + 1; } else { @@ -334,8 +334,8 @@ namespace Aaru.Partitions Name = StringHandlers.CToString(entry.name), Offset = entry.start * entrySize, Size = entry.sectors * entrySize, - Start = ((entry.start * entrySize) / sectorSize) + sectorOffset, - Length = (entry.sectors * entrySize) / sectorSize, + Start = (entry.start * entrySize / sectorSize) + sectorOffset, + Length = entry.sectors * entrySize / sectorSize, Scheme = Name }; @@ -361,7 +361,7 @@ namespace Aaru.Partitions if(flags.HasFlag(AppleMapFlags.Bootable)) { - sb.AppendFormat("First boot sector: {0}", (entry.first_boot_block * entrySize) / sectorSize). + sb.AppendFormat("First boot sector: {0}", entry.first_boot_block * entrySize / sectorSize). AppendLine(); sb.AppendFormat("Boot is {0} bytes.", entry.boot_size).AppendLine(); diff --git a/Aaru.Partitions/BSD.cs b/Aaru.Partitions/BSD.cs index 966eb0ddd..f0ac34dc3 100644 --- a/Aaru.Partitions/BSD.cs +++ b/Aaru.Partitions/BSD.cs @@ -176,10 +176,10 @@ namespace Aaru.Partitions var part = new Partition { - Start = (dl.d_partitions[i].p_offset * dl.d_secsize) / imagePlugin.Info.SectorSize, - Offset = dl.d_partitions[i].p_offset * dl.d_secsize, - Length = (dl.d_partitions[i].p_size * dl.d_secsize) / imagePlugin.Info.SectorSize, - Size = dl.d_partitions[i].p_size * dl.d_secsize, + Start = dl.d_partitions[i].p_offset * dl.d_secsize / imagePlugin.Info.SectorSize, + Offset = dl.d_partitions[i].p_offset * dl.d_secsize, + Length = dl.d_partitions[i].p_size * dl.d_secsize / imagePlugin.Info.SectorSize, + Size = dl.d_partitions[i].p_size * dl.d_secsize, Type = fsTypeToString(dl.d_partitions[i].p_fstype), Sequence = counter, Scheme = Name diff --git a/Aaru.Partitions/GPT.cs b/Aaru.Partitions/GPT.cs index cfc1b5990..74dacaba9 100644 --- a/Aaru.Partitions/GPT.cs +++ b/Aaru.Partitions/GPT.cs @@ -141,9 +141,9 @@ namespace Aaru.Partitions sectorSize = imagePlugin.Info.SectorSize; } - uint totalEntriesSectors = (hdr.entries * hdr.entriesSize) / imagePlugin.Info.SectorSize; + uint totalEntriesSectors = hdr.entries * hdr.entriesSize / imagePlugin.Info.SectorSize; - if((hdr.entries * hdr.entriesSize) % imagePlugin.Info.SectorSize > 0) + if(hdr.entries * hdr.entriesSize % imagePlugin.Info.SectorSize > 0) totalEntriesSectors++; byte[] temp = imagePlugin.ReadSectors(hdr.entryLBA / divisor, totalEntriesSectors + modulo); @@ -189,9 +189,9 @@ namespace Aaru.Partitions var part = new Partition { Description = $"ID: {entry.partitionId}", - Size = ((entry.endLBA - entry.startLBA) + 1) * sectorSize, + Size = (entry.endLBA - entry.startLBA + 1) * sectorSize, Name = entry.name, - Length = ((entry.endLBA - entry.startLBA) + 1) / divisor, + Length = (entry.endLBA - entry.startLBA + 1) / divisor, Sequence = pSeq++, Offset = entry.startLBA * sectorSize, Start = entry.startLBA / divisor, diff --git a/Aaru.Partitions/NeXT.cs b/Aaru.Partitions/NeXT.cs index 20f2e0b78..4d61f8aad 100644 --- a/Aaru.Partitions/NeXT.cs +++ b/Aaru.Partitions/NeXT.cs @@ -223,9 +223,9 @@ namespace Aaru.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) / sectorSize), - Start = (ulong)(((label.dl_dt.d_partitions[i].p_base + label.dl_dt.d_front) * - label.dl_dt.d_secsize) / sectorSize), + Length = (ulong)(label.dl_dt.d_partitions[i].p_size * label.dl_dt.d_secsize / sectorSize), + Start = (ulong)((label.dl_dt.d_partitions[i].p_base + label.dl_dt.d_front) * + label.dl_dt.d_secsize / sectorSize), Scheme = Name }; diff --git a/Aaru.Partitions/Plan9.cs b/Aaru.Partitions/Plan9.cs index 3ae18dae1..82719a358 100644 --- a/Aaru.Partitions/Plan9.cs +++ b/Aaru.Partitions/Plan9.cs @@ -79,11 +79,11 @@ namespace Aaru.Partitions var part = new Partition { - Length = (end - start) + 1, + Length = end - start + 1, Offset = (start + sectorOffset) * imagePlugin.Info.SectorSize, Scheme = Name, Sequence = (ulong)partitions.Count, - Size = ((end - start) + 1) * imagePlugin.Info.SectorSize, + Size = (end - start + 1) * imagePlugin.Info.SectorSize, Start = start + sectorOffset, Type = tokens[1] }; diff --git a/Aaru.Partitions/RDB.cs b/Aaru.Partitions/RDB.cs index e6c73b907..acbd895e7 100644 --- a/Aaru.Partitions/RDB.cs +++ b/Aaru.Partitions/RDB.cs @@ -710,7 +710,7 @@ namespace Aaru.Partitions Description = AmigaDosTypeToDescriptionString(rdbEntry.DosEnvVec.DosType), Name = rdbEntry.DriveName, Sequence = sequence, - Length = ((rdbEntry.DosEnvVec.HighCylinder + 1) - rdbEntry.DosEnvVec.LowCylinder) * + Length = (rdbEntry.DosEnvVec.HighCylinder + 1 - rdbEntry.DosEnvVec.LowCylinder) * rdbEntry.DosEnvVec.Surfaces * rdbEntry.DosEnvVec.Bpt, Start = (rdbEntry.DosEnvVec.LowCylinder * rdbEntry.DosEnvVec.Surfaces * rdbEntry.DosEnvVec.Bpt) + sectorOffset, @@ -718,7 +718,7 @@ namespace Aaru.Partitions Scheme = Name, Offset = ((rdbEntry.DosEnvVec.LowCylinder * rdbEntry.DosEnvVec.Surfaces * rdbEntry.DosEnvVec.Bpt) + sectorOffset) * rdb.BlockSize, - Size = ((rdbEntry.DosEnvVec.HighCylinder + 1) - rdbEntry.DosEnvVec.LowCylinder) * + Size = (rdbEntry.DosEnvVec.HighCylinder + 1 - rdbEntry.DosEnvVec.LowCylinder) * rdbEntry.DosEnvVec.Surfaces * rdbEntry.DosEnvVec.Bpt * rdb.BlockSize })) { diff --git a/Aaru.Partitions/SGI.cs b/Aaru.Partitions/SGI.cs index 9c423790f..b95cc6de1 100644 --- a/Aaru.Partitions/SGI.cs +++ b/Aaru.Partitions/SGI.cs @@ -152,10 +152,10 @@ namespace Aaru.Partitions var part = new CommonTypes.Partition { - Start = (dvh.partitions[i].first_block * dvh.device_params.dp_secbytes) / + Start = dvh.partitions[i].first_block * dvh.device_params.dp_secbytes / imagePlugin.Info.SectorSize, Offset = dvh.partitions[i].first_block * dvh.device_params.dp_secbytes, - Length = (dvh.partitions[i].num_blocks * dvh.device_params.dp_secbytes) / + Length = dvh.partitions[i].num_blocks * dvh.device_params.dp_secbytes / imagePlugin.Info.SectorSize, Size = dvh.partitions[i].num_blocks * dvh.device_params.dp_secbytes, Type = TypeToString(dvh.partitions[i].type), diff --git a/Aaru.Partitions/Sun.cs b/Aaru.Partitions/Sun.cs index b525b0e95..6e11ef193 100644 --- a/Aaru.Partitions/Sun.cs +++ b/Aaru.Partitions/Sun.cs @@ -191,12 +191,12 @@ namespace Aaru.Partitions var part = new Partition { Size = (ulong)dkl.dkl_map[i].dkl_nblk * DK_LABEL_SIZE, - Length = (ulong)((dkl.dkl_map[i].dkl_nblk * DK_LABEL_SIZE) / imagePlugin.Info.SectorSize), + Length = (ulong)(dkl.dkl_map[i].dkl_nblk * DK_LABEL_SIZE / imagePlugin.Info.SectorSize), 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.Info.SectorSize, + Start = (((ulong)dkl.dkl_map[i].dkl_cylno * sectorsPerCylinder) + sectorOffset) * + DK_LABEL_SIZE / imagePlugin.Info.SectorSize, Type = "SunOS partition", Scheme = Name }; @@ -269,12 +269,12 @@ namespace Aaru.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.Info.SectorSize), + Length = (ulong)(dkl8.dkl_map[i].dkl_nblk * DK_LABEL_SIZE / imagePlugin.Info.SectorSize), 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.Info.SectorSize, + Start = (((ulong)dkl8.dkl_map[i].dkl_cylno * sectorsPerCylinder) + sectorOffset) * + DK_LABEL_SIZE / imagePlugin.Info.SectorSize, Type = SunIdToString(dkl8.dkl_vtoc.v_part[i].p_tag), Scheme = Name }; @@ -352,13 +352,13 @@ namespace Aaru.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) / + Length = (ulong)(dkl16.dkl_vtoc.v_part[i].p_size * dkl16.dkl_vtoc.v_sectorsz / imagePlugin.Info.SectorSize), 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) / imagePlugin.Info.SectorSize, + Start = ((ulong)dkl16.dkl_vtoc.v_part[i].p_start + sectorOffset) * + dkl16.dkl_vtoc.v_sectorsz / imagePlugin.Info.SectorSize, Type = SunIdToString(dkl16.dkl_vtoc.v_part[i].p_tag), Scheme = Name }; diff --git a/Aaru.Tests.Devices/SCSI_MMC/GdRom.cs b/Aaru.Tests.Devices/SCSI_MMC/GdRom.cs index 39eea9455..719ba68f4 100644 --- a/Aaru.Tests.Devices/SCSI_MMC/GdRom.cs +++ b/Aaru.Tests.Devices/SCSI_MMC/GdRom.cs @@ -116,7 +116,7 @@ namespace Aaru.Tests.Devices frame = ((leadOutTrack.PFRAME >> 4) * 10) + (leadOutTrack.PFRAME & 0x0F); } - int sectors = ((min * 60 * 75) + (sec * 75) + frame) - 150; + int sectors = (min * 60 * 75) + (sec * 75) + frame - 150; AaruConsole.WriteLine("Trap disc shows {0} sectors...", sectors); diff --git a/Aaru/Commands/Image/Checksum.cs b/Aaru/Commands/Image/Checksum.cs index 3da4a5a8f..274495ae3 100644 --- a/Aaru/Commands/Image/Checksum.cs +++ b/Aaru/Commands/Image/Checksum.cs @@ -299,7 +299,7 @@ namespace Aaru.Commands.Image if(separatedTracks) trackChecksum = new Checksum(enabledChecksums); - ulong sectors = (currentTrack.TrackEndSector - currentTrack.TrackStartSector) + 1; + ulong sectors = currentTrack.TrackEndSector - currentTrack.TrackStartSector + 1; ulong doneSectors = 0; AaruConsole.WriteLine("Track {0} has {1} sectors", currentTrack.TrackSequence, sectors); @@ -401,7 +401,7 @@ namespace Aaru.Commands.Image if(separatedTracks) trackChecksum = new Checksum(enabledChecksums); - ulong sectors = (currentFile.LastBlock - currentFile.FirstBlock) + 1; + ulong sectors = currentFile.LastBlock - currentFile.FirstBlock + 1; ulong doneSectors = 0; AaruConsole.WriteLine("File {0} has {1} sectors", currentFile.File, sectors);