[Refactor] Fix some code warnings.

This commit is contained in:
2024-05-01 23:52:03 +01:00
parent facfb0a972
commit feb9ea589f
37 changed files with 235 additions and 256 deletions

View File

@@ -71,7 +71,7 @@ static class Neon
while(blocks != 0)
{
uint n = Adler32Context.NMAX / blockSize; /* The NMAX constraint. */
uint n = Adler32Context.NMax / blockSize; /* The NMAX constraint. */
if(n > blocks) n = blocks;
@@ -196,8 +196,8 @@ static class Neon
/*
* Reduce.
*/
s1 %= Adler32Context.ADLER_MODULE;
s2 %= Adler32Context.ADLER_MODULE;
s1 %= Adler32Context.AdlerModule;
s2 %= Adler32Context.AdlerModule;
}
/*
@@ -228,9 +228,9 @@ static class Neon
while(len-- != 0) s2 += s1 += buf[bufPos++];
if(s1 >= Adler32Context.ADLER_MODULE) s1 -= Adler32Context.ADLER_MODULE;
if(s1 >= Adler32Context.AdlerModule) s1 -= Adler32Context.AdlerModule;
s2 %= Adler32Context.ADLER_MODULE;
s2 %= Adler32Context.AdlerModule;
}
/*

View File

@@ -68,7 +68,7 @@ static class Ssse3
while(blocks != 0)
{
uint n = Adler32Context.NMAX / blockSize; /* The NMAX constraint. */
uint n = Adler32Context.NMax / blockSize; /* The NMAX constraint. */
if(n > blocks) n = blocks;
@@ -142,8 +142,8 @@ static class Ssse3
/*
* Reduce.
*/
s1 %= Adler32Context.ADLER_MODULE;
s2 %= Adler32Context.ADLER_MODULE;
s1 %= Adler32Context.AdlerModule;
s2 %= Adler32Context.AdlerModule;
}
/*
@@ -174,9 +174,9 @@ static class Ssse3
while(len-- != 0) s2 += s1 += buf[bufPos++];
if(s1 >= Adler32Context.ADLER_MODULE) s1 -= Adler32Context.ADLER_MODULE;
if(s1 >= Adler32Context.AdlerModule) s1 -= Adler32Context.AdlerModule;
s2 %= Adler32Context.ADLER_MODULE;
s2 %= Adler32Context.AdlerModule;
}
/*

View File

@@ -54,8 +54,8 @@ namespace Aaru.Checksums;
[SuppressMessage("ReSharper", "UnusedMethodReturnValue.Global")]
public sealed partial class Adler32Context : IChecksum
{
internal const ushort ADLER_MODULE = 65521;
internal const uint NMAX = 5552;
internal const ushort AdlerModule = 65521;
internal const uint NMax = 5552;
readonly IntPtr _nativeContext;
readonly bool _useNative;
ushort _sum1, _sum2;
@@ -177,11 +177,11 @@ public sealed partial class Adler32Context : IChecksum
{
sum1 += data[dataOff];
if(sum1 >= ADLER_MODULE) sum1 -= ADLER_MODULE;
if(sum1 >= AdlerModule) sum1 -= AdlerModule;
sum2 += sum1;
if(sum2 >= ADLER_MODULE) sum2 -= ADLER_MODULE;
if(sum2 >= AdlerModule) sum2 -= AdlerModule;
preSum1 = (ushort)(sum1 & 0xFFFF);
preSum2 = (ushort)(sum2 & 0xFFFF);
@@ -197,9 +197,9 @@ public sealed partial class Adler32Context : IChecksum
sum2 += sum1;
}
if(sum1 >= ADLER_MODULE) sum1 -= ADLER_MODULE;
if(sum1 >= AdlerModule) sum1 -= AdlerModule;
sum2 %= ADLER_MODULE; /* only added so many ADLER_MODULE's */
sum2 %= AdlerModule; /* only added so many ADLER_MODULE's */
preSum1 = (ushort)(sum1 & 0xFFFF);
preSum2 = (ushort)(sum2 & 0xFFFF);
@@ -208,10 +208,10 @@ public sealed partial class Adler32Context : IChecksum
}
/* do length NMAX blocks -- requires just one modulo operation */
while(len >= NMAX)
while(len >= NMax)
{
len -= NMAX;
uint n = NMAX / 16;
len -= NMax;
uint n = NMax / 16;
do
{
@@ -252,8 +252,8 @@ public sealed partial class Adler32Context : IChecksum
dataOff += 16;
} while(--n != 0);
sum1 %= ADLER_MODULE;
sum2 %= ADLER_MODULE;
sum1 %= AdlerModule;
sum2 %= AdlerModule;
}
/* do remaining bytes (less than NMAX, still just one modulo) */
@@ -305,8 +305,8 @@ public sealed partial class Adler32Context : IChecksum
sum2 += sum1;
}
sum1 %= ADLER_MODULE;
sum2 %= ADLER_MODULE;
sum1 %= AdlerModule;
sum2 %= AdlerModule;
}
preSum1 = (ushort)(sum1 & 0xFFFF);

View File

@@ -41,9 +41,9 @@ namespace Aaru.Checksums;
public sealed class CRC16CcittContext : Crc16Context
{
/// <summary>CCITT CRC16 polynomial</summary>
public const ushort CRC16_CCITT_POLY = 0x8408;
public const ushort CRC16CcittPoly = 0x8408;
/// <summary>CCITT CRC16 seed</summary>
public const ushort CRC16_CCITT_SEED = 0x0000;
public const ushort CRC16CcittSeed = 0x0000;
static readonly ushort[][] _ccittCrc16Table =
[
[
@@ -226,11 +226,11 @@ public sealed class CRC16CcittContext : Crc16Context
/// <summary>Initializes an instance of the CRC16 with CCITT polynomial and seed.</summary>
/// <inheritdoc />
public CRC16CcittContext() : base(CRC16_CCITT_POLY, CRC16_CCITT_SEED, _ccittCrc16Table, true) {}
public CRC16CcittContext() : base(CRC16CcittPoly, CRC16CcittSeed, _ccittCrc16Table, true) {}
public string Name => Localization.CRC16_CCITT_Name;
public Guid Id => new("4C3BD0D5-24BD-4D45-BC19-A90A5AA5CC9D");
public string Author => Authors.NataliaPortillo;
public new string Name => Localization.CRC16_CCITT_Name;
public new Guid Id => new("4C3BD0D5-24BD-4D45-BC19-A90A5AA5CC9D");
public new string Author => Authors.NataliaPortillo;
/// <summary>Gets the hash of a file</summary>
/// <param name="filename">File path.</param>
@@ -245,14 +245,14 @@ public sealed class CRC16CcittContext : Crc16Context
/// <param name="filename">File path.</param>
/// <param name="hash">Byte array of the hash value.</param>
public static string File(string filename, out byte[] hash) =>
File(filename, out hash, CRC16_CCITT_POLY, CRC16_CCITT_SEED, _ccittCrc16Table, true);
File(filename, out hash, CRC16CcittPoly, CRC16CcittSeed, _ccittCrc16Table, true);
/// <summary>Gets the hash of the specified data buffer.</summary>
/// <param name="data">Data buffer.</param>
/// <param name="len">Length of the data buffer to hash.</param>
/// <param name="hash">Byte array of the hash value.</param>
public static string Data(byte[] data, uint len, out byte[] hash) =>
Data(data, len, out hash, CRC16_CCITT_POLY, CRC16_CCITT_SEED, _ccittCrc16Table, true);
Data(data, len, out hash, CRC16CcittPoly, CRC16CcittSeed, _ccittCrc16Table, true);
/// <summary>Gets the hash of the specified data buffer.</summary>
/// <param name="data">Data buffer.</param>
@@ -262,5 +262,5 @@ public sealed class CRC16CcittContext : Crc16Context
/// <summary>Calculates the CCITT CRC16 of the specified buffer with the specified parameters</summary>
/// <param name="buffer">Buffer</param>
public static ushort Calculate(byte[] buffer) =>
Calculate(buffer, CRC16_CCITT_POLY, CRC16_CCITT_SEED, _ccittCrc16Table, true);
Calculate(buffer, CRC16CcittPoly, CRC16CcittSeed, _ccittCrc16Table, true);
}

View File

@@ -61,11 +61,11 @@ public partial class Crc16Context : IChecksum
_useNative = Native.IsSupported;
_useCcitt = polynomial == CRC16CcittContext.CRC16_CCITT_POLY &&
seed == CRC16CcittContext.CRC16_CCITT_SEED &&
_useCcitt = polynomial == CRC16CcittContext.CRC16CcittPoly &&
seed == CRC16CcittContext.CRC16CcittSeed &&
inverse;
_useIbm = polynomial == CRC16IbmContext.CRC16_IBM_POLY && seed == CRC16IbmContext.CRC16_IBM_SEED && !inverse;
_useIbm = polynomial == CRC16IbmContext.CRC16IbmPoly && seed == CRC16IbmContext.CRC16IbmSeed && !inverse;
if(_useCcitt && _useNative)
{
@@ -369,13 +369,11 @@ public partial class Crc16Context : IChecksum
{
bool useNative = Native.IsSupported;
bool useCcitt = polynomial == CRC16CcittContext.CRC16_CCITT_POLY &&
seed == CRC16CcittContext.CRC16_CCITT_SEED &&
bool useCcitt = polynomial == CRC16CcittContext.CRC16CcittPoly &&
seed == CRC16CcittContext.CRC16CcittSeed &&
inverse;
bool useIbm = polynomial == CRC16IbmContext.CRC16_IBM_POLY &&
seed == CRC16IbmContext.CRC16_IBM_SEED &&
!inverse;
bool useIbm = polynomial == CRC16IbmContext.CRC16IbmPoly && seed == CRC16IbmContext.CRC16IbmSeed && !inverse;
IntPtr nativeContext = IntPtr.Zero;
@@ -474,13 +472,11 @@ public partial class Crc16Context : IChecksum
{
bool useNative = Native.IsSupported;
bool useCcitt = polynomial == CRC16CcittContext.CRC16_CCITT_POLY &&
seed == CRC16CcittContext.CRC16_CCITT_SEED &&
bool useCcitt = polynomial == CRC16CcittContext.CRC16CcittPoly &&
seed == CRC16CcittContext.CRC16CcittSeed &&
inverse;
bool useIbm = polynomial == CRC16IbmContext.CRC16_IBM_POLY &&
seed == CRC16IbmContext.CRC16_IBM_SEED &&
!inverse;
bool useIbm = polynomial == CRC16IbmContext.CRC16IbmPoly && seed == CRC16IbmContext.CRC16IbmSeed && !inverse;
IntPtr nativeContext = IntPtr.Zero;
@@ -565,13 +561,11 @@ public partial class Crc16Context : IChecksum
{
bool useNative = Native.IsSupported;
bool useCcitt = polynomial == CRC16CcittContext.CRC16_CCITT_POLY &&
seed == CRC16CcittContext.CRC16_CCITT_SEED &&
bool useCcitt = polynomial == CRC16CcittContext.CRC16CcittPoly &&
seed == CRC16CcittContext.CRC16CcittSeed &&
inverse;
bool useIbm = polynomial == CRC16IbmContext.CRC16_IBM_POLY &&
seed == CRC16IbmContext.CRC16_IBM_SEED &&
!inverse;
bool useIbm = polynomial == CRC16IbmContext.CRC16IbmPoly && seed == CRC16IbmContext.CRC16IbmSeed && !inverse;
IntPtr nativeContext = IntPtr.Zero;

View File

@@ -42,8 +42,8 @@ namespace Aaru.Checksums;
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
public sealed class CRC16IbmContext : Crc16Context
{
internal const ushort CRC16_IBM_POLY = 0xA001;
internal const ushort CRC16_IBM_SEED = 0x0000;
internal const ushort CRC16IbmPoly = 0xA001;
internal const ushort CRC16IbmSeed = 0x0000;
static readonly ushort[][] _ibmCrc16Table =
[
@@ -227,16 +227,11 @@ public sealed class CRC16IbmContext : Crc16Context
/// <summary>Initializes an instance of the CRC16 with IBM polynomial and seed.</summary>
/// <inheritdoc />
public CRC16IbmContext() : base(CRC16_IBM_POLY, CRC16_IBM_SEED, _ibmCrc16Table, false) {}
public CRC16IbmContext() : base(CRC16IbmPoly, CRC16IbmSeed, _ibmCrc16Table, false) {}
/// <inheritdoc />
public string Name => Localization.CRC16_IBM_Name;
/// <inheritdoc />
public Guid Id => new("0470433E-0C78-4C37-8C9F-BD8E72340E78");
/// <inheritdoc />
public string Author => Authors.NataliaPortillo;
public new string Name => Localization.CRC16_IBM_Name;
public new Guid Id => new("0470433E-0C78-4C37-8C9F-BD8E72340E78");
public new string Author => Authors.NataliaPortillo;
/// <summary>Gets the hash of a file</summary>
/// <param name="filename">File path.</param>
@@ -253,14 +248,14 @@ public sealed class CRC16IbmContext : Crc16Context
/// <param name="filename">File path.</param>
/// <param name="hash">Byte array of the hash value.</param>
public static string File(string filename, out byte[] hash) =>
File(filename, out hash, CRC16_IBM_POLY, CRC16_IBM_SEED, _ibmCrc16Table, false);
File(filename, out hash, CRC16IbmPoly, CRC16IbmSeed, _ibmCrc16Table, false);
/// <summary>Gets the hash of the specified data buffer.</summary>
/// <param name="data">Data buffer.</param>
/// <param name="len">Length of the data buffer to hash.</param>
/// <param name="hash">Byte array of the hash value.</param>
public static string Data(byte[] data, uint len, out byte[] hash) =>
Data(data, len, out hash, CRC16_IBM_POLY, CRC16_IBM_SEED, _ibmCrc16Table, false);
Data(data, len, out hash, CRC16IbmPoly, CRC16IbmSeed, _ibmCrc16Table, false);
/// <summary>Gets the hash of the specified data buffer.</summary>
/// <param name="data">Data buffer.</param>

View File

@@ -71,7 +71,7 @@ static class Neon
while(blocks != 0)
{
uint n = Fletcher32Context.NMAX / block_Size; /* The NMAX constraint. */
uint n = Fletcher32Context.Nmax / block_Size; /* The NMAX constraint. */
if(n > blocks) n = blocks;
@@ -200,8 +200,8 @@ static class Neon
/*
* Reduce.
*/
s1 %= Fletcher32Context.FLETCHER_MODULE;
s2 %= Fletcher32Context.FLETCHER_MODULE;
s1 %= Fletcher32Context.FletcherModule;
s2 %= Fletcher32Context.FletcherModule;
}
/*
@@ -232,9 +232,9 @@ static class Neon
while(len-- != 0) s2 += s1 += buf[bufPos++];
if(s1 >= Fletcher32Context.FLETCHER_MODULE) s1 -= Fletcher32Context.FLETCHER_MODULE;
if(s1 >= Fletcher32Context.FletcherModule) s1 -= Fletcher32Context.FletcherModule;
s2 %= Fletcher32Context.FLETCHER_MODULE;
s2 %= Fletcher32Context.FletcherModule;
}
/*

View File

@@ -68,7 +68,7 @@ static class Ssse3
while(blocks != 0)
{
uint n = Fletcher32Context.NMAX / block_Size; /* The NMAX constraint. */
uint n = Fletcher32Context.Nmax / block_Size; /* The NMAX constraint. */
if(n > blocks) n = blocks;
@@ -142,8 +142,8 @@ static class Ssse3
/*
* Reduce.
*/
s1 %= Fletcher32Context.FLETCHER_MODULE;
s2 %= Fletcher32Context.FLETCHER_MODULE;
s1 %= Fletcher32Context.FletcherModule;
s2 %= Fletcher32Context.FletcherModule;
}
/*
@@ -174,9 +174,9 @@ static class Ssse3
while(len-- != 0) s2 += s1 += buf[bufPos++];
if(s1 >= Fletcher32Context.FLETCHER_MODULE) s1 -= Fletcher32Context.FLETCHER_MODULE;
if(s1 >= Fletcher32Context.FletcherModule) s1 -= Fletcher32Context.FletcherModule;
s2 %= Fletcher32Context.FLETCHER_MODULE;
s2 %= Fletcher32Context.FletcherModule;
}
/*

View File

@@ -52,8 +52,8 @@ namespace Aaru.Checksums;
[SuppressMessage("ReSharper", "UnusedMember.Global")]
public sealed partial class Fletcher32Context : IChecksum
{
internal const ushort FLETCHER_MODULE = 0xFFFF;
internal const uint NMAX = 5552;
internal const ushort FletcherModule = 0xFFFF;
internal const uint Nmax = 5552;
readonly IntPtr _nativeContext;
readonly bool _useNative;
ushort _sum1, _sum2;
@@ -175,11 +175,11 @@ public sealed partial class Fletcher32Context : IChecksum
{
sum1 += data[dataOff];
if(sum1 >= FLETCHER_MODULE) sum1 -= FLETCHER_MODULE;
if(sum1 >= FletcherModule) sum1 -= FletcherModule;
sum2 += sum1;
if(sum2 >= FLETCHER_MODULE) sum2 -= FLETCHER_MODULE;
if(sum2 >= FletcherModule) sum2 -= FletcherModule;
previousSum1 = (ushort)(sum1 & 0xFFFF);
previousSum2 = (ushort)(sum2 & 0xFFFF);
@@ -195,9 +195,9 @@ public sealed partial class Fletcher32Context : IChecksum
sum2 += sum1;
}
if(sum1 >= FLETCHER_MODULE) sum1 -= FLETCHER_MODULE;
if(sum1 >= FletcherModule) sum1 -= FletcherModule;
sum2 %= FLETCHER_MODULE; /* only added so many FLETCHER_MODULE's */
sum2 %= FletcherModule; /* only added so many FLETCHER_MODULE's */
previousSum1 = (ushort)(sum1 & 0xFFFF);
previousSum2 = (ushort)(sum2 & 0xFFFF);
@@ -206,10 +206,10 @@ public sealed partial class Fletcher32Context : IChecksum
}
/* do length NMAX blocks -- requires just one modulo operation */
while(len >= NMAX)
while(len >= Nmax)
{
len -= NMAX;
uint n = NMAX / 16;
len -= Nmax;
uint n = Nmax / 16;
do
{
@@ -250,8 +250,8 @@ public sealed partial class Fletcher32Context : IChecksum
dataOff += 16;
} while(--n != 0);
sum1 %= FLETCHER_MODULE;
sum2 %= FLETCHER_MODULE;
sum1 %= FletcherModule;
sum2 %= FletcherModule;
}
/* do remaining bytes (less than NMAX, still just one modulo) */
@@ -303,8 +303,8 @@ public sealed partial class Fletcher32Context : IChecksum
sum2 += sum1;
}
sum1 %= FLETCHER_MODULE;
sum2 %= FLETCHER_MODULE;
sum1 %= FletcherModule;
sum2 %= FletcherModule;
}
previousSum1 = (ushort)(sum1 & 0xFFFF);

View File

@@ -40,8 +40,6 @@ namespace Aaru.Core;
/// <summary>Image information operations</summary>
public static class ArchiveInfo
{
const string MODULE_NAME = "Archive information";
/// <summary>Prints archive information to console</summary>
/// <param name="imageFormat">Archive</param>
public static void PrintArchiveInfo(IArchive imageFormat, IFilter filter, Encoding encoding)

View File

@@ -99,7 +99,7 @@ sealed partial class Dump
int sessions; // Number of sessions in disc
SubchannelLog subLog = null; // Subchannel log
uint subSize = 0; // Subchannel size in bytes
TrackSubchannelType subType = TrackSubchannelType.None; // Track subchannel type
TrackSubchannelType subType; // Track subchannel type
var supportsLongSectors = true; // Supports reading EDC and ECC
bool supportsPqSubchannel; // Supports reading PQ subchannel
bool supportsRwSubchannel; // Supports reading RW subchannel
@@ -375,13 +375,11 @@ sealed partial class Dump
UpdateStatus?.Invoke(Localization.Core.Drive_can_read_without_subchannel);
subSize = 0;
subType = TrackSubchannelType.None;
break;
case MmcSubchannel.Raw:
_dumpLog.WriteLine(Localization.Core.Full_raw_subchannel_reading_supported);
UpdateStatus?.Invoke(Localization.Core.Full_raw_subchannel_reading_supported);
subType = TrackSubchannelType.Raw;
subSize = 96;
break;
@@ -392,7 +390,6 @@ sealed partial class Dump
UpdateStatus?.Invoke(Localization.Core.WARNING_If_disc_says_CDG_CDEG_CDMIDI_dump_will_be_incorrect);
subType = TrackSubchannelType.Q16;
subSize = 16;
break;
@@ -401,7 +398,8 @@ sealed partial class Dump
subType = desiredSubchannel switch
{
MmcSubchannel.None => TrackSubchannelType.None,
MmcSubchannel.Raw or MmcSubchannel.Q16 => TrackSubchannelType.Raw
MmcSubchannel.Raw or MmcSubchannel.Q16 => TrackSubchannelType.Raw,
_ => throw new ArgumentOutOfRangeException()
};
blockSize = sectorSize + subSize;
@@ -1103,8 +1101,9 @@ sealed partial class Dump
foreach(int sub in _resume.BadSubchannels) subchannelExtents.Add(sub);
if(_resume.NextBlock < blocks)
for(ulong i = _resume.NextBlock; i < blocks; i++)
subchannelExtents.Add((int)i);
{
for(ulong i = _resume.NextBlock; i < blocks; i++) subchannelExtents.Add((int)i);
}
}
if(_resume.NextBlock > 0)
@@ -1593,8 +1592,9 @@ sealed partial class Dump
supportsLongSectors);
foreach(Tuple<ulong, ulong> leadoutExtent in leadOutExtents.ToArray())
for(ulong e = leadoutExtent.Item1; e <= leadoutExtent.Item2; e++)
subchannelExtents.Remove((int)e);
{
for(ulong e = leadoutExtent.Item1; e <= leadoutExtent.Item2; e++) subchannelExtents.Remove((int)e);
}
if(subchannelExtents.Count > 0 && _retryPasses > 0 && _retrySubchannel)
{

View File

@@ -145,7 +145,7 @@ partial class Dump
}
else
{
if(dcMode6?.Pages != null)
if(dcMode6.Value.Pages != null)
{
foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage => modePage is
{
@@ -469,8 +469,9 @@ partial class Dump
// MEDIUM ERROR, retry with ignore error below
if(decSense is { ASC: 0x11 })
if(!sectorsNotEvenPartial.Contains(badSector))
sectorsNotEvenPartial.Add(badSector);
{
if(!sectorsNotEvenPartial.Contains(badSector)) sectorsNotEvenPartial.Add(badSector);
}
}
// Because one block has been partially used to fix the offset

View File

@@ -285,8 +285,9 @@ partial class Dump
Modes.DecodedMode? decMode = null;
if(!sense && !_dev.Error)
if(Modes.DecodeMode10(cmdBuf, _dev.ScsiType).HasValue)
decMode = Modes.DecodeMode10(cmdBuf, _dev.ScsiType);
{
if(Modes.DecodeMode10(cmdBuf, _dev.ScsiType).HasValue) decMode = Modes.DecodeMode10(cmdBuf, _dev.ScsiType);
}
UpdateStatus?.Invoke(Localization.Core.Requesting_MODE_SENSE_6);
@@ -314,8 +315,9 @@ partial class Dump
if(sense || _dev.Error) sense = _dev.ModeSense(out cmdBuf, out senseBuf, 5, out duration);
if(!sense && !_dev.Error)
if(Modes.DecodeMode6(cmdBuf, _dev.ScsiType).HasValue)
decMode = Modes.DecodeMode6(cmdBuf, _dev.ScsiType);
{
if(Modes.DecodeMode6(cmdBuf, _dev.ScsiType).HasValue) decMode = Modes.DecodeMode6(cmdBuf, _dev.ScsiType);
}
// TODO: Check partitions page
if(decMode.HasValue)
@@ -1249,7 +1251,7 @@ partial class Dump
var forward = false;
const bool runningPersistent = false;
Modes.ModePage? currentModePage = null;
Modes.ModePage? currentModePage;
if(_persistent)
{

View File

@@ -94,7 +94,7 @@ partial class Dump
opticalDisc = dskType switch
{
MediaType.REV35 or MediaType.REV70 or MediaType.REV120 => false,
_ => opticalDisc
_ => true
};
}

View File

@@ -109,7 +109,7 @@ partial class Dump
}
else
{
if(dcMode6?.Pages != null)
if(dcMode6.Value.Pages != null)
{
foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage => modePage is
{

View File

@@ -843,7 +843,7 @@ public static class ImageInfo
}
}
if(imageFormat is IFluxImage fluxImage) AaruConsole.WriteLine(Localization.Core.Image_flux_captures);
if(imageFormat is IFluxImage) AaruConsole.WriteLine(Localization.Core.Image_flux_captures);
if(imageFormat is not IOpticalMediaImage opticalImage) return;

View File

@@ -124,8 +124,10 @@ public static class Remote
foreach(string migration in mctx.Database.GetPendingMigrations())
{
mctx.Database
#pragma warning disable EF1002
.ExecuteSqlRaw($"INSERT INTO \"__EFMigrationsHistory\" (MigrationId, ProductVersion) VALUES ('{
migration}', '0.0.0')");
#pragma warning restore EF1002
}
}
else

View File

@@ -8329,9 +8329,6 @@
</data>
<data name="Software_write_protect_is_enabled" xml:space="preserve">
<value>La protección contra escritura está activada</value>
</data>
<data name="Software_write_protect_is_enabled" xml:space="preserve">
<value>La protección contra escritura está activada</value>
</data>
<data name="Spare_Area_Full_Flags_0" xml:space="preserve">
<value>Valores completos del área de reserva: 0x{0:X2}</value>

View File

@@ -7453,9 +7453,6 @@
</data>
<data name="Port_A_link_is_down" xml:space="preserve">
<value>Port A link is down</value>
</data>
<data name="Port_A_uses_Parallel_SCSI_Ultra_160_interface" xml:space="preserve">
<value>Port A uses Parallel SCSI Ultra-160 interface</value>
</data>
<data name="Unknown_port_A_transport_type_code_0" xml:space="preserve">
<value>Unknown port A transport type code {0}</value>

View File

@@ -251,7 +251,7 @@ public static class CIS
continue;
}
if(strings == null) strings = [];
strings ??= [];
strings.Add(StringHandlers.CToString(buffer.ToArray()));
buffer = [];

View File

@@ -130,7 +130,7 @@ public static partial class Modes
double blocks;
if(page.LBAFormat == 8)
blocks = page.BlocksPerSecondOfAudio * (1 / 256);
blocks = page.BlocksPerSecondOfAudio * (1 / 256f);
else
blocks = page.BlocksPerSecondOfAudio;

View File

@@ -913,7 +913,7 @@ public class CSS
for(i = 0; i < 4; i++)
{
lfsr1Lo = lfsr0 & 0xff;
lfsr0 = lfsr0 >> 8;
lfsr0 >>= 8;
for(uint j = 0; j < 256; j++)
{

View File

@@ -39,7 +39,7 @@ namespace Aaru.Devices;
public partial class Device
{
protected static bool ReadMultipleBlockCannotSetBlockCount;
protected static bool _readMultipleBlockCannotSetBlockCount;
/// <summary>Reads the CSD register from a SecureDigital or MultiMediaCard device</summary>
/// <param name="buffer">Data buffer</param>
@@ -212,7 +212,7 @@ public partial class Device
if(transferLength <= 1)
return ReadSingleBlock(out buffer, out response, lba, blockSize, byteAddressed, timeout, out duration);
if(!ReadMultipleBlockCannotSetBlockCount)
if(!_readMultipleBlockCannotSetBlockCount)
{
sense = ReadMultipleBlock(out buffer,
out response,
@@ -224,7 +224,7 @@ public partial class Device
out duration);
}
if(ReadMultipleBlockCannotSetBlockCount)
if(_readMultipleBlockCannotSetBlockCount)
{
return ReadMultipleUsingSingle(out buffer,
out response,

View File

@@ -96,7 +96,7 @@ partial class Device : Devices.Device
}
// Seems ioctl(2) does not allow the atomicity needed
if(dev.PlatformId == PlatformID.Linux) ReadMultipleBlockCannotSetBlockCount = true;
if(dev.PlatformId == PlatformID.Linux) _readMultipleBlockCannotSetBlockCount = true;
dev.Type = DeviceType.Unknown;
dev.ScsiType = PeripheralDeviceTypes.UnknownDevice;

View File

@@ -132,7 +132,7 @@ public sealed partial class Device : Devices.Device
return null;
}
if(dev._remote.ServerOperatingSystem == "Linux") ReadMultipleBlockCannotSetBlockCount = true;
if(dev._remote.ServerOperatingSystem == "Linux") _readMultipleBlockCannotSetBlockCount = true;
dev.Type = DeviceType.Unknown;
dev.ScsiType = PeripheralDeviceTypes.UnknownDevice;

View File

@@ -219,9 +219,8 @@ public sealed partial class LisaFS
if(!_mounted || !_debug) return ErrorNumber.AccessDenied;
if(fileId is > 4 or <= 0)
{
if(fileId != FILEID_BOOT_SIGNED && fileId != FILEID_LOADER_SIGNED) return ErrorNumber.InvalidArgument;
}
if(fileId != FILEID_BOOT_SIGNED && fileId != FILEID_LOADER_SIGNED)
return ErrorNumber.InvalidArgument;
if(_systemFileCache.TryGetValue(fileId, out buf) && !tags) return ErrorNumber.NoError;
@@ -306,6 +305,7 @@ public sealed partial class LisaFS
if(fileId <= 4)
{
if(!_debug || fileId == 0) return ErrorNumber.NoSuchFile;
stat = new FileEntryInfo();
error = GetAttributes(fileId, out FileAttributes attrs);
@@ -435,9 +435,8 @@ public sealed partial class LisaFS
if(!tags)
{
if(_fileSizeCache.TryGetValue(fileId, out int realSize))
{
if(realSize > temp.Length) AaruConsole.ErrorWriteLine(Localization.File_0_gets_truncated, fileId);
}
if(realSize > temp.Length)
AaruConsole.ErrorWriteLine(Localization.File_0_gets_truncated, fileId);
buf = temp;

View File

@@ -149,8 +149,10 @@ public sealed class SplashWindowViewModel(SplashWindow view) : ViewModelBase
foreach(string migration in ctx.Database.GetPendingMigrations())
{
ctx.Database
#pragma warning disable EF1002
.ExecuteSqlRaw($"INSERT INTO \"__EFMigrationsHistory\" (MigrationId, ProductVersion) VALUES ('{
migration}', '0.0.0')");
#pragma warning restore EF1002
}
ctx.SaveChanges();

View File

@@ -1926,9 +1926,8 @@ public sealed partial class AaruFormat
// Fill FLAC block
if(remaining != 0)
{
for(var r = 0; r < remaining * 4; r++) _writingBuffer[_writingBufferPosition + r] = 0;
}
for(var r = 0; r < remaining * 4; r++)
_writingBuffer[_writingBufferPosition + r] = 0;
compressedLength = FLAC.EncodeBuffer(_writingBuffer,
_compressedBuffer,
@@ -2720,9 +2719,8 @@ public sealed partial class AaruFormat
// Fill FLAC block
if(remaining != 0)
{
for(var r = 0; r < remaining * 4; r++) _writingBuffer[_writingBufferPosition + r] = 0;
}
for(var r = 0; r < remaining * 4; r++)
_writingBuffer[_writingBufferPosition + r] = 0;
compressedLength = FLAC.EncodeBuffer(_writingBuffer,
_compressedBuffer,
@@ -5262,8 +5260,7 @@ public sealed partial class AaruFormat
foreach(IndexEntry entry in _index)
{
_structureBytes = new byte[Marshal.SizeOf<IndexEntry>()];
IndexEntry indexEntry = entry;
MemoryMarshal.Write(_structureBytes, in indexEntry);
MemoryMarshal.Write(_structureBytes, in entry);
blockStream.Write(_structureBytes, 0, _structureBytes.Length);
}

View File

@@ -92,7 +92,7 @@ public class MasterSystem : IByteAddressableImage
// Not sure but seems to be a multiple of at least this, maybe more
if(stream.Length % 8192 != 0) return ErrorNumber.InvalidArgument;
var headerPosition = 0;
int headerPosition;
stream.Position = 0x7ff0;
var magicBytes = new byte[8];

View File

@@ -235,8 +235,7 @@ public sealed partial class DiskCopy42
<= 28 => 18,
<= 34 => 17,
<= 41 => 16,
<= 45 => 15,
_ => sectorsToCopy
<= 45 => 15
};
Array.Copy(data,

View File

@@ -423,9 +423,9 @@ public sealed partial class DiskCopy42
}
/// <inheritdoc />
public bool SetImageInfo(ImageInfo imageInfo)
public bool SetImageInfo(ImageInfo info)
{
header.DiskName = imageInfo.MediaTitle ?? "-Aaru converted image-";
header.DiskName = info.MediaTitle ?? "-Aaru converted image-";
return true;
}

View File

@@ -93,10 +93,9 @@ public sealed partial class KryoFlux
if(!File.Exists(trackfile))
{
if(cylinder == 0)
{
if(head == 0)
switch(cylinder)
{
case 0 when head == 0:
AaruConsole.DebugWriteLine(MODULE_NAME,
Localization
.Cannot_find_cyl_0_hd_0_supposing_only_top_head_was_dumped);
@@ -105,8 +104,7 @@ public sealed partial class KryoFlux
heads = 1;
continue;
}
case 0:
AaruConsole.DebugWriteLine(MODULE_NAME,
Localization
.Cannot_find_cyl_0_hd_1_supposing_only_bottom_head_was_dumped);
@@ -114,11 +112,9 @@ public sealed partial class KryoFlux
heads = 1;
continue;
}
if(cylinder == 1)
{
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Cannot_find_cyl_1_supposing_double_stepping);
case 1:
AaruConsole.DebugWriteLine(MODULE_NAME,
Localization.Cannot_find_cyl_1_supposing_double_stepping);
step = 2;

View File

@@ -2949,4 +2949,7 @@
<data name="Create_a_dynamic_image" xml:space="preserve">
<value>Crear una imagen dinámica, los sectores vacíos se ignoran</value>
</data>
<data name="A2R_Name" xml:space="preserve">
<value>A2R</value>
</data>
</root>

View File

@@ -942,9 +942,6 @@
</data>
<data name="Dumping_Xbox_Game_Discs_requires_a_drive_with_Kreon_firmware" xml:space="preserve">
<value>Volcar discos de Xbox requiere una unidad con firmware Kreon.</value>
</data>
<data name="Dumping_Xbox_Game_Discs_requires_a_drive_with_Kreon_firmware" xml:space="preserve">
<value>Volcar discos de Xbox requiere una unidad con firmware Kreon.</value>
</data>
<data name="Dump_Ata_Output_format_does_not_support_ATA_IDENTIFY_" xml:space="preserve">
<value>El formato de salida no soporta ATA IDENTIFY.</value>

View File

@@ -3026,4 +3026,7 @@ Probadores:
<data name="LogEntry_Type_Exception" xml:space="preserve">
<value>Excepción</value>
</data>
<data name="CD_PMA" xml:space="preserve">
<value>CD PMA:</value>
</data>
</root>

View File

@@ -217,14 +217,11 @@ public sealed class AtariPartitions : IPartition
Offset = table.Entries[i].Start * sectorSize,
Start = table.Entries[i].Start,
Type = Encoding.ASCII.GetString(partType),
Scheme = Name
};
part.Description = type switch
Scheme = Name,
Description = type switch
{
TYPE_GEMDOS => Localization.Atari_GEMDOS_partition,
TYPE_BIG_GEMDOS => Localization
.Atari_GEMDOS_partition_bigger_than_32_MiB,
TYPE_BIG_GEMDOS => Localization.Atari_GEMDOS_partition_bigger_than_32_MiB,
TYPE_LINUX => Localization.Linux_partition,
TYPE_SWAP => Localization.Swap_partition,
TYPE_RAW => Localization.RAW_partition,
@@ -234,6 +231,7 @@ public sealed class AtariPartitions : IPartition
TYPE_MAC => Localization.Macintosh_partition,
TYPE_MINIX or TYPE_MINIX2 => Localization.MINIX_partition,
_ => Localization.Unknown_partition_type
}
};
partitions.Add(part);
@@ -308,14 +306,11 @@ public sealed class AtariPartitions : IPartition
Offset = extendedTable.Entries[j].Start * sectorSize,
Start = extendedTable.Entries[j].Start,
Type = Encoding.ASCII.GetString(partType),
Scheme = Name
};
part.Description = extendedType switch
Scheme = Name,
Description = extendedType switch
{
TYPE_GEMDOS => Localization.Atari_GEMDOS_partition,
TYPE_BIG_GEMDOS => Localization
.Atari_GEMDOS_partition_bigger_than_32_MiB,
TYPE_BIG_GEMDOS => Localization.Atari_GEMDOS_partition_bigger_than_32_MiB,
TYPE_LINUX => Localization.Linux_partition,
TYPE_SWAP => Localization.Swap_partition,
TYPE_RAW => Localization.RAW_partition,
@@ -325,6 +320,7 @@ public sealed class AtariPartitions : IPartition
TYPE_MAC => Localization.Macintosh_partition,
TYPE_MINIX or TYPE_MINIX2 => Localization.MINIX_partition,
_ => Localization.Unknown_partition_type
}
};
partitions.Add(part);
@@ -377,10 +373,8 @@ public sealed class AtariPartitions : IPartition
Offset = table.IcdEntries[i].Start * sectorSize,
Start = table.IcdEntries[i].Start,
Type = Encoding.ASCII.GetString(partType),
Scheme = Name
};
part.Description = type switch
Scheme = Name,
Description = type switch
{
TYPE_GEMDOS => Localization.Atari_GEMDOS_partition,
TYPE_BIG_GEMDOS => Localization.Atari_GEMDOS_partition_bigger_than_32_MiB,
@@ -393,6 +387,7 @@ public sealed class AtariPartitions : IPartition
TYPE_MAC => Localization.Macintosh_partition,
TYPE_MINIX or TYPE_MINIX2 => Localization.MINIX_partition,
_ => Localization.Unknown_partition_type
}
};
partitions.Add(part);

View File

@@ -137,8 +137,10 @@ class MainClass
foreach(string migration in ctx.Database.GetPendingMigrations())
{
ctx.Database
#pragma warning disable EF1002
.ExecuteSqlRaw($"INSERT INTO \"__EFMigrationsHistory\" (MigrationId, ProductVersion) VALUES ('{
migration}', '0.0.0')");
#pragma warning restore EF1002
}
ctx.SaveChanges();