Keep clang-tidy clean for the converted modules

Once the C headers are included from C++ translation units,
bugprone-dynamic-static-initializers reports each extern variable
declaration in them; none is defined in a header, so disable the check.
Mark the two bounded memchr searches in ssurl.cpp, which
bugprone-not-null-terminated-result misreads as string copies.
This commit is contained in:
Max Lv
2026-10-14 22:51:15 +08:00
parent 96ce822c6b
commit 21c13e8ddc
2 changed files with 6 additions and 1 deletions
+4 -1
View File
@@ -12,7 +12,9 @@
# reserved-identifier: the codebase uses _prefixed names and vendored
# uthash.h/generated config.h trip them ~600 times) or produce false
# positives with the event callback style (casting-through-void,
# multi-level-implicit-pointer-conversion).
# multi-level-implicit-pointer-conversion). dynamic-static-initializers
# fires on every extern variable declaration in the C headers once they are
# included from C++; none of them is defined or initialised in a header.
Checks: >
clang-analyzer-*,
bugprone-*,
@@ -20,6 +22,7 @@ Checks: >
-bugprone-assignment-in-if-condition,
-bugprone-branch-clone,
-bugprone-casting-through-void,
-bugprone-dynamic-static-initializers,
-bugprone-easily-swappable-parameters,
-bugprone-inc-dec-in-conditions,
-bugprone-implicit-widening-of-multiplication-result,
+2
View File
@@ -244,12 +244,14 @@ ss_url_parse(const char *uri, ss_url_t *url)
return -1;
/* The fragment is a human-readable tag and is not part of the config. */
// NOLINTNEXTLINE(bugprone-not-null-terminated-result): memchr searches a bounded span, no string is produced
const char *hash = (const char *)memchr(body, '#', body_len);
if (hash != NULL) {
url->tag = percent_decode(hash + 1, body_len - (size_t)(hash - body) - 1);
body_len = (size_t)(hash - body);
}
// NOLINTNEXTLINE(bugprone-not-null-terminated-result): memchr searches a bounded span, no string is produced
const char *query = (const char *)memchr(body, '?', body_len);
size_t head_len = query ? (size_t)(query - body) : body_len;