From: Brett Gordon Date: Mon, 8 May 2017 01:32:12 +0000 (-0400) Subject: dasm09: actually handle errors. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=fb8658b1d19ac73004fac8a74544416d41468d7f;p=FUZIX.git dasm09: actually handle errors. --- diff --git a/Applications/dasm09/dasm09.c b/Applications/dasm09/dasm09.c index 7cb36e6f..022a39ca 100755 --- a/Applications/dasm09/dasm09.c +++ b/Applications/dasm09/dasm09.c @@ -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); }