Code cleaning, using sorting and pragma to not mark necessary

casts that seem unnecessary to the compiler.
This commit is contained in:
2016-10-12 06:37:24 +01:00
parent 35ac5aa3e4
commit 7593fd38a0
2 changed files with 34 additions and 12 deletions

View File

@@ -1,3 +1,9 @@
2016-10-12 Natalia Portillo <claunia@claunia.com>
* Commands/DumpMedia.cs:
Code cleaning, using sorting and pragma to not mark
necessary casts that seem unnecessary to the compiler.
2016-10-12 Natalia Portillo <claunia@claunia.com> 2016-10-12 Natalia Portillo <claunia@claunia.com>
* Commands/DumpMedia.cs: * Commands/DumpMedia.cs:

View File

@@ -31,16 +31,16 @@
// ****************************************************************************/ // ****************************************************************************/
using System; using System;
using DiscImageChef.Console;
using System.IO;
using DiscImageChef.Devices;
using System.Collections.Generic; using System.Collections.Generic;
using Schemas; using System.IO;
using DiscImageChef.CommonTypes; using DiscImageChef.CommonTypes;
using DiscImageChef.ImagePlugins; using DiscImageChef.Console;
using DiscImageChef.PartPlugins; using DiscImageChef.Devices;
using DiscImageChef.Filesystems; using DiscImageChef.Filesystems;
using DiscImageChef.Filters; using DiscImageChef.Filters;
using DiscImageChef.ImagePlugins;
using DiscImageChef.PartPlugins;
using Schemas;
namespace DiscImageChef.Commands namespace DiscImageChef.Commands
{ {
@@ -1360,13 +1360,13 @@ namespace DiscImageChef.Commands
continue; continue;
} }
#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator #pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
if(currentSpeed > maxSpeed && currentSpeed != 0) if(currentSpeed > maxSpeed && currentSpeed != 0)
maxSpeed = currentSpeed; maxSpeed = currentSpeed;
if(currentSpeed < minSpeed && currentSpeed != 0) if(currentSpeed < minSpeed && currentSpeed != 0)
minSpeed = currentSpeed; minSpeed = currentSpeed;
#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator #pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator
DicConsole.Write("\rReading block {0} ({1:F3} MiB/sec.)", currentBlock, currentSpeed); DicConsole.Write("\rReading block {0} ({1:F3} MiB/sec.)", currentBlock, currentSpeed);
@@ -2400,7 +2400,7 @@ namespace DiscImageChef.Commands
minSpeed = currentSpeed; minSpeed = currentSpeed;
#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator #pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator
DicConsole.Write("\rTrying to read lead-in sector {0} ({1:F3} MiB/sec.)", (int)leadInBlock, currentSpeed); DicConsole.Write("\rTrying to read lead-in sector {0} ({1:F3} MiB/sec.)", leadInBlock, currentSpeed);
sense = dev.ReadCd(out readBuffer, out senseBuf, (uint)leadInBlock, 2448, 1, MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, sense = dev.ReadCd(out readBuffer, out senseBuf, (uint)leadInBlock, 2448, 1, MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders,
true, true, MmcErrorField.None, MmcSubchannel.Raw, dev.Timeout, out cmdDuration); true, true, MmcErrorField.None, MmcSubchannel.Raw, dev.Timeout, out cmdDuration);
@@ -2424,7 +2424,9 @@ namespace DiscImageChef.Commands
} }
} }
#pragma warning disable IDE0004 // Remove Unnecessary Cast
currentSpeed = ((double)2448 / (double)1048576) / (cmdDuration / (double)1000); currentSpeed = ((double)2448 / (double)1048576) / (cmdDuration / (double)1000);
#pragma warning restore IDE0004 // Remove Unnecessary Cast
} }
closeDataFile(); closeDataFile();
@@ -2523,12 +2525,16 @@ namespace DiscImageChef.Commands
ibgLog.Write(i, 0); ibgLog.Write(i, 0);
} }
#pragma warning disable IDE0004 // Remove Unnecessary Cast
currentSpeed = ((double)2448 * blocksToRead / (double)1048576) / (cmdDuration / (double)1000); currentSpeed = ((double)2448 * blocksToRead / (double)1048576) / (cmdDuration / (double)1000);
#pragma warning restore IDE0004 // Remove Unnecessary Cast
} }
DicConsole.WriteLine(); DicConsole.WriteLine();
end = DateTime.UtcNow; end = DateTime.UtcNow;
mhddLog.Close(); mhddLog.Close();
#pragma warning disable IDE0004 // Remove Unnecessary Cast
ibgLog.Close(dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalDuration / 1000), options.DevicePath); ibgLog.Close(dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalDuration / 1000), options.DevicePath);
#pragma warning restore IDE0004 // Remove Unnecessary Cast
#region Compact Disc Error handling #region Compact Disc Error handling
if(unreadableSectors.Count > 0 && !aborted) if(unreadableSectors.Count > 0 && !aborted)
@@ -2676,7 +2682,9 @@ namespace DiscImageChef.Commands
double chkDuration = (chkEnd - chkStart).TotalMilliseconds; double chkDuration = (chkEnd - chkStart).TotalMilliseconds;
totalChkDuration += chkDuration; totalChkDuration += chkDuration;
#pragma warning disable IDE0004 // Remove Unnecessary Cast
currentSpeed = ((double)blockSize * blocksToRead / (double)1048576) / (chkDuration / (double)1000); currentSpeed = ((double)blockSize * blocksToRead / (double)1048576) / (chkDuration / (double)1000);
#pragma warning restore IDE0004 // Remove Unnecessary Cast
} }
DicConsole.WriteLine(); DicConsole.WriteLine();
closeDataFile(); closeDataFile();
@@ -3020,9 +3028,13 @@ namespace DiscImageChef.Commands
return; return;
} }
#pragma warning disable IDE0004 // Remove Unnecessary Cast
if(!read16 && blocks > ((long)0xFFFFFFFF + (long)1)) if(!read16 && blocks > ((long)0xFFFFFFFF + (long)1))
#pragma warning restore IDE0004 // Remove Unnecessary Cast
{ {
#pragma warning disable IDE0004 // Remove Unnecessary Cast
DicConsole.ErrorWriteLine("Device only supports SCSI READ (10) but has more than {0} blocks ({1} blocks total)", (long)0xFFFFFFFF + (long)1, blocks); DicConsole.ErrorWriteLine("Device only supports SCSI READ (10) but has more than {0} blocks ({1} blocks total)", (long)0xFFFFFFFF + (long)1, blocks);
#pragma warning restore IDE0004 // Remove Unnecessary Cast
return; return;
} }
@@ -3181,12 +3193,16 @@ namespace DiscImageChef.Commands
ibgLog.Write(i, 0); ibgLog.Write(i, 0);
} }
#pragma warning disable IDE0004 // Remove Unnecessary Cast
currentSpeed = ((double)blockSize * blocksToRead / (double)1048576) / (cmdDuration / (double)1000); currentSpeed = ((double)blockSize * blocksToRead / (double)1048576) / (cmdDuration / (double)1000);
#pragma warning restore IDE0004 // Remove Unnecessary Cast
} }
end = DateTime.UtcNow; end = DateTime.UtcNow;
DicConsole.WriteLine(); DicConsole.WriteLine();
mhddLog.Close(); mhddLog.Close();
#pragma warning disable IDE0004 // Remove Unnecessary Cast
ibgLog.Close(dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalDuration / 1000), options.DevicePath); ibgLog.Close(dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalDuration / 1000), options.DevicePath);
#pragma warning restore IDE0004 // Remove Unnecessary Cast
#region Error handling #region Error handling
if(unreadableSectors.Count > 0 && !aborted) if(unreadableSectors.Count > 0 && !aborted)
@@ -3260,12 +3276,12 @@ namespace DiscImageChef.Commands
} }
else if(read10) else if(read10)
{ {
sense = dev.Read10(out readBuffer, out senseBuf, 0, false, true, false, false, (uint)badSector, blockSize, 0, (ushort)1, dev.Timeout, out cmdDuration); sense = dev.Read10(out readBuffer, out senseBuf, 0, false, true, false, false, (uint)badSector, blockSize, 0, 1, dev.Timeout, out cmdDuration);
totalDuration += cmdDuration; totalDuration += cmdDuration;
} }
else if(read6) else if(read6)
{ {
sense = dev.Read6(out readBuffer, out senseBuf, (uint)badSector, blockSize, (byte)1, dev.Timeout, out cmdDuration); sense = dev.Read6(out readBuffer, out senseBuf, (uint)badSector, blockSize, 1, dev.Timeout, out cmdDuration);
totalDuration += cmdDuration; totalDuration += cmdDuration;
} }