[Aaru.Core] Improve null safety

Several files in the Aaru.Core project have been updated to improve null safety. The modification of these files specifically handled null occurrences. Nullable value types are now correctly handled and default values are set to be used where nulls were previously unhandled. This will help prevent null reference exceptions and improve the overall stability of the code.
This commit is contained in:
2023-10-05 02:19:02 +01:00
parent 71a00378b4
commit 2c955cfc49
11 changed files with 77 additions and 61 deletions

View File

@@ -176,15 +176,15 @@ partial class Dump
if(decMode.HasValue)
{
scsiMediumType = (byte)decMode.Value.Header.MediumType;
scsiMediumType = (byte)(decMode?.Header.MediumType ?? default(MediumTypes));
if(decMode.Value.Header.BlockDescriptors?.Length > 0)
scsiDensityCode = (byte)decMode.Value.Header.BlockDescriptors[0].Density;
if(decMode?.Header.BlockDescriptors?.Length > 0)
scsiDensityCode = (byte)(decMode?.Header.BlockDescriptors[0].Density ?? default(DensityType));
// TODO: Fix this
containsFloppyPage = decMode.Value.Pages?.Aggregate(containsFloppyPage,
(current, modePage) =>
current | modePage.Page == 0x05) ==
containsFloppyPage = decMode?.Pages?.Aggregate(containsFloppyPage,
(current, modePage) =>
current | modePage.Page == 0x05) ==
true;
}
}