From 7f7b4cc7bfc96cd192346360b305dfa9916a5c8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Sat, 8 Jun 2019 13:32:42 +0200 Subject: [PATCH] Fix #17: Reference loop detection fix. This will be part of v1.0-1 --- gds-utils/gds-tree-checker.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gds-utils/gds-tree-checker.c b/gds-utils/gds-tree-checker.c index bb571d6..22500f8 100644 --- a/gds-utils/gds-tree-checker.c +++ b/gds-utils/gds-tree-checker.c @@ -176,6 +176,16 @@ int gds_tree_check_reference_loops(struct gds_library *lib) /* iterate through references and check if loop exists */ res = gds_tree_check_iterate_ref_and_check(cell_to_check, &visited_cells); + if (visited_cells) { + /* If cell contains no loop, print error when list not empty. + * In case of a loop, it is completely normal that the list is not empty, + * due to the instant return from gds_tree_check_iterate_ref_and_check() + */ + if (res == 0) + fprintf(stderr, "Visited cell list should be empty. This is a bug. Please report this.\n"); + g_list_free(visited_cells); + } + if (res < 0) { /* Error */ return res; @@ -190,10 +200,6 @@ int gds_tree_check_reference_loops(struct gds_library *lib) } - if (visited_cells) { - fprintf(stderr, "Visited cell list should be empty. This is a bug. Please report this.\n"); - g_list_free(visited_cells); - } return loop_count; }