From patchwork Wed May 8 13:27:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sascha Hauer X-Patchwork-Id: 2538991 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id A99EC3FE1F for ; Wed, 8 May 2013 13:28:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754550Ab3EHN17 (ORCPT ); Wed, 8 May 2013 09:27:59 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:39873 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752186Ab3EHN16 (ORCPT ); Wed, 8 May 2013 09:27:58 -0400 Received: from dude.hi.pengutronix.de ([2001:6f8:1178:2:21e:67ff:fe11:9c5c]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1Ua4PV-00087H-2q; Wed, 08 May 2013 15:27:57 +0200 Received: from sha by dude.hi.pengutronix.de with local (Exim 4.80) (envelope-from ) id 1Ua4PU-0005hK-6l; Wed, 08 May 2013 15:27:56 +0200 From: Sascha Hauer To: Laurent Pinchart Cc: linux-media@vger.kernel.org, Sascha Hauer Subject: [PATCH 1/2] Print more detailed parse error messages Date: Wed, 8 May 2013 15:27:53 +0200 Message-Id: <1368019674-25761-2-git-send-email-s.hauer@pengutronix.de> X-Mailer: git-send-email 1.8.2.rc2 In-Reply-To: <1368019674-25761-1-git-send-email-s.hauer@pengutronix.de> References: <1368019674-25761-1-git-send-email-s.hauer@pengutronix.de> X-SA-Exim-Connect-IP: 2001:6f8:1178:2:21e:67ff:fe11:9c5c X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-media@vger.kernel.org Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The following errors usually resulted in the same 'Unable to parse link' message: - one of the given entities does not exist - one of the pads of a given entity does not exist - No link exists between given pads - syntax error in link description Add more detailed error messages to give the user a clue what is going wrong. Signed-off-by: Sascha Hauer --- src/mediactl.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/src/mediactl.c b/src/mediactl.c index 4783a58..c65de50 100644 --- a/src/mediactl.c +++ b/src/mediactl.c @@ -537,31 +537,42 @@ struct media_pad *media_parse_pad(struct media_device *media, if (*p == '"') { for (end = (char *)p + 1; *end && *end != '"'; ++end); - if (*end != '"') + if (*end != '"') { + media_dbg(media, "missing matching '\"'\n"); return NULL; + } entity = media_get_entity_by_name(media, p + 1, end - p - 1); - if (entity == NULL) + if (entity == NULL) { + media_dbg(media, "no such entity \"%.*s\"\n", end - p - 1, p + 1); return NULL; + } ++end; } else { entity_id = strtoul(p, &end, 10); entity = media_get_entity_by_id(media, entity_id); - if (entity == NULL) + if (entity == NULL) { + media_dbg(media, "no such entity %d\n", entity_id); return NULL; + } } for (; isspace(*end); ++end); - if (*end != ':') + if (*end != ':') { + media_dbg(media, "Expected ':'\n", *end); return NULL; + } + for (p = end + 1; isspace(*p); ++p); pad = strtoul(p, &end, 10); - for (p = end; isspace(*p); ++p); - if (pad >= entity->info.pads) + if (pad >= entity->info.pads) { + media_dbg(media, "No pad '%d' on entity \"%s\". Maximum pad number is %d\n", + pad, entity->info.name, entity->info.pads - 1); return NULL; + } for (p = end; isspace(*p); ++p); if (endp) @@ -583,8 +594,11 @@ struct media_link *media_parse_link(struct media_device *media, if (source == NULL) return NULL; - if (end[0] != '-' || end[1] != '>') + if (end[0] != '-' || end[1] != '>') { + media_dbg(media, "Expected '->'\n"); return NULL; + } + p = end + 2; sink = media_parse_pad(media, p, &end); @@ -600,6 +614,9 @@ struct media_link *media_parse_link(struct media_device *media, return link; } + media_dbg(media, "No link between \"%s\":%d and \"%s\":%d\n", + source->entity->info.name, source->index, + sink->entity->info.name, sink->index); return NULL; } @@ -619,14 +636,14 @@ int media_parse_setup_link(struct media_device *media, p = end; if (*p++ != '[') { - media_dbg(media, "Unable to parse link flags\n"); + media_dbg(media, "Unable to parse link flags: expected '['.\n"); return -EINVAL; } flags = strtoul(p, &end, 10); for (p = end; isspace(*p); p++); if (*p++ != ']') { - media_dbg(media, "Unable to parse link flags\n"); + media_dbg(media, "Unable to parse link flags: expected ']'.\n"); return -EINVAL; }