summaryrefslogtreecommitdiff
path: root/instance.c
diff options
context:
space:
mode:
authorUwe Hermann <uwe@hermann-uwe.de>2019-04-02 21:35:32 +0200
committerUwe Hermann <uwe@hermann-uwe.de>2019-04-02 21:35:32 +0200
commit369e82655340777c7fbf03847c8ffe73ad05af5a (patch)
tree6a6b53ef237e7b8ec7cf0748b14986c2b3d3e176 /instance.c
parent6cbba91f23b9f9ace75b4722c9c0776b9211008d (diff)
downloadlibsigrokdecode-369e82655340777c7fbf03847c8ffe73ad05af5a.tar.gz
libsigrokdecode-369e82655340777c7fbf03847c8ffe73ad05af5a.zip
srd_inst_stack(): Warn upon potentially incorrect stacking.
Currently there must be at least one match of inputs/outputs for decoders that are stacked. If not, we emit an informational warning (but this is not a hard error for the time being).
Diffstat (limited to 'instance.c')
-rw-r--r--instance.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/instance.c b/instance.c
index 99c5012..23732dd 100644
--- a/instance.c
+++ b/instance.c
@@ -529,6 +529,27 @@ SRD_API int srd_inst_stack(struct srd_session *sess,
sess->di_list = g_slist_remove(sess->di_list, di_top);
}
+ /*
+ * Check if there's at least one matching input/output pair
+ * for the stacked PDs. We warn if that's not the case, but it's
+ * not a hard error for the time being.
+ */
+ gboolean at_least_one_match = FALSE;
+ for (GSList *out = di_bottom->decoder->outputs; out; out = out->next) {
+ const char *o = out->data;
+ for (GSList *in = di_top->decoder->inputs; in; in = in->next) {
+ const char *i = in->data;
+ if (!strcmp(o, i)) {
+ at_least_one_match = TRUE;
+ break;
+ }
+ }
+ }
+
+ if (!at_least_one_match)
+ srd_warn("No matching in-/output when stacking %s onto %s.",
+ di_top->inst_id, di_bottom->inst_id);
+
/* Stack on top of source di. */
di_bottom->next_di = g_slist_append(di_bottom->next_di, di_top);