Properly check write results

This commit is contained in:
Maschell 2022-07-28 12:54:31 +02:00
parent 4a6269a8e5
commit bc74da90dc
2 changed files with 2 additions and 2 deletions

View File

@ -76,7 +76,7 @@ int32_t WUXFileWriter::writeSector(const uint8_t *buffer, uint32_t numberOfSecto
indexTable[this->currentSector] = swap_uint32(this->writtenSector);
hashMap[hashOut] = writtenSector;
if (isOpen()) {
if (!write((uint8_t *) addr, this->sectorSize)) {
if (write((uint8_t *) addr, this->sectorSize) != this->sectorSize) {
DEBUG_FUNCTION_LINE_ERR("Write failed");
return -1;
}

View File

@ -45,7 +45,7 @@ WriteOnlyFileWithCache::~WriteOnlyFileWithCache() {
bool WriteOnlyFileWithCache::flush() {
if (this->writeBufferPos > 0) {
int32_t res = CFile::write(static_cast<const uint8_t *>(this->writeBuffer), this->writeBufferPos);
if (res < 0) {
if (res != this->writeBufferPos) {
DEBUG_FUNCTION_LINE_ERR("Failed to flush cache, write failed: %d (expected %d)", res, this->writeBufferPos);
return false;
}