diff --git a/Storage/Cartridge/Formats/BinaryDump.cpp b/Storage/Cartridge/Formats/BinaryDump.cpp index f286a5850..fb4e76d8f 100644 --- a/Storage/Cartridge/Formats/BinaryDump.cpp +++ b/Storage/Cartridge/Formats/BinaryDump.cpp @@ -19,12 +19,12 @@ BinaryDump::BinaryDump(const char *file_name) { stat(file_name, &file_stats); // grab contents - FILE *file = fopen(file_name, "rb"); + FILE *file = std::fopen(file_name, "rb"); if(!file) throw ErrorNotAccessible; std::size_t data_length = static_cast(file_stats.st_size); std::vector contents(data_length); - fread(&contents[0], 1, static_cast(data_length), file); - fclose(file); + contents.resize(std::fread(&contents[0], 1, static_cast(data_length), file)); + std::fclose(file); // enshrine segments_.emplace_back( diff --git a/Storage/Cartridge/Formats/PRG.cpp b/Storage/Cartridge/Formats/PRG.cpp index a971b1314..165437c9f 100644 --- a/Storage/Cartridge/Formats/PRG.cpp +++ b/Storage/Cartridge/Formats/PRG.cpp @@ -10,6 +10,7 @@ #include #include + #include "../Encodings/CommodoreROM.hpp" using namespace Storage::Cartridge; @@ -23,7 +24,7 @@ PRG::PRG(const char *file_name) { throw ErrorNotROM; // get the loading address, and the rest of the contents - FILE *file = fopen(file_name, "rb"); + FILE *file = std::fopen(file_name, "rb"); int loading_address = fgetc(file); loading_address |= fgetc(file) << 8; @@ -32,11 +33,11 @@ PRG::PRG(const char *file_name) { std::size_t padded_data_length = 1; while(padded_data_length < data_length) padded_data_length <<= 1; std::vector contents(padded_data_length); - fread(&contents[0], 1, static_cast(data_length), file); - fclose(file); + std::size_t length = std::fread(contents.data(), 1, static_cast(data_length), file); + std::fclose(file); // accept only files intended to load at 0xa000 - if(loading_address != 0xa000) + if(loading_address != 0xa000 || length != static_cast(data_length)) throw ErrorNotROM; // also accept only cartridges with the proper signature diff --git a/Storage/Data/ZX8081.cpp b/Storage/Data/ZX8081.cpp index b4092df58..ea541ead4 100644 --- a/Storage/Data/ZX8081.cpp +++ b/Storage/Data/ZX8081.cpp @@ -27,7 +27,7 @@ static std::shared_ptr ZX80FileFromData(const std::vector &data) uint16_t display_address = short_at(0xc, data); // check that the end of file is contained within the supplied data - if(end_of_file - 0x4000 > data.size()) return nullptr; + if(static_cast(end_of_file - 0x4000) > data.size()) return nullptr; // check for the proper ordering of buffers if(vars > end_of_file) return nullptr; diff --git a/Storage/Disk/DiskImage/Formats/CPCDSK.cpp b/Storage/Disk/DiskImage/Formats/CPCDSK.cpp index cb732f363..5d972926a 100644 --- a/Storage/Disk/DiskImage/Formats/CPCDSK.cpp +++ b/Storage/Disk/DiskImage/Formats/CPCDSK.cpp @@ -365,7 +365,7 @@ void CPCDSK::set_tracks(const std::map<::Storage::Disk::Track::Address, std::sha } // Move to next 256-byte boundary. - long distance = (256 - output.tell()&255)&255; + long distance = (256 - (output.tell()&255))&255; output.putn(static_cast(distance), 0); // Output sector contents. @@ -376,7 +376,7 @@ void CPCDSK::set_tracks(const std::map<::Storage::Disk::Track::Address, std::sha } // Move to next 256-byte boundary. - distance = (256 - output.tell()&255)&255; + distance = (256 - (output.tell()&255))&255; output.putn(static_cast(distance), 0); } } diff --git a/Storage/Tape/Formats/CSW.cpp b/Storage/Tape/Formats/CSW.cpp index 363b00708..ac70cb8b4 100644 --- a/Storage/Tape/Formats/CSW.cpp +++ b/Storage/Tape/Formats/CSW.cpp @@ -8,6 +8,8 @@ #include "CSW.hpp" +#include + using namespace Storage::Tape; CSW::CSW(const char *file_name) : @@ -90,6 +92,8 @@ uint8_t CSW::get_next_byte() { source_data_pointer_++; return result; } + + default: assert(false); break; } } @@ -107,7 +111,7 @@ uint32_t CSW::get_next_int32le() { return result; } - default: return 0; + default: assert(false); break; } } @@ -120,7 +124,7 @@ bool CSW::is_at_end() { case CompressionType::RLE: return file_.eof(); case CompressionType::ZRLE: return source_data_pointer_ == source_data_.size(); - default: return true; + default: assert(false); break; } } @@ -129,7 +133,7 @@ void CSW::virtual_reset() { case CompressionType::RLE: file_.seek(rle_start_, SEEK_SET); break; case CompressionType::ZRLE: source_data_pointer_ = 0; break; - default: break; + default: assert(false); break; } }