From 3712ef9efea18016fbc42d71126d3616ad01ee56 Mon Sep 17 00:00:00 2001 From: tth Date: Sat, 21 Dec 2019 12:35:52 +0100 Subject: [PATCH] no exit on errors --- lib/fimg-file.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/fimg-file.c b/lib/fimg-file.c index 7523ca29..d0c894eb 100644 --- a/lib/fimg-file.c +++ b/lib/fimg-file.c @@ -117,7 +117,7 @@ if (NULL==(fp = fopen(fname, "r"))) { } foo = fread(&filehead, sizeof(FimgFileHead), 1, fp); if (1 != foo) { - fprintf(stderr, "%s : short read\n", fname); + fprintf(stderr, "%s: short read on '%s'\n", __func__, fname); fclose(fp); return -1; } @@ -127,15 +127,17 @@ if ( (filehead.w != where->width) || (filehead.h != where->height) || (filehead.t != where->type) ) { - fprintf(stderr, "file '%s' incompatible\n", fname); - exit(3); + fprintf(stderr, "%s: file '%s' incompatible\n", __func__, fname); + fclose(fp); + return -17; } nbre = filehead.w*filehead.h*filehead.t; /* ugly quirk */ foo = fread(where->R, sizeof(float), nbre, fp); if (nbre != foo) { - fprintf(stderr, "err read '%s' : %d\n", fname, errno); - exit(3); + fprintf(stderr, "%s: err read '%s' : %d\n", __func__, fname, errno); + fclose(fp); + return -18; } fclose(fp);