History

media: uapi: v4l: Change V4L2_TYPE_IS_CAPTURE condition

Explicitly compare a buffer type only with valid buffer types, to avoid matching a buffer type outside of the valid buffer type set.

Nas Chung committed 2 years ago

Commit ad2698e1 parent 0af2f6b1 file · +10 −1Browse files

Showing the changes to include/uapi (1 of 1 file). Show all

Unified · Split

include/uapi/linux/videodev2.h+10−1
@@ -153,10 +153,18 @@ enum v4l2_buf_type { · 152 unmodified lines
153 V4L2_BUF_TYPE_SDR_OUTPUT = 12,153 V4L2_BUF_TYPE_SDR_OUTPUT = 12,
154 V4L2_BUF_TYPE_META_CAPTURE = 13,154 V4L2_BUF_TYPE_META_CAPTURE = 13,
155 V4L2_BUF_TYPE_META_OUTPUT = 14,155 V4L2_BUF_TYPE_META_OUTPUT = 14,
156 /*
157 * Note: V4L2_TYPE_IS_VALID and V4L2_TYPE_IS_OUTPUT must
158 * be updated if a new type is added.
159 */
156 /* Deprecated, do not use */160 /* Deprecated, do not use */
157 V4L2_BUF_TYPE_PRIVATE = 0x80,161 V4L2_BUF_TYPE_PRIVATE = 0x80,
158};162};
159 163
164#define V4L2_TYPE_IS_VALID(type) \
165 ((type) >= V4L2_BUF_TYPE_VIDEO_CAPTURE &&\
166 (type) <= V4L2_BUF_TYPE_META_OUTPUT)
167
160#define V4L2_TYPE_IS_MULTIPLANAR(type) \168#define V4L2_TYPE_IS_MULTIPLANAR(type) \
161 ((type) == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE \169 ((type) == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE \
162 || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)170 || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
@@ -171,7 +179,8 @@ enum v4l2_buf_type { · 8 unmodified lines
171 || (type) == V4L2_BUF_TYPE_SDR_OUTPUT \179 || (type) == V4L2_BUF_TYPE_SDR_OUTPUT \
172 || (type) == V4L2_BUF_TYPE_META_OUTPUT)180 || (type) == V4L2_BUF_TYPE_META_OUTPUT)
173 181
174#define V4L2_TYPE_IS_CAPTURE(type) (!V4L2_TYPE_IS_OUTPUT(type))182#define V4L2_TYPE_IS_CAPTURE(type) \
183 (V4L2_TYPE_IS_VALID(type) && !V4L2_TYPE_IS_OUTPUT(type))
175 184
176enum v4l2_tuner_type {185enum v4l2_tuner_type {
177 V4L2_TUNER_RADIO = 1,186 V4L2_TUNER_RADIO = 1,