From 86924ed5cda425597b1ca3b073438bb87c330684 Mon Sep 17 00:00:00 2001 From: James Zern Date: Mon, 28 Jul 2025 18:02:39 -0700 Subject: [PATCH 1/2] examples/{webpmux,unicode}: simplify W_CHAR casts in calls to `LOCAL_FREE()`: `(W_CHAR** const) -> (W_CHAR**)`. This will improve formatting when clang-format is applied. Bug: 433996651 Change-Id: I54e62206c83473e9369b8c67fb8d6c44d7808d52 --- examples/unicode.h | 2 +- examples/webpmux.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/unicode.h b/examples/unicode.h index 0831e23c..640d8e7e 100644 --- a/examples/unicode.h +++ b/examples/unicode.h @@ -48,7 +48,7 @@ #define GET_WARGV_OR_NULL() wargv // 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) \ do { \ if ((WARGV) != NULL) LocalFree(WARGV); \ diff --git a/examples/webpmux.c b/examples/webpmux.c index 02818590..be9da672 100644 --- a/examples/webpmux.c +++ b/examples/webpmux.c @@ -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")) { PrintHelp(); DeleteConfig(config); - LOCAL_FREE((W_CHAR** const)unicode_argv); + LOCAL_FREE((W_CHAR**)unicode_argv); exit(0); } else if (!strcmp(argv[i], "-version")) { const int version = WebPGetMuxVersion(); printf("%d.%d.%d\n", (version >> 16) & 0xff, (version >> 8) & 0xff, version & 0xff); DeleteConfig(config); - LOCAL_FREE((W_CHAR** const)unicode_argv); + LOCAL_FREE((W_CHAR**)unicode_argv); exit(0); } else if (!strcmp(argv[i], "--")) { if (i < argc - 1) { From e721627c250224ab9d9f0192213fe555dfd7c432 Mon Sep 17 00:00:00 2001 From: James Zern Date: Mon, 28 Jul 2025 18:11:16 -0700 Subject: [PATCH 2/2] anim_diff: normalize `ok = ... && ok` statements `ok &= ...` is more common in the codebase than `ok = ... && ok` when accumulating a result while unconditionally executing functions. (`ok = ok &&` is used in cases that should short circuit.) In this case multiple checks may fail and their error messages may aid in debugging. This will also improve the formatting when clang-format is applied to the codebase. Bug: 433996651 Change-Id: Ie4e2908b857122d90f6e93f06b10cb48dc86b18e --- examples/anim_diff.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/examples/anim_diff.c b/examples/anim_diff.c index 62cee714..75986971 100644 --- a/examples/anim_diff.c +++ b/examples/anim_diff.c @@ -137,12 +137,12 @@ static int CompareAnimatedImagePair(const AnimatedImage* const img1, const int is_multi_frame_image = (img1->num_frames > 1); uint32_t i; - ok = CompareValues(img1->canvas_width, img2->canvas_width, - "Canvas width mismatch") && ok; - ok = CompareValues(img1->canvas_height, img2->canvas_height, - "Canvas height mismatch") && ok; - ok = CompareValues(img1->num_frames, img2->num_frames, - "Frame count mismatch") && ok; + ok &= CompareValues(img1->canvas_width, img2->canvas_width, + "Canvas width mismatch"); + ok &= CompareValues(img1->canvas_height, img2->canvas_height, + "Canvas height mismatch"); + ok &= CompareValues(img1->num_frames, img2->num_frames, + "Frame count mismatch"); if (!ok) return 0; // These are fatal failures, can't proceed. 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)) { max_loop_count_workaround = 1; } - ok = (max_loop_count_workaround || - CompareValues(img1->loop_count, img2->loop_count, - "Loop count mismatch")) && ok; - ok = CompareBackgroundColor(img1->bgcolor, img2->bgcolor, - premultiply) && ok; + ok &= (max_loop_count_workaround || + CompareValues(img1->loop_count, img2->loop_count, + "Loop count mismatch")); + ok &= CompareBackgroundColor(img1->bgcolor, img2->bgcolor, premultiply); } for (i = 0; i < img1->num_frames; ++i) {