Clang-Tidy fixes (#6725)

(cherry picked from commit 3c501b963d)
This commit is contained in:
Pierre Wendling
2022-12-01 16:07:03 -05:00
committed by Sam Lantinga
parent e29c0661cc
commit d0bbfdbfb8
179 changed files with 1260 additions and 1101 deletions

View File

@@ -41,23 +41,27 @@ __declspec(selectany) int _fltused = 1;
/* The optimizer on Visual Studio 2005 and later generates memcpy() and memset() calls.
Always provide it for the SDL2 DLL, but skip it when building static lib w/ static runtime. */
#if (_MSC_VER >= 1400) && (!defined(_MT) || defined(DLL_EXPORT))
/* NOLINTNEXTLINE(readability-redundant-declaration) */
extern void *memcpy(void *dst, const void *src, size_t len);
#pragma intrinsic(memcpy)
#if !defined(__clang__)
#pragma function(memcpy)
#endif
/* NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name) */
void *memcpy(void *dst, const void *src, size_t len)
{
return SDL_memcpy(dst, src, len);
}
/* NOLINTNEXTLINE(readability-redundant-declaration) */
extern void *memset(void *dst, int c, size_t len);
#pragma intrinsic(memset)
#if !defined(__clang__)
#pragma function(memset)
#endif
/* NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name) */
void *memset(void *dst, int c, size_t len)
{
return SDL_memset(dst, c, len);

View File

@@ -43,14 +43,15 @@
static unsigned UTF8_TrailingBytes(unsigned char c)
{
if (c >= 0xC0 && c <= 0xDF)
if (c >= 0xC0 && c <= 0xDF) {
return 1;
else if (c >= 0xE0 && c <= 0xEF)
} else if (c >= 0xE0 && c <= 0xEF) {
return 2;
else if (c >= 0xF0 && c <= 0xF4)
} else if (c >= 0xF0 && c <= 0xF4) {
return 3;
else
return 0;
}
return 0;
}
#if !defined(HAVE_VSSCANF) || !defined(HAVE_STRTOL) || !defined(HAVE_STRTOUL) || !defined(HAVE_STRTOD)
@@ -443,7 +444,7 @@ int SDL_wcscmp(const wchar_t *str1, const wchar_t *str2)
++str1;
++str2;
}
return (int)(*str1 - *str2);
return *str1 - *str2;
#endif /* HAVE_WCSCMP */
}
@@ -463,7 +464,7 @@ int SDL_wcsncmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen)
if (!maxlen) {
return 0;
}
return (int)(*str1 - *str2);
return *str1 - *str2;
#endif /* HAVE_WCSNCMP */
}
@@ -666,7 +667,7 @@ SDL_strrev(char *string)
char *b = &string[len - 1];
len /= 2;
while (len--) {
char c = *a;
char c = *a; /* NOLINT(clang-analyzer-core.uninitialized.Assign) */
*a++ = *b;
*b-- = c;
}
@@ -1038,7 +1039,7 @@ int SDL_strcmp(const char *str1, const char *str2)
int result;
while (1) {
result = (int)((unsigned char)*str1 - (unsigned char)*str2);
result = ((unsigned char)*str1 - (unsigned char)*str2);
if (result != 0 || (*str1 == '\0' /* && *str2 == '\0'*/)) {
break;
}
@@ -1138,6 +1139,7 @@ int SDL_vsscanf(const char *text, const char *fmt, va_list ap)
return vsscanf(text, fmt, ap);
}
#else
/* NOLINTNEXTLINE(readability-non-const-parameter) */
int SDL_vsscanf(const char *text, const char *fmt, va_list ap)
{
int retval = 0;
@@ -1678,6 +1680,7 @@ SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, double arg)
return length;
}
/* NOLINTNEXTLINE(readability-non-const-parameter) */
int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, va_list ap)
{
size_t length = 0;