From 5e7b41ab683ba2f5da49d18dca98fd156cabbf38 Mon Sep 17 00:00:00 2001 From: anth64 Date: Tue, 3 Mar 2026 23:03:46 +0100 Subject: [PATCH] feat(module.c): log offending modules on circular dependency detection --- src/module.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/module.c b/src/module.c index eef0714..f4d4b3f 100644 --- a/src/module.c +++ b/src/module.c @@ -1,5 +1,6 @@ #include "platform.h" #include "stk.h" +#include "stk_log.h" #include #include @@ -229,9 +230,26 @@ unsigned char stk_topo_sort(size_t count, size_t *order) } } - if (sorted != count) - result = STK_MOD_DEP_CIRCULAR_ERROR; + if (sorted != count) { + size_t j; + int in_order; + for (i = 0; i < count; i++) { + in_order = 0; + for (j = 0; j < sorted; j++) { + if (order[j] == i) { + in_order = 1; + break; + } + } + if (!in_order) + stk_log(STK_LOG_ERROR, + "Circular dependency detected with %s", + stk_modules[i].id); + } + + result = STK_MOD_DEP_CIRCULAR_ERROR; + } done: if (in_degree) free(in_degree);