Join local variable declaration and assignment.

This commit is contained in:
2022-11-13 20:27:32 +00:00
parent 0f94c5fc01
commit 6586721321
22 changed files with 107 additions and 137 deletions

View File

@@ -76,8 +76,6 @@ public static class ImageInfo
/// <param name="imageFormat">Media image</param>
public static void PrintImageInfo(IBaseImage imageFormat)
{
Table table;
AaruConsole.WriteLine("[bold]Image information:[/]");
if(!string.IsNullOrWhiteSpace(imageFormat.Info.Version))
@@ -247,7 +245,7 @@ public static class ImageInfo
}
}
table = new Table
var table = new Table
{
Title = new TableTitle("Dump hardware information")
};

View File

@@ -890,7 +890,6 @@ public static class CompactDisc
var nextQ = new byte[12];
Array.Copy(deSub, subPos + 12 - 96, preQ, 0, 12);
Array.Copy(deSub, subPos + 12 + 96, nextQ, 0, 12);
bool status;
CRC16CCITTContext.Data(preQ, 10, out byte[] preCrc);
bool preCrcOk = preCrc[0] == preQ[10] && preCrc[1] == preQ[11];
@@ -908,7 +907,7 @@ public static class CompactDisc
}
CRC16CCITTContext.Data(q, 10, out byte[] qCrc);
status = qCrc[0] == q[10] && qCrc[1] == q[11];
bool status = qCrc[0] == q[10] && qCrc[1] == q[11];
if(fixedAdr && status)
return true;

View File

@@ -480,7 +480,6 @@ partial class Device
duration = 0;
sense = false;
int off;
// Create array for buffers
var bufferPointers = new nint[commands.Length];
@@ -491,7 +490,7 @@ partial class Device
// First value of array is uint64 with count of commands
Array.Copy(BitConverter.GetBytes((ulong)commands.Length), 0, ioMultiCmd, 0, sizeof(ulong));
off = sizeof(ulong);
int off = sizeof(ulong);
for(var i = 0; i < commands.Length; i++)
{

View File

@@ -278,8 +278,6 @@ static partial class Usb
/// <summary>Return Root Hub for this Controller</summary>
internal UsbHub GetRootHub()
{
IntPtr h, h2;
var root = new UsbHub
{
_hubIsRootHub = true,
@@ -287,7 +285,7 @@ static partial class Usb
};
// Open a handle to the Host Controller
h = CreateFile(_controllerDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0,
IntPtr h = CreateFile(_controllerDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0,
IntPtr.Zero);
if(h == _invalidHandleValue)
@@ -307,9 +305,8 @@ static partial class Usb
}
// TODO: Get DriverKeyName for Root Hub
// Now let's open the Hub (based upon the HubName we got above)
h2 = CreateFile(root._hubDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0,
IntPtr h2 = CreateFile(root._hubDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0,
IntPtr.Zero);
if(h2 != _invalidHandleValue)
@@ -709,12 +706,11 @@ static partial class Usb
return null;
var hub = new UsbHub();
IntPtr h, h2;
hub._hubIsRootHub = false;
hub._hubDeviceDesc = "External Hub";
// Open a handle to the Host Controller
h = CreateFile(_portHubDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0,
IntPtr h = CreateFile(_portHubDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0,
IntPtr.Zero);
if(h == _invalidHandleValue)
@@ -741,7 +737,7 @@ static partial class Usb
}
// Now let's open the Hub (based upon the HubName we got above)
h2 = CreateFile(hub._hubDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0,
IntPtr h2 = CreateFile(hub._hubDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0,
IntPtr.Zero);
if(h2 != _invalidHandleValue)

View File

@@ -361,9 +361,8 @@ public sealed partial class AppleMFS
do
{
byte[] sectors;
ErrorNumber errno;
errno =
ErrorNumber errno =
tags
? _device.
ReadSectorsTag((ulong)((nextBlock - 2) * _sectorsPerBlock) + _volMdb.drAlBlSt + _partitionStart,

View File

@@ -54,7 +54,6 @@ public sealed partial class AppleMFS
_device = imagePlugin;
_partitionStart = partition.Start;
Encoding = encoding ?? Encoding.GetEncoding("macintosh");
ErrorNumber errno;
options ??= GetDefaultOptions();
@@ -63,7 +62,7 @@ public sealed partial class AppleMFS
_volMdb = new MasterDirectoryBlock();
errno = _device.ReadSector(2 + _partitionStart, out _mdbBlocks);
ErrorNumber errno = _device.ReadSector(2 + _partitionStart, out _mdbBlocks);
if(errno != ErrorNumber.NoError)
return errno;

View File

@@ -432,14 +432,13 @@ public sealed partial class FAT
{
Encoding = encoding ?? Encoding.GetEncoding("IBM437");
information = "";
ErrorNumber errno;
var sb = new StringBuilder();
XmlFsType = new FileSystemType();
uint sectorsPerBpb = imagePlugin.Info.SectorSize < 512 ? 512 / imagePlugin.Info.SectorSize : 1;
errno = imagePlugin.ReadSectors(0 + partition.Start, sectorsPerBpb, out byte[] bpbSector);
ErrorNumber errno = imagePlugin.ReadSectors(0 + partition.Start, sectorsPerBpb, out byte[] bpbSector);
if(errno != ErrorNumber.NoError)
return;

View File

@@ -59,7 +59,6 @@ public sealed partial class FAT
Dictionary<string, string> options, string @namespace)
{
XmlFsType = new FileSystemType();
ErrorNumber errno;
options ??= GetDefaultOptions();
@@ -102,7 +101,7 @@ public sealed partial class FAT
uint sectorsPerBpb = imagePlugin.Info.SectorSize < 512 ? 512 / imagePlugin.Info.SectorSize : 1;
errno = imagePlugin.ReadSectors(0 + partition.Start, sectorsPerBpb, out byte[] bpbSector);
ErrorNumber errno = imagePlugin.ReadSectors(0 + partition.Start, sectorsPerBpb, out byte[] bpbSector);
if(errno != ErrorNumber.NoError)
return errno;

View File

@@ -98,8 +98,6 @@ public sealed class HAMMER : IFilesystem
var sb = new StringBuilder();
SuperBlock superBlock;
uint run = HAMMER_VOLHDR_SIZE / imagePlugin.Info.SectorSize;
if(HAMMER_VOLHDR_SIZE % imagePlugin.Info.SectorSize > 0)
@@ -112,7 +110,8 @@ public sealed class HAMMER : IFilesystem
var magic = BitConverter.ToUInt64(sbSector, 0);
superBlock = magic == HAMMER_FSBUF_VOLUME ? Marshal.ByteArrayToStructureLittleEndian<SuperBlock>(sbSector)
SuperBlock superBlock = magic == HAMMER_FSBUF_VOLUME
? Marshal.ByteArrayToStructureLittleEndian<SuperBlock>(sbSector)
: Marshal.ByteArrayToStructureBigEndian<SuperBlock>(sbSector);
sb.AppendLine("HAMMER filesystem");

View File

@@ -43,17 +43,15 @@ public sealed partial class ISO9660
{
ErrorNumber ReadSector(ulong sector, out byte[] buffer, bool interleaved = false, byte fileNumber = 0)
{
ulong realSector;
uint sectorCount;
ErrorNumber errno;
buffer = null;
sectorCount = (uint)_blockSize / 2048;
uint sectorCount = (uint)_blockSize / 2048;
if(_blockSize % 2048 > 0)
sectorCount++;
realSector = sector * _blockSize / 2048;
ulong realSector = sector * _blockSize / 2048;
ulong offset = sector * _blockSize % 2048;

View File

@@ -294,7 +294,6 @@ public sealed class UDF : IFilesystem
var pvd = new PrimaryVolumeDescriptor();
var lvd = new LogicalVolumeDescriptor();
LogicalVolumeIntegrityDescriptor lvid;
var lvidiu = new LogicalVolumeIntegrityDescriptorImplementationUse();
while(count < 256)
@@ -338,7 +337,8 @@ public sealed class UDF : IFilesystem
if(errno != ErrorNumber.NoError)
return;
lvid = Marshal.ByteArrayToStructureLittleEndian<LogicalVolumeIntegrityDescriptor>(sector);
LogicalVolumeIntegrityDescriptor lvid =
Marshal.ByteArrayToStructureLittleEndian<LogicalVolumeIntegrityDescriptor>(sector);
if(lvid.tag.tagIdentifier == TagIdentifier.LogicalVolumeIntegrityDescriptor &&
lvid.tag.tagLocation == lvd.integritySequenceExtent.location)

View File

@@ -608,10 +608,9 @@ public sealed class ScsiInfoViewModel : ViewModelBase
foreach(Features.FeatureDescriptor desc in ftr.Descriptors)
{
string featureNumber = $"Feature {desc.Code:X4}h";
string featureDescription;
AaruConsole.DebugWriteLine("Device-Info command", "Feature {0:X4}h", desc.Code);
featureDescription = desc.Code switch
string featureDescription = desc.Code switch
{
0x0000 => Features.Prettify_0000(desc.Data),
0x0001 => Features.Prettify_0001(desc.Data),

View File

@@ -78,9 +78,8 @@ public sealed class ViewSectorViewModel : ViewModelBase
this.RaiseAndSetIfChanged(ref _sectorNumber, value);
byte[] sector;
ErrorNumber errno;
errno = LongSectorChecked ? _inputFormat.ReadSectorLong((ulong)SectorNumber, out sector)
ErrorNumber errno = LongSectorChecked ? _inputFormat.ReadSectorLong((ulong)SectorNumber, out sector)
: _inputFormat.ReadSector((ulong)SectorNumber, out sector);
if(errno == ErrorNumber.NoError)

View File

@@ -168,8 +168,7 @@ public sealed partial class Chd
break;
case EntryFlagsV3.Mini:
buffer = new byte[_bytesPerHunk];
byte[] mini;
mini = BigEndianBitConverter.GetBytes(entry.offset);
byte[] mini = BigEndianBitConverter.GetBytes(entry.offset);
for(var i = 0; i < _bytesPerHunk; i++)
buffer[i] = mini[i % 8];

View File

@@ -300,7 +300,6 @@ public sealed partial class CloneCd
_subStream?.Close();
FullTOC.CDFullTOC? nullableToc = null;
FullTOC.CDFullTOC toc;
// Easy, just decode the real toc
if(_fullToc != null)
@@ -312,7 +311,7 @@ public sealed partial class CloneCd
}
// Not easy, create a toc from scratch
toc = nullableToc ?? FullTOC.Create(Tracks, _trackFlags, true);
FullTOC.CDFullTOC toc = nullableToc ?? FullTOC.Create(Tracks, _trackFlags, true);
_descriptorStream.WriteLine("[CloneCD]");
_descriptorStream.WriteLine("Version=2");

View File

@@ -42,12 +42,8 @@ public sealed partial class DiskDupe
{
bool TryReadHeader(Stream stream, ref FileHeader fhdr, ref TrackInfo[] tmap, ref long[] toffsets)
{
int numTracks;
int trackLen; // the length of a single track, in bytes
TrackInfo[] trackMap;
var buffer = new byte[6];
FileHeader fHeader;
long[] trackOffsets;
stream.Seek(0, SeekOrigin.Begin);
@@ -69,10 +65,10 @@ public sealed partial class DiskDupe
// seek to start of the trackmap
stream.Seek(TRACKMAP_OFFSET, SeekOrigin.Begin);
numTracks = _diskTypes[fHeader.diskType].cyl * _diskTypes[fHeader.diskType].hd;
trackLen = 512 * _diskTypes[fHeader.diskType].spt;
trackMap = new TrackInfo[numTracks];
trackOffsets = new long[numTracks];
int numTracks = _diskTypes[fHeader.diskType].cyl * _diskTypes[fHeader.diskType].hd;
int trackLen = 512 * _diskTypes[fHeader.diskType].spt; // the length of a single track, in bytes
var trackMap = new TrackInfo[numTracks];
var trackOffsets = new long[numTracks];
AaruConsole.DebugWriteLine("DiskDupe plugin", "Identified image with C/H/S = {0}/{1}/{2}",
_diskTypes[fHeader.diskType].cyl, _diskTypes[fHeader.diskType].hd,

View File

@@ -522,8 +522,7 @@ public sealed partial class Vhdx
return ErrorNumber.NoError;
}
bool partialBlock;
partialBlock = (blkFlags & BAT_FLAGS_MASK) == PAYLOAD_BLOCK_PARTIALLY_PRESENT;
bool partialBlock = (blkFlags & BAT_FLAGS_MASK) == PAYLOAD_BLOCK_PARTIALLY_PRESENT;
if(partialBlock &&
_hasParent &&

View File

@@ -13,13 +13,11 @@ static partial class ScsiMmc
{
static void CheckGdromReadability(string devPath, Device dev)
{
string strDev;
int item;
var tocIsNotBcd = false;
bool sense;
byte[] buffer;
byte[] senseBuffer;
int retries;
start:
Console.Clear();
@@ -35,7 +33,7 @@ static partial class ScsiMmc
AaruConsole.WriteLine("Sending READ FULL TOC to the device...");
retries = 0;
var retries = 0;
do
{
@@ -410,7 +408,7 @@ static partial class ScsiMmc
AaruConsole.WriteLine("0.- Return to special SCSI MultiMedia Commands menu.");
AaruConsole.Write("Choose: ");
strDev = Console.ReadLine();
string strDev = Console.ReadLine();
if(!int.TryParse(strDev, out item))
{

View File

@@ -13,13 +13,11 @@ static partial class ScsiMmc
{
static void ReadLeadOutUsingTrapDisc(string devPath, Device dev)
{
string strDev;
int item;
var tocIsNotBcd = false;
bool sense;
byte[] buffer;
byte[] senseBuffer;
int retries;
start:
Console.Clear();
@@ -35,7 +33,7 @@ static partial class ScsiMmc
AaruConsole.WriteLine("Sending READ FULL TOC to the device...");
retries = 0;
var retries = 0;
do
{
@@ -399,7 +397,7 @@ static partial class ScsiMmc
AaruConsole.WriteLine("0.- Return to special SCSI MultiMedia Commands menu.");
AaruConsole.Write("Choose: ");
strDev = Console.ReadLine();
string strDev = Console.ReadLine();
if(!int.TryParse(strDev, out item))
{

View File

@@ -240,9 +240,7 @@ sealed class EntropyCommand : Command
if(!wholeDisc)
return;
EntropyResults entropy;
entropy = inputFormat.Info.XmlMediaType == XmlMediaType.LinearMedia
EntropyResults entropy = inputFormat.Info.XmlMediaType == XmlMediaType.LinearMedia
? entropyCalculator.CalculateLinearMediaEntropy()
: entropyCalculator.CalculateMediaEntropy(duplicatedSectors);