summaryrefslogtreecommitdiffstats
path: root/hl/test/test_image.c
diff options
context:
space:
mode:
Diffstat (limited to 'hl/test/test_image.c')
-rw-r--r--hl/test/test_image.c55
1 files changed, 45 insertions, 10 deletions
diff --git a/hl/test/test_image.c b/hl/test/test_image.c
index 8ba0083..8bc6f95 100644
--- a/hl/test/test_image.c
+++ b/hl/test/test_image.c
@@ -603,8 +603,14 @@ static int test_generate(void)
*/
- fscanf( f, "%d %d %d", &imax, &jmax, &kmax );
- fscanf( f, "%f %f %f", &valex, &xmin, &xmax );
+ if(fscanf( f, "%d %d %d", &imax, &jmax, &kmax ) < 0 && HDferror(f)) {
+ printf( "fscanf error in file %s.\n", data_file );
+ goto out;
+ } /* end if */
+ if(fscanf( f, "%f %f %f", &valex, &xmin, &xmax ) < 0 && HDferror(f)) {
+ printf( "fscanf error in file %s.\n", data_file );
+ goto out;
+ } /* end if */
/* Sanity check on scanned-in values */
if(imax < 1 || jmax < 1 || kmax < 1)
@@ -633,7 +639,10 @@ static int test_generate(void)
for ( i = 0; i < n_elements; i++ )
{
- fscanf( f, "%f ", &value );
+ if(fscanf( f, "%f ", &value ) < 0 && HDferror(f)) {
+ printf( "fscanf error in file %s.\n", data_file );
+ goto out;
+ } /* end if */
data[i] = value;
}
HDfclose(f);
@@ -794,12 +803,35 @@ static int read_data(const char* fname, /*IN*/
goto out;
}
- fscanf(f, "%s", str);
- fscanf(f, "%d", &color_planes);
- fscanf(f, "%s", str);
- fscanf(f, "%d", &h);
- fscanf(f, "%s", str);
- fscanf(f, "%d", &w);
+ if(fscanf(f, "%s", str) < 0 && HDferror(f)) {
+ printf( "fscanf error in file %s.\n", data_file );
+ goto out;
+ } /* end if */
+
+ if(fscanf(f, "%d", &color_planes) < 0 && HDferror(f)) {
+ printf( "fscanf error in file %s.\n", data_file );
+ goto out;
+ } /* end if */
+
+ if(fscanf(f, "%s", str) < 0 && HDferror(f)) {
+ printf( "fscanf error in file %s.\n", data_file );
+ goto out;
+ } /* end if */
+
+ if(fscanf(f, "%d", &h) < 0 && HDferror(f)) {
+ printf( "fscanf error in file %s.\n", data_file );
+ goto out;
+ } /* end if */
+
+ if(fscanf(f, "%s", str) < 0 && HDferror(f)) {
+ printf( "fscanf error in file %s.\n", data_file );
+ goto out;
+ } /* end if */
+
+ if(fscanf(f, "%d", &w) < 0 && HDferror(f)) {
+ printf( "fscanf error in file %s.\n", data_file );
+ goto out;
+ } /* end if */
/* Check product for overflow */
if(w < 1 || h < 1 || color_planes < 1)
@@ -830,7 +862,10 @@ static int read_data(const char* fname, /*IN*/
/* Read data elements */
for(i = 0; i < n_elements; i++) {
- fscanf(f, "%d",&n);
+ if(fscanf(f, "%d", &n) < 0 && HDferror(f)) {
+ printf( "fscanf error in file %s.\n", data_file );
+ goto out;
+ } /* end if */
image_data[i] = (unsigned char)n;
} /* end for */