From 47965f0584c6629c861aaa6db4e8cc476d29b37e Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Tue, 15 Nov 2022 00:20:20 +0000 Subject: [PATCH] Inline temporary variable. --- Aaru.Core/Devices/Dumping/MiniDisc.cs | 3 +-- Aaru.Devices/Windows/Usb.cs | 14 +++++--------- Aaru.Devices/Windows/UsbFunctions.cs | 7 +++---- Aaru.Gui/Controls/BlockMap.cs | 11 +++++------ Aaru.Images/Alcohol120/Write.cs | 9 ++++----- Aaru.Images/CDRDAO/Write.cs | 14 ++++++-------- Aaru.Images/CDRWin/Write.cs | 10 ++++------ 7 files changed, 28 insertions(+), 40 deletions(-) diff --git a/Aaru.Core/Devices/Dumping/MiniDisc.cs b/Aaru.Core/Devices/Dumping/MiniDisc.cs index 89fb4eab8..5f6c78b67 100644 --- a/Aaru.Core/Devices/Dumping/MiniDisc.cs +++ b/Aaru.Core/Devices/Dumping/MiniDisc.cs @@ -165,7 +165,6 @@ partial class Dump } uint blocksToRead = scsiReader.BlocksToRead; - uint logicalBlockSize = blockSize; uint physicalBlockSize = scsiReader.PhysicalBlockSize; if(blocks == 0) @@ -794,7 +793,7 @@ partial class Dump sidecar.BlockMedia[0].LogicalBlocks = blocks; sidecar.BlockMedia[0].PhysicalBlockSize = physicalBlockSize; - sidecar.BlockMedia[0].LogicalBlockSize = logicalBlockSize; + sidecar.BlockMedia[0].LogicalBlockSize = blockSize; sidecar.BlockMedia[0].Manufacturer = _dev.Manufacturer; sidecar.BlockMedia[0].Model = _dev.Model; diff --git a/Aaru.Devices/Windows/Usb.cs b/Aaru.Devices/Windows/Usb.cs index 708416778..b76f9cf98 100644 --- a/Aaru.Devices/Windows/Usb.cs +++ b/Aaru.Devices/Windows/Usb.cs @@ -93,9 +93,8 @@ static partial class Usb // now we can get some more detailed information var nRequiredSize = 0; - const int nBytes = BUFFER_SIZE; - if(SetupDiGetDeviceInterfaceDetail(h, ref dia, ref didd, nBytes, ref nRequiredSize, ref da)) + if(SetupDiGetDeviceInterfaceDetail(h, ref dia, ref didd, BUFFER_SIZE, ref nRequiredSize, ref da)) { host._controllerDevicePath = didd.DevicePath; @@ -131,11 +130,10 @@ static partial class Usb static string GetDescriptionByKeyName(string driverKeyName) { var ans = ""; - const string devEnum = REGSTR_KEY_USB; // Use the "enumerator form" of the SetupDiGetClassDevs API // to generate a list of all USB devices - IntPtr h = SetupDiGetClassDevs(0, devEnum, IntPtr.Zero, DIGCF_PRESENT | DIGCF_ALLCLASSES); + IntPtr h = SetupDiGetClassDevs(0, REGSTR_KEY_USB, IntPtr.Zero, DIGCF_PRESENT | DIGCF_ALLCLASSES); if(h == _invalidHandleValue) return ans; @@ -190,11 +188,10 @@ static partial class Usb static string GetInstanceIdByKeyName(string driverKeyName) { var ans = ""; - const string devEnum = REGSTR_KEY_USB; // Use the "enumerator form" of the SetupDiGetClassDevs API // to generate a list of all USB devices - IntPtr h = SetupDiGetClassDevs(0, devEnum, IntPtr.Zero, DIGCF_PRESENT | DIGCF_ALLCLASSES); + IntPtr h = SetupDiGetClassDevs(0, REGSTR_KEY_USB, IntPtr.Zero, DIGCF_PRESENT | DIGCF_ALLCLASSES); if(h == _invalidHandleValue) return ans; @@ -227,9 +224,8 @@ static partial class Usb // is it a match? if(keyName == driverKeyName) { - const int nBytes = BUFFER_SIZE; - var sb = new StringBuilder(nBytes); - SetupDiGetDeviceInstanceId(h, ref da, sb, nBytes, out requiredSize); + var sb = new StringBuilder(BUFFER_SIZE); + SetupDiGetDeviceInstanceId(h, ref da, sb, BUFFER_SIZE, out requiredSize); ans = sb.ToString(); break; diff --git a/Aaru.Devices/Windows/UsbFunctions.cs b/Aaru.Devices/Windows/UsbFunctions.cs index a9fe7e30b..ff0f4c66e 100644 --- a/Aaru.Devices/Windows/UsbFunctions.cs +++ b/Aaru.Devices/Windows/UsbFunctions.cs @@ -241,9 +241,8 @@ static partial class Usb // now we can get some more detailed information var nRequiredSize = 0; - const int nBytes = BUFFER_SIZE; - if(SetupDiGetDeviceInterfaceDetail(h, ref dia, ref didd, nBytes, ref nRequiredSize, ref da)) + if(SetupDiGetDeviceInterfaceDetail(h, ref dia, ref didd, BUFFER_SIZE, ref nRequiredSize, ref da)) if(GetDeviceNumber(didd.DevicePath) == devNum) { // current InstanceID is at the "USBSTOR" level, so we @@ -251,8 +250,8 @@ static partial class Usb CM_Get_Parent(out IntPtr ptrPrevious, da.DevInst, 0); // Now we get the InstanceID of the USB level device - IntPtr ptrInstanceBuf = Marshal.AllocHGlobal(nBytes); - CM_Get_Device_ID(ptrPrevious, ptrInstanceBuf, nBytes, 0); + nint ptrInstanceBuf = Marshal.AllocHGlobal(BUFFER_SIZE); + CM_Get_Device_ID(ptrPrevious, ptrInstanceBuf, BUFFER_SIZE, 0); instanceId = Marshal.PtrToStringAuto(ptrInstanceBuf); Marshal.FreeHGlobal(ptrInstanceBuf); diff --git a/Aaru.Gui/Controls/BlockMap.cs b/Aaru.Gui/Controls/BlockMap.cs index 9a6325395..6038b9705 100644 --- a/Aaru.Gui/Controls/BlockMap.cs +++ b/Aaru.Gui/Controls/BlockMap.cs @@ -444,21 +444,20 @@ public sealed class BlockMap : ItemsControl using IDrawingContextImpl ctxi = _bitmap.CreateDrawingContext(null); using var ctx = new DrawingContext(ctxi, false); - int squareWidth = (sideLength - 2 * borderWidth) / colors.Length; - int squareHeight = squareWidth; - var x = 0; - var y = 0; + int squareWidth = (sideLength - 2 * borderWidth) / colors.Length; + var x = 0; + var y = 0; foreach(Color color in colors) { - ctx.FillRectangle(new SolidColorBrush(color), new Rect(x, y, squareWidth, squareHeight)); + ctx.FillRectangle(new SolidColorBrush(color), new Rect(x, y, squareWidth, squareWidth)); x += squareWidth + 2 * borderWidth; if(x < sideLength) continue; x = 0; - y += squareHeight + 2 * borderWidth; + y += squareWidth + 2 * borderWidth; } } diff --git a/Aaru.Images/Alcohol120/Write.cs b/Aaru.Images/Alcohol120/Write.cs index ff8e07bc6..abfa0bc6f 100644 --- a/Aaru.Images/Alcohol120/Write.cs +++ b/Aaru.Images/Alcohol120/Write.cs @@ -457,7 +457,6 @@ public sealed partial class Alcohol120 foreach(CommonTypes.Structs.Track track in tracks.OrderBy(t => t.Sequence)) { - CommonTypes.Structs.Track newTrack = track; uint subchannelSize; switch(track.SubchannelType) @@ -477,12 +476,12 @@ public sealed partial class Alcohol120 return false; } - newTrack.FileOffset = currentDataOffset; + track.FileOffset = currentDataOffset; - currentDataOffset += (ulong)(newTrack.RawBytesPerSector + subchannelSize) * - (newTrack.EndSector - newTrack.StartSector + 1); + currentDataOffset += (ulong)(track.RawBytesPerSector + subchannelSize) * + (track.EndSector - track.StartSector + 1); - _writingTracks.Add(newTrack); + _writingTracks.Add(track); } return true; diff --git a/Aaru.Images/CDRDAO/Write.cs b/Aaru.Images/CDRDAO/Write.cs index 99b6e6557..29311dfda 100644 --- a/Aaru.Images/CDRDAO/Write.cs +++ b/Aaru.Images/CDRDAO/Write.cs @@ -468,18 +468,16 @@ public sealed partial class Cdrdao return false; } - Track newTrack = track; + track.File = _separateTracksWriting ? _writingBaseName + $"_track{track.Sequence:D2}.bin" + : _writingBaseName + ".bin"; - newTrack.File = _separateTracksWriting ? _writingBaseName + $"_track{track.Sequence:D2}.bin" - : _writingBaseName + ".bin"; + track.FileOffset = _separateTracksWriting ? 0 : currentOffset; + _writingTracks.Add(track); - newTrack.FileOffset = _separateTracksWriting ? 0 : currentOffset; - _writingTracks.Add(newTrack); - - currentOffset += (ulong)newTrack.RawBytesPerSector * (newTrack.EndSector - newTrack.StartSector + 1); + currentOffset += (ulong)track.RawBytesPerSector * (track.EndSector - track.StartSector + 1); if(track.SubchannelType != TrackSubchannelType.None) - currentOffset += 96 * (newTrack.EndSector - newTrack.StartSector + 1); + currentOffset += 96 * (track.EndSector - track.StartSector + 1); } _writingStreams = new Dictionary(); diff --git a/Aaru.Images/CDRWin/Write.cs b/Aaru.Images/CDRWin/Write.cs index 28235b097..867c3713c 100644 --- a/Aaru.Images/CDRWin/Write.cs +++ b/Aaru.Images/CDRWin/Write.cs @@ -389,13 +389,11 @@ public sealed partial class CdrWin foreach(Track track in tracks.OrderBy(t => t.Sequence)) { - Track newTrack = track; + track.File = _separateTracksWriting ? _writingBaseName + $"_track{track.Sequence:D2}.bin" + : _writingBaseName + ".bin"; - newTrack.File = _separateTracksWriting ? _writingBaseName + $"_track{track.Sequence:D2}.bin" - : _writingBaseName + ".bin"; - - newTrack.FileOffset = _separateTracksWriting ? 0 : track.StartSector * 2352; - _writingTracks.Add(newTrack); + track.FileOffset = _separateTracksWriting ? 0 : track.StartSector * 2352; + _writingTracks.Add(track); } _writingStreams = new Dictionary();