Remove redundant parentheses.

This commit is contained in:
2021-08-17 14:27:19 +01:00
parent 6dd5fb5c5c
commit c1287c00cf
61 changed files with 201 additions and 201 deletions

View File

@@ -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;
}
}

View File

@@ -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;

View File

@@ -314,9 +314,9 @@ namespace Aaru.Core.Logging
/// <param name="message">Message to log</param>
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}");

View File

@@ -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;

View File

@@ -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
}));
}

View File

@@ -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();

View File

@@ -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();

View File

@@ -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);

View File

@@ -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)

View File

@@ -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)
};

View File

@@ -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;
}
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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
};
}

View File

@@ -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()
};

View File

@@ -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,

View File

@@ -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();

View File

@@ -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()
};

View File

@@ -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();

View File

@@ -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();

View File

@@ -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);
}
/// <inheritdoc />

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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)

View File

@@ -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)

View File

@@ -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;

View File

@@ -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)

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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)
{

View File

@@ -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<uint, FileStream>();
@@ -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);

View File

@@ -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);

View File

@@ -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));
}
}

View File

@@ -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++;
}

View File

@@ -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

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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];

View File

@@ -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();

View File

@@ -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

View File

@@ -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,

View File

@@ -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
};

View File

@@ -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]
};

View File

@@ -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
}))
{

View File

@@ -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),

View File

@@ -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
};

View File

@@ -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);

View File

@@ -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);