From 259504f3a0200793a7ec813d84655520d250a1c2 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 21 Nov 2025 17:03:34 -0800 Subject: [PATCH 01/17] common emit_html_rules: remove dead store to 'pts' CodeChecker says: [LOW] lib/common/htmltable.c:454:10: Value stored to 'pts' during its initialization is never read [deadcode.DeadStores] boxf pts = cp->data.box; ^ Reported-by: CodeChecker 6.26.2 --- lib/common/htmltable.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/common/htmltable.c b/lib/common/htmltable.c index 129f5ed8d1..0627d16378 100644 --- a/lib/common/htmltable.c +++ b/lib/common/htmltable.c @@ -451,7 +451,6 @@ emit_html_rules(GVJ_t * job, htmlcell_t * cp, htmlenv_t * env, char *color, html pointf rule_pt; double rule_length; double base; - boxf pts = cp->data.box; pointf pos = env->pos; if (!color) @@ -459,7 +458,7 @@ emit_html_rules(GVJ_t * job, htmlcell_t * cp, htmlenv_t * env, char *color, html gvrender_set_fillcolor(job, color); gvrender_set_pencolor(job, color); - pts = cp->data.box; + boxf pts = cp->data.box; pts.LL.x += pos.x; pts.UR.x += pos.x; pts.LL.y += pos.y; -- GitLab From d9647fe862100b85ff976154085b5a7c9d6394ee Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 21 Nov 2025 17:03:34 -0800 Subject: [PATCH 02/17] common node_in_layer: remove dead store to 'e' CodeChecker says: [LOW] lib/common/emit.c:1595:10: Although the value stored to 'e' is used in the enclosing expression, the value is never actually read from 'e' [deadcode.DeadStores] if ((e = agfstedge(g, n)) == NULL) ^ Reported-by: CodeChecker 6.26.2 --- lib/common/emit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/common/emit.c b/lib/common/emit.c index fa85e3ba8c..ac5b0b09bb 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -1592,7 +1592,7 @@ static bool node_in_layer(GVJ_t *job, graph_t * g, node_t * n) return true; if (pn[0]) return false; /* Only check edges if pn = "" */ - if ((e = agfstedge(g, n)) == NULL) + if (agfstedge(g, n) == NULL) return true; for (e = agfstedge(g, n); e; e = agnxtedge(g, e, n)) { pe = late_string(e, E_layer, ""); -- GitLab From 56f0218e219b0641e51518c31c559b2145acec39 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 21 Nov 2025 17:03:34 -0800 Subject: [PATCH 03/17] common node_in_layer: more tightly scope 'e' This should hopefully make issues like that fixed in the previous commit harder to reintroduce unnoticed. --- lib/common/emit.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/common/emit.c b/lib/common/emit.c index ac5b0b09bb..50bdb48c23 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -1583,7 +1583,6 @@ static void setup_page(GVJ_t * job) static bool node_in_layer(GVJ_t *job, graph_t * g, node_t * n) { char *pn, *pe; - edge_t *e; if (job->numLayers <= 1) return true; @@ -1594,7 +1593,7 @@ static bool node_in_layer(GVJ_t *job, graph_t * g, node_t * n) return false; /* Only check edges if pn = "" */ if (agfstedge(g, n) == NULL) return true; - for (e = agfstedge(g, n); e; e = agnxtedge(g, e, n)) { + for (edge_t *e = agfstedge(g, n); e; e = agnxtedge(g, e, n)) { pe = late_string(e, E_layer, ""); if (pe[0] == '\0' || selectedlayer(job, pe)) return true; -- GitLab From 7d65760bcff639d0e320a914bda3fc8deb292e56 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 21 Nov 2025 17:03:34 -0800 Subject: [PATCH 04/17] common node_in_layer: more tightly scope 'pn' --- lib/common/emit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/common/emit.c b/lib/common/emit.c index 50bdb48c23..8b2d9e632d 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -1582,11 +1582,11 @@ static void setup_page(GVJ_t * job) static bool node_in_layer(GVJ_t *job, graph_t * g, node_t * n) { - char *pn, *pe; + char *pe; if (job->numLayers <= 1) return true; - pn = late_string(n, N_layer, ""); + char *const pn = late_string(n, N_layer, ""); if (selectedlayer(job, pn)) return true; if (pn[0]) -- GitLab From c11597237a4ed1d021f3722acb0f661c0aa0e43e Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 21 Nov 2025 17:03:34 -0800 Subject: [PATCH 05/17] common node_in_layer: more tightly scope 'pe' --- lib/common/emit.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/common/emit.c b/lib/common/emit.c index 8b2d9e632d..753591529a 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -1582,8 +1582,6 @@ static void setup_page(GVJ_t * job) static bool node_in_layer(GVJ_t *job, graph_t * g, node_t * n) { - char *pe; - if (job->numLayers <= 1) return true; char *const pn = late_string(n, N_layer, ""); @@ -1594,7 +1592,7 @@ static bool node_in_layer(GVJ_t *job, graph_t * g, node_t * n) if (agfstedge(g, n) == NULL) return true; for (edge_t *e = agfstedge(g, n); e; e = agnxtedge(g, e, n)) { - pe = late_string(e, E_layer, ""); + char *const pe = late_string(e, E_layer, ""); if (pe[0] == '\0' || selectedlayer(job, pe)) return true; } -- GitLab From 70b41d63633a26230228be18f3c0f73c567c201e Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 21 Nov 2025 17:03:34 -0800 Subject: [PATCH 06/17] common node_in_layer: make string comparisons clearer --- lib/common/emit.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/common/emit.c b/lib/common/emit.c index 753591529a..ecc3c10c76 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -1587,13 +1587,13 @@ static bool node_in_layer(GVJ_t *job, graph_t * g, node_t * n) char *const pn = late_string(n, N_layer, ""); if (selectedlayer(job, pn)) return true; - if (pn[0]) - return false; /* Only check edges if pn = "" */ + if (!streq(pn, "")) + return false; if (agfstedge(g, n) == NULL) return true; for (edge_t *e = agfstedge(g, n); e; e = agnxtedge(g, e, n)) { char *const pe = late_string(e, E_layer, ""); - if (pe[0] == '\0' || selectedlayer(job, pe)) + if (streq(pe, "") || selectedlayer(job, pe)) return true; } return false; -- GitLab From 39ef755068f539a0e17d29f9d43c8c2c2fb4bc01 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 21 Nov 2025 17:03:34 -0800 Subject: [PATCH 07/17] common selectedLayer: take 'spec' as a const --- lib/common/emit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/common/emit.c b/lib/common/emit.c index ecc3c10c76..82769d909c 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -952,8 +952,8 @@ static int layer_index(GVC_t *gvc, char *str, int all) return -1; } -static bool selectedLayer(GVC_t *gvc, int layerNum, int numLayers, char *spec) -{ +static bool selectedLayer(GVC_t *gvc, int layerNum, int numLayers, + const char *spec) { int n0, n1; char *w0, *w1; char *buf_part_p = NULL, *buf_p = NULL, *cur, *part_in_p; -- GitLab From 2b1e50182d37e576dd477d729720e7a24ba2a0cf Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 21 Nov 2025 17:03:34 -0800 Subject: [PATCH 08/17] common selectedlayer: take 'spec' as a const --- lib/common/emit.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/common/emit.c b/lib/common/emit.c index 82769d909c..9acfcb2890 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -989,8 +989,7 @@ static bool selectedLayer(GVC_t *gvc, int layerNum, int numLayers, return rval; } -static bool selectedlayer(GVJ_t *job, char *spec) -{ +static bool selectedlayer(GVJ_t *job, const char *spec) { return selectedLayer (job->gvc, job->layerNum, job->numLayers, spec); } -- GitLab From 874d0565a376487d8760171c4795a60b5dec618e Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 21 Nov 2025 17:03:34 -0800 Subject: [PATCH 09/17] common parse_layerselect: take 'p' as a const --- lib/common/emit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/common/emit.c b/lib/common/emit.c index 9acfcb2890..1de478bd76 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -1008,7 +1008,7 @@ static bool selectedlayer(GVJ_t *job, const char *spec) { * efficient way to do this, but this is simple and until we find people * using huge numbers of layers, it should be adequate. */ -static int *parse_layerselect(GVC_t *gvc, char *p) { +static int *parse_layerselect(GVC_t *gvc, const char *p) { int* laylist = gv_calloc(gvc->numLayers + 2, sizeof(int)); int i, cnt = 0; for (i = 1; i <=gvc->numLayers; i++) { -- GitLab From 56daf90407cf867beb128e5fe469c9bb08d0f18a Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 21 Nov 2025 17:03:34 -0800 Subject: [PATCH 10/17] common node_in_layer: use const inputs to 'selectedlayer' --- lib/common/emit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/common/emit.c b/lib/common/emit.c index 1de478bd76..3e3a31992d 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -1583,7 +1583,7 @@ static bool node_in_layer(GVJ_t *job, graph_t * g, node_t * n) { if (job->numLayers <= 1) return true; - char *const pn = late_string(n, N_layer, ""); + const char *const pn = late_string(n, N_layer, ""); if (selectedlayer(job, pn)) return true; if (!streq(pn, "")) @@ -1591,7 +1591,7 @@ static bool node_in_layer(GVJ_t *job, graph_t * g, node_t * n) if (agfstedge(g, n) == NULL) return true; for (edge_t *e = agfstedge(g, n); e; e = agnxtedge(g, e, n)) { - char *const pe = late_string(e, E_layer, ""); + const char *const pe = late_string(e, E_layer, ""); if (streq(pe, "") || selectedlayer(job, pe)) return true; } -- GitLab From b7a37f9fa64c7d3ec6f2afa72c69d87432681eed Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 21 Nov 2025 17:03:34 -0800 Subject: [PATCH 11/17] common edge_in_layer: more tightly scope 'pe' --- lib/common/emit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/common/emit.c b/lib/common/emit.c index 3e3a31992d..115abeb9c6 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -1600,12 +1600,12 @@ static bool node_in_layer(GVJ_t *job, graph_t * g, node_t * n) static bool edge_in_layer(GVJ_t *job, edge_t * e) { - char *pe, *pn; + char *pn; int cnt; if (job->numLayers <= 1) return true; - pe = late_string(e, E_layer, ""); + const char *const pe = late_string(e, E_layer, ""); if (selectedlayer(job, pe)) return true; if (pe[0]) -- GitLab From ba42a6ceba4b07bebcc398d6cd63c7351f344871 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 21 Nov 2025 17:03:34 -0800 Subject: [PATCH 12/17] common edge_in_layer: more tightly scope 'pn' --- lib/common/emit.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/common/emit.c b/lib/common/emit.c index 115abeb9c6..5ae86efbd2 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -1600,7 +1600,6 @@ static bool node_in_layer(GVJ_t *job, graph_t * g, node_t * n) static bool edge_in_layer(GVJ_t *job, edge_t * e) { - char *pn; int cnt; if (job->numLayers <= 1) @@ -1611,7 +1610,7 @@ static bool edge_in_layer(GVJ_t *job, edge_t * e) if (pe[0]) return false; for (cnt = 0; cnt < 2; cnt++) { - pn = late_string(cnt < 1 ? agtail(e) : aghead(e), N_layer, ""); + const char *const pn = late_string(cnt < 1 ? agtail(e) : aghead(e), N_layer, ""); if (pn[0] == '\0' || selectedlayer(job, pn)) return true; } -- GitLab From aea86f96b2df1f3142eff3e4035f217aa744c5b2 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 21 Nov 2025 17:03:34 -0800 Subject: [PATCH 13/17] common edge_in_layer: more tightly scope 'cnt' --- lib/common/emit.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/common/emit.c b/lib/common/emit.c index 5ae86efbd2..e60ed02b47 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -1600,8 +1600,6 @@ static bool node_in_layer(GVJ_t *job, graph_t * g, node_t * n) static bool edge_in_layer(GVJ_t *job, edge_t * e) { - int cnt; - if (job->numLayers <= 1) return true; const char *const pe = late_string(e, E_layer, ""); @@ -1609,7 +1607,7 @@ static bool edge_in_layer(GVJ_t *job, edge_t * e) return true; if (pe[0]) return false; - for (cnt = 0; cnt < 2; cnt++) { + for (int cnt = 0; cnt < 2; cnt++) { const char *const pn = late_string(cnt < 1 ? agtail(e) : aghead(e), N_layer, ""); if (pn[0] == '\0' || selectedlayer(job, pn)) return true; -- GitLab From 14437e7120c27dfda28916b7b5f0eed5812e64d5 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 21 Nov 2025 17:03:34 -0800 Subject: [PATCH 14/17] common edge_in_layer: make string comparisons clearer --- lib/common/emit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/common/emit.c b/lib/common/emit.c index e60ed02b47..4661e3b02d 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -1605,11 +1605,11 @@ static bool edge_in_layer(GVJ_t *job, edge_t * e) const char *const pe = late_string(e, E_layer, ""); if (selectedlayer(job, pe)) return true; - if (pe[0]) + if (!streq(pe, "")) return false; for (int cnt = 0; cnt < 2; cnt++) { const char *const pn = late_string(cnt < 1 ? agtail(e) : aghead(e), N_layer, ""); - if (pn[0] == '\0' || selectedlayer(job, pn)) + if (streq(pn, "") || selectedlayer(job, pn)) return true; } return false; -- GitLab From d940b847412ec82b59d1d08d8ab1097c2e0b1c1a Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 21 Nov 2025 17:03:34 -0800 Subject: [PATCH 15/17] common clust_in_layer: more tightly scope 'pg' --- lib/common/emit.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/common/emit.c b/lib/common/emit.c index 4661e3b02d..f788ecacbb 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -1617,12 +1617,11 @@ static bool edge_in_layer(GVJ_t *job, edge_t * e) static bool clust_in_layer(GVJ_t *job, graph_t * sg) { - char *pg; node_t *n; if (job->numLayers <= 1) return true; - pg = late_string(sg, agattr_text(sg, AGRAPH, "layer", 0), ""); + const char *const pg = late_string(sg, agattr_text(sg, AGRAPH, "layer", 0), ""); if (selectedlayer(job, pg)) return true; if (pg[0]) -- GitLab From 55f30e6a58076152ff7f894a69fe03728a95280f Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 21 Nov 2025 17:03:34 -0800 Subject: [PATCH 16/17] common clust_in_layer: more tightly scope 'n' --- lib/common/emit.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/common/emit.c b/lib/common/emit.c index f788ecacbb..7bc64eb29d 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -1617,8 +1617,6 @@ static bool edge_in_layer(GVJ_t *job, edge_t * e) static bool clust_in_layer(GVJ_t *job, graph_t * sg) { - node_t *n; - if (job->numLayers <= 1) return true; const char *const pg = late_string(sg, agattr_text(sg, AGRAPH, "layer", 0), ""); @@ -1626,7 +1624,7 @@ static bool clust_in_layer(GVJ_t *job, graph_t * sg) return true; if (pg[0]) return false; - for (n = agfstnode(sg); n; n = agnxtnode(sg, n)) + for (node_t *n = agfstnode(sg); n; n = agnxtnode(sg, n)) if (node_in_layer(job, sg, n)) return true; return false; -- GitLab From 74c5b55fe77c4e6b2ba813007dc8ab2e907b279c Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 21 Nov 2025 17:03:34 -0800 Subject: [PATCH 17/17] common clust_in_layer: make string comparison clearer --- lib/common/emit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/common/emit.c b/lib/common/emit.c index 7bc64eb29d..f4a14b5162 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -1622,7 +1622,7 @@ static bool clust_in_layer(GVJ_t *job, graph_t * sg) const char *const pg = late_string(sg, agattr_text(sg, AGRAPH, "layer", 0), ""); if (selectedlayer(job, pg)) return true; - if (pg[0]) + if (!streq(pg, "")) return false; for (node_t *n = agfstnode(sg); n; n = agnxtnode(sg, n)) if (node_in_layer(job, sg, n)) -- GitLab