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:
@@ -22,6 +22,7 @@
|
|||||||
* values baked in at configure time.
|
* values baked in at configure time.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* clang-format off */
|
||||||
#ifndef VLIBC_LEVEL
|
#ifndef VLIBC_LEVEL
|
||||||
#define VLIBC_LEVEL @vlibc_level@
|
#define VLIBC_LEVEL @vlibc_level@
|
||||||
#endif
|
#endif
|
||||||
@@ -29,6 +30,7 @@
|
|||||||
#ifndef VLIBC_PROFILE
|
#ifndef VLIBC_PROFILE
|
||||||
#define VLIBC_PROFILE "@vlibc_profile@"
|
#define VLIBC_PROFILE "@vlibc_profile@"
|
||||||
#endif
|
#endif
|
||||||
|
/* clang-format on */
|
||||||
|
|
||||||
/* True when the active profile is at least level n. */
|
/* True when the active profile is at least level n. */
|
||||||
#define VLIBC_LEVEL_GE(n) (VLIBC_LEVEL >= (n))
|
#define VLIBC_LEVEL_GE(n) (VLIBC_LEVEL >= (n))
|
||||||
|
|||||||
+4
-5
@@ -16,9 +16,8 @@
|
|||||||
* self-recursion and stack overflow. Disable that one transformation for
|
* self-recursion and stack overflow. Disable that one transformation for
|
||||||
* this function only.
|
* this function only.
|
||||||
*/
|
*/
|
||||||
__attribute__((optimize("no-tree-loop-distribute-patterns")))
|
__attribute__((optimize("no-tree-loop-distribute-patterns"))) void *
|
||||||
void *
|
memcpy(void *restrict dst, const void *restrict src, size_t n) // NOLINT(bugprone-*)
|
||||||
memcpy(void *restrict dst, const void *restrict src, size_t n)
|
|
||||||
{
|
{
|
||||||
const unsigned long word = sizeof(unsigned long);
|
const unsigned long word = sizeof(unsigned long);
|
||||||
unsigned char *d = dst;
|
unsigned char *d = dst;
|
||||||
@@ -35,8 +34,8 @@ memcpy(void *restrict dst, const void *restrict src, size_t n)
|
|||||||
{
|
{
|
||||||
unsigned long w;
|
unsigned long w;
|
||||||
|
|
||||||
__builtin_memcpy(&w, s, sizeof w);
|
__builtin_memcpy(&w, s, sizeof w); // NOLINT(clang-analyzer-security.insecureAPI.*)
|
||||||
__builtin_memcpy(d, &w, sizeof w);
|
__builtin_memcpy(d, &w, sizeof w); // NOLINT(clang-analyzer-security.insecureAPI.*)
|
||||||
d += word;
|
d += word;
|
||||||
s += word;
|
s += word;
|
||||||
n -= word;
|
n -= word;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
* and tails; word loads and stores go through __builtin_memcpy.
|
* and tails; word loads and stores go through __builtin_memcpy.
|
||||||
*/
|
*/
|
||||||
void *
|
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);
|
const unsigned long word = sizeof(unsigned long);
|
||||||
unsigned char *d = dst;
|
unsigned char *d = dst;
|
||||||
@@ -29,8 +29,8 @@ memmove(void *dst, const void *src, size_t n)
|
|||||||
{
|
{
|
||||||
unsigned long w;
|
unsigned long w;
|
||||||
|
|
||||||
__builtin_memcpy(&w, s, sizeof w);
|
__builtin_memcpy(&w, s, sizeof w); // NOLINT(clang-analyzer-security.insecureAPI.*)
|
||||||
__builtin_memcpy(d, &w, sizeof w);
|
__builtin_memcpy(d, &w, sizeof w); // NOLINT(clang-analyzer-security.insecureAPI.*)
|
||||||
d += word;
|
d += word;
|
||||||
s += word;
|
s += word;
|
||||||
n -= word;
|
n -= word;
|
||||||
@@ -56,8 +56,8 @@ memmove(void *dst, const void *src, size_t n)
|
|||||||
|
|
||||||
d -= word;
|
d -= word;
|
||||||
s -= word;
|
s -= word;
|
||||||
__builtin_memcpy(&w, s, sizeof w);
|
__builtin_memcpy(&w, s, sizeof w); // NOLINT(clang-analyzer-security.insecureAPI.*)
|
||||||
__builtin_memcpy(d, &w, sizeof w);
|
__builtin_memcpy(d, &w, sizeof w); // NOLINT(clang-analyzer-security.insecureAPI.*)
|
||||||
n -= word;
|
n -= word;
|
||||||
}
|
}
|
||||||
while (n != 0)
|
while (n != 0)
|
||||||
|
|||||||
+2
-2
@@ -11,7 +11,7 @@
|
|||||||
* carry between bytes because each byte is at most 0xff.
|
* carry between bytes because each byte is at most 0xff.
|
||||||
*/
|
*/
|
||||||
void *
|
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 long word = sizeof(unsigned long);
|
||||||
const unsigned char byte = (unsigned char)c;
|
const unsigned char byte = (unsigned char)c;
|
||||||
@@ -27,7 +27,7 @@ memset(void *dst, int c, size_t n)
|
|||||||
/* Fill whole words. */
|
/* Fill whole words. */
|
||||||
while (n >= word)
|
while (n >= word)
|
||||||
{
|
{
|
||||||
__builtin_memcpy(d, &fill, sizeof fill);
|
__builtin_memcpy(d, &fill, sizeof fill); // NOLINT(clang-analyzer-security.insecureAPI.*)
|
||||||
d += word;
|
d += word;
|
||||||
n -= word;
|
n -= word;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -52,8 +52,8 @@ strcmp(const char *lhs, const char *rhs)
|
|||||||
unsigned long wl;
|
unsigned long wl;
|
||||||
unsigned long wr;
|
unsigned long wr;
|
||||||
|
|
||||||
__builtin_memcpy(&wl, l, sizeof wl);
|
__builtin_memcpy(&wl, l, sizeof wl); // NOLINT(clang-analyzer-security.insecureAPI.*)
|
||||||
__builtin_memcpy(&wr, r, sizeof wr);
|
__builtin_memcpy(&wr, r, sizeof wr); // NOLINT(clang-analyzer-security.insecureAPI.*)
|
||||||
if (wl != wr || haszero(wl))
|
if (wl != wr || haszero(wl))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
|||||||
+1
-1
@@ -42,7 +42,7 @@ strlen(const char *s)
|
|||||||
{
|
{
|
||||||
unsigned long w;
|
unsigned long w;
|
||||||
|
|
||||||
__builtin_memcpy(&w, p, sizeof w);
|
__builtin_memcpy(&w, p, sizeof w); // NOLINT(clang-analyzer-security.insecureAPI.*)
|
||||||
if (haszero(w))
|
if (haszero(w))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user