diff --git a/Aaru.Core/Devices/Dumping/SSC.cs b/Aaru.Core/Devices/Dumping/SSC.cs index bcb2daf72..994d0f70c 100644 --- a/Aaru.Core/Devices/Dumping/SSC.cs +++ b/Aaru.Core/Devices/Dumping/SSC.cs @@ -285,8 +285,7 @@ namespace Aaru.Core.Devices.Dumping { scsiMediumTypeTape = (byte)decMode.Value.Header.MediumType; - if(decMode.Value.Header.BlockDescriptors != null && - decMode.Value.Header.BlockDescriptors.Length >= 1) + if(decMode.Value.Header.BlockDescriptors?.Length > 0) scsiDensityCodeTape = (byte)decMode.Value.Header.BlockDescriptors[0].Density; blockSize = decMode.Value.Header.BlockDescriptors?[0].BlockLength ?? 0; @@ -301,7 +300,7 @@ namespace Aaru.Core.Devices.Dumping BlockLimits.BlockLimitsData? blockLimits = BlockLimits.Decode(cmdBuf); if(blockLimits?.minBlockLen > blockSize) - blockSize = blockLimits.Value.minBlockLen; + blockSize = blockLimits?.minBlockLen ?? 0; } if(blockSize == 0) @@ -774,15 +773,12 @@ namespace Aaru.Core.Devices.Dumping currentTapeFile = (_outputPlugin as IWritableTapeImage).Files.FirstOrDefault(f => f.LastBlock == - (_outputPlugin as IWritableTapeImage - )?.Files.Max(g => g.LastBlock)); + (_outputPlugin as IWritableTapeImage + )?.Files.Max(g => g.LastBlock)); currentTapePartition = (_outputPlugin as IWritableTapeImage).TapePartitions.FirstOrDefault(p => p.LastBlock == - (_outputPlugin as - IWritableTapeImage)?. - TapePartitions. - Max(g => g.LastBlock)); + (_outputPlugin as IWritableTapeImage)?.TapePartitions.Max(g => g.LastBlock)); } if(mode6Data != null) diff --git a/Aaru.Core/Devices/Dumping/Sbc/Dump.cs b/Aaru.Core/Devices/Dumping/Sbc/Dump.cs index 498e1259a..c037fcde0 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Dump.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Dump.cs @@ -167,8 +167,7 @@ namespace Aaru.Core.Devices.Dumping { scsiMediumType = (byte)decMode.Value.Header.MediumType; - if(decMode.Value.Header.BlockDescriptors != null && - decMode.Value.Header.BlockDescriptors.Length >= 1) + if(decMode.Value.Header.BlockDescriptors?.Length > 0) scsiDensityCode = (byte)decMode.Value.Header.BlockDescriptors[0].Density; containsFloppyPage = decMode.Value.Pages?.Aggregate(containsFloppyPage, diff --git a/Aaru.Core/Devices/Report/MMC.cs b/Aaru.Core/Devices/Report/MMC.cs index ee39d8031..c6728efc3 100644 --- a/Aaru.Core/Devices/Report/MMC.cs +++ b/Aaru.Core/Devices/Report/MMC.cs @@ -630,10 +630,10 @@ namespace Aaru.Core.Devices.Report if(decMode != null) { - mediaTest.MediumType = (byte)decMode.Value.Header.MediumType; + mediaTest.MediumType = (byte?)decMode?.Header.MediumType; - if(decMode?.Header.BlockDescriptors.Length > 0) - mediaTest.Density = (byte)decMode.Value.Header.BlockDescriptors[0].Density; + if(decMode?.Header.BlockDescriptors?.Length > 0) + mediaTest.Density = (byte?)decMode?.Header.BlockDescriptors?[0].Density; } if(mediaType.StartsWith("CD-", StringComparison.Ordinal) || @@ -1280,12 +1280,10 @@ namespace Aaru.Core.Devices.Report if(mediaTest.CanReadCorrectedSubchannelWithC2 == false) mediaTest.CanReadCorrectedSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 11, 2714, - 1, MmcSectorTypes.Cdda, false, false, - false, MmcHeaderCodes.None, true, - false, - MmcErrorField.C2PointersAndBlock, - MmcSubchannel.Rw, _dev.Timeout, - out _); + 1, MmcSectorTypes.Cdda, false, false, + false, MmcHeaderCodes.None, true, false, + MmcErrorField.C2PointersAndBlock, + MmcSubchannel.Rw, _dev.Timeout, out _); AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadCorrectedSubchannelWithC2); @@ -1389,12 +1387,10 @@ namespace Aaru.Core.Devices.Report if(mediaTest.CanReadCorrectedSubchannelWithC2 == false) mediaTest.CanReadCorrectedSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2714, - 1, MmcSectorTypes.AllTypes, false, - false, true, - MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.C2PointersAndBlock, - MmcSubchannel.Rw, _dev.Timeout, - out _); + 1, MmcSectorTypes.AllTypes, false, false, + true, MmcHeaderCodes.AllHeaders, true, + true, MmcErrorField.C2PointersAndBlock, + MmcSubchannel.Rw, _dev.Timeout, out _); AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadCorrectedSubchannelWithC2); @@ -1496,12 +1492,10 @@ namespace Aaru.Core.Devices.Report if(mediaTest.CanReadCorrectedSubchannelWithC2 == false) mediaTest.CanReadCorrectedSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2440, - 1, MmcSectorTypes.AllTypes, false, - false, false, MmcHeaderCodes.None, - true, false, - MmcErrorField.C2PointersAndBlock, - MmcSubchannel.Rw, _dev.Timeout, - out _); + 1, MmcSectorTypes.AllTypes, false, false, + false, MmcHeaderCodes.None, true, false, + MmcErrorField.C2PointersAndBlock, + MmcSubchannel.Rw, _dev.Timeout, out _); AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadCorrectedSubchannelWithC2); @@ -1825,12 +1819,12 @@ namespace Aaru.Core.Devices.Report // Skip Lead-Out pre-gap uint firstSessionLeadOutLba = (uint)((firstSessionLeadOutTrack.PMIN * 60 * 75) + - (firstSessionLeadOutTrack.PSEC * 75) + + (firstSessionLeadOutTrack.PSEC * 75) + firstSessionLeadOutTrack.PFRAME + 150); // Skip second session track pre-gap uint secondSessionLeadInLba = (uint)(((secondSessionFirstTrack.PMIN * 60 * 75) + - (secondSessionFirstTrack.PSEC * 75) + + (secondSessionFirstTrack.PSEC * 75) + secondSessionFirstTrack.PFRAME) - 300); AaruConsole.WriteLine("Trying SCSI READ CD in first session Lead-Out..."); @@ -1845,23 +1839,21 @@ namespace Aaru.Core.Devices.Report if(mediaTest.CanReadingIntersessionLeadOut == false) { mediaTest.CanReadingIntersessionLeadOut = !_dev.ReadCd(out buffer, out senseBuffer, - firstSessionLeadOutLba, 2368, 1, - MmcSectorTypes.AllTypes, false, - false, false, - MmcHeaderCodes.AllHeaders, true, - false, MmcErrorField.None, - MmcSubchannel.Q16, _dev.Timeout, - out _); + firstSessionLeadOutLba, 2368, 1, + MmcSectorTypes.AllTypes, false, false, + false, MmcHeaderCodes.AllHeaders, true, + false, MmcErrorField.None, + MmcSubchannel.Q16, _dev.Timeout, out _); if(mediaTest.CanReadingIntersessionLeadOut == false) mediaTest.CanReadingIntersessionLeadOut = !_dev.ReadCd(out buffer, out senseBuffer, - firstSessionLeadOutLba, 2352, 1, - MmcSectorTypes.AllTypes, false, - false, false, - MmcHeaderCodes.AllHeaders, true, - false, MmcErrorField.None, - MmcSubchannel.None, _dev.Timeout, - out _); + firstSessionLeadOutLba, 2352, 1, + MmcSectorTypes.AllTypes, false, + false, false, + MmcHeaderCodes.AllHeaders, true, + false, MmcErrorField.None, + MmcSubchannel.None, _dev.Timeout, + out _); } AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", @@ -1881,22 +1873,20 @@ namespace Aaru.Core.Devices.Report if(mediaTest.CanReadingIntersessionLeadIn == false) { mediaTest.CanReadingIntersessionLeadIn = !_dev.ReadCd(out buffer, out senseBuffer, - secondSessionLeadInLba, 2368, 1, - MmcSectorTypes.AllTypes, false, false, - false, MmcHeaderCodes.AllHeaders, - true, false, MmcErrorField.None, - MmcSubchannel.Q16, _dev.Timeout, - out _); + secondSessionLeadInLba, 2368, 1, + MmcSectorTypes.AllTypes, false, false, + false, MmcHeaderCodes.AllHeaders, true, + false, MmcErrorField.None, + MmcSubchannel.Q16, _dev.Timeout, out _); if(mediaTest.CanReadingIntersessionLeadIn == false) mediaTest.CanReadingIntersessionLeadIn = !_dev.ReadCd(out buffer, out senseBuffer, - secondSessionLeadInLba, 2352, 1, - MmcSectorTypes.AllTypes, false, - false, false, - MmcHeaderCodes.AllHeaders, true, - false, MmcErrorField.None, - MmcSubchannel.None, _dev.Timeout, - out _); + secondSessionLeadInLba, 2352, 1, + MmcSectorTypes.AllTypes, false, false, + false, MmcHeaderCodes.AllHeaders, + true, false, MmcErrorField.None, + MmcSubchannel.None, _dev.Timeout, + out _); } AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", diff --git a/Aaru.Core/Devices/Report/SSC.cs b/Aaru.Core/Devices/Report/SSC.cs index 19f353105..26464d6e8 100644 --- a/Aaru.Core/Devices/Report/SSC.cs +++ b/Aaru.Core/Devices/Report/SSC.cs @@ -170,9 +170,8 @@ namespace Aaru.Core.Devices.Report { seqTest.MediumType = (byte)decMode.Value.Header.MediumType; - if(decMode.Value.Header.BlockDescriptors != null && - decMode.Value.Header.BlockDescriptors.Length > 0) - seqTest.Density = (byte)decMode.Value.Header.BlockDescriptors[0].Density; + if(decMode.Value.Header.BlockDescriptors?.Length > 0) + seqTest.Density = (byte)decMode.Value.Header.BlockDescriptors?[0].Density; } AaruConsole.WriteLine("Querying SCSI REPORT DENSITY SUPPORT for current media..."); diff --git a/Aaru.Core/Devices/Report/Scsi.cs b/Aaru.Core/Devices/Report/Scsi.cs index e65e204c3..425280421 100644 --- a/Aaru.Core/Devices/Report/Scsi.cs +++ b/Aaru.Core/Devices/Report/Scsi.cs @@ -425,8 +425,7 @@ namespace Aaru.Core.Devices.Report { mediaTest.MediumType = (byte)decMode.Value.Header.MediumType; - if(decMode.Value.Header.BlockDescriptors != null && - decMode.Value.Header.BlockDescriptors.Length > 0) + if(decMode?.Header.BlockDescriptors?.Length > 0) mediaTest.Density = (byte)decMode.Value.Header.BlockDescriptors[0].Density; } @@ -634,8 +633,7 @@ namespace Aaru.Core.Devices.Report { capabilities.MediumType = (byte)decMode.Value.Header.MediumType; - if(decMode.Value.Header.BlockDescriptors != null && - decMode.Value.Header.BlockDescriptors.Length > 0) + if(decMode?.Header.BlockDescriptors?.Length > 0) capabilities.Density = (byte)decMode.Value.Header.BlockDescriptors[0].Density; } diff --git a/Aaru.Core/Media/Info/ScsiInfo.cs b/Aaru.Core/Media/Info/ScsiInfo.cs index 01a0434aa..ba00f2283 100644 --- a/Aaru.Core/Media/Info/ScsiInfo.cs +++ b/Aaru.Core/Media/Info/ScsiInfo.cs @@ -166,8 +166,7 @@ namespace Aaru.Core.Media.Info { scsiMediumType = (byte)DeviceInfo.ScsiMode.Value.Header.MediumType; - if(DeviceInfo.ScsiMode.Value.Header.BlockDescriptors != null && - DeviceInfo.ScsiMode.Value.Header.BlockDescriptors.Length >= 1) + if(DeviceInfo.ScsiMode?.Header.BlockDescriptors?.Length > 0) scsiDensityCode = (byte)DeviceInfo.ScsiMode.Value.Header.BlockDescriptors[0].Density; if(DeviceInfo.ScsiMode.Value.Pages != null) diff --git a/Aaru.Images/ZZZRawImage/Read.cs b/Aaru.Images/ZZZRawImage/Read.cs index f8fb9ac64..91e980f1b 100644 --- a/Aaru.Images/ZZZRawImage/Read.cs +++ b/Aaru.Images/ZZZRawImage/Read.cs @@ -930,8 +930,7 @@ namespace Aaru.DiscImages { mediumType = (byte)decMode.Value.Header.MediumType; - if(decMode.Value.Header.BlockDescriptors != null && - decMode.Value.Header.BlockDescriptors.Length >= 1) + if(decMode?.Header.BlockDescriptors?.Length > 0) densityCode = (byte)decMode.Value.Header.BlockDescriptors[0].Density; if(decMode.Value.Pages != null)