From 90f8ae418840f9897e397f6b6a6ff0c8c0fef7ab Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Mon, 17 Jun 2024 13:46:09 +0200 Subject: [PATCH] Allow marks without labels defined The labels are optional, so they shouldn't be required when processing the mark types. --- src/emu/ovni/mark.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/emu/ovni/mark.c b/src/emu/ovni/mark.c index 3ed5391..792011f 100644 --- a/src/emu/ovni/mark.c +++ b/src/emu/ovni/mark.c @@ -215,12 +215,6 @@ parse_mark(struct ovni_mark_emu *m, const char *typestr, JSON_Value *markval) return -1; } - JSON_Object *labels = json_object_get_object(mark, "labels"); - if (labels == NULL) { - err("json_object_get_object() for labels failed"); - return -1; - } - struct mark_type *t = find_mark_type(m, type); if (t == NULL) { t = create_mark_type(m, type, chan_type, title); @@ -239,11 +233,21 @@ parse_mark(struct ovni_mark_emu *m, const char *typestr, JSON_Value *markval) } } - /* Now populate the mark type with all value labels */ + /* The labels are optional */ + if (json_object_has_value(mark, "labels")) { - if (parse_labels(t, labels) != 0) { - err("cannot parse labels"); - return -1; + JSON_Object *labels = json_object_get_object(mark, "labels"); + if (labels == NULL) { + err("json_object_get_object() for labels failed"); + return -1; + } + + /* Now populate the mark type with all value labels */ + + if (parse_labels(t, labels) != 0) { + err("cannot parse labels"); + return -1; + } } return 0;