From 1a9bbd9c6bceb43a11d7e78e2260de1fe0142a43 Mon Sep 17 00:00:00 2001 From: obarun <eric@obarun.org> Date: Fri, 18 Mar 2022 12:39:36 +1100 Subject: [PATCH] use new name of graph_matrix_get_edge_g_sorted() --- src/66/66-inservice.c | 4 ++-- src/66/66-intree.c | 7 ++++--- src/lib66/exec/ssexec_tree.c | 16 ++++++++++------ src/lib66/info/info_utils.c | 8 +++++--- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/66/66-inservice.c b/src/66/66-inservice.c index 6648b539..d8538502 100644 --- a/src/66/66-inservice.c +++ b/src/66/66-inservice.c @@ -377,7 +377,7 @@ static void info_display_requiredby(char const *field, resolve_service_t *res) } else { deps.len = 0 ; - r = graph_matrix_get_edge_g_sorted(&deps,&graph, res->sa.s + res->name, 1) ; + r = graph_matrix_get_edge_g_sorted_sa(&deps,&graph, res->sa.s + res->name, 1) ; if (r == -1) log_dieu(LOG_EXIT_SYS, "get the requiredby list") ; @@ -447,7 +447,7 @@ static void info_display_deps(char const *field, resolve_service_t *res) } else { - r = graph_matrix_get_edge_g_sorted(&deps,&graph, res->sa.s + res->name, 0) ; + r = graph_matrix_get_edge_g_sorted_sa(&deps,&graph, res->sa.s + res->name, 0) ; if (r == -1) log_dieu(LOG_EXIT_SYS, "get the dependencies list") ; diff --git a/src/66/66-intree.c b/src/66/66-intree.c index 53a2a5c8..eef49e39 100644 --- a/src/66/66-intree.c +++ b/src/66/66-intree.c @@ -137,7 +137,8 @@ static void info_display_init(char const *field,char const *treename) if (!r) log_die_nomem("stralloc") ; if (r == -1) log_die(LOG_EXIT_SYS,"live: ",live.s," must be an absolute path") ; - init = tree_isinitialized(live.s, treename, OWNER) ; + init = tree_isinitialized(base.s, treename) ; + if (init == -1) log_dieu(LOG_EXIT_SYS, "resolve file of tree: ", treename) ; if (NOFIELD) info_display_field_name(field) ; if (!bprintf(buffer_1,"%s%s%s",init ? log_color->valid : log_color->warning, init ? "yes":"no",log_color->off)) @@ -189,7 +190,7 @@ static void info_display_depends(char const *field, char const *treename) if (!graph_build_g(&graph, base.s, treename, DATA_TREE)) log_dieu(LOG_EXIT_SYS,"build the graph") ; - r = graph_matrix_get_edge_g_sorted(&sa, &graph, treename, 0) ; + r = graph_matrix_get_edge_g_sorted_sa(&sa, &graph, treename, 0) ; if (r < 0) log_dieu(LOG_EXIT_SYS, "get the dependencies list") ; @@ -250,7 +251,7 @@ static void info_display_requiredby(char const *field, char const *treename) if (!graph_build_g(&graph, base.s, treename, DATA_TREE)) log_dieu(LOG_EXIT_SYS,"build the graph") ; - r = graph_matrix_get_edge_g_sorted(&sa, &graph, treename, 1) ; + r = graph_matrix_get_edge_g_sorted_sa(&sa, &graph, treename, 1) ; if (r < 0) log_dieu(LOG_EXIT_SYS, "get the dependencies list") ; diff --git a/src/lib66/exec/ssexec_tree.c b/src/lib66/exec/ssexec_tree.c index f9f9f794..f8bc658f 100644 --- a/src/lib66/exec/ssexec_tree.c +++ b/src/lib66/exec/ssexec_tree.c @@ -576,7 +576,7 @@ void tree_parse_seed(char const *treename, tree_seed_t *seed, tree_what_t *what) if (tree_seed_isvalid(treename)) { - if (!tree_seed_setseed(seed, treename, 0)) + if (!tree_seed_setseed(seed, treename)) log_dieu_nclean(LOG_EXIT_SYS, &cleanup, "parse seed file: ", treename) ; if (seed->depends) @@ -785,10 +785,14 @@ void tree_create(graph_t *g, ssexec_t *info, tree_what_t *what, char const *cons if (!resolve_write(wres, solve, info->treename.s)) log_dieu_nclean(LOG_EXIT_SYS, &cleanup, "write resolve file: ", solve, SS_RESOLVE, "/", info->treename.s) ; - if (what->depends) + /** check of the seed.sa.len: if the seed file is not parse at this point + * the seed.sa.s + seed.depends is empty which produce a segmentation fault + * when the -o options is passed at commandline. We have already passed + * through the tree_parse_options_depends anyway when it's the case */ + if (what->depends && seed.sa.len) tree_parse_options_depends(g, info, seed.sa.s + seed.depends, 0, what) ; - if (what->requiredby) + if (what->requiredby && seed.sa.len) tree_parse_options_depends(g, info, seed.sa.s + seed.requiredby, 1, what) ; resolve_free(wres) ; @@ -888,7 +892,7 @@ void tree_enable_disable_deps(graph_t *g,char const *base, char const *treename, size_t pos = 0, element = 0 ; stralloc sa = STRALLOC_ZERO ; - if (graph_matrix_get_edge_g(&sa, g, treename, action ? 0 : 1) < 0) + if (graph_matrix_get_edge_g_sa(&sa, g, treename, action ? 0 : 1) < 0) log_dieu(LOG_EXIT_SYS, "get ", action ? "dependencies" : "required by" ," of: ", treename) ; size_t len = sastr_nelement(&sa) ; @@ -980,7 +984,7 @@ void tree_depends_requiredby(graph_t *g, char const *base, char const *treename, auto_strings(solve, base, SS_SYSTEM) ; - if (graph_matrix_get_edge_g_sorted(&sa, g, treename, requiredby) < 0) + if (graph_matrix_get_edge_g_sorted_sa(&sa, g, treename, requiredby) < 0) log_dieu(LOG_EXIT_SYS,"get sorted ", requiredby ? "required by" : "dependency", " list of tree: ", treename) ; size_t vlen = sastr_nelement(&sa) ; @@ -1075,7 +1079,7 @@ void tree_depends_requiredby_deps(graph_t *g, char const *base, char const *tree stralloc sa = STRALLOC_ZERO ; char solve[baselen + SS_SYSTEM_LEN + 1] ; - if (graph_matrix_get_edge_g_sorted(&sa, g, treename, requiredby) < 0) + if (graph_matrix_get_edge_g_sorted_sa(&sa, g, treename, requiredby) < 0) log_dieu(LOG_EXIT_SYS,"get sorted ", requiredby ? "required by" : "dependency", " list of tree: ", treename) ; size_t vlen = sastr_nelement(&sa) ; diff --git a/src/lib66/info/info_utils.c b/src/lib66/info/info_utils.c index b46748f1..8b50e985 100644 --- a/src/lib66/info/info_utils.c +++ b/src/lib66/info/info_utils.c @@ -268,7 +268,9 @@ int info_graph_display_tree(char const *name, char const *obj) if (r <= 0) goto freed ; - int init = tree_isinitialized(sa.s, name, owner) ; + int init = tres.init ; + if (init < 0) + goto freed ; int enabled = tree_isenabled(base, name) ; if (enabled < 0) @@ -450,7 +452,7 @@ int info_walk(graph_t *g, char const *name, char const *obj, info_graph_func *fu } else { - count = graph_matrix_get_edge_g_sorted(&sa, g, name, requiredby) ; + count = graph_matrix_get_edge_g_sorted_sa(&sa, g, name, requiredby) ; if (count == -1) { stralloc_free(&sa) ; @@ -479,7 +481,7 @@ int info_walk(graph_t *g, char const *name, char const *obj, info_graph_func *fu if (!info_graph_display(name, obj, func, depth, last, padding, style)) goto err ; - if (graph_matrix_get_edge_g_sorted(&sa, g, name, requiredby) == -1) + if (graph_matrix_get_edge_g_sorted_sa(&sa, g, name, requiredby) == -1) goto err ; if (sa.len) -- GitLab