Spring cleaning

This commit is contained in:
Willy-JL
2025-04-04 13:18:36 +01:00
parent 32ad9ea25b
commit 81581c79b5
17 changed files with 39 additions and 138 deletions

View File

@@ -88,17 +88,12 @@ bool saved_struct_load(const char* path, void* data, size_t size, uint8_t magic,
}
if(result) {
size_t bytes_expected = sizeof(SavedStructHeader) + size;
uint64_t bytes_file = storage_file_size(file);
result = bytes_file == bytes_expected;
if(result) {
size_t bytes_count = storage_file_read(file, &header, sizeof(SavedStructHeader));
bytes_count += storage_file_read(file, data_read, size);
result = bytes_count == bytes_expected;
}
size_t bytes_count = storage_file_read(file, &header, sizeof(SavedStructHeader));
bytes_count += storage_file_read(file, data_read, size);
if(!result) {
if(bytes_count != (sizeof(SavedStructHeader) + size)) {
FURI_LOG_E(TAG, "Size mismatch of file \"%s\"", path);
result = false;
}
}