summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2014-03-10 19:49:22 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2014-03-10 19:53:54 +0100
commit45033a900fb0d004b9790f7b9d57045ea7510cd3 (patch)
treeb2e56cc633c39dd17babc79d58ec50883583f0fe
parent87f58c2ed885d636229f7209fde883058433a1ce (diff)
Read errno before media_dbg calls
The media_dbg() in error paths can modify the errno value, leading to the wrong error (or no error at all) being returned. Fix this by reading the errno value before calling media_dbg(). Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r--src/mediactl.c6
-rw-r--r--src/v4l2subdev.c3
2 files changed, 6 insertions, 3 deletions
diff --git a/src/mediactl.c b/src/mediactl.c
index 57cf86b..7b18ca7 100644
--- a/src/mediactl.c
+++ b/src/mediactl.c
@@ -140,9 +140,10 @@ int media_setup_link(struct media_device *media,
ret = ioctl(media->fd, MEDIA_IOC_SETUP_LINK, &ulink);
if (ret == -1) {
+ ret = -errno;
media_dbg(media, "%s: Unable to setup link (%s)\n",
__func__, strerror(errno));
- return -errno;
+ return ret;
}
link->flags = ulink.flags;
@@ -211,12 +212,13 @@ static int media_enum_links(struct media_device *media)
links.links = calloc(entity->info.links, sizeof(struct media_link_desc));
if (ioctl(media->fd, MEDIA_IOC_ENUM_LINKS, &links) < 0) {
+ ret = -errno;
media_dbg(media,
"%s: Unable to enumerate pads and links (%s).\n",
__func__, strerror(errno));
free(links.pads);
free(links.links);
- return -errno;
+ return ret;
}
for (i = 0; i < entity->info.pads; ++i) {
diff --git a/src/v4l2subdev.c b/src/v4l2subdev.c
index 2d45d7f..efc6708 100644
--- a/src/v4l2subdev.c
+++ b/src/v4l2subdev.c
@@ -45,10 +45,11 @@ int v4l2_subdev_open(struct media_entity *entity)
entity->fd = open(entity->devname, O_RDWR);
if (entity->fd == -1) {
+ int ret = -errno;
media_dbg(entity->media,
"%s: Failed to open subdev device node %s\n", __func__,
entity->devname);
- return -errno;
+ return ret;
}
return 0;