REFACTOR: Possible 'System.InvalidOperationException'.

This commit is contained in:
2017-12-21 17:10:37 +00:00
parent e06c140e45
commit 13a6473236
5 changed files with 1964 additions and 1956 deletions

View File

@@ -83,7 +83,9 @@ namespace DiscImageChef.Core.Devices.Dumping
sense = dev.AtaIdentify(out byte[] cmdBuf, out AtaErrorRegistersCHS errorChs);
if(!sense && Identify.Decode(cmdBuf).HasValue)
{
Identify.IdentifyDevice ataId = Identify.Decode(cmdBuf).Value;
Identify.IdentifyDevice? ataIdNullable = Identify.Decode(cmdBuf);
if(ataIdNullable != null) {
Identify.IdentifyDevice ataId = ataIdNullable.Value;
CICMMetadataType sidecar =
new CICMMetadataType {BlockMedia = new[] {new BlockMediaType()}};
@@ -609,6 +611,7 @@ namespace DiscImageChef.Core.Devices.Dumping
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
}
}
Statistics.AddMedia(CommonTypes.MediaType.GENERIC_HDD, true);
}

View File

@@ -67,7 +67,8 @@ namespace DiscImageChef.Core.Devices
switch(dev.Type)
{
case DeviceType.ATA:
if(Identify.Decode(identification).HasValue) ataId = Identify.Decode(identification).Value;
Identify.IdentifyDevice? ataIdNullable = Identify.Decode(identification);
if(ataIdNullable.HasValue) ataId = ataIdNullable.Value;
break;
case DeviceType.NVMe: throw new NotImplementedException("NVMe devices not yet supported.");
}

View File

@@ -63,7 +63,9 @@ namespace DiscImageChef.Core.Devices.Report
if(!Identify.Decode(buffer).HasValue) return;
Identify.IdentifyDevice ataId = Identify.Decode(buffer).Value;
Identify.IdentifyDevice? ataIdNullable = Identify.Decode(buffer);
if(ataIdNullable != null) {
Identify.IdentifyDevice ataId = ataIdNullable.Value;
if((ushort)ataId.GeneralConfiguration == 0x848A)
{
@@ -1228,4 +1230,5 @@ namespace DiscImageChef.Core.Devices.Report
}
}
}
}
}

View File

@@ -54,7 +54,9 @@ namespace DiscImageChef.Core.Devices.Report
if(!Identify.Decode(buffer).HasValue) return;
Identify.IdentifyDevice atapiId = Identify.Decode(buffer).Value;
Identify.IdentifyDevice? atapiIdNullable = Identify.Decode(buffer);
if(atapiIdNullable != null) {
Identify.IdentifyDevice atapiId = atapiIdNullable.Value;
report.ATAPI = new ataType();
@@ -453,6 +455,7 @@ namespace DiscImageChef.Core.Devices.Report
report.ATAPI.WRVSectorCountMode2 = atapiId.WRVSectorCountMode2;
report.ATAPI.WRVSectorCountMode2Specified = true;
}
}
if(debug) report.ATAPI.Identify = buffer;
}
}

View File

@@ -58,8 +58,6 @@ namespace DiscImageChef.Core.Devices.Scanning
sense = dev.AtaIdentify(out cmdBuf, out errorChs);
if(!sense && Identify.Decode(cmdBuf).HasValue)
{
Identify.IdentifyDevice ataId = Identify.Decode(cmdBuf).Value;
// Initializate reader
Reader ataReader = new Reader(dev, timeout, cmdBuf);
// Fill reader blocks