dasm09: actually handle errors.
authorBrett Gordon <beretta42@gmail.com>
Mon, 8 May 2017 01:32:12 +0000 (21:32 -0400)
committerBrett Gordon <beretta42@gmail.com>
Mon, 8 May 2017 01:32:12 +0000 (21:32 -0400)
Applications/dasm09/dasm09.c

index 7cb36e6..022a39c 100755 (executable)
@@ -40,15 +40,24 @@ uint16_t offset = 0;
 #define ARGBYTE(address) getb(address)
 #define ARGWORD(address) getword(address)
 
+
+static void readerr(void)
+{
+    perror("infile");
+    exit(1);
+}
+
 static uint8_t getb(uint16_t addr)
 {
-    fseek(infile, addr-offset, SEEK_SET);
+    if (fseek(infile, addr-offset, SEEK_SET)<0)
+       readerr();
     return getc(infile);
 }
 
 static uint16_t getword(uint16_t addr)
 {
-    fseek(infile, addr-offset, SEEK_SET);
+    if (fseek(infile, addr-offset, SEEK_SET)<0)
+       readerr();
     return (getc(infile)<<8) | getc(infile);
 }