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
153153 V4L2_BUF_TYPE_SDR_OUTPUT = 12,
154154 V4L2_BUF_TYPE_META_CAPTURE = 13,
155155 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+ */
156160 /* Deprecated, do not use */
157161 V4L2_BUF_TYPE_PRIVATE = 0x80,
158162 };
159163
164+#define V4L2_TYPE_IS_VALID(type) \
165+ ((type) >= V4L2_BUF_TYPE_VIDEO_CAPTURE &&\
166+ (type) <= V4L2_BUF_TYPE_META_OUTPUT)
167+
160168 #define V4L2_TYPE_IS_MULTIPLANAR(type) \
161169 ((type) == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE \
162170 || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
@@ -171,7 +179,8 @@ enum v4l2_buf_type { · 8 unmodified lines
171179 || (type) == V4L2_BUF_TYPE_SDR_OUTPUT \
172180 || (type) == V4L2_BUF_TYPE_META_OUTPUT)
173181
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))
175184
176185 enum v4l2_tuner_type {
177186 V4L2_TUNER_RADIO = 1,