Description: Handling of some errors

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: vendor
Forwarded: no
Last-Update: 2019-07-25

--- genromfs-0.5.2.orig/Makefile
+++ genromfs-0.5.2/Makefile
@@ -6,8 +6,9 @@ all: genromfs
 PACKAGE = genromfs
 VERSION = 0.5.2
 CC = gcc
-CFLAGS = -O2 -Wall -DVERSION=\"$(VERSION)\"#-g#
-LDFLAGS = -s#-g
+CPPFLAGS = -DVERSION=\"$(VERSION)\"
+CFLAGS = -O2 -Wall -g
+#LDFLAGS = -s#-g
 
 DISTDIR = $(PACKAGE)-$(VERSION)
 
@@ -24,7 +25,7 @@ genromfs: genromfs.o
 	$(CC) $(LDFLAGS) genromfs.o -o genromfs
 
 .c.o:
-	$(CC) $(CFLAGS) $< -c -o $@
+	$(CC) $(CPPFLAGS) $(CFLAGS) $< -c -o $@
 
 clean:
 	rm -f genromfs *.o
--- genromfs-0.5.2.orig/genromfs.c
+++ genromfs-0.5.2/genromfs.c
@@ -75,6 +75,7 @@
 #include <sys/sysmacros.h>
 #endif
 
+char *outf = NULL;
 
 struct romfh {
 	int32_t nextfh;
@@ -254,10 +255,16 @@ void dumpdata(void *addr, int len, FILE
 	if (atoffs==512) {
 		ri = (struct romfh *)&fixbuf;
 		fixsum(ri, atoffs<ntohl(ri->size)?atoffs:ntohl(ri->size));
-		fwrite(fixbuf, atoffs, 1, f);
+		if (fwrite(fixbuf, atoffs, 1, f) != 1) {
+			perror(outf);
+			exit(1);
+		}
 	}
 	if (len) {
-		fwrite(addr, len, 1, f);
+		if (fwrite(addr, len, 1, f) != 1) {
+			perror(outf);
+			exit(1);
+		}
 		atoffs+=len;
 	}
 }
@@ -702,7 +709,6 @@ int main(int argc, char *argv[])
 {
 	int c;
 	char *dir = ".";
-	char *outf = NULL;
 	char *volname = NULL;
 	int verbose=0;
 	char buf[256];
