[FFmpeg-cvslog] avutil/tests/channel_layout: Improve enum range check

Andreas Rheinhardt git at videolan.org
Wed Apr 9 13:20:39 EEST 2025


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Sun Mar 30 16:23:51 2025 +0200| [830fab689153a41fc4491b1add411a628a00fb5a] | committer: Andreas Rheinhardt

avutil/tests/channel_layout: Improve enum range check

Both GCC and Clang use unsigned as underlying type of
an enum with no negative enumeration constants, making
checks like "layout->order >= 0" here tautologically true.
Clang warns about this. Combine both range checks
by casting to unsigned to suppress this warning.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=830fab689153a41fc4491b1add411a628a00fb5a
---

 libavutil/tests/channel_layout.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/tests/channel_layout.c b/libavutil/tests/channel_layout.c
index 8132b83434..e79e4c3611 100644
--- a/libavutil/tests/channel_layout.c
+++ b/libavutil/tests/channel_layout.c
@@ -118,7 +118,7 @@ static const char* channel_order_names[]  = {"UNSPEC", "NATIVE", "CUSTOM", "AMBI
 
 static void describe_type(AVBPrint *bp, AVChannelLayout *layout)
 {
-    if (layout->order >= 0 && layout->order < FF_ARRAY_ELEMS(channel_order_names)) {
+    if ((unsigned)layout->order < FF_ARRAY_ELEMS(channel_order_names)) {
         av_bprintf(bp, "%-6s (", channel_order_names[layout->order]);
         av_channel_layout_describe_bprint(layout, bp);
         av_bprintf(bp, ")");



More information about the ffmpeg-cvslog mailing list