aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Zern <jzern@google.com>2024-02-15 18:10:26 -0800
committerJames Zern <jzern@google.com>2024-02-15 18:55:22 -0800
commitf4b9bc9ea1048afc9e6a9e7d2e3a2869b974ea8e (patch)
tree28e6ee87eb44f51ab2802d8a74201d1feadacc30
parent713982b883715c1e953834ebc5bad2295442ab94 (diff)
downloadwebp-f4b9bc9ea1048afc9e6a9e7d2e3a2869b974ea8e.tar.gz
clear -Wextra-semi-stmt warnings
This is available with clang. Clears warnings of the form: warning: empty expression statement has no effect; remove unnecessary ';' to silence this warning [-Wextra-semi-stmt] As a side-effect it also clear a few -Wpedantic warnings with gcc: warning: ISO C does not allow extra ';' outside of a function [-Wpedantic] Change-Id: I9295c767aad475c68b1fbbdff855b0d6650a25f5
-rw-r--r--configure.ac1
-rw-r--r--examples/webpmux.c46
-rw-r--r--src/dsp/dec_sse2.c20
-rw-r--r--src/dsp/filters.c18
-rw-r--r--src/dsp/filters_mips_dsp_r2.c18
-rw-r--r--src/dsp/filters_msa.c12
-rw-r--r--src/dsp/filters_neon.c18
-rw-r--r--src/dsp/filters_sse2.c18
-rw-r--r--src/dsp/lossless_neon.c6
-rw-r--r--src/dsp/rescaler_neon.c2
-rw-r--r--src/dsp/upsampling_sse2.c12
-rw-r--r--src/dsp/upsampling_sse41.c8
-rw-r--r--src/mux/muxedit.c16
-rw-r--r--src/mux/muxread.c20
14 files changed, 120 insertions, 95 deletions
diff --git a/configure.ac b/configure.ac
index 3933a6f0..651c6e9d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -106,6 +106,7 @@ TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wall])
TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wconstant-conversion])
TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wdeclaration-after-statement])
TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wextra])
+TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wextra-semi-stmt])
TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wfloat-conversion])
TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wformat -Wformat-nonliteral])
TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wformat -Wformat-security])
diff --git a/examples/webpmux.c b/examples/webpmux.c
index b61eed6e..9bf45103 100644
--- a/examples/webpmux.c
+++ b/examples/webpmux.c
@@ -150,16 +150,20 @@ static const char* ErrorString(WebPMuxError err) {
}
#define RETURN_IF_ERROR(ERR_MSG) \
- if (err != WEBP_MUX_OK) { \
- fprintf(stderr, ERR_MSG); \
- return err; \
- }
+ do { \
+ if (err != WEBP_MUX_OK) { \
+ fprintf(stderr, ERR_MSG); \
+ return err; \
+ } \
+ } while (0)
#define RETURN_IF_ERROR3(ERR_MSG, FORMAT_STR1, FORMAT_STR2) \
- if (err != WEBP_MUX_OK) { \
- fprintf(stderr, ERR_MSG, FORMAT_STR1, FORMAT_STR2); \
- return err; \
- }
+ do { \
+ if (err != WEBP_MUX_OK) { \
+ fprintf(stderr, ERR_MSG, FORMAT_STR1, FORMAT_STR2); \
+ return err; \
+ } \
+ } while (0)
#define ERROR_GOTO1(ERR_MSG, LABEL) \
do { \
@@ -605,20 +609,26 @@ static int ValidateCommandLine(const CommandLineArguments* const cmd_args,
#define FEATURETYPE_IS_NIL (config->type_ == NIL_FEATURE)
#define CHECK_NUM_ARGS_AT_LEAST(NUM, LABEL) \
- if (argc < i + (NUM)) { \
- fprintf(stderr, "ERROR: Too few arguments for '%s'.\n", argv[i]); \
- goto LABEL; \
- }
+ do { \
+ if (argc < i + (NUM)) { \
+ fprintf(stderr, "ERROR: Too few arguments for '%s'.\n", argv[i]); \
+ goto LABEL; \
+ } \
+ } while (0)
#define CHECK_NUM_ARGS_AT_MOST(NUM, LABEL) \
- if (argc > i + (NUM)) { \
- fprintf(stderr, "ERROR: Too many arguments for '%s'.\n", argv[i]); \
- goto LABEL; \
- }
+ do { \
+ if (argc > i + (NUM)) { \
+ fprintf(stderr, "ERROR: Too many arguments for '%s'.\n", argv[i]); \
+ goto LABEL; \
+ } \
+ } while (0)
#define CHECK_NUM_ARGS_EXACTLY(NUM, LABEL) \
- CHECK_NUM_ARGS_AT_LEAST(NUM, LABEL); \
- CHECK_NUM_ARGS_AT_MOST(NUM, LABEL);
+ do { \
+ CHECK_NUM_ARGS_AT_LEAST(NUM, LABEL); \
+ CHECK_NUM_ARGS_AT_MOST(NUM, LABEL); \
+ } while (0)
// Parses command-line arguments to fill up config object. Also performs some
// semantic checks. unicode_argv contains wchar_t arguments or is null.
diff --git a/src/dsp/dec_sse2.c b/src/dsp/dec_sse2.c
index 01e6bcb6..a0163c37 100644
--- a/src/dsp/dec_sse2.c
+++ b/src/dsp/dec_sse2.c
@@ -259,15 +259,15 @@ static WEBP_INLINE void SignedShift8b_SSE2(__m128i* const x) {
*x = _mm_packs_epi16(lo_1, hi_1);
}
-#define FLIP_SIGN_BIT2(a, b) { \
+#define FLIP_SIGN_BIT2(a, b) do { \
(a) = _mm_xor_si128(a, sign_bit); \
(b) = _mm_xor_si128(b, sign_bit); \
-}
+} while (0)
-#define FLIP_SIGN_BIT4(a, b, c, d) { \
+#define FLIP_SIGN_BIT4(a, b, c, d) do { \
FLIP_SIGN_BIT2(a, b); \
FLIP_SIGN_BIT2(c, d); \
-}
+} while (0)
// input/output is uint8_t
static WEBP_INLINE void GetNotHEV_SSE2(const __m128i* const p1,
@@ -645,12 +645,12 @@ static void SimpleHFilter16i_SSE2(uint8_t* p, int stride, int thresh) {
(m) = _mm_max_epu8(m, MM_ABS(p2, p1)); \
} while (0)
-#define LOAD_H_EDGES4(p, stride, e1, e2, e3, e4) { \
+#define LOAD_H_EDGES4(p, stride, e1, e2, e3, e4) do { \
(e1) = _mm_loadu_si128((__m128i*)&(p)[0 * (stride)]); \
(e2) = _mm_loadu_si128((__m128i*)&(p)[1 * (stride)]); \
(e3) = _mm_loadu_si128((__m128i*)&(p)[2 * (stride)]); \
(e4) = _mm_loadu_si128((__m128i*)&(p)[3 * (stride)]); \
-}
+} while (0)
#define LOADUV_H_EDGE(p, u, v, stride) do { \
const __m128i U = _mm_loadl_epi64((__m128i*)&(u)[(stride)]); \
@@ -658,18 +658,18 @@ static void SimpleHFilter16i_SSE2(uint8_t* p, int stride, int thresh) {
(p) = _mm_unpacklo_epi64(U, V); \
} while (0)
-#define LOADUV_H_EDGES4(u, v, stride, e1, e2, e3, e4) { \
+#define LOADUV_H_EDGES4(u, v, stride, e1, e2, e3, e4) do { \
LOADUV_H_EDGE(e1, u, v, 0 * (stride)); \
LOADUV_H_EDGE(e2, u, v, 1 * (stride)); \
LOADUV_H_EDGE(e3, u, v, 2 * (stride)); \
LOADUV_H_EDGE(e4, u, v, 3 * (stride)); \
-}
+} while (0)
-#define STOREUV(p, u, v, stride) { \
+#define STOREUV(p, u, v, stride) do { \
_mm_storel_epi64((__m128i*)&(u)[(stride)], p); \
(p) = _mm_srli_si128(p, 8); \
_mm_storel_epi64((__m128i*)&(v)[(stride)], p); \
-}
+} while (0)
static WEBP_INLINE void ComplexMask_SSE2(const __m128i* const p1,
const __m128i* const p0,
diff --git a/src/dsp/filters.c b/src/dsp/filters.c
index c1350d5c..ecaf89e2 100644
--- a/src/dsp/filters.c
+++ b/src/dsp/filters.c
@@ -19,14 +19,16 @@
//------------------------------------------------------------------------------
// Helpful macro.
-# define SANITY_CHECK(in, out) \
- assert((in) != NULL); \
- assert((out) != NULL); \
- assert(width > 0); \
- assert(height > 0); \
- assert(stride >= width); \
- assert(row >= 0 && num_rows > 0 && row + num_rows <= height); \
- (void)height; // Silence unused warning.
+#define SANITY_CHECK(in, out) \
+ do { \
+ assert((in) != NULL); \
+ assert((out) != NULL); \
+ assert(width > 0); \
+ assert(height > 0); \
+ assert(stride >= width); \
+ assert(row >= 0 && num_rows > 0 && row + num_rows <= height); \
+ (void)height; /* Silence unused warning. */ \
+ } while (0)
#if !WEBP_NEON_OMIT_C_CODE
static WEBP_INLINE void PredictLine_C(const uint8_t* src, const uint8_t* pred,
diff --git a/src/dsp/filters_mips_dsp_r2.c b/src/dsp/filters_mips_dsp_r2.c
index 9382b128..a12fd842 100644
--- a/src/dsp/filters_mips_dsp_r2.c
+++ b/src/dsp/filters_mips_dsp_r2.c
@@ -24,14 +24,16 @@
//------------------------------------------------------------------------------
// Helpful macro.
-# define SANITY_CHECK(in, out) \
- assert(in != NULL); \
- assert(out != NULL); \
- assert(width > 0); \
- assert(height > 0); \
- assert(stride >= width); \
- assert(row >= 0 && num_rows > 0 && row + num_rows <= height); \
- (void)height; // Silence unused warning.
+#define SANITY_CHECK(in, out) \
+ do { \
+ assert(in != NULL); \
+ assert(out != NULL); \
+ assert(width > 0); \
+ assert(height > 0); \
+ assert(stride >= width); \
+ assert(row >= 0 && num_rows > 0 && row + num_rows <= height); \
+ (void)height; /* Silence unused warning. */ \
+ } while (0)
#define DO_PREDICT_LINE(SRC, DST, LENGTH, INVERSE) do { \
const uint8_t* psrc = (uint8_t*)(SRC); \
diff --git a/src/dsp/filters_msa.c b/src/dsp/filters_msa.c
index 14c437d1..d939d309 100644
--- a/src/dsp/filters_msa.c
+++ b/src/dsp/filters_msa.c
@@ -57,11 +57,13 @@ static WEBP_INLINE void PredictLineInverse0(const uint8_t* src,
// Helpful macro.
#define SANITY_CHECK(in, out) \
- assert(in != NULL); \
- assert(out != NULL); \
- assert(width > 0); \
- assert(height > 0); \
- assert(stride >= width);
+ do { \
+ assert(in != NULL); \
+ assert(out != NULL); \
+ assert(width > 0); \
+ assert(height > 0); \
+ assert(stride >= width); \
+ } while (0)
//------------------------------------------------------------------------------
// Horrizontal filter
diff --git a/src/dsp/filters_neon.c b/src/dsp/filters_neon.c
index 3e6a578e..3d34fcd2 100644
--- a/src/dsp/filters_neon.c
+++ b/src/dsp/filters_neon.c
@@ -21,14 +21,16 @@
//------------------------------------------------------------------------------
// Helpful macros.
-# define SANITY_CHECK(in, out) \
- assert(in != NULL); \
- assert(out != NULL); \
- assert(width > 0); \
- assert(height > 0); \
- assert(stride >= width); \
- assert(row >= 0 && num_rows > 0 && row + num_rows <= height); \
- (void)height; // Silence unused warning.
+#define SANITY_CHECK(in, out) \
+ do { \
+ assert(in != NULL); \
+ assert(out != NULL); \
+ assert(width > 0); \
+ assert(height > 0); \
+ assert(stride >= width); \
+ assert(row >= 0 && num_rows > 0 && row + num_rows <= height); \
+ (void)height; /* Silence unused warning. */ \
+ } while (0)
// load eight u8 and widen to s16
#define U8_TO_S16(A) vreinterpretq_s16_u16(vmovl_u8(A))
diff --git a/src/dsp/filters_sse2.c b/src/dsp/filters_sse2.c
index 5c33ec15..2ad3851b 100644
--- a/src/dsp/filters_sse2.c
+++ b/src/dsp/filters_sse2.c
@@ -23,14 +23,16 @@
//------------------------------------------------------------------------------
// Helpful macro.
-# define SANITY_CHECK(in, out) \
- assert((in) != NULL); \
- assert((out) != NULL); \
- assert(width > 0); \
- assert(height > 0); \
- assert(stride >= width); \
- assert(row >= 0 && num_rows > 0 && row + num_rows <= height); \
- (void)height; // Silence unused warning.
+#define SANITY_CHECK(in, out) \
+ do { \
+ assert((in) != NULL); \
+ assert((out) != NULL); \
+ assert(width > 0); \
+ assert(height > 0); \
+ assert(stride >= width); \
+ assert(row >= 0 && num_rows > 0 && row + num_rows <= height); \
+ (void)height; /* Silence unused warning. */ \
+ } while (0)
static void PredictLineTop_SSE2(const uint8_t* src, const uint8_t* pred,
uint8_t* dst, int length) {
diff --git a/src/dsp/lossless_neon.c b/src/dsp/lossless_neon.c
index ddc9b617..e9960db3 100644
--- a/src/dsp/lossless_neon.c
+++ b/src/dsp/lossless_neon.c
@@ -146,9 +146,9 @@ static void ConvertBGRAToRGB_NEON(const uint32_t* src,
#define LOAD_U32P_AS_U8(IN) vreinterpret_u8_u32(vld1_u32((IN)))
#define LOADQ_U32_AS_U8(IN) vreinterpretq_u8_u32(vdupq_n_u32((IN)))
#define LOADQ_U32P_AS_U8(IN) vreinterpretq_u8_u32(vld1q_u32((IN)))
-#define GET_U8_AS_U32(IN) vget_lane_u32(vreinterpret_u32_u8((IN)), 0);
-#define GETQ_U8_AS_U32(IN) vgetq_lane_u32(vreinterpretq_u32_u8((IN)), 0);
-#define STOREQ_U8_AS_U32P(OUT, IN) vst1q_u32((OUT), vreinterpretq_u32_u8((IN)));
+#define GET_U8_AS_U32(IN) vget_lane_u32(vreinterpret_u32_u8((IN)), 0)
+#define GETQ_U8_AS_U32(IN) vgetq_lane_u32(vreinterpretq_u32_u8((IN)), 0)
+#define STOREQ_U8_AS_U32P(OUT, IN) vst1q_u32((OUT), vreinterpretq_u32_u8((IN)))
#define ROTATE32_LEFT(L) vextq_u8((L), (L), 12) // D|C|B|A -> C|B|A|D
static WEBP_INLINE uint8x8_t Average2_u8_NEON(uint32_t a0, uint32_t a1) {
diff --git a/src/dsp/rescaler_neon.c b/src/dsp/rescaler_neon.c
index b976a852..957a92db 100644
--- a/src/dsp/rescaler_neon.c
+++ b/src/dsp/rescaler_neon.c
@@ -32,7 +32,7 @@
#define STORE_32x8(SRC0, SRC1, DST) do { \
vst1q_u32((DST) + 0, SRC0); \
vst1q_u32((DST) + 4, SRC1); \
-} while (0);
+} while (0)
#if (WEBP_RESCALER_RFIX == 32)
#define MAKE_HALF_CST(C) vdupq_n_s32((int32_t)((C) >> 1))
diff --git a/src/dsp/upsampling_sse2.c b/src/dsp/upsampling_sse2.c
index 08b6d0b1..77b4f722 100644
--- a/src/dsp/upsampling_sse2.c
+++ b/src/dsp/upsampling_sse2.c
@@ -58,7 +58,7 @@
} while (0)
// Loads 17 pixels each from rows r1 and r2 and generates 32 pixels.
-#define UPSAMPLE_32PIXELS(r1, r2, out) { \
+#define UPSAMPLE_32PIXELS(r1, r2, out) do { \
const __m128i one = _mm_set1_epi8(1); \
const __m128i a = _mm_loadu_si128((const __m128i*)&(r1)[0]); \
const __m128i b = _mm_loadu_si128((const __m128i*)&(r1)[1]); \
@@ -85,7 +85,7 @@
/* pack the alternate pixels */ \
PACK_AND_STORE(a, b, diag1, diag2, (out) + 0); /* store top */ \
PACK_AND_STORE(c, d, diag2, diag1, (out) + 2 * 32); /* store bottom */ \
-}
+} while (0)
// Turn the macro into a function for reducing code-size when non-critical
static void Upsample32Pixels_SSE2(const uint8_t r1[], const uint8_t r2[],
@@ -229,11 +229,11 @@ static void FUNC_NAME(const uint8_t* y, const uint8_t* u, const uint8_t* v, \
} \
}
-YUV444_FUNC(Yuv444ToRgba_SSE2, VP8YuvToRgba32_SSE2, WebPYuv444ToRgba_C, 4);
-YUV444_FUNC(Yuv444ToBgra_SSE2, VP8YuvToBgra32_SSE2, WebPYuv444ToBgra_C, 4);
+YUV444_FUNC(Yuv444ToRgba_SSE2, VP8YuvToRgba32_SSE2, WebPYuv444ToRgba_C, 4)
+YUV444_FUNC(Yuv444ToBgra_SSE2, VP8YuvToBgra32_SSE2, WebPYuv444ToBgra_C, 4)
#if !defined(WEBP_REDUCE_CSP)
-YUV444_FUNC(Yuv444ToRgb_SSE2, VP8YuvToRgb32_SSE2, WebPYuv444ToRgb_C, 3);
-YUV444_FUNC(Yuv444ToBgr_SSE2, VP8YuvToBgr32_SSE2, WebPYuv444ToBgr_C, 3);
+YUV444_FUNC(Yuv444ToRgb_SSE2, VP8YuvToRgb32_SSE2, WebPYuv444ToRgb_C, 3)
+YUV444_FUNC(Yuv444ToBgr_SSE2, VP8YuvToBgr32_SSE2, WebPYuv444ToBgr_C, 3)
YUV444_FUNC(Yuv444ToArgb_SSE2, VP8YuvToArgb32_SSE2, WebPYuv444ToArgb_C, 4)
YUV444_FUNC(Yuv444ToRgba4444_SSE2, VP8YuvToRgba444432_SSE2, \
WebPYuv444ToRgba4444_C, 2)
diff --git a/src/dsp/upsampling_sse41.c b/src/dsp/upsampling_sse41.c
index 648d4560..e38c88d5 100644
--- a/src/dsp/upsampling_sse41.c
+++ b/src/dsp/upsampling_sse41.c
@@ -60,7 +60,7 @@
} while (0)
// Loads 17 pixels each from rows r1 and r2 and generates 32 pixels.
-#define UPSAMPLE_32PIXELS(r1, r2, out) { \
+#define UPSAMPLE_32PIXELS(r1, r2, out) do { \
const __m128i one = _mm_set1_epi8(1); \
const __m128i a = _mm_loadu_si128((const __m128i*)&(r1)[0]); \
const __m128i b = _mm_loadu_si128((const __m128i*)&(r1)[1]); \
@@ -87,7 +87,7 @@
/* pack the alternate pixels */ \
PACK_AND_STORE(a, b, diag1, diag2, (out) + 0); /* store top */ \
PACK_AND_STORE(c, d, diag2, diag1, (out) + 2 * 32); /* store bottom */ \
-}
+} while (0)
// Turn the macro into a function for reducing code-size when non-critical
static void Upsample32Pixels_SSE41(const uint8_t r1[], const uint8_t r2[],
@@ -217,8 +217,8 @@ static void FUNC_NAME(const uint8_t* y, const uint8_t* u, const uint8_t* v, \
}
#if !defined(WEBP_REDUCE_CSP)
-YUV444_FUNC(Yuv444ToRgb_SSE41, VP8YuvToRgb32_SSE41, WebPYuv444ToRgb_C, 3);
-YUV444_FUNC(Yuv444ToBgr_SSE41, VP8YuvToBgr32_SSE41, WebPYuv444ToBgr_C, 3);
+YUV444_FUNC(Yuv444ToRgb_SSE41, VP8YuvToRgb32_SSE41, WebPYuv444ToRgb_C, 3)
+YUV444_FUNC(Yuv444ToBgr_SSE41, VP8YuvToBgr32_SSE41, WebPYuv444ToBgr_C, 3)
#endif // WEBP_REDUCE_CSP
WEBP_TSAN_IGNORE_FUNCTION void WebPInitYUV444ConvertersSSE41(void) {
diff --git a/src/mux/muxedit.c b/src/mux/muxedit.c
index aab479cc..48c6834a 100644
--- a/src/mux/muxedit.c
+++ b/src/mux/muxedit.c
@@ -66,14 +66,16 @@ void WebPMuxDelete(WebPMux* mux) {
// Handy MACRO, makes MuxSet() very symmetric to MuxGet().
#define SWITCH_ID_LIST(INDEX, LIST) \
- if (idx == (INDEX)) { \
- err = ChunkAssignData(&chunk, data, copy_data, tag); \
- if (err == WEBP_MUX_OK) { \
- err = ChunkSetHead(&chunk, (LIST)); \
- if (err != WEBP_MUX_OK) ChunkRelease(&chunk); \
+ do { \
+ if (idx == (INDEX)) { \
+ err = ChunkAssignData(&chunk, data, copy_data, tag); \
+ if (err == WEBP_MUX_OK) { \
+ err = ChunkSetHead(&chunk, (LIST)); \
+ if (err != WEBP_MUX_OK) ChunkRelease(&chunk); \
+ } \
+ return err; \
} \
- return err; \
- }
+ } while (0)
static WebPMuxError MuxSet(WebPMux* const mux, uint32_t tag,
const WebPData* const data, int copy_data) {
diff --git a/src/mux/muxread.c b/src/mux/muxread.c
index 9862ec68..37ddd901 100644
--- a/src/mux/muxread.c
+++ b/src/mux/muxread.c
@@ -21,16 +21,18 @@
// Handy MACRO.
#define SWITCH_ID_LIST(INDEX, LIST) \
- if (idx == (INDEX)) { \
- const WebPChunk* const chunk = ChunkSearchList((LIST), nth, \
- kChunks[(INDEX)].tag); \
- if (chunk) { \
- *data = chunk->data_; \
- return WEBP_MUX_OK; \
- } else { \
- return WEBP_MUX_NOT_FOUND; \
+ do { \
+ if (idx == (INDEX)) { \
+ const WebPChunk* const chunk = ChunkSearchList((LIST), nth, \
+ kChunks[(INDEX)].tag); \
+ if (chunk) { \
+ *data = chunk->data_; \
+ return WEBP_MUX_OK; \
+ } else { \
+ return WEBP_MUX_NOT_FOUND; \
+ } \
} \
- }
+ } while (0)
static WebPMuxError MuxGet(const WebPMux* const mux, CHUNK_INDEX idx,
uint32_t nth, WebPData* const data) {