--- a/src/inhx32.c Wed Jun 19 14:03:42 2019 +0100
+++ b/src/inhx32.c Wed Jun 19 18:04:29 2019 +0100
@@ -157,18 +157,25 @@
return -8; /* Invalid record type for this architecture */
}
-static void
+static int
inhx32_perror(int err, int val)
{
static char warning[] = "warning", error[] = "error";
char *msg;
+ int rc;
- if (!p.f || err >= 0)
- return; /* No message output */
+ if (err >= 0)
+ return 0; /* No warning or error */
+
+ if (p.error & BADINPUT) {
+ msg = error;
+ rc = -1; /* Error */
+ } else {
+ msg = warning;
+ rc = 0; /* Warning */
+ }
- msg = (p.error & BADINPUT) ? error : warning;
-
- switch (err) {
+ if (p.f) switch (err) {
case -1:fprintf(p.f, "%s: %s: invalid line prefix\n", __func__, msg);
break;
case -2:fprintf(p.f, "%s: %s: invalid line length\n", __func__, msg);
@@ -186,6 +193,8 @@
case -8:fprintf(p.f, "%s: %s: invalid record type [0x%02X]\n", __func__, msg, val);
break;
}
+
+ return rc;
}
/*
@@ -208,8 +217,8 @@
rc = inhx32_fgets(line, fp, &bb, &aaaa, &tt, &extended_addr);
if (rc == 0 || tt == TT_EOF)
return NULL; /* EOF */
- if (rc < 0)
- inhx32_perror(rc, tt);
+ if (inhx32_perror(rc, tt) < 0)
+ /* exit pending */;
}
while (tt != TT_DATA); /* Skip non data records */