diff --git a/dse/clib/data/marshal.c b/dse/clib/data/marshal.c index 29a6ddc..5e2c4df 100644 --- a/dse/clib/data/marshal.c +++ b/dse/clib/data/marshal.c @@ -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; diff --git a/tests/data/test_marshal.c b/tests/data/test_marshal.c index 4595da2..e61631c 100644 --- a/tests/data/test_marshal.c +++ b/tests/data/test_marshal.c @@ -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}, }, }, { @@ -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}, }, }, {