Skip to content

Commit 8478e6d

Browse files
committed
Code review for cstdint constants
1 parent 415563b commit 8478e6d

File tree

3 files changed

+78
-78
lines changed

3 files changed

+78
-78
lines changed

Texassemble/texassemble.cpp

+25-25
Original file line numberDiff line numberDiff line change
@@ -940,13 +940,13 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
940940
return 0;
941941

942942
default:
943-
if (dwOptions & (1u << dwOption))
943+
if (dwOptions & (UINT32_C(1) << dwOption))
944944
{
945945
wprintf(L"ERROR: Duplicate option: `%ls`\n\n", pArg);
946946
return 1;
947947
}
948948

949-
dwOptions |= (1u << dwOption);
949+
dwOptions |= (UINT32_C(1) << dwOption);
950950
break;
951951
}
952952

@@ -1168,7 +1168,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
11681168
{
11691169
const size_t count = conversion.size();
11701170
std::filesystem::path path(pArg);
1171-
SearchForFiles(path.make_preferred(), conversion, (dwOptions & (1u << OPT_RECURSIVE)) != 0, nullptr);
1171+
SearchForFiles(path.make_preferred(), conversion, (dwOptions & (UINT32_C(1) << OPT_RECURSIVE)) != 0, nullptr);
11721172
if (conversion.size() <= count)
11731173
{
11741174
wprintf(L"No matching files found for %ls\n", pArg);
@@ -1190,7 +1190,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
11901190
return 0;
11911191
}
11921192

1193-
if (~dwOptions & (1u << OPT_NOLOGO))
1193+
if (~dwOptions & (UINT32_C(1) << OPT_NOLOGO))
11941194
PrintLogo(false, g_ToolName, g_Description);
11951195

11961196
switch (dwCommand)
@@ -1245,7 +1245,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
12451245
outputFile = curpath.stem().concat(L".dds").native();
12461246
}
12471247

1248-
hr = LoadAnimatedGif(curpath.c_str(), loadedImages, (dwOptions & (1u << OPT_GIF_BGCOLOR)) != 0);
1248+
hr = LoadAnimatedGif(curpath.c_str(), loadedImages, (dwOptions & (UINT32_C(1) << OPT_GIF_BGCOLOR)) != 0);
12491249
if (FAILED(hr))
12501250
{
12511251
wprintf(L" FAILED (%08X%ls)\n", static_cast<unsigned int>(hr), GetErrorDesc(hr));
@@ -1372,7 +1372,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
13721372
wprintf(L"\nERROR: Can't assemble complex surfaces\n");
13731373
return 1;
13741374
}
1375-
else if ((info.mipLevels > 1) && ((dwOptions & (1u << OPT_STRIP_MIPS)) == 0))
1375+
else if ((info.mipLevels > 1) && ((dwOptions & (UINT32_C(1) << OPT_STRIP_MIPS)) == 0))
13761376
{
13771377
switch (dwCommand)
13781378
{
@@ -1552,7 +1552,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
15521552
}
15531553

15541554
// --- Strip Mips (if requested) -----------------------------------------------
1555-
if ((info.mipLevels > 1) && (dwOptions & (1u << OPT_STRIP_MIPS)))
1555+
if ((info.mipLevels > 1) && (dwOptions & (UINT32_C(1) << OPT_STRIP_MIPS)))
15561556
{
15571557
std::unique_ptr<ScratchImage> timage(new (std::nothrow) ScratchImage);
15581558
if (!timage)
@@ -1602,7 +1602,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
16021602
}
16031603

16041604
// --- Undo Premultiplied Alpha (if requested) ---------------------------------
1605-
if ((dwOptions & (1u << OPT_DEMUL_ALPHA))
1605+
if ((dwOptions & (UINT32_C(1) << OPT_DEMUL_ALPHA))
16061606
&& HasAlpha(info.format)
16071607
&& info.format != DXGI_FORMAT_A8_UNORM)
16081608
{
@@ -1709,7 +1709,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
17091709
}
17101710

17111711
// --- Tonemap (if requested) --------------------------------------------------
1712-
if (dwOptions & (1u << OPT_TONEMAP))
1712+
if (dwOptions & (UINT32_C(1) << OPT_TONEMAP))
17131713
{
17141714
std::unique_ptr<ScratchImage> timage(new (std::nothrow) ScratchImage);
17151715
if (!timage)
@@ -2049,12 +2049,12 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
20492049
wprintf(L"\n");
20502050
fflush(stdout);
20512051

2052-
if (dwOptions & (1u << OPT_TOLOWER))
2052+
if (dwOptions & (UINT32_C(1) << OPT_TOLOWER))
20532053
{
20542054
std::transform(outputFile.begin(), outputFile.end(), outputFile.begin(), towlower);
20552055
}
20562056

2057-
if (~dwOptions & (1u << OPT_OVERWRITE))
2057+
if (~dwOptions & (UINT32_C(1) << OPT_OVERWRITE))
20582058
{
20592059
if (GetFileAttributesW(outputFile.c_str()) != INVALID_FILE_ATTRIBUTES)
20602060
{
@@ -2117,12 +2117,12 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
21172117
wprintf(L"\n");
21182118
fflush(stdout);
21192119

2120-
if (dwOptions & (1u << OPT_TOLOWER))
2120+
if (dwOptions & (UINT32_C(1) << OPT_TOLOWER))
21212121
{
21222122
std::transform(outputFile.begin(), outputFile.end(), outputFile.begin(), towlower);
21232123
}
21242124

2125-
if (~dwOptions & (1u << OPT_OVERWRITE))
2125+
if (~dwOptions & (UINT32_C(1) << OPT_OVERWRITE))
21262126
{
21272127
if (GetFileAttributesW(outputFile.c_str()) != INVALID_FILE_ATTRIBUTES)
21282128
{
@@ -2186,12 +2186,12 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
21862186
wprintf(L"\n");
21872187
fflush(stdout);
21882188

2189-
if (dwOptions & (1u << OPT_TOLOWER))
2189+
if (dwOptions & (UINT32_C(1) << OPT_TOLOWER))
21902190
{
21912191
std::transform(outputFile.begin(), outputFile.end(), outputFile.begin(), towlower);
21922192
}
21932193

2194-
if (~dwOptions & (1u << OPT_OVERWRITE))
2194+
if (~dwOptions & (UINT32_C(1) << OPT_OVERWRITE))
21952195
{
21962196
if (GetFileAttributesW(outputFile.c_str()) != INVALID_FILE_ATTRIBUTES)
21972197
{
@@ -2385,12 +2385,12 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
23852385
wprintf(L"\n");
23862386
fflush(stdout);
23872387

2388-
if (dwOptions & (1u << OPT_TOLOWER))
2388+
if (dwOptions & (UINT32_C(1) << OPT_TOLOWER))
23892389
{
23902390
std::transform(outputFile.begin(), outputFile.end(), outputFile.begin(), towlower);
23912391
}
23922392

2393-
if (~dwOptions & (1u << OPT_OVERWRITE))
2393+
if (~dwOptions & (UINT32_C(1) << OPT_OVERWRITE))
23942394
{
23952395
if (GetFileAttributesW(outputFile.c_str()) != INVALID_FILE_ATTRIBUTES)
23962396
{
@@ -2400,7 +2400,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
24002400
}
24012401

24022402
hr = SaveToDDSFile(result.GetImages(), result.GetImageCount(), result.GetMetadata(),
2403-
(dwOptions & (1u << OPT_USE_DX10)) ? (DDS_FLAGS_FORCE_DX10_EXT | DDS_FLAGS_FORCE_DX10_EXT_MISC2) : DDS_FLAGS_NONE,
2403+
(dwOptions & (UINT32_C(1) << OPT_USE_DX10)) ? (DDS_FLAGS_FORCE_DX10_EXT | DDS_FLAGS_FORCE_DX10_EXT_MISC2) : DDS_FLAGS_NONE,
24042404
outputFile.c_str());
24052405
if (FAILED(hr))
24062406
{
@@ -2443,12 +2443,12 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
24432443
wprintf(L"\n");
24442444
fflush(stdout);
24452445

2446-
if (dwOptions & (1u << OPT_TOLOWER))
2446+
if (dwOptions & (UINT32_C(1) << OPT_TOLOWER))
24472447
{
24482448
std::transform(outputFile.begin(), outputFile.end(), outputFile.begin(), towlower);
24492449
}
24502450

2451-
if (~dwOptions & (1u << OPT_OVERWRITE))
2451+
if (~dwOptions & (UINT32_C(1) << OPT_OVERWRITE))
24522452
{
24532453
if (GetFileAttributesW(outputFile.c_str()) != INVALID_FILE_ATTRIBUTES)
24542454
{
@@ -2458,7 +2458,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
24582458
}
24592459

24602460
hr = SaveToDDSFile(result.GetImages(), result.GetImageCount(), result.GetMetadata(),
2461-
(dwOptions & (1u << OPT_USE_DX10)) ? (DDS_FLAGS_FORCE_DX10_EXT | DDS_FLAGS_FORCE_DX10_EXT_MISC2) : DDS_FLAGS_NONE,
2461+
(dwOptions & (UINT32_C(1) << OPT_USE_DX10)) ? (DDS_FLAGS_FORCE_DX10_EXT | DDS_FLAGS_FORCE_DX10_EXT_MISC2) : DDS_FLAGS_NONE,
24622462
outputFile.c_str());
24632463
if (FAILED(hr))
24642464
{
@@ -2532,7 +2532,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
25322532

25332533
case CMD_ARRAY:
25342534
case CMD_GIF:
2535-
hr = result.InitializeArrayFromImages(&imageArray[0], imageArray.size(), (dwOptions & (1u << OPT_USE_DX10)) != 0);
2535+
hr = result.InitializeArrayFromImages(&imageArray[0], imageArray.size(), (dwOptions & (UINT32_C(1) << OPT_USE_DX10)) != 0);
25362536
break;
25372537

25382538
case CMD_CUBE:
@@ -2556,12 +2556,12 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
25562556
wprintf(L"\n");
25572557
fflush(stdout);
25582558

2559-
if (dwOptions & (1u << OPT_TOLOWER))
2559+
if (dwOptions & (UINT32_C(1) << OPT_TOLOWER))
25602560
{
25612561
std::transform(outputFile.begin(), outputFile.end(), outputFile.begin(), towlower);
25622562
}
25632563

2564-
if (~dwOptions & (1u << OPT_OVERWRITE))
2564+
if (~dwOptions & (UINT32_C(1) << OPT_OVERWRITE))
25652565
{
25662566
if (GetFileAttributesW(outputFile.c_str()) != INVALID_FILE_ATTRIBUTES)
25672567
{
@@ -2571,7 +2571,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
25712571
}
25722572

25732573
hr = SaveToDDSFile(result.GetImages(), result.GetImageCount(), result.GetMetadata(),
2574-
(dwOptions & (1u << OPT_USE_DX10)) ? (DDS_FLAGS_FORCE_DX10_EXT | DDS_FLAGS_FORCE_DX10_EXT_MISC2) : DDS_FLAGS_NONE,
2574+
(dwOptions & (UINT32_C(1) << OPT_USE_DX10)) ? (DDS_FLAGS_FORCE_DX10_EXT | DDS_FLAGS_FORCE_DX10_EXT_MISC2) : DDS_FLAGS_NONE,
25752575
outputFile.c_str());
25762576
if (FAILED(hr))
25772577
{

0 commit comments

Comments
 (0)