Re: [PATCH 1/2] Print more detailed parse error messages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, May 08, 2013 at 03:27:53PM +0200, Sascha Hauer wrote:
> 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@xxxxxxxxxxxxxx>
> ---
>  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);

Oops, this maybe should be a separate patch. This is not needed here...

>  
> -	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);

... since eating whitespaces once is enough.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux