int main(int argc, char *argv[])
{
uint8_t *buf;
- unsigned long size;
+ unsigned long size, numbytes;
uint32_t erasedbytes;
FILE *image;
/* Probe for up to three flash chips. */
exclude_end_position -
exclude_start_position);
- fwrite(buf, sizeof(char), size, image);
+ numbytes = fwrite(buf, 1, size, image);
fclose(image);
- printf("done.\n");
+ printf("%s.\n", numbytes == size ? "done" : "FAILED");
free(buf);
- exit(0);
+ return numbytes != size;
}
// FIXME: flash writes stay enabled!
exit(1);
memset(buf + exclude_start_position, 0,
exclude_end_position - exclude_start_position);
- fwrite(buf, sizeof(char), size, image);
+ numbytes = fwrite(buf, 1, size, image);
fclose(image);
- printf("done.\n");
+ printf("%s.\n", numbytes == size ? "done" : "FAILED");
+ if (numbytes != size)
+ return 1;
} else {
struct stat image_stat;
exit(1);
}
- fread(buf, sizeof(char), size, image);
+ numbytes = fread(buf, 1, size, image);
show_id(buf, size, force);
fclose(image);
+ if (numbytes != size) {
+ fprintf(stderr, "Error: Failed to read file. Got %ld bytes, wanted %ld!\n", numbytes, size);
+ return 1;
+ }
}
/* exclude range stuff. Nice idea, but at the moment it is only
while (!feof(romlayout)) {
char *tstr1, *tstr2;
- fscanf(romlayout, "%s %s\n", tempstr,
- rom_entries[romimages].name);
+ if (2 != fscanf(romlayout, "%s %s\n", tempstr, rom_entries[romimages].name))
+ continue;
#if 0
// fscanf does not like arbitrary comments like that :( later
if (tempstr[0] == '#') {