Add missing {}s to conditionals & loops

This was necessary after:
44257cb8 apply clang-format

Which made some single-line statements into multi-line. Using braces on
multi-line statements better conforms with the Google style guide.

Bug: 433996651
Change-Id: I615c0ecf3b94571f67fceadfe8c15914aea45ccb
This commit is contained in:
James Zern
2025-08-20 16:22:29 -07:00
parent dab2cf21fa
commit 235286fd78
5 changed files with 31 additions and 23 deletions

View File

@@ -235,33 +235,33 @@ int main(int argc, const char* argv[]) {
format = RAW_YUV; format = RAW_YUV;
} else if (!strcmp(argv[c], "-pixel_format") && c < argc - 1) { } else if (!strcmp(argv[c], "-pixel_format") && c < argc - 1) {
const char* const fmt = argv[++c]; const char* const fmt = argv[++c];
if (!strcmp(fmt, "RGB")) if (!strcmp(fmt, "RGB")) {
format = RGB; format = RGB;
else if (!strcmp(fmt, "RGBA")) } else if (!strcmp(fmt, "RGBA")) {
format = RGBA; format = RGBA;
else if (!strcmp(fmt, "BGR")) } else if (!strcmp(fmt, "BGR")) {
format = BGR; format = BGR;
else if (!strcmp(fmt, "BGRA")) } else if (!strcmp(fmt, "BGRA")) {
format = BGRA; format = BGRA;
else if (!strcmp(fmt, "ARGB")) } else if (!strcmp(fmt, "ARGB")) {
format = ARGB; format = ARGB;
else if (!strcmp(fmt, "RGBA_4444")) } else if (!strcmp(fmt, "RGBA_4444")) {
format = RGBA_4444; format = RGBA_4444;
else if (!strcmp(fmt, "RGB_565")) } else if (!strcmp(fmt, "RGB_565")) {
format = RGB_565; format = RGB_565;
else if (!strcmp(fmt, "rgbA")) } else if (!strcmp(fmt, "rgbA")) {
format = rgbA; format = rgbA;
else if (!strcmp(fmt, "bgrA")) } else if (!strcmp(fmt, "bgrA")) {
format = bgrA; format = bgrA;
else if (!strcmp(fmt, "Argb")) } else if (!strcmp(fmt, "Argb")) {
format = Argb; format = Argb;
else if (!strcmp(fmt, "rgbA_4444")) } else if (!strcmp(fmt, "rgbA_4444")) {
format = rgbA_4444; format = rgbA_4444;
else if (!strcmp(fmt, "YUV")) } else if (!strcmp(fmt, "YUV")) {
format = YUV; format = YUV;
else if (!strcmp(fmt, "YUVA")) } else if (!strcmp(fmt, "YUVA")) {
format = YUVA; format = YUVA;
else { } else {
fprintf(stderr, "Can't parse pixel_format %s\n", fmt); fprintf(stderr, "Can't parse pixel_format %s\n", fmt);
parse_error = 1; parse_error = 1;
} }

View File

@@ -121,10 +121,11 @@ static uint16_t FromLinearSrgb(uint32_t value, int bit_depth) {
#define MAX(a, b) (((a) > (b)) ? (a) : (b)) #define MAX(a, b) (((a) > (b)) ? (a) : (b))
static WEBP_INLINE float Roundf(float x) { static WEBP_INLINE float Roundf(float x) {
if (x < 0) if (x < 0) {
return (float)ceil((double)(x - 0.5f)); return (float)ceil((double)(x - 0.5f));
else } else {
return (float)floor((double)(x + 0.5f)); return (float)floor((double)(x + 0.5f));
}
} }
static WEBP_INLINE float Powf(float base, float exp) { static WEBP_INLINE float Powf(float base, float exp) {

View File

@@ -355,22 +355,25 @@ static void ExtractGreen_C(const uint32_t* WEBP_RESTRICT argb,
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
static int HasAlpha8b_C(const uint8_t* src, int length) { static int HasAlpha8b_C(const uint8_t* src, int length) {
while (length-- > 0) while (length-- > 0) {
if (*src++ != 0xff) return 1; if (*src++ != 0xff) return 1;
}
return 0; return 0;
} }
static int HasAlpha32b_C(const uint8_t* src, int length) { static int HasAlpha32b_C(const uint8_t* src, int length) {
int x; int x;
for (x = 0; length-- > 0; x += 4) for (x = 0; length-- > 0; x += 4) {
if (src[x] != 0xff) return 1; if (src[x] != 0xff) return 1;
}
return 0; return 0;
} }
static void AlphaReplace_C(uint32_t* src, int length, uint32_t color) { static void AlphaReplace_C(uint32_t* src, int length, uint32_t color) {
int x; int x;
for (x = 0; x < length; ++x) for (x = 0; x < length; ++x) {
if ((src[x] >> 24) == 0) src[x] = color; if ((src[x] >> 24) == 0) src[x] = color;
}
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

View File

@@ -274,8 +274,9 @@ static int HasAlpha8b_SSE2(const uint8_t* src, int length) {
const int mask = _mm_movemask_epi8(bits); const int mask = _mm_movemask_epi8(bits);
if (mask != 0xffff) return 1; if (mask != 0xffff) return 1;
} }
for (; i < length; ++i) for (; i < length; ++i) {
if (src[i] != 0xff) return 1; if (src[i] != 0xff) return 1;
}
return 0; return 0;
} }
@@ -314,8 +315,9 @@ static int HasAlpha32b_SSE2(const uint8_t* src, int length) {
const int mask = _mm_movemask_epi8(bits); const int mask = _mm_movemask_epi8(bits);
if (mask != 0xffff) return 1; if (mask != 0xffff) return 1;
} }
for (; i <= length; i += 4) for (; i <= length; i += 4) {
if (src[i] != 0xff) return 1; if (src[i] != 0xff) return 1;
}
return 0; return 0;
} }
@@ -337,8 +339,9 @@ static void AlphaReplace_SSE2(uint32_t* src, int length, uint32_t color) {
_mm_storeu_si128((__m128i*)(src + i + 0), _mm_or_si128(d0, e0)); _mm_storeu_si128((__m128i*)(src + i + 0), _mm_or_si128(d0, e0));
_mm_storeu_si128((__m128i*)(src + i + 4), _mm_or_si128(d1, e1)); _mm_storeu_si128((__m128i*)(src + i + 4), _mm_or_si128(d1, e1));
} }
for (; i < length; ++i) for (; i < length; ++i) {
if ((src[i] >> 24) == 0) src[i] = color; if ((src[i] >> 24) == 0) src[i] = color;
}
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

@@ -278,9 +278,10 @@ WebPMux* WebPMuxCreateInternal(const WebPData* bitstream, int copy_data,
ChunkRelease(&chunk); ChunkRelease(&chunk);
goto PushImage; goto PushImage;
default: // A non-image chunk. default: // A non-image chunk.
if (wpi->is_partial) if (wpi->is_partial) {
goto Err; // Encountered a non-image chunk before goto Err; // Encountered a non-image chunk before
// getting all chunks of an image. // getting all chunks of an image.
}
if (chunk_list_ends[id] == NULL) { if (chunk_list_ends[id] == NULL) {
chunk_list_ends[id] = chunk_list_ends[id] =
MuxGetChunkListFromId(mux, id); // List to add this chunk. MuxGetChunkListFromId(mux, id); // List to add this chunk.