Merge changes Ie4e2908b,I54e62206 into main

* changes:
  anim_diff: normalize `ok = ... && ok` statements
  examples/{webpmux,unicode}: simplify W_CHAR casts
This commit is contained in:
James Zern
2025-07-30 13:54:51 -07:00
committed by Gerrit Code Review
3 changed files with 13 additions and 14 deletions

View File

@@ -137,12 +137,12 @@ static int CompareAnimatedImagePair(const AnimatedImage* const img1,
const int is_multi_frame_image = (img1->num_frames > 1); const int is_multi_frame_image = (img1->num_frames > 1);
uint32_t i; uint32_t i;
ok = CompareValues(img1->canvas_width, img2->canvas_width, ok &= CompareValues(img1->canvas_width, img2->canvas_width,
"Canvas width mismatch") && ok; "Canvas width mismatch");
ok = CompareValues(img1->canvas_height, img2->canvas_height, ok &= CompareValues(img1->canvas_height, img2->canvas_height,
"Canvas height mismatch") && ok; "Canvas height mismatch");
ok = CompareValues(img1->num_frames, img2->num_frames, ok &= CompareValues(img1->num_frames, img2->num_frames,
"Frame count mismatch") && ok; "Frame count mismatch");
if (!ok) return 0; // These are fatal failures, can't proceed. if (!ok) return 0; // These are fatal failures, can't proceed.
if (is_multi_frame_image) { // Checks relevant for multi-frame images only. if (is_multi_frame_image) { // Checks relevant for multi-frame images only.
@@ -155,11 +155,10 @@ static int CompareAnimatedImagePair(const AnimatedImage* const img1,
img2->format == ANIM_GIF && img2->loop_count == 65536)) { img2->format == ANIM_GIF && img2->loop_count == 65536)) {
max_loop_count_workaround = 1; max_loop_count_workaround = 1;
} }
ok = (max_loop_count_workaround || ok &= (max_loop_count_workaround ||
CompareValues(img1->loop_count, img2->loop_count, CompareValues(img1->loop_count, img2->loop_count,
"Loop count mismatch")) && ok; "Loop count mismatch"));
ok = CompareBackgroundColor(img1->bgcolor, img2->bgcolor, ok &= CompareBackgroundColor(img1->bgcolor, img2->bgcolor, premultiply);
premultiply) && ok;
} }
for (i = 0; i < img1->num_frames; ++i) { for (i = 0; i < img1->num_frames; ++i) {

View File

@@ -48,7 +48,7 @@
#define GET_WARGV_OR_NULL() wargv #define GET_WARGV_OR_NULL() wargv
// Release resources. LocalFree() is needed after CommandLineToArgvW(). // Release resources. LocalFree() is needed after CommandLineToArgvW().
#define FREE_WARGV() LOCAL_FREE((W_CHAR** const)wargv) #define FREE_WARGV() LOCAL_FREE((W_CHAR**)wargv)
#define LOCAL_FREE(WARGV) \ #define LOCAL_FREE(WARGV) \
do { \ do { \
if ((WARGV) != NULL) LocalFree(WARGV); \ if ((WARGV) != NULL) LocalFree(WARGV); \

View File

@@ -735,14 +735,14 @@ static int ParseCommandLine(Config* config, const W_CHAR** const unicode_argv) {
} else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "-help")) { } else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "-help")) {
PrintHelp(); PrintHelp();
DeleteConfig(config); DeleteConfig(config);
LOCAL_FREE((W_CHAR** const)unicode_argv); LOCAL_FREE((W_CHAR**)unicode_argv);
exit(0); exit(0);
} else if (!strcmp(argv[i], "-version")) { } else if (!strcmp(argv[i], "-version")) {
const int version = WebPGetMuxVersion(); const int version = WebPGetMuxVersion();
printf("%d.%d.%d\n", printf("%d.%d.%d\n",
(version >> 16) & 0xff, (version >> 8) & 0xff, version & 0xff); (version >> 16) & 0xff, (version >> 8) & 0xff, version & 0xff);
DeleteConfig(config); DeleteConfig(config);
LOCAL_FREE((W_CHAR** const)unicode_argv); LOCAL_FREE((W_CHAR**)unicode_argv);
exit(0); exit(0);
} else if (!strcmp(argv[i], "--")) { } else if (!strcmp(argv[i], "--")) {
if (i < argc - 1) { if (i < argc - 1) {