mirror of
https://github.com/DeusData/codebase-memory-mcp.git
synced 2026-11-04 10:48:20 +00:00
fix(doc-links): compare a PDF hit's nodes through same_definition
cppcheck 2.20 in CI (x86_64) reports the name comparison in collapse()'s
duplicate-node loop as knownConditionTrueFalse ("always false") on main
5d4b50fe. It is a false positive: the loop compares s->v[i] with s->v[0]
for i >= 1, two different nodes. Neither the arm64 lint image nor a
--platform=unix64 whole-tree run reproduces it, so it is CI-only.
The file/line/name comparison moves into a same_definition() helper.
Behaviour is unchanged: the same three fields, the same NULL-as-empty
handling; doc-link suites 56 passed.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
This commit is contained in:
1 parent
5d4b50fe1c
commit
337f868d68
1 file changed
+11
-4
@@ -380,6 +380,16 @@ static int node_id_cmp(const void *a, const void *b) {
|
||||
return x->id < y->id ? -1 : x->id > y->id ? 1 : 0;
|
||||
}
|
||||
|
||||
/* Two nodes of one definition: the same file, start line and name. */
|
||||
static bool same_definition(const cbm_gbuf_node_t *a, const cbm_gbuf_node_t *b) {
|
||||
const char *a_file = a->file_path ? a->file_path : "";
|
||||
const char *b_file = b->file_path ? b->file_path : "";
|
||||
const char *a_name = a->name ? a->name : "";
|
||||
const char *b_name = b->name ? b->name : "";
|
||||
return a->start_line == b->start_line && strcmp(a_file, b_file) == 0 &&
|
||||
strcmp(a_name, b_name) == 0;
|
||||
}
|
||||
|
||||
/* The field test's _collapse: one entity's several nodes become one. */
|
||||
static const cbm_gbuf_node_t *collapse(const pdfr_index_t *x, nodeset_t *s) {
|
||||
if (s->n == 1) {
|
||||
@@ -416,10 +426,7 @@ static const cbm_gbuf_node_t *collapse(const pdfr_index_t *x, nodeset_t *s) {
|
||||
}
|
||||
const cbm_gbuf_node_t *f = s->v[0];
|
||||
for (int i = 1; i < s->n; i++) {
|
||||
const cbm_gbuf_node_t *n = s->v[i];
|
||||
if (strcmp(n->file_path ? n->file_path : "", f->file_path ? f->file_path : "") != 0 ||
|
||||
n->start_line != f->start_line ||
|
||||
strcmp(n->name ? n->name : "", f->name ? f->name : "") != 0) {
|
||||
if (!same_definition(s->v[i], f)) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user