From 746e8d12f66e85bacb2fa920aae9a014256cc28d Mon Sep 17 00:00:00 2001 From: Tonton Th Date: Sat, 21 Dec 2019 14:42:55 +0100 Subject: [PATCH] minor tweaks --- lib/fimg-file.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/fimg-file.c b/lib/fimg-file.c index d0c894eb..3646a41f 100644 --- a/lib/fimg-file.c +++ b/lib/fimg-file.c @@ -102,6 +102,9 @@ fclose(fp); return 0; } /* ---------------------------------------------------------------- */ +/* + * load a dump in a pre-allocated FloatImg + */ int fimg_load_from_dump(char *fname, FloatImg *where) { FILE *fp; @@ -113,13 +116,14 @@ fprintf(stderr, ">>> %-25s ( '%s' %p )\n", __func__, fname, head); #endif if (NULL==(fp = fopen(fname, "r"))) { - perror(fname); exit(1); + perror(fname); + return -15; } foo = fread(&filehead, sizeof(FimgFileHead), 1, fp); if (1 != foo) { fprintf(stderr, "%s: short read on '%s'\n", __func__, fname); fclose(fp); - return -1; + return -16; } /* check compatibility */ @@ -135,7 +139,7 @@ if ( (filehead.w != where->width) || nbre = filehead.w*filehead.h*filehead.t; /* ugly quirk */ foo = fread(where->R, sizeof(float), nbre, fp); if (nbre != foo) { - fprintf(stderr, "%s: err read '%s' : %d\n", __func__, fname, errno); + fprintf(stderr, "%s: err read '%s' : %d\n", __func__, fname, foo); fclose(fp); return -18; }