return romarea;
}
-void writerom(const char *filename, void *start, uint32_t size)
+int writerom(const char *filename, void *start, uint32_t size)
{
FILE *file = fopen(filename, "wb");
- fwrite(start, size, 1, file);
+ if (!file) {
+ fprintf(stderr, "Could not open '%s' for writing: ", filename);
+ perror("");
+ return 1;
+ }
+
+ if (fwrite(start, size, 1, file) != 1) {
+ fprintf(stderr, "Could not write to '%s': ", filename);
+ perror("");
+ return 1;
+ }
+
fclose(file);
+ return 0;
}
int cbfs_file_header(uint32_t physaddr)
(struct cbfs_file *)phys_to_virt(current);
uint32_t length = ntohl(thisfile->len);
char *fname = (char *)(phys_to_virt(current) + sizeof(struct cbfs_file));
- if (strlen(fname) == 0)
+ if (strlen(fname) == 0)
fname = "(empty)";
- printf("%-30s 0x%-8x %-12s %d\n", fname,
+ printf("%-30s 0x%-8x %-12s %d\n", fname,
current - phys_start, strfiletype(ntohl(thisfile->type)),
length);
current =