History

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.

Andreas Rheinhardt committed 1 year ago

Commit 830fab61 parent 02eda841 file · +1 −1Browse files

Unified · Split

libavutil/tests/channel_layout.c+1−1
@@ -118,7 +118,7 @@ static const char* channel_order_names[] = {"UNSPEC", "NATIVE", "CUSTOM", "AMBI · 117 unmodified lines
118118
119119 static void describe_type(AVBPrint *bp, AVChannelLayout *layout)
120120 {
121− if (layout->order >= 0 && layout->order < FF_ARRAY_ELEMS(channel_order_names)) {
121+ if ((unsigned)layout->order < FF_ARRAY_ELEMS(channel_order_names)) {
122122 av_bprintf(bp, "%-6s (", channel_order_names[layout->order]);
123123 av_channel_layout_describe_bprint(layout, bp);
124124 av_bprintf(bp, ")");

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t