Remove unused code.

This commit is contained in:
2022-03-17 23:54:41 +00:00
parent b05dc45d09
commit f0fa4d4320
30 changed files with 51 additions and 94 deletions

View File

@@ -157,8 +157,6 @@ partial class Dump
sectorsToTrim = (byte)(sectorsForOffset + 1);
}
var forceFixOffset = false;
if(_supportsPlextorD8 && audioExtents.Contains(badSector))
sense = ReadPlextorWithSubchannel(out cmdBuf, out senseBuf, badSectorToRead, blockSize, sectorsToTrim,
supportedPlextorSubchannel, out cmdDuration);

View File

@@ -121,8 +121,7 @@ partial class Dump
return;
}
if(blocks != 0 &&
blockSize != 0)
if(blocks != 0)
{
blocks++;

View File

@@ -110,10 +110,7 @@ public partial class Dump
ulong totalSize = blocks * blockSize;
if(totalSize > 1099511627776)
UpdateStatus?.
Invoke($"Media has {blocks} blocks of {blockSize} bytes/each. (for a total of {totalSize / 1099511627776d:F3} TiB)");
else if(totalSize > 1073741824)
if(totalSize > 1073741824)
UpdateStatus?.
Invoke($"Media has {blocks} blocks of {blockSize} bytes/each. (for a total of {totalSize / 1073741824d:F3} GiB)");
else if(totalSize > 1048576)

View File

@@ -64,7 +64,7 @@ partial class Dump
bool sense;
uint blockSize;
ulong blocks = 0;
MediaType dskType = MediaType.Unknown;
MediaType dskType;
DateTime start;
DateTime end;
double totalDuration = 0;
@@ -109,8 +109,7 @@ partial class Dump
PulseProgress?.Invoke("Rewinding, please wait...");
_dev.RequestSense(out senseBuf, _dev.Timeout, out duration);
decSense = Sense.Decode(senseBuf);
} while(decSense is { ASC: 0x00 } &&
decSense.Value.ASCQ is 0x1A or not (0x04 and 0x00));
} while(decSense is { ASC: 0x00, ASCQ: 0x1A or not (0x04 and 0x00) });
_dev.RequestSense(out senseBuf, _dev.Timeout, out duration);
decSense = Sense.Decode(senseBuf);
@@ -286,7 +285,7 @@ partial class Dump
blockSize = decMode.Value.Header.BlockDescriptors?[0].BlockLength ?? 0;
UpdateStatus?.Invoke($"Device reports {blocks} blocks ({blocks * blockSize} bytes).");
UpdateStatus?.Invoke($"Device reports {blocks} blocks.");
}
else
blockSize = 1;
@@ -302,7 +301,6 @@ partial class Dump
if(blockSize == 0)
blockSize = 1;
if(dskType == MediaType.Unknown)
dskType = MediaTypeFromDevice.GetFromScsi((byte)_dev.ScsiType, _dev.Manufacturer, _dev.Model,
scsiMediumTypeTape, scsiDensityCodeTape, blocks, blockSize,
_dev.IsUsb, false);

View File

@@ -333,7 +333,7 @@ public partial class Dump
// Device is in timeout, reopen to reset
if(_dev.LastError == 110)
sense = _dev.ReOpen();
_dev.ReOpen();
}
if(error)
@@ -359,7 +359,7 @@ public partial class Dump
// Device is in timeout, reopen to reset
if(_dev.LastError == 110)
sense = _dev.ReOpen();
_dev.ReOpen();
if(!error ||
blocksToRead == 1)

View File

@@ -325,7 +325,7 @@ public sealed partial class DeviceReport
Spectre.ProgressSingleSpinner(ctx =>
{
ctx.AddTask("Trying READ SECTOR(S) in LBA48 mode...").IsIndeterminate();
sense = _dev.Read(out readBuf, out AtaErrorRegistersLba48 errorLba48, 0, 1, _dev.Timeout, out _);
sense = _dev.Read(out readBuf, out AtaErrorRegistersLba28 _, 0, 1, _dev.Timeout, out _);
});
mediaTest.SupportsReadLba48 = !sense && (errorLba48.Status & 0x01) != 0x01 && errorLba48.Error == 0 &&

View File

@@ -372,7 +372,7 @@ public sealed partial class Sidecar
xmlTrk.StartSector = trk.StartSector;
xmlTrk.EndSector = trk.EndSector;
int idx0 = -1;
int idx0;
if(trk.Indexes?.TryGetValue(0, out idx0) == true &&
idx0 >= 0)

View File

@@ -654,9 +654,9 @@ public sealed class AcornADFS : IFilesystem
Don't add the check byte when calculating its value
*/
sumVector0 += sumVector3 >> 8;
sumVector1 += mapBase[rover + 1] + (sumVector0 >> 8);
sumVector2 += mapBase[rover + 2] + (sumVector1 >> 8);
sumVector3 += mapBase[rover + 3] + (sumVector2 >> 8);
sumVector1 += mapBase[1] + (sumVector0 >> 8);
sumVector2 += mapBase[2] + (sumVector1 >> 8);
sumVector3 += mapBase[3] + (sumVector2 >> 8);
return (byte)((sumVector0 ^ sumVector1 ^ sumVector2 ^ sumVector3) & 0xff);
}

View File

@@ -98,11 +98,4 @@ public sealed partial class CPM : IReadOnlyFilesystem
/// <inheritdoc />
public Dictionary<string, string> Namespaces => null;
static Dictionary<string, string> GetDefaultOptions() => new()
{
{
"debug", false.ToString()
}
};
}

View File

@@ -48,7 +48,7 @@ public sealed partial class CPM
/// <inheritdoc />
public bool Identify(IMediaImage imagePlugin, Partition partition)
{
ErrorNumber errno = ErrorNumber.NoError;
ErrorNumber errno;
// This will only continue on devices with a chance to have ever been used by CP/M while failing on all others
// It's ugly, but will stop a lot of false positives
@@ -245,7 +245,7 @@ public sealed partial class CPM
_dpb.spt = (ushort)(amsSb.spt * (sectorSize / 128));
var directoryLength = (uint)(((ulong)_dpb.drm + 1) * 32 / sectorSize);
errno = imagePlugin.ReadSectors(firstDirectorySector + partition.Start, directoryLength,
imagePlugin.ReadSectors(firstDirectorySector + partition.Start, directoryLength,
out directory);
// Build a CP/M disk definition

View File

@@ -61,7 +61,7 @@ public sealed partial class FAT
public ErrorNumber ReadDir(string path, out List<string> contents)
{
contents = null;
ErrorNumber errno = ErrorNumber.NoError;
ErrorNumber errno;
if(!_mounted)
return ErrorNumber.AccessDenied;

View File

@@ -128,7 +128,7 @@ public sealed class Fossil : IFilesystem
if(sbLocation <= partition.End)
{
errno = imagePlugin.ReadSector(sbLocation, out sector);
imagePlugin.ReadSector(sbLocation, out sector);
SuperBlock fsb = Marshal.ByteArrayToStructureBigEndian<SuperBlock>(sector);
AaruConsole.DebugWriteLine("Fossil plugin", "magic 0x{0:X8} (expected 0x{1:X8})", fsb.magic,

View File

@@ -115,7 +115,7 @@ public sealed partial class ISO9660
ulong counter = 0;
ErrorNumber errno = imagePlugin.ReadSector(16 + counter + partition.Start, out byte[] vdSector);
ErrorNumber errno = imagePlugin.ReadSector(16 + partition.Start, out byte[] vdSector);
if(errno != ErrorNumber.NoError)
return;

View File

@@ -113,7 +113,7 @@ public sealed partial class ISO9660
ulong counter = 0;
ErrorNumber errno = imagePlugin.ReadSector(16 + counter + partition.Start, out byte[] vdSector);
ErrorNumber errno = imagePlugin.ReadSector(16 + partition.Start, out byte[] vdSector);
if(errno != ErrorNumber.NoError)
return errno;
@@ -393,7 +393,7 @@ public sealed partial class ISO9660
rootLocation = _pathTable[0].Extent;
errno = ReadSector(_pathTable[0].Extent, out firstRootSector);
ReadSector(_pathTable[0].Extent, out firstRootSector);
if(_highSierra)
{

View File

@@ -107,6 +107,9 @@ public sealed class ProDOSPlugin : IFilesystem
ErrorNumber errno = imagePlugin.ReadSectors(2 * multiplier + partition.Start, multiplier,
out byte[] rootDirectoryKeyBlock);
if(errno != ErrorNumber.NoError)
return false;
var apmFromHddOnCd = false;
if(imagePlugin.Info.SectorSize is 2352 or 2448 or 2048)

View File

@@ -134,8 +134,8 @@ public sealed class ForcedSeekStream<T> : Stream where T : Stream
var fullBufferReads = (int)(toPosition / BUFFER_LEN);
var restToRead = (int)(toPosition % BUFFER_LEN);
byte[] buffer;
var bufPos = 0;
int left = BUFFER_LEN;
int bufPos;
int left;
for(var i = 0; i < fullBufferReads; i++)
{

View File

@@ -221,7 +221,7 @@ public sealed class BlockMap : ItemsControl
}
}
public override void Render([NotNull] DrawingContext context)
public override void Render(DrawingContext context)
{
if((int?)_bitmap?.Size.Height != (int)Height ||
(int?)_bitmap?.Size.Width != (int)Width)

View File

@@ -2455,7 +2455,7 @@ public sealed partial class AaruFormat
var cmpCrc64Context = new Crc64Context();
byte[] lzmaProperties = Array.Empty<byte>();
var compressedLength = 0;
int compressedLength;
switch(_currentBlockHeader.compression)
{

View File

@@ -498,10 +498,10 @@ public sealed partial class Alcohol120
// First track is data
firstData |= alcoholTrack.point == 1 &&
alcoholTrack.mode is not (TrackMode.Audio and TrackMode.AudioAlt);
alcoholTrack.mode != TrackMode.Audio && alcoholTrack.mode != TrackMode.AudioAlt;
// Any non first track is data
data |= alcoholTrack.point != 1 && alcoholTrack.mode is not (TrackMode.Audio and TrackMode.AudioAlt);
data |= alcoholTrack.point != 1 && alcoholTrack.mode != TrackMode.Audio && alcoholTrack.mode != TrackMode.AudioAlt;
// Any non first track is audio
audio |= alcoholTrack.point != 1 && alcoholTrack.mode is TrackMode.Audio or TrackMode.AudioAlt;
@@ -1446,7 +1446,7 @@ public sealed partial class Alcohol120
sectorAddress -= alcExtra.pregap - 150;
}
uint pregapBytes = alcExtra.pregap * (sectorOffset + sectorSize + sectorSkip);
uint pregapBytes = alcExtra.pregap * (sectorSize + sectorSkip);
var fileOffset = (long)alcTrack.startOffset;
if(alcTrack.startOffset >= pregapBytes)
@@ -1455,11 +1455,10 @@ public sealed partial class Alcohol120
_imageStream = _alcImage.GetDataForkStream();
var br = new BinaryReader(_imageStream);
br.BaseStream.Seek(fileOffset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)),
br.BaseStream.Seek(fileOffset + (long)(sectorAddress * (sectorSize + sectorSkip)),
SeekOrigin.Begin);
if(sectorOffset == 0 &&
sectorSkip == 0)
if(sectorSkip == 0)
buffer = br.ReadBytes((int)(sectorSize * length));
else
for(var i = 0; i < length; i++)

View File

@@ -850,12 +850,8 @@ public sealed partial class BlindWrite4
from track in Tracks where track.Sequence == kvp.Key
where sectorAddress - kvp.Value <
track.EndSector - track.StartSector + 1 select kvp)
{
return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag, out buffer);
return buffer is null ? ErrorNumber.NoData : ErrorNumber.NoError;
}
return ErrorNumber.SectorNotFound;
}

View File

@@ -940,12 +940,8 @@ public sealed partial class Cdrdao
from cdrdaoTrack in _discimage.Tracks
where cdrdaoTrack.Sequence == kvp.Key
where sectorAddress - kvp.Value < cdrdaoTrack.Sectors select kvp)
{
return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag, out buffer);
return buffer is null ? ErrorNumber.NoData : ErrorNumber.NoError;
}
return ErrorNumber.SectorNotFound;
}

View File

@@ -1685,7 +1685,7 @@ public sealed partial class CdrWin
public ErrorNumber ReadSectors(ulong sectorAddress, uint length, uint track, out byte[] buffer)
{
buffer = null;
CdrWinTrack? aaruTrack = _discImage.Tracks.FirstOrDefault(cdrwinTrack => cdrwinTrack.Sequence == track);
CdrWinTrack aaruTrack = _discImage.Tracks.FirstOrDefault(cdrwinTrack => cdrwinTrack.Sequence == track);
if(aaruTrack is null)
return ErrorNumber.SectorNotFound;
@@ -1864,7 +1864,7 @@ public sealed partial class CdrWin
if(tag is SectorTagType.CdTrackFlags or SectorTagType.CdTrackIsrc)
track = (uint)sectorAddress;
CdrWinTrack? aaruTrack = _discImage.Tracks.FirstOrDefault(cdrwinTrack => cdrwinTrack.Sequence == track);
CdrWinTrack aaruTrack = _discImage.Tracks.FirstOrDefault(cdrwinTrack => cdrwinTrack.Sequence == track);
if(aaruTrack is null)
return ErrorNumber.SectorNotFound;
@@ -2140,7 +2140,7 @@ public sealed partial class CdrWin
if(!_isCd)
return ReadSectors(sectorAddress, length, track, out buffer);
CdrWinTrack? aaruTrack = _discImage.Tracks.FirstOrDefault(cdrwinTrack => cdrwinTrack.Sequence == track);
CdrWinTrack aaruTrack = _discImage.Tracks.FirstOrDefault(cdrwinTrack => cdrwinTrack.Sequence == track);
if(aaruTrack is null)
return ErrorNumber.SectorNotFound;

View File

@@ -961,12 +961,8 @@ public sealed partial class CloneCd
Where(t => sectorAddress - t.kvp.Value <
t.track.EndSector - t.track.StartSector + 1).
Select(t => t.kvp))
{
return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag, out buffer);
return buffer is null ? ErrorNumber.NoData : ErrorNumber.NoError;
}
return ErrorNumber.SectorNotFound;
}
@@ -974,7 +970,7 @@ public sealed partial class CloneCd
public ErrorNumber ReadSectors(ulong sectorAddress, uint length, uint track, out byte[] buffer)
{
buffer = null;
Track? aaruTrack = Tracks.FirstOrDefault(linqTrack => linqTrack.Sequence == track);
Track aaruTrack = Tracks.FirstOrDefault(linqTrack => linqTrack.Sequence == track);
if(aaruTrack is null)
return ErrorNumber.SectorNotFound;
@@ -1064,7 +1060,7 @@ public sealed partial class CloneCd
if(tag == SectorTagType.CdTrackFlags)
track = (uint)sectorAddress;
Track? aaruTrack = Tracks.FirstOrDefault(linqTrack => linqTrack.Sequence == track);
Track aaruTrack = Tracks.FirstOrDefault(linqTrack => linqTrack.Sequence == track);
if(aaruTrack is null)
return ErrorNumber.SectorNotFound;
@@ -1352,7 +1348,7 @@ public sealed partial class CloneCd
public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, uint track, out byte[] buffer)
{
buffer = null;
Track? aaruTrack = Tracks.FirstOrDefault(linqTrack => linqTrack.Sequence == track);
Track aaruTrack = Tracks.FirstOrDefault(linqTrack => linqTrack.Sequence == track);
if(aaruTrack is null)
return ErrorNumber.SectorNotFound;

View File

@@ -858,12 +858,8 @@ public sealed partial class DiscJuggler
from track in Tracks where track.Sequence == kvp.Key
where sectorAddress - kvp.Value <
track.EndSector - track.StartSector + 1 select kvp)
{
return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag, out buffer);
return buffer is null ? ErrorNumber.NoData : ErrorNumber.NoError;
}
return ErrorNumber.SectorNotFound;
}

View File

@@ -1604,12 +1604,8 @@ public sealed partial class Nero
from track in Tracks where track.Sequence == kvp.Key
where sectorAddress - kvp.Value <= track.EndSector - track.StartSector
select kvp)
{
return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag, out buffer);
return buffer is null ? ErrorNumber.NoData : ErrorNumber.NoError;
}
return ErrorNumber.SectorNotFound;
}

View File

@@ -661,8 +661,6 @@ public sealed partial class Vhd
return ErrorNumber.InvalidArgument;
}
return ErrorNumber.NoError;
}
case TYPE_DEPRECATED1:

View File

@@ -223,7 +223,7 @@ public abstract class OpticalMediaImageTest : BaseMediaImageTest
if(track.FileSystems[i].Contents != null ||
track.FileSystems[i].ContentsJson != null ||
File.Exists($"{testFile}.track{track.Number}.filesystem{i}.contents.json"))
Assert.NotNull(rofs,
Assert.NotNull(null,
$"Could not instantiate filesystem for {testFile}, track {track.Number}, filesystem {i}");
continue;

View File

@@ -43,8 +43,6 @@ public abstract class OpticalImageReadIssueTest
var ctx = new Crc32Context();
Checksum trackChecksum = null;
ulong previousTrackEnd = 0;
List<Track> inputTracks = opticalInput.Tracks;

View File

@@ -167,12 +167,8 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest
foreach(MediaTagType mediaTag in inputFormat.Info.ReadableMediaTags.Where(mediaTag =>
outputFormat.SupportedMediaTags.Contains(mediaTag)))
{
ErrorNumber errno = inputFormat.ReadMediaTag(mediaTag, out byte[] buffer);
if(errno == ErrorNumber.NoError)
if(inputFormat.ReadMediaTag(mediaTag, out byte[] buffer) == ErrorNumber.NoError)
outputFormat.WriteMediaTag(buffer, mediaTag);
}
Assert.IsTrue(outputFormat.SetTracks(inputFormat.Tracks),
$"Error {outputFormat.ErrorMessage} sending tracks list to output image.");

View File

@@ -345,14 +345,14 @@ sealed class VerifyCommand : Command
TimeSpan checkTime = endCheck - startCheck;
if(unknownSectors > 0)
if(unknownLbas.Count > 0)
AaruConsole.WriteLine("There is at least one sector that does not contain a checksum");
if(errorSectors > 0)
if(failingLbas.Count > 0)
AaruConsole.WriteLine("There is at least one sector with incorrect checksum or errors");
if(unknownSectors == 0 &&
errorSectors == 0)
if(unknownLbas.Count == 0 &&
failingLbas.Count == 0)
AaruConsole.WriteLine("All sector checksums are correct");
AaruConsole.VerboseWriteLine("Checking sector checksums took {0} seconds", checkTime.TotalSeconds);
@@ -391,15 +391,13 @@ sealed class VerifyCommand : Command
{
case null when correctSectors is null: return (int)ErrorNumber.NotVerifiable;
case null when correctSectors == false: return (int)ErrorNumber.BadSectorsImageNotVerified;
case null when correctSectors == true: return (int)ErrorNumber.CorrectSectorsImageNotVerified;
case null: return (int)ErrorNumber.CorrectSectorsImageNotVerified;
case false when correctSectors is null: return (int)ErrorNumber.BadImageSectorsNotVerified;
case false when correctSectors == false: return (int)ErrorNumber.BadImageBadSectors;
case false when correctSectors == true: return (int)ErrorNumber.CorrectSectorsBadImage;
case false: return (int)ErrorNumber.CorrectSectorsBadImage;
case true when correctSectors is null: return (int)ErrorNumber.CorrectImageSectorsNotVerified;
case true when correctSectors == false: return (int)ErrorNumber.CorrectImageBadSectors;
case true when correctSectors == true: return (int)ErrorNumber.NoError;
}
return (int)ErrorNumber.NoError;
case true: return (int)ErrorNumber.NoError;
}
}
}