aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/datatemplate.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-07-09 11:43:56 +0200
committerThomas White <taw@physics.org>2020-07-29 18:53:45 +0200
commit60d17122506a3f8b4c2b65993e724e224172ee76 (patch)
treec75c86f0363e5f2221162019b6eacd341e0fbdfc /libcrystfel/src/datatemplate.c
parent4a8e2441796b72c2e2df1402071918dfdb22119d (diff)
Add an error path for parse_toplevel
Diffstat (limited to 'libcrystfel/src/datatemplate.c')
-rw-r--r--libcrystfel/src/datatemplate.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/libcrystfel/src/datatemplate.c b/libcrystfel/src/datatemplate.c
index 73227f38..e9d98639 100644
--- a/libcrystfel/src/datatemplate.c
+++ b/libcrystfel/src/datatemplate.c
@@ -628,12 +628,14 @@ static int parse_field_bad(struct dt_badregion *badr, const char *key,
}
-static void parse_toplevel(DataTemplate *dt,
- const char *key, const char *val,
- struct rg_definition ***rg_defl,
- struct rgc_definition ***rgc_defl,
- int *n_rg_defs, int *n_rgc_defs,
- struct panel_template *defaults)
+static int parse_toplevel(DataTemplate *dt,
+ const char *key,
+ const char *val,
+ struct rg_definition ***rg_defl,
+ struct rgc_definition ***rgc_defl,
+ int *n_rg_defs,
+ int *n_rgc_defs,
+ struct panel_template *defaults)
{
if ( strcmp(key, "mask_bad") == 0 ) {
@@ -643,6 +645,8 @@ static void parse_toplevel(DataTemplate *dt,
if ( end != val ) {
dt->mask_bad = v;
+ } else {
+ return 1;
}
} else if ( strcmp(key, "mask_good") == 0 ) {
@@ -652,6 +656,8 @@ static void parse_toplevel(DataTemplate *dt,
if ( end != val ) {
dt->mask_good = v;
+ } else {
+ return 1;
}
} else if ( strcmp(key, "coffset") == 0 ) {
@@ -703,8 +709,10 @@ static void parse_toplevel(DataTemplate *dt,
*n_rgc_defs = *n_rgc_defs+1;
} else if ( parse_field_for_panel(defaults, key, val, dt) ) {
- ERROR("Unrecognised top level field '%s'\n", key);
+ return 1;
}
+
+ return 0;
}
@@ -867,12 +875,17 @@ DataTemplate *data_template_new_from_string(const char *string_in)
if ( slash == NULL ) {
/* Top-level option */
- parse_toplevel(dt, line, val,
- &rg_defl,
- &rgc_defl,
- &n_rg_definitions,
- &n_rgc_definitions,
- &defaults);
+ if ( parse_toplevel(dt, line, val,
+ &rg_defl,
+ &rgc_defl,
+ &n_rg_definitions,
+ &n_rgc_definitions,
+ &defaults) )
+ {
+ ERROR("Invalid top-level line '%s'\n",
+ line);
+ reject = 1;
+ }
free(line);
continue;
}