Encapsulate fseek+ftell idiom in seekSize

This allows a single check for the return value of `seekSize`
to verify all three `fseek`+`ftell`+`fseek` calls.
This commit is contained in:
Rangi
2026-07-14 01:32:18 -04:00
parent e7855ea1b8
commit 7e2a3491a5
5 changed files with 34 additions and 23 deletions
+3 -6
View File
@@ -112,16 +112,13 @@ static uint32_t checkOverlaySize() {
return 0;
}
if (fseek(overlayFile, 0, SEEK_END) != 0) {
long overlaySize = seekSize(overlayFile);
if (overlaySize == -1) {
warnx("Overlay file is not seekable, cannot check if properly formed");
return 0;
}
long overlaySize = ftell(overlayFile);
// Reset back to beginning
fseek(overlayFile, 0, SEEK_SET);
if (overlaySize % BANK_SIZE) {
warnx("Overlay file does not have a size multiple of 0x4000");
} else if (options.is32kMode && overlaySize != 0x8000) {