diff options
Diffstat (limited to 'tools/h5repack')
-rw-r--r-- | tools/h5repack/h5repack_main.c | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/tools/h5repack/h5repack_main.c b/tools/h5repack/h5repack_main.c index 7745860..e903435 100644 --- a/tools/h5repack/h5repack_main.c +++ b/tools/h5repack/h5repack_main.c @@ -264,14 +264,24 @@ int read_info(const char *filename, pack_opt_t *options) { i = 0; c = '0'; while (c != ' ') { - fscanf(fp, "%c", &c); + if(fscanf(fp, "%c", &c) < 0 && HDferror(fp)) { + error_msg("fscanf error\n"); + h5tools_setstatus(EXIT_FAILURE); + ret_value = EXIT_FAILURE; + goto done; + } /* end if */ if (HDfeof(fp)) break; } c = '0'; /* go until end */ while (c != ' ') { - fscanf(fp, "%c", &c); + if(fscanf(fp, "%c", &c) < 0 && HDferror(fp)) { + error_msg("fscanf error\n"); + h5tools_setstatus(EXIT_FAILURE); + ret_value = EXIT_FAILURE; + goto done; + } /* end if */ comp_info[i] = c; i++; if (HDfeof(fp)) @@ -282,10 +292,10 @@ int read_info(const char *filename, pack_opt_t *options) { comp_info[i - 1] = '\0'; /*cut the last " */ if (h5repack_addfilter(comp_info, options) == -1) { - error_msg("could not add compression option\n"); - h5tools_setstatus(EXIT_FAILURE); - ret_value = EXIT_FAILURE; - goto done; + error_msg("could not add compression option\n"); + h5tools_setstatus(EXIT_FAILURE); + ret_value = EXIT_FAILURE; + goto done; } } /*------------------------------------------------------------------------- @@ -298,14 +308,24 @@ int read_info(const char *filename, pack_opt_t *options) { i = 0; c = '0'; while (c != ' ') { - fscanf(fp, "%c", &c); + if(fscanf(fp, "%c", &c) < 0 && HDferror(fp)) { + error_msg("fscanf error\n"); + h5tools_setstatus(EXIT_FAILURE); + ret_value = EXIT_FAILURE; + goto done; + } /* end if */ if (HDfeof(fp)) break; } c = '0'; /* go until end */ while (c != ' ') { - fscanf(fp, "%c", &c); + if(fscanf(fp, "%c", &c) < 0 && HDferror(fp)) { + error_msg("fscanf error\n"); + h5tools_setstatus(EXIT_FAILURE); + ret_value = EXIT_FAILURE; + goto done; + } /* end if */ comp_info[i] = c; i++; if (HDfeof(fp)) @@ -316,10 +336,10 @@ int read_info(const char *filename, pack_opt_t *options) { comp_info[i - 1] = '\0'; /*cut the last " */ if (h5repack_addlayout(comp_info, options) == -1) { - error_msg("could not add chunck option\n"); - h5tools_setstatus(EXIT_FAILURE); - ret_value = EXIT_FAILURE; - goto done; + error_msg("could not add chunck option\n"); + h5tools_setstatus(EXIT_FAILURE); + ret_value = EXIT_FAILURE; + goto done; } } /*------------------------------------------------------------------------- |