X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=instance.c;h=594f144edcabe9dc44ec3a60265e3b5a257ecfa3;hp=6b8d6b45a2d3b4d868e8e187131895f5101e98eb;hb=d780f0071d3052931a953bb2dbbe6c7f20e1e638;hpb=37b94c205e4c1c43e77e29993108f23066cbce05 diff --git a/instance.c b/instance.c index 6b8d6b4..594f144 100644 --- a/instance.c +++ b/instance.c @@ -305,6 +305,16 @@ SRD_API int srd_inst_probe_set_all(struct srd_decoder_inst *di, (i < num_required_probes) ? "required" : "optional"); } + /* Report an error if not all required probes were specified. */ + for (i = 0; i < num_required_probes; i++) { + if (new_probemap[i] != -1) + continue; + p = g_slist_nth(di->decoder->probes, i)->data; + srd_err("Required probe '%s' (index %d) was not specified.", + p->id, i); + return SRD_ERR; + } + g_free(di->dec_probemap); di->dec_probemap = new_probemap; @@ -412,15 +422,16 @@ SRD_API struct srd_decoder_inst *srd_inst_new(struct srd_session *sess, * Stack a decoder instance on top of another. * * @param sess The session holding the protocol decoder instances. - * @param di_from The instance to move. - * @param di_to The instance on top of which di_from will be stacked. + * @param di_bottom The instance on top of which di_top will be stacked. + * @param di_top The instance to go on top. * * @return SRD_OK upon success, a (negative) error code otherwise. * * @since 0.3.0 */ SRD_API int srd_inst_stack(struct srd_session *sess, - struct srd_decoder_inst *di_from, struct srd_decoder_inst *di_to) + struct srd_decoder_inst *di_bottom, + struct srd_decoder_inst *di_top) { if (session_is_valid(sess) != SRD_OK) { @@ -428,18 +439,20 @@ SRD_API int srd_inst_stack(struct srd_session *sess, return SRD_ERR_ARG; } - if (!di_from || !di_to) { + if (!di_bottom || !di_top) { srd_err("Invalid from/to instance pair."); return SRD_ERR_ARG; } - if (g_slist_find(sess->di_list, di_to)) { + if (g_slist_find(sess->di_list, di_top)) { /* Remove from the unstacked list. */ - sess->di_list = g_slist_remove(sess->di_list, di_to); + sess->di_list = g_slist_remove(sess->di_list, di_top); } /* Stack on top of source di. */ - di_from->next_di = g_slist_append(di_from->next_di, di_to); + di_bottom->next_di = g_slist_append(di_bottom->next_di, di_top); + + srd_dbg("Stacked %s on top of %s.", di_top->inst_id, di_bottom->inst_id); return SRD_OK; }