Skip to content

Commit

Permalink
Fix 1:N signal to marshal variable mapping.
Browse files Browse the repository at this point in the history
Signed-off-by: Rule Timothy (VM/EMT3) <Timothy.Rule@de.bosch.com>
  • Loading branch information
jsmidtbosch authored and timrulebosch committed Jun 27, 2024
1 parent d553d8e commit c90de6b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
9 changes: 3 additions & 6 deletions dse/clib/data/marshal.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,31 +242,28 @@ MarshalSignalMap
MarshalSignalMap* marshal_generate_signalmap(MarshalMapSpec signal,
MarshalMapSpec source, SimpleSet* ex_signals, bool is_binary)
{
assert(ex_signals);

HashList index_list;
hashlist_init(&index_list, signal.count);

for (size_t i = 0; i < signal.count; i++) {
for (size_t j = 0; j < source.count; j++) {
for (size_t j = 0; j < source.count; j++) {
for (size_t i = 0; i < signal.count; i++) {
if (strcmp(signal.signal[i], source.signal[j]) == 0) {
/* If a set is provided, signal mappings are unique. */
if (ex_signals) {
/* Match. */
if (set_contains(ex_signals, signal.signal[i]) == SET_TRUE) {
/* Signal already mapped. */
errno = -EINVAL;
for (uint32_t i = 0; i < hashlist_length(&index_list);
i++) {
free(hashlist_at(&index_list, i));
}
hashlist_destroy(&index_list);
errno = -EINVAL;
return NULL;
};
/* Mark the Signal as mapped */
set_add(ex_signals, signal.signal[i]);
}

IndexItem* index = calloc(1, sizeof(IndexItem));
index->signal_idx = i;
index->source_idx = j;
Expand Down
8 changes: 4 additions & 4 deletions tests/data/test_marshal.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ void test_marshal__signalmap_generate(void** state)
},
.expect = {
.count = 4,
.signal_index = {0, 1, 2, 3},
.source_index = {3, 1, 2, 0},
.signal_index = {3, 1, 2, 0},
.source_index = {0, 1, 2, 3},
},
},
{
Expand All @@ -308,8 +308,8 @@ void test_marshal__signalmap_generate(void** state)
},
.expect = {
.count = 4,
.signal_index = {0, 1, 2, 3},
.source_index = {0, 2, 1, 3},
.signal_index = {0, 2, 1, 3},
.source_index = {0, 1, 2, 3},
},
},
{
Expand Down

0 comments on commit c90de6b

Please sign in to comment.