[Refactor] Replace array initializations with new byte[] for consistency

This commit is contained in:
2025-11-24 03:22:07 +00:00
parent d29afd403a
commit 0ddd930ee1
18 changed files with 44 additions and 65 deletions

View File

@@ -125,7 +125,7 @@ partial class Dump
if(key.All(static k => k == 0)) if(key.All(static k => k == 0))
{ {
outputFormat.WriteSectorTag([0, 0, 0, 0, 0], i + j, false, SectorTagType.DvdTitleKeyDecrypted); outputFormat.WriteSectorTag(new byte[5], i + j, false, SectorTagType.DvdTitleKeyDecrypted);
_resume.MissingTitleKeys?.Remove(i + j); _resume.MissingTitleKeys?.Remove(i + j);

View File

@@ -143,12 +143,9 @@ partial class Dump
// not encrypted even if the CMI says it is. // not encrypted even if the CMI says it is.
if(titleKey.Value.Key.All(static k => k == 0)) if(titleKey.Value.Key.All(static k => k == 0))
{ {
outputFormat.WriteSectorTag([0, 0, 0, 0, 0], i + j, false, SectorTagType.DvdSectorTitleKey); outputFormat.WriteSectorTag(new byte[5], i + j, false, SectorTagType.DvdSectorTitleKey);
outputFormat.WriteSectorTag([0, 0, 0, 0, 0], outputFormat.WriteSectorTag(new byte[5], i + j, false, SectorTagType.DvdTitleKeyDecrypted);
i + j,
false,
SectorTagType.DvdTitleKeyDecrypted);
_resume.MissingTitleKeys.Remove(i + j); _resume.MissingTitleKeys.Remove(i + j);

View File

@@ -314,10 +314,7 @@ partial class Dump
if(key.All(static k => k == 0)) if(key.All(static k => k == 0))
{ {
outputFormat.WriteSectorTag([0, 0, 0, 0, 0], outputFormat.WriteSectorTag(new byte[5], badSector, false, SectorTagType.DvdTitleKeyDecrypted);
badSector,
false,
SectorTagType.DvdTitleKeyDecrypted);
_resume.MissingTitleKeys?.Remove(badSector); _resume.MissingTitleKeys?.Remove(badSector);
} }
@@ -449,9 +446,9 @@ partial class Dump
// If the decoded title key is zeroed, there should be no copy protection // If the decoded title key is zeroed, there should be no copy protection
if((titleKey.Value.CMI & 0x80) >> 7 == 0 || titleKey.Value.Key.All(static k => k == 0)) if((titleKey.Value.CMI & 0x80) >> 7 == 0 || titleKey.Value.Key.All(static k => k == 0))
{ {
outputFormat.WriteSectorTag([0, 0, 0, 0, 0], missingKey, false, SectorTagType.DvdSectorTitleKey); outputFormat.WriteSectorTag(new byte[5], missingKey, false, SectorTagType.DvdSectorTitleKey);
outputFormat.WriteSectorTag([0, 0, 0, 0, 0], missingKey, false, SectorTagType.DvdTitleKeyDecrypted); outputFormat.WriteSectorTag(new byte[5], missingKey, false, SectorTagType.DvdTitleKeyDecrypted);
_resume.MissingTitleKeys.Remove(missingKey); _resume.MissingTitleKeys.Remove(missingKey);

View File

@@ -107,7 +107,7 @@ partial class Dump
if(key.All(static k => k == 0)) if(key.All(static k => k == 0))
{ {
outputFormat.WriteSectorTag([0, 0, 0, 0, 0], badSector, false, SectorTagType.DvdTitleKeyDecrypted); outputFormat.WriteSectorTag(new byte[5], badSector, false, SectorTagType.DvdTitleKeyDecrypted);
_resume.MissingTitleKeys?.Remove(badSector); _resume.MissingTitleKeys?.Remove(badSector);
} }

View File

@@ -277,7 +277,7 @@ public sealed partial class A2R
_writingStream.WriteByte(1); _writingStream.WriteByte(1);
_writingStream.Write(BitConverter.GetBytes(_currentResolution), 0, 4); _writingStream.Write(BitConverter.GetBytes(_currentResolution), 0, 4);
byte[] reserved = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; var reserved = new byte[11];
_writingStream.Write(reserved, 0, 11); _writingStream.Write(reserved, 0, 11);

View File

@@ -676,7 +676,7 @@ public sealed partial class Alcohol120
byte lastSession = 0; byte lastSession = 0;
var tocMs = new MemoryStream(); var tocMs = new MemoryStream();
tocMs.Write([0, 0], 0, 2); // Reserved for TOC session numbers tocMs.Write(new byte[2], 0, 2); // Reserved for TOC session numbers
foreach(KeyValuePair<int, Dictionary<int, Track>> sessionToc in _alcToc) foreach(KeyValuePair<int, Dictionary<int, Track>> sessionToc in _alcToc)
{ {

View File

@@ -1073,7 +1073,7 @@ public sealed partial class Alcohol120
_descriptorStream.Write(filename, 0, filename.Length); _descriptorStream.Write(filename, 0, filename.Length);
// Write filename null termination // Write filename null termination
_descriptorStream.Write([0, 0], 0, 2); _descriptorStream.Write(new byte[2], 0, 2);
_descriptorStream.Flush(); _descriptorStream.Flush();
_descriptorStream.Close(); _descriptorStream.Close();

View File

@@ -72,6 +72,8 @@ public sealed partial class Blu
public IEnumerable<MediaTagType> SupportedMediaTags => []; public IEnumerable<MediaTagType> SupportedMediaTags => [];
/// <inheritdoc /> /// <inheritdoc />
// ReSharper disable once ArrayWithDefaultValuesInitialization
public IEnumerable<SectorTagType> SupportedSectorTags => [SectorTagType.AppleSonyTag]; public IEnumerable<SectorTagType> SupportedSectorTags => [SectorTagType.AppleSonyTag];
/// <inheritdoc /> /// <inheritdoc />

View File

@@ -700,7 +700,7 @@ public sealed partial class BlindWrite5
Partitions = []; Partitions = [];
var fullTocStream = new MemoryStream(); var fullTocStream = new MemoryStream();
fullTocStream.Write([0, 0], 0, 2); fullTocStream.Write(new byte[2], 0, 2);
ulong offsetBytes = 0; ulong offsetBytes = 0;
_offsetMap = new Dictionary<uint, ulong>(); _offsetMap = new Dictionary<uint, ulong>();

View File

@@ -38,5 +38,5 @@ namespace Aaru.Images;
public sealed partial class D88 public sealed partial class D88
{ {
const byte READ_ONLY = 0x10; const byte READ_ONLY = 0x10;
readonly byte[] _reservedEmpty = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]; readonly byte[] _reservedEmpty = new byte[9];
} }

View File

@@ -68,6 +68,8 @@ public sealed partial class DiskCopy42
public IEnumerable<MediaTagType> SupportedMediaTags => []; public IEnumerable<MediaTagType> SupportedMediaTags => [];
/// <inheritdoc /> /// <inheritdoc />
// ReSharper disable once ArrayWithDefaultValuesInitialization
public IEnumerable<SectorTagType> SupportedSectorTags => [SectorTagType.AppleSonyTag]; public IEnumerable<SectorTagType> SupportedSectorTags => [SectorTagType.AppleSonyTag];
/// <inheritdoc /> /// <inheritdoc />

View File

@@ -553,7 +553,7 @@ public sealed partial class Gdi
if(tag != SectorTagType.CdTrackFlags) return ErrorNumber.NotSupported; if(tag != SectorTagType.CdTrackFlags) return ErrorNumber.NotSupported;
buffer = [0x00]; buffer = new byte[1];
return ErrorNumber.NoError; return ErrorNumber.NoError;
} }

View File

@@ -38,7 +38,7 @@ namespace Aaru.Tests.Checksums;
[TestFixture] [TestFixture]
public class Crc16Ibm public class Crc16Ibm
{ {
static readonly byte[] _expectedEmpty = [0x00, 0x00]; static readonly byte[] _expectedEmpty = new byte[2];
static readonly byte[] _expectedRandom = static readonly byte[] _expectedRandom =
[ [
// ReSharper disable once UseUtf8StringLiteral // ReSharper disable once UseUtf8StringLiteral

View File

@@ -18,7 +18,7 @@ public class CID
readonly byte[] manufacturers = [0x15, 0x06, 0x2c]; readonly byte[] manufacturers = [0x15, 0x06, 0x2c];
readonly ushort[] applications = [0, 0, 0]; readonly ushort[] applications = new ushort[3];
readonly string[] names = ["000000", "32M ", "AF HMP"]; readonly string[] names = ["000000", "32M ", "AF HMP"];
@@ -28,7 +28,7 @@ public class CID
readonly byte[] dates = [0x97, 0xc6, 0x68]; readonly byte[] dates = [0x97, 0xc6, 0x68];
readonly byte[] crcs = [0x00, 0x00, 0x00]; readonly byte[] crcs = new byte[3];
[Test] [Test]
public void Test() public void Test()

View File

@@ -34,11 +34,11 @@ public class CSD
readonly bool[] read_partial_blocks = [false, true, true]; readonly bool[] read_partial_blocks = [false, true, true];
readonly bool[] write_misaligned_block = [false, false, false]; readonly bool[] write_misaligned_block = new bool[3];
readonly bool[] read_misaligned_block = [false, false, false]; readonly bool[] read_misaligned_block = new bool[3];
readonly bool[] dsr_implemented = [false, false, false]; readonly bool[] dsr_implemented = new bool[3];
readonly uint[] card_sizes = [1959, 1959, 3919]; readonly uint[] card_sizes = [1959, 1959, 3919];
@@ -52,7 +52,7 @@ public class CSD
readonly byte[] size_multiplier = [3, 3, 5]; readonly byte[] size_multiplier = [3, 3, 5];
readonly byte[] sector_sizes = [0, 0, 0]; readonly byte[] sector_sizes = new byte[3];
readonly byte[] erase_sector_sizes = [31, 15, 31]; readonly byte[] erase_sector_sizes = [31, 15, 31];
@@ -60,25 +60,25 @@ public class CSD
readonly bool[] write_protect_group_enable = [true, true, true]; readonly bool[] write_protect_group_enable = [true, true, true];
readonly byte[] default_eccs = [0, 0, 0]; readonly byte[] default_eccs = new byte[3];
readonly byte[] r2w_factors = [4, 2, 5]; readonly byte[] r2w_factors = [4, 2, 5];
readonly byte[] write_block_lengths = [9, 9, 9]; readonly byte[] write_block_lengths = [9, 9, 9];
readonly bool[] write_partial_blocks = [false, false, false]; readonly bool[] write_partial_blocks = new bool[3];
readonly bool[] file_format_group = [false, false, false]; readonly bool[] file_format_group = new bool[3];
readonly bool[] copy = [true, false, false]; readonly bool[] copy = [true, false, false];
readonly bool[] permanent_write_protect = [false, false, false]; readonly bool[] permanent_write_protect = new bool[3];
readonly bool[] temporary_write_protect = [false, false, false]; readonly bool[] temporary_write_protect = new bool[3];
readonly byte[] file_format = [0, 0, 0]; readonly byte[] file_format = new byte[3];
readonly byte[] ecc = [0, 0, 0]; readonly byte[] ecc = new byte[3];
[Test] [Test]
public void Test() public void Test()

View File

@@ -53,7 +53,7 @@ public class CID
0x147, 0x089, 0x09a, 0x0a5, 0x091, 0x0e8, 0x123, 0x0b2, 0x067, 0x0b8, 0x0aa, 0x095, 0x0fa, 0x034 0x147, 0x089, 0x09a, 0x0a5, 0x091, 0x0e8, 0x123, 0x0b2, 0x067, 0x0b8, 0x0aa, 0x095, 0x0fa, 0x034
]; ];
readonly byte[] crcs = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]; readonly byte[] crcs = new byte[14];
[Test] [Test]
public void Test() public void Test()

View File

@@ -46,20 +46,11 @@ public class CSD
false, false, false, true, true, false, false, true, true, false, false, false, false, true false, false, false, true, true, false, false, true, true, false, false, false, false, true
]; ];
readonly bool[] write_misaligned_block = readonly bool[] write_misaligned_block = new bool[14];
[
false, false, false, false, false, false, false, false, false, false, false, false, false, false
];
readonly bool[] read_misaligned_block = readonly bool[] read_misaligned_block = new bool[14];
[
false, false, false, false, false, false, false, false, false, false, false, false, false, false
];
readonly bool[] dsr_implemented = readonly bool[] dsr_implemented = new bool[14];
[
false, false, false, false, false, false, false, false, false, false, false, false, false, false
];
readonly uint[] card_sizes = readonly uint[] card_sizes =
[ [
@@ -102,17 +93,11 @@ public class CSD
false, false, false, true, false, true, true, false, false, false, false, true, false, false, false false, false, false, true, false, true, true, false, false, false, false, true, false, false, false
]; ];
readonly bool[] permanent_write_protect = readonly bool[] permanent_write_protect = new bool[14];
[
false, false, false, false, false, false, false, false, false, false, false, false, false, false
];
readonly bool[] temporary_write_protect = readonly bool[] temporary_write_protect = new bool[14];
[
false, false, false, false, false, false, false, false, false, false, false, false, false, false
];
readonly byte[] file_format = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; readonly byte[] file_format = new byte[14];
[Test] [Test]
public void Test() public void Test()

View File

@@ -24,7 +24,7 @@ public class SCR
"0235000000000000", "0235000000000000", "02b5800000000000", "00a5000008070302" "0235000000000000", "0235000000000000", "02b5800000000000", "00a5000008070302"
]; ];
readonly byte[] structure_version = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; readonly byte[] structure_version = new byte[14];
readonly byte[] specification_version = [2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 0]; readonly byte[] specification_version = [2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 0];
@@ -42,12 +42,9 @@ public class SCR
true, false, true, false, false, true, true, true, false, true, false, false, true, false true, false, true, false, false, true, true, true, false, true, false, false, true, false
]; ];
readonly byte[] ex_security = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; readonly byte[] ex_security = new byte[14];
readonly bool[] sd_spec4 = readonly bool[] sd_spec4 = new bool[14];
[
false, false, false, false, false, false, false, false, false, false, false, false, false, false
];
readonly byte[] sd_specx = [2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]; readonly byte[] sd_specx = [2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0];
@@ -55,10 +52,9 @@ public class SCR
readonly byte[][] mfg = readonly byte[][] mfg =
[ [
[0x01, 0x00, 0x00, 0x00], [0x1c, 0x02, 0x21, 0x02], [0x01, 0x00, 0x00, 0x00], [0x00, 0x00, 0x00, 0x00], [0x01, 0x00, 0x00, 0x00], [0x1c, 0x02, 0x21, 0x02], [0x01, 0x00, 0x00, 0x00], new byte[4],
[0x1c, 0x02, 0x14, 0x02], [0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x00, 0x00], [0x1c, 0x02, 0x14, 0x02], new byte[4], new byte[4], new byte[4], new byte[4], [0x01, 0x00, 0x00, 0x00],
[0x00, 0x00, 0x00, 0x00], [0x01, 0x00, 0x00, 0x00], [0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x00, 0x00], new byte[4], new byte[4], new byte[4], [0x08, 0x07, 0x03, 0x02]
[0x00, 0x00, 0x00, 0x00], [0x08, 0x07, 0x03, 0x02]
]; ];
[Test] [Test]