Explicitly compare a buffer type only with valid buffer types, to avoid matching a buffer type outside of the valid buffer type set.
Showing the changes to include/uapi (1 of 1 file). Show all
Unified · Split
| @@ -153,10 +153,18 @@ enum v4l2_buf_type { · 152 unmodified lines | ||
| 153 | 153 | V4L2_BUF_TYPE_SDR_OUTPUT = 12, |
| 154 | 154 | V4L2_BUF_TYPE_META_CAPTURE = 13, |
| 155 | 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 | 160 | /* Deprecated, do not use */ |
| 157 | 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 | 168 | #define V4L2_TYPE_IS_MULTIPLANAR(type) \ |
| 161 | 169 | ((type) == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE \ |
| 162 | 170 | || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) |
| @@ -171,7 +179,8 @@ enum v4l2_buf_type { · 8 unmodified lines | ||
| 171 | 179 | || (type) == V4L2_BUF_TYPE_SDR_OUTPUT \ |
| 172 | 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 | |
| 176 | 185 | enum v4l2_tuner_type { |
| 177 | 186 | V4L2_TUNER_RADIO = 1, |