diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2013-05-08 15:27:53 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2013-06-10 15:30:23 +0200 |
commit | c758a54f7dc56875eb95e410d6695e76aab6fa29 (patch) | |
tree | c2875d93a979f03f5ebf8a7f6247ba84473ad3ad /src/mediactl.c | |
parent | 67b66c052e75645439e230fae81d969c834046ac (diff) |
Print more detailed parse error messages
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 <s.hauer@pengutronix.de>
Diffstat (limited to 'src/mediactl.c')
-rw-r--r-- | src/mediactl.c | 35 |
1 files 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; } |