@@ -888,17 +888,6 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
888
888
*pValue++ = 0 ;
889
889
890
890
dwOption = LookupByName (pArg, g_pOptionsLong);
891
-
892
- if (dwOption == OPT_VERSION)
893
- {
894
- PrintLogo (true , g_ToolName, g_Description);
895
- return 0 ;
896
- }
897
- else if (dwOption == OPT_HELP)
898
- {
899
- PrintUsage ();
900
- return 0 ;
901
- }
902
891
}
903
892
}
904
893
else
@@ -922,19 +911,30 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
922
911
}
923
912
}
924
913
925
- if (! dwOption)
914
+ switch ( dwOption)
926
915
{
916
+ case 0 :
927
917
wprintf (L" ERROR: Unknown option: `%ls`\n\n Use %ls --help\n " , pArg, g_ToolName);
928
918
return 1 ;
929
- }
930
919
931
- if (dwOptions & (1 << dwOption))
932
- {
933
- wprintf (L" ERROR: Duplicate option: `%ls`\n\n " , pArg);
934
- return 1 ;
935
- }
920
+ case OPT_VERSION:
921
+ PrintLogo (true , g_ToolName, g_Description);
922
+ return 0 ;
923
+
924
+ case OPT_HELP:
925
+ PrintUsage ();
926
+ return 0 ;
936
927
937
- dwOptions |= 1 << dwOption;
928
+ default :
929
+ if (dwOptions & (1u << dwOption))
930
+ {
931
+ wprintf (L" ERROR: Duplicate option: `%ls`\n\n " , pArg);
932
+ return 1 ;
933
+ }
934
+
935
+ dwOptions |= (1u << dwOption);
936
+ break ;
937
+ }
938
938
939
939
// Handle options with additional value parameter
940
940
switch (dwOption)
@@ -1154,7 +1154,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
1154
1154
{
1155
1155
const size_t count = conversion.size ();
1156
1156
std::filesystem::path path (pArg);
1157
- SearchForFiles (path.make_preferred (), conversion, (dwOptions & (1 << OPT_RECURSIVE)) != 0 , nullptr );
1157
+ SearchForFiles (path.make_preferred (), conversion, (dwOptions & (1u << OPT_RECURSIVE)) != 0 , nullptr );
1158
1158
if (conversion.size () <= count)
1159
1159
{
1160
1160
wprintf (L" No matching files found for %ls\n " , pArg);
@@ -1176,7 +1176,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
1176
1176
return 0 ;
1177
1177
}
1178
1178
1179
- if (~dwOptions & (1 << OPT_NOLOGO))
1179
+ if (~dwOptions & (1u << OPT_NOLOGO))
1180
1180
PrintLogo (false , g_ToolName, g_Description);
1181
1181
1182
1182
switch (dwCommand)
@@ -1231,7 +1231,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
1231
1231
outputFile = curpath.stem ().concat (L" .dds" ).native ();
1232
1232
}
1233
1233
1234
- hr = LoadAnimatedGif (curpath.c_str (), loadedImages, (dwOptions & (1 << OPT_GIF_BGCOLOR)) != 0 );
1234
+ hr = LoadAnimatedGif (curpath.c_str (), loadedImages, (dwOptions & (1u << OPT_GIF_BGCOLOR)) != 0 );
1235
1235
if (FAILED (hr))
1236
1236
{
1237
1237
wprintf (L" FAILED (%08X%ls)\n " , static_cast <unsigned int >(hr), GetErrorDesc (hr));
@@ -1358,7 +1358,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
1358
1358
wprintf (L" \n ERROR: Can't assemble complex surfaces\n " );
1359
1359
return 1 ;
1360
1360
}
1361
- else if ((info.mipLevels > 1 ) && ((dwOptions & (1 << OPT_STRIP_MIPS)) == 0 ))
1361
+ else if ((info.mipLevels > 1 ) && ((dwOptions & (1u << OPT_STRIP_MIPS)) == 0 ))
1362
1362
{
1363
1363
switch (dwCommand)
1364
1364
{
@@ -1538,7 +1538,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
1538
1538
}
1539
1539
1540
1540
// --- Strip Mips (if requested) -----------------------------------------------
1541
- if ((info.mipLevels > 1 ) && (dwOptions & (1 << OPT_STRIP_MIPS)))
1541
+ if ((info.mipLevels > 1 ) && (dwOptions & (1u << OPT_STRIP_MIPS)))
1542
1542
{
1543
1543
std::unique_ptr<ScratchImage> timage (new (std::nothrow) ScratchImage);
1544
1544
if (!timage)
@@ -1588,7 +1588,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
1588
1588
}
1589
1589
1590
1590
// --- Undo Premultiplied Alpha (if requested) ---------------------------------
1591
- if ((dwOptions & (1 << OPT_DEMUL_ALPHA))
1591
+ if ((dwOptions & (1u << OPT_DEMUL_ALPHA))
1592
1592
&& HasAlpha (info.format )
1593
1593
&& info.format != DXGI_FORMAT_A8_UNORM)
1594
1594
{
@@ -1695,7 +1695,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
1695
1695
}
1696
1696
1697
1697
// --- Tonemap (if requested) --------------------------------------------------
1698
- if (dwOptions & (1 << OPT_TONEMAP))
1698
+ if (dwOptions & (1u << OPT_TONEMAP))
1699
1699
{
1700
1700
std::unique_ptr<ScratchImage> timage (new (std::nothrow) ScratchImage);
1701
1701
if (!timage)
@@ -2035,12 +2035,12 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
2035
2035
wprintf (L" \n " );
2036
2036
fflush (stdout);
2037
2037
2038
- if (dwOptions & (1 << OPT_TOLOWER))
2038
+ if (dwOptions & (1u << OPT_TOLOWER))
2039
2039
{
2040
2040
std::transform (outputFile.begin (), outputFile.end (), outputFile.begin (), towlower);
2041
2041
}
2042
2042
2043
- if (~dwOptions & (1 << OPT_OVERWRITE))
2043
+ if (~dwOptions & (1u << OPT_OVERWRITE))
2044
2044
{
2045
2045
if (GetFileAttributesW (outputFile.c_str ()) != INVALID_FILE_ATTRIBUTES)
2046
2046
{
@@ -2103,12 +2103,12 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
2103
2103
wprintf (L" \n " );
2104
2104
fflush (stdout);
2105
2105
2106
- if (dwOptions & (1 << OPT_TOLOWER))
2106
+ if (dwOptions & (1u << OPT_TOLOWER))
2107
2107
{
2108
2108
std::transform (outputFile.begin (), outputFile.end (), outputFile.begin (), towlower);
2109
2109
}
2110
2110
2111
- if (~dwOptions & (1 << OPT_OVERWRITE))
2111
+ if (~dwOptions & (1u << OPT_OVERWRITE))
2112
2112
{
2113
2113
if (GetFileAttributesW (outputFile.c_str ()) != INVALID_FILE_ATTRIBUTES)
2114
2114
{
@@ -2172,12 +2172,12 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
2172
2172
wprintf (L" \n " );
2173
2173
fflush (stdout);
2174
2174
2175
- if (dwOptions & (1 << OPT_TOLOWER))
2175
+ if (dwOptions & (1u << OPT_TOLOWER))
2176
2176
{
2177
2177
std::transform (outputFile.begin (), outputFile.end (), outputFile.begin (), towlower);
2178
2178
}
2179
2179
2180
- if (~dwOptions & (1 << OPT_OVERWRITE))
2180
+ if (~dwOptions & (1u << OPT_OVERWRITE))
2181
2181
{
2182
2182
if (GetFileAttributesW (outputFile.c_str ()) != INVALID_FILE_ATTRIBUTES)
2183
2183
{
@@ -2371,12 +2371,12 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
2371
2371
wprintf (L" \n " );
2372
2372
fflush (stdout);
2373
2373
2374
- if (dwOptions & (1 << OPT_TOLOWER))
2374
+ if (dwOptions & (1u << OPT_TOLOWER))
2375
2375
{
2376
2376
std::transform (outputFile.begin (), outputFile.end (), outputFile.begin (), towlower);
2377
2377
}
2378
2378
2379
- if (~dwOptions & (1 << OPT_OVERWRITE))
2379
+ if (~dwOptions & (1u << OPT_OVERWRITE))
2380
2380
{
2381
2381
if (GetFileAttributesW (outputFile.c_str ()) != INVALID_FILE_ATTRIBUTES)
2382
2382
{
@@ -2386,7 +2386,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
2386
2386
}
2387
2387
2388
2388
hr = SaveToDDSFile (result.GetImages (), result.GetImageCount (), result.GetMetadata (),
2389
- (dwOptions & (1 << OPT_USE_DX10)) ? (DDS_FLAGS_FORCE_DX10_EXT | DDS_FLAGS_FORCE_DX10_EXT_MISC2) : DDS_FLAGS_NONE,
2389
+ (dwOptions & (1u << OPT_USE_DX10)) ? (DDS_FLAGS_FORCE_DX10_EXT | DDS_FLAGS_FORCE_DX10_EXT_MISC2) : DDS_FLAGS_NONE,
2390
2390
outputFile.c_str ());
2391
2391
if (FAILED (hr))
2392
2392
{
@@ -2429,12 +2429,12 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
2429
2429
wprintf (L" \n " );
2430
2430
fflush (stdout);
2431
2431
2432
- if (dwOptions & (1 << OPT_TOLOWER))
2432
+ if (dwOptions & (1u << OPT_TOLOWER))
2433
2433
{
2434
2434
std::transform (outputFile.begin (), outputFile.end (), outputFile.begin (), towlower);
2435
2435
}
2436
2436
2437
- if (~dwOptions & (1 << OPT_OVERWRITE))
2437
+ if (~dwOptions & (1u << OPT_OVERWRITE))
2438
2438
{
2439
2439
if (GetFileAttributesW (outputFile.c_str ()) != INVALID_FILE_ATTRIBUTES)
2440
2440
{
@@ -2444,7 +2444,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
2444
2444
}
2445
2445
2446
2446
hr = SaveToDDSFile (result.GetImages (), result.GetImageCount (), result.GetMetadata (),
2447
- (dwOptions & (1 << OPT_USE_DX10)) ? (DDS_FLAGS_FORCE_DX10_EXT | DDS_FLAGS_FORCE_DX10_EXT_MISC2) : DDS_FLAGS_NONE,
2447
+ (dwOptions & (1u << OPT_USE_DX10)) ? (DDS_FLAGS_FORCE_DX10_EXT | DDS_FLAGS_FORCE_DX10_EXT_MISC2) : DDS_FLAGS_NONE,
2448
2448
outputFile.c_str ());
2449
2449
if (FAILED (hr))
2450
2450
{
@@ -2518,7 +2518,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
2518
2518
2519
2519
case CMD_ARRAY:
2520
2520
case CMD_GIF:
2521
- hr = result.InitializeArrayFromImages (&imageArray[0 ], imageArray.size (), (dwOptions & (1 << OPT_USE_DX10)) != 0 );
2521
+ hr = result.InitializeArrayFromImages (&imageArray[0 ], imageArray.size (), (dwOptions & (1u << OPT_USE_DX10)) != 0 );
2522
2522
break ;
2523
2523
2524
2524
case CMD_CUBE:
@@ -2542,12 +2542,12 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
2542
2542
wprintf (L" \n " );
2543
2543
fflush (stdout);
2544
2544
2545
- if (dwOptions & (1 << OPT_TOLOWER))
2545
+ if (dwOptions & (1u << OPT_TOLOWER))
2546
2546
{
2547
2547
std::transform (outputFile.begin (), outputFile.end (), outputFile.begin (), towlower);
2548
2548
}
2549
2549
2550
- if (~dwOptions & (1 << OPT_OVERWRITE))
2550
+ if (~dwOptions & (1u << OPT_OVERWRITE))
2551
2551
{
2552
2552
if (GetFileAttributesW (outputFile.c_str ()) != INVALID_FILE_ATTRIBUTES)
2553
2553
{
@@ -2557,7 +2557,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
2557
2557
}
2558
2558
2559
2559
hr = SaveToDDSFile (result.GetImages (), result.GetImageCount (), result.GetMetadata (),
2560
- (dwOptions & (1 << OPT_USE_DX10)) ? (DDS_FLAGS_FORCE_DX10_EXT | DDS_FLAGS_FORCE_DX10_EXT_MISC2) : DDS_FLAGS_NONE,
2560
+ (dwOptions & (1u << OPT_USE_DX10)) ? (DDS_FLAGS_FORCE_DX10_EXT | DDS_FLAGS_FORCE_DX10_EXT_MISC2) : DDS_FLAGS_NONE,
2561
2561
outputFile.c_str ());
2562
2562
if (FAILED (hr))
2563
2563
{
0 commit comments