From patchwork Tue Aug 16 10:28:02 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1071012 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p7GASaSg018004 for ; Tue, 16 Aug 2011 10:28:36 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751427Ab1HPK2e (ORCPT ); Tue, 16 Aug 2011 06:28:34 -0400 Received: from mga11.intel.com ([192.55.52.93]:6927 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751337Ab1HPK2d (ORCPT ); Tue, 16 Aug 2011 06:28:33 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 16 Aug 2011 03:28:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.67,379,1309762800"; d="scan'208";a="40000698" Received: from unknown (HELO smile) ([10.255.18.93]) by fmsmga002.fm.intel.com with ESMTP; 16 Aug 2011 03:28:32 -0700 Received: from andy by smile with local (Exim 4.76) (envelope-from ) id 1QtGsc-0000Cb-FS; Tue, 16 Aug 2011 13:28:18 +0300 From: Andy Shevchenko To: Laurent Pinchart , linux-media@vger.kernel.org Cc: Andy Shevchenko Subject: [media-ctl][PATCHv2 1/4] libmediactl: restruct error path Date: Tue, 16 Aug 2011 13:28:02 +0300 Message-Id: <6075971b959c2e808cd4ceec6540dc09b101346f.1313490446.git.andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <201108151652.54417.laurent.pinchart@ideasonboard.com> References: <201108151652.54417.laurent.pinchart@ideasonboard.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 16 Aug 2011 10:28:36 +0000 (UTC) Signed-off-by: Andy Shevchenko --- src/media.c | 16 +++++++++------- 1 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/media.c b/src/media.c index e3cab86..050289e 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,9 @@ 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; + if (errno != EINVAL) + ret = -errno; + break; } /* Number of links (for outbound links) plus number of pads (for @@ -281,8 +281,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 +318,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)