aboutsummaryrefslogtreecommitdiff
path: root/src/process_hkl.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2011-03-28 18:47:13 +0200
committerThomas White <taw@physics.org>2012-02-22 15:27:22 +0100
commit176b63b62ec8e9ee1cc782d25399f3abf25c85f2 (patch)
tree5f7616652715a3f33dd926934d432d5b8c219d96 /src/process_hkl.c
parent2a6ce4a23bd88ca2603b47559ac831dbead6c6ad (diff)
Fix up stream error handling
Diffstat (limited to 'src/process_hkl.c')
-rw-r--r--src/process_hkl.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/process_hkl.c b/src/process_hkl.c
index 9b7c0dcd..4dc49128 100644
--- a/src/process_hkl.c
+++ b/src/process_hkl.c
@@ -307,7 +307,7 @@ static void merge_all(FILE *fh, RefList *model,
/* Get data from next chunk */
rval = read_chunk(fh, &image);
- if ( rval ) continue;
+ if ( rval ) break;
n_patterns++;
@@ -509,6 +509,10 @@ int main(int argc, char *argv[])
/* Count the number of patterns in the file */
n_total_patterns = count_patterns(fh);
+ if ( n_total_patterns == 0 ) {
+ ERROR("No patterns to process.\n");
+ return 1;
+ }
STATUS("There are %i patterns to process\n", n_total_patterns);
rewind(fh);
@@ -536,6 +540,10 @@ int main(int argc, char *argv[])
config_startafter, config_stopafter,
sym, n_total_patterns,
hist_vals, hist_h, hist_k, hist_l, &hist_i, 1);
+ if ( ferror(fh) ) {
+ ERROR("Stream read error.\n");
+ return 1;
+ }
rewind(fh);
if ( space_for_hist && (hist_i >= space_for_hist) ) {
ERROR("Histogram array was too small!\n");
@@ -552,6 +560,10 @@ int main(int argc, char *argv[])
merge_all(fh, model, config_maxonly, config_scale, 0,
config_startafter, config_stopafter, sym, n_total_patterns,
NULL, 0, 0, 0, NULL, 2);
+ if ( ferror(fh) ) {
+ ERROR("Stream read error.\n");
+ return 1;
+ }
write_reflist(output, model, cell);