conditional expression is constant

MSVC: C4127: conditional expression is constant
This commit is contained in:
Max Seidenstücker
2026-02-08 11:59:55 +01:00
committed by Sam Lantinga
parent d063cb01e9
commit 0c121ad6a7
3 changed files with 12 additions and 6 deletions

View File

@@ -365,7 +365,8 @@ static int SDLCALL stdlib_snprintf(void *arg)
result == SDL_strlen(expected5),
"Check result value, expected: %d, got: %d", (int)SDL_strlen(expected), result);
if (sizeof(void *) >= 8) {
const bool is_at_least_64bit_system = sizeof(void *) >= 8;
if (is_at_least_64bit_system) {
result = SDL_snprintf(text, sizeof(text), "%p", (void *)SDL_SINT64_C(0x1ba07bddf60));
expected = "0x1ba07bddf60";
expected2 = "000001BA07BDDF60";
@@ -1324,7 +1325,8 @@ static int SDLCALL stdlib_wcstol(void *arg)
WCSTOL_TEST_CASE(L" - 1", 0, 0, 0); // invalid input
// values near the bounds of the type
if (sizeof(long) == 4) {
const bool long_is_32bit = sizeof(long) == 4;
if (long_is_32bit) {
WCSTOL_TEST_CASE(L"2147483647", 10, 2147483647, 10);
WCSTOL_TEST_CASE(L"2147483648", 10, 2147483647, 10);
WCSTOL_TEST_CASE(L"-2147483648", 10, -2147483647L - 1, 11);
@@ -1383,7 +1385,8 @@ static int SDLCALL stdlib_strtox(void *arg)
// Suppressing warnings would be difficult otherwise.
// Since the CI runs the tests against a variety of targets, this should be fine in practice.
if (sizeof(long) == 4) {
const bool long_is_32bit = sizeof(long) == 4;
if (long_is_32bit) {
STRTOX_TEST_CASE(SDL_strtol, long, "%ld", "0", 0, 0, 1);
STRTOX_TEST_CASE(SDL_strtol, long, "%ld", "0", 10, 0, 1);
STRTOX_TEST_CASE(SDL_strtol, long, "%ld", "-0", 0, 0, 2);
@@ -1399,7 +1402,8 @@ static int SDLCALL stdlib_strtox(void *arg)
STRTOX_TEST_CASE(SDL_strtoul, unsigned long, "%lu", "-4294967295", 10, 1, 11);
}
if (sizeof(long long) == 8) {
const bool long_long_is_64bit = sizeof(long long) == 8;
if (long_long_is_64bit) {
STRTOX_TEST_CASE(SDL_strtoll, long long, FMT_PRILLd, "0", 0, 0LL, 1);
STRTOX_TEST_CASE(SDL_strtoll, long long, FMT_PRILLd, "0", 10, 0LL, 1);
STRTOX_TEST_CASE(SDL_strtoll, long long, FMT_PRILLd, "-0", 0, 0LL, 2);