i855: Remove useless memctrl indirection.
[coreboot.git] / util / cbfstool / common.c
index 30d52816b100f811ce22069376419acff1c2b1a1..8478c5a492cc69005dc6acdc593db6fc9f4609ef 100644 (file)
@@ -90,11 +90,23 @@ void *loadrom(const char *filename)
        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)
@@ -183,10 +195,10 @@ void print_cbfs_directory(const char *filename)
                    (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 =