From 0e2ba0cc745e763279510d943593abce52a36040 Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Sun, 30 Jun 2019 20:04:00 +0200 Subject: [PATCH] decoder_selector: Fix an issue with PD auto-stacking. Before the fix, PDs with common prefix would incorrectly be found as a match. Example: Both "spi" and "spiflash" would be considered valid candidates when looking for PDs which emit "spi" OUTPUT_PYTHON output. --- pv/subwindows/decoder_selector/subwindow.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pv/subwindows/decoder_selector/subwindow.cpp b/pv/subwindows/decoder_selector/subwindow.cpp index 5665a322..96da710f 100644 --- a/pv/subwindows/decoder_selector/subwindow.cpp +++ b/pv/subwindows/decoder_selector/subwindow.cpp @@ -193,8 +193,10 @@ vector SubWindow::get_decoders_providing(const char* output) if (!d->outputs) continue; + const int maxlen = 1024; + // TODO For now we ignore that d->outputs is actually a list - if (strncmp((char*)(d->outputs->data), output, strlen(output)) == 0) + if (strncmp((char*)(d->outputs->data), output, maxlen) == 0) ret_val.push_back(d); } @@ -255,13 +257,13 @@ void SubWindow::on_item_activated(const QModelIndex& index) return; } - if (strncmp(inputs.at(0), "logic", 5) == 0) { + if (strcmp(inputs.at(0), "logic") == 0) { new_decoders_selected(decoders); return; } // Check if we can automatically fulfill the stacking requirements - while (strncmp(inputs.at(0), "logic", 5) != 0) { + while (strcmp(inputs.at(0), "logic") != 0) { vector prov_decoders = get_decoders_providing(inputs.at(0)); if (prov_decoders.size() == 0) { -- 2.30.2