Skip to contentSkip to conversation

media-info: ensure -1 is returned when a media device doesn't match

PATCH New Matthew Laux 1 participant 1 message Nov 16 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media-info: ensure -1 is returned when a media device doesn't match

In the case of a non-match, mi_get_media_bus_info() would return the last closed fd number. This led to the "Requests" tests running the "requests are supported" path on a random fd and failing. Set the return value back to -1 to prevent this. This only shows up when testing devices without a media device, when other /dev/mediaN are present.

Fixes 3b412f2890e7 ("v4l2-compliance: the -z/-u options failed to find the media device")
---
 utils/common/media-info.cpp | 2 ++
 1 file changed, 2 insertions(+)
utils/common/media-info.cpp +2 -0
index 6d6d7904..22eb897d 100644
@@ -245,6 +245,7 @@ int mi_get_media_fd(int fd)
 
 			if (ioctl(media_fd, MEDIA_IOC_DEVICE_INFO, &mdinfo)) {
 				close(media_fd);
+				media_fd = -1;
 				continue;
 			}
 			break;
@@ -277,6 +278,7 @@ int mi_get_media_bus_info(const char *bus_info)
 			if (ioctl(media_fd, MEDIA_IOC_DEVICE_INFO, &mdinfo) ||
 			    strcmp(mdinfo.bus_info, bus_info)) {
 				close(media_fd);
+				media_fd = -1;
 				continue;
 			}
 			break;
Signature · 1 line
2.47.3