diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2011-09-05 18:24:03 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2011-09-06 12:16:41 +0200 |
commit | 9abe990480a602ff076caa1010edee033e74b54c (patch) | |
tree | 074bffe2f9495c03dd62842d819d863f0738c0e7 /src | |
parent | cefd89c8b444e76e663b63734cf3c55b315ceb9f (diff) |
libmediactl: restruct error path
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
[laurent.pinchart@ideasonboard.com: Fix return value at end of
enumeration]
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/media.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/media.c b/src/media.c index e3cab86..3819b69 100644 --- a/src/media.c +++ b/src/media.c @@ -255,7 +255,7 @@ static int media_enum_entities(struct media_device *media) char target[1024]; char *p; __u32 id; - int ret; + int ret = 0; for (id = 0; ; id = entity->info.id) { size = (media->entities_count + 1) * sizeof(*media->entities); @@ -268,9 +268,8 @@ static int media_enum_entities(struct media_device *media) ret = ioctl(media->fd, MEDIA_IOC_ENUM_ENTITIES, &entity->info); if (ret < 0) { - if (errno == EINVAL) - break; - return -errno; + ret = errno != EINVAL ? -errno : 0; + break; } /* Number of links (for outbound links) plus number of pads (for @@ -281,8 +280,10 @@ static int media_enum_entities(struct media_device *media) entity->pads = malloc(entity->info.pads * sizeof(*entity->pads)); entity->links = malloc(entity->max_links * sizeof(*entity->links)); - if (entity->pads == NULL || entity->links == NULL) - return -ENOMEM; + if (entity->pads == NULL || entity->links == NULL) { + ret = -ENOMEM; + break; + } media->entities_count++; @@ -316,7 +317,7 @@ static int media_enum_entities(struct media_device *media) strcpy(entity->devname, devname); } - return 0; + return ret; } struct media_device *media_open(const char *name, int verbose) |