aboutsummaryrefslogtreecommitdiffstats
path: root/utils/rds-ctl/rds-ctl.cpp
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2017-11-27 16:39:03 +0100
committerHans Verkuil <hans.verkuil@cisco.com>2017-11-27 16:39:03 +0100
commit45722ce368eec47123e3e7a16bdeeb50dadcc00a (patch)
tree9b8a2eaa4ccdd834063c23dba6891c2df88ca91a /utils/rds-ctl/rds-ctl.cpp
parent90f5b0fa7afaddb0c4a992bf3f13dd375bb0c846 (diff)
cec/rds/v4l2-ctl: fix --list-devices option
All three utilities use the 'files.erase(iter)' construct inside a for-loop over 'files'. This should be 'iter = files.erase(iter)'. It works by accident only as long as you don't erase the last element, after that iter is suddenly invalid. I discovered this with rds-ctl, but the same problem is in all three utilities. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Diffstat (limited to 'utils/rds-ctl/rds-ctl.cpp')
-rw-r--r--utils/rds-ctl/rds-ctl.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/utils/rds-ctl/rds-ctl.cpp b/utils/rds-ctl/rds-ctl.cpp
index bd9cb836..589c6bb8 100644
--- a/utils/rds-ctl/rds-ctl.cpp
+++ b/utils/rds-ctl/rds-ctl.cpp
@@ -378,20 +378,23 @@ static dev_vec list_devices(void)
/* Iterate through all devices, and remove all non-accessible devices
* and all devices that don't offer the RDS_BLOCK_IO capability */
for (dev_vec::iterator iter = files.begin();
- iter != files.end(); ++iter) {
+ iter != files.end();) {
int fd = open(iter->c_str(), O_RDONLY | O_NONBLOCK);
std::string bus_info;
- if (fd < 0)
+ if (fd < 0) {
+ iter++;
continue;
+ }
memset(&vt, 0, sizeof(vt));
if (ioctl(fd, VIDIOC_G_TUNER, &vt) != 0) {
close(fd);
+ iter++;
continue;
}
/* remove device if it doesn't support rds block I/O */
if (vt.capability & V4L2_TUNER_CAP_RDS_BLOCK_IO)
- valid_devices.push_back(*iter);
+ valid_devices.push_back(*iter++);
else
iter = files.erase(iter);
close(fd);

Privacy Policy