Fix static-analysis issues in cdrom_image
One issue in BinaryFile's constructor: There is no sense in testing the 'file' pointer against null, as the memory was allocated using the 'new' operator. The exception will be generated in the case of memory allocation error. 'new' - https://www.viva64.com/en/w/v668/ Two issues relating to assigning a value that's already assigned - https://www.viva64.com/en/w/v1048/
This commit is contained in:
parent
5777fb97fe
commit
02506d293e
1 changed files with 4 additions and 3 deletions
|
@ -57,7 +57,8 @@ CDROM_Interface_Image::BinaryFile::BinaryFile(const char *filename, bool &error)
|
|||
file(nullptr)
|
||||
{
|
||||
file = new ifstream(filename, ios::in | ios::binary);
|
||||
error = (file == nullptr) || (file->fail());
|
||||
// If new fails, an exception is generated and scope leaves this constructor
|
||||
error = file->fail();
|
||||
}
|
||||
|
||||
CDROM_Interface_Image::BinaryFile::~BinaryFile()
|
||||
|
@ -803,10 +804,10 @@ bool CDROM_Interface_Image::LoadIsoFile(char* filename)
|
|||
// try to detect iso type
|
||||
if (CanReadPVD(track.file.get(), BYTES_PER_COOKED_REDBOOK_FRAME, false)) {
|
||||
track.sectorSize = BYTES_PER_COOKED_REDBOOK_FRAME;
|
||||
track.mode2 = false;
|
||||
// track.mode2 = false (comment only, because this is the default value)
|
||||
} else if (CanReadPVD(track.file.get(), BYTES_PER_RAW_REDBOOK_FRAME, false)) {
|
||||
track.sectorSize = BYTES_PER_RAW_REDBOOK_FRAME;
|
||||
track.mode2 = false;
|
||||
// track.mode2 = false (comment only, because this is the default value)
|
||||
} else if (CanReadPVD(track.file.get(), 2336, true)) {
|
||||
track.sectorSize = 2336;
|
||||
track.mode2 = true;
|
||||
|
|
Loading…
Add table
Reference in a new issue