style(string): satisfy clang-tidy and clang-format for final-wave gate

Suppress clang-analyzer-security buffer-handling diagnostics on the
plan-mandated __builtin_memcpy word loads and bugprone swappable-
parameter diagnostics on the C-standard signatures; wrap the autoconf
substitution tokens in clang-format off/on (the space clang-format wants
before the closing @ would break config.status substitution).

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <[email protected]>
This commit is contained in:
2026-08-31 21:34:25 -04:00
co-authored by Sisyphus
parent 53c8531eab
commit 6854c7771d
6 changed files with 16 additions and 15 deletions
+4 -5
View File
@@ -16,9 +16,8 @@
* self-recursion and stack overflow. Disable that one transformation for
* this function only.
*/
__attribute__((optimize("no-tree-loop-distribute-patterns")))
void *
memcpy(void *restrict dst, const void *restrict src, size_t n)
__attribute__((optimize("no-tree-loop-distribute-patterns"))) void *
memcpy(void *restrict dst, const void *restrict src, size_t n) // NOLINT(bugprone-*)
{
const unsigned long word = sizeof(unsigned long);
unsigned char *d = dst;
@@ -35,8 +34,8 @@ memcpy(void *restrict dst, const void *restrict src, size_t n)
{
unsigned long w;
__builtin_memcpy(&w, s, sizeof w);
__builtin_memcpy(d, &w, sizeof w);
__builtin_memcpy(&w, s, sizeof w); // NOLINT(clang-analyzer-security.insecureAPI.*)
__builtin_memcpy(d, &w, sizeof w); // NOLINT(clang-analyzer-security.insecureAPI.*)
d += word;
s += word;
n -= word;
+5 -5
View File
@@ -12,7 +12,7 @@
* and tails; word loads and stores go through __builtin_memcpy.
*/
void *
memmove(void *dst, const void *src, size_t n)
memmove(void *dst, const void *src, size_t n) // NOLINT(bugprone-easily-swappable-parameters)
{
const unsigned long word = sizeof(unsigned long);
unsigned char *d = dst;
@@ -29,8 +29,8 @@ memmove(void *dst, const void *src, size_t n)
{
unsigned long w;
__builtin_memcpy(&w, s, sizeof w);
__builtin_memcpy(d, &w, sizeof w);
__builtin_memcpy(&w, s, sizeof w); // NOLINT(clang-analyzer-security.insecureAPI.*)
__builtin_memcpy(d, &w, sizeof w); // NOLINT(clang-analyzer-security.insecureAPI.*)
d += word;
s += word;
n -= word;
@@ -56,8 +56,8 @@ memmove(void *dst, const void *src, size_t n)
d -= word;
s -= word;
__builtin_memcpy(&w, s, sizeof w);
__builtin_memcpy(d, &w, sizeof w);
__builtin_memcpy(&w, s, sizeof w); // NOLINT(clang-analyzer-security.insecureAPI.*)
__builtin_memcpy(d, &w, sizeof w); // NOLINT(clang-analyzer-security.insecureAPI.*)
n -= word;
}
while (n != 0)
+2 -2
View File
@@ -11,7 +11,7 @@
* carry between bytes because each byte is at most 0xff.
*/
void *
memset(void *dst, int c, size_t n)
memset(void *dst, int c, size_t n) // NOLINT(bugprone-easily-swappable-parameters)
{
const unsigned long word = sizeof(unsigned long);
const unsigned char byte = (unsigned char)c;
@@ -27,7 +27,7 @@ memset(void *dst, int c, size_t n)
/* Fill whole words. */
while (n >= word)
{
__builtin_memcpy(d, &fill, sizeof fill);
__builtin_memcpy(d, &fill, sizeof fill); // NOLINT(clang-analyzer-security.insecureAPI.*)
d += word;
n -= word;
}
+2 -2
View File
@@ -52,8 +52,8 @@ strcmp(const char *lhs, const char *rhs)
unsigned long wl;
unsigned long wr;
__builtin_memcpy(&wl, l, sizeof wl);
__builtin_memcpy(&wr, r, sizeof wr);
__builtin_memcpy(&wl, l, sizeof wl); // NOLINT(clang-analyzer-security.insecureAPI.*)
__builtin_memcpy(&wr, r, sizeof wr); // NOLINT(clang-analyzer-security.insecureAPI.*)
if (wl != wr || haszero(wl))
{
break;
+1 -1
View File
@@ -42,7 +42,7 @@ strlen(const char *s)
{
unsigned long w;
__builtin_memcpy(&w, p, sizeof w);
__builtin_memcpy(&w, p, sizeof w); // NOLINT(clang-analyzer-security.insecureAPI.*)
if (haszero(w))
{
break;