[FFmpeg-devel] [PATCH 1/9] Change the signature of parse_link_name() to make it return an error code.

Michael Niedermayer michaelni
Sat Nov 6 02:51:26 CET 2010


On Fri, Nov 05, 2010 at 06:20:25PM +0100, Stefano Sabatini wrote:
> ---
>  libavfilter/graphparser.c |   40 ++++++++++++++++++++++------------------
>  1 files changed, 22 insertions(+), 18 deletions(-)
> 
> diff --git a/libavfilter/graphparser.c b/libavfilter/graphparser.c
> index fb70805..caaa505 100644
> --- a/libavfilter/graphparser.c
> +++ b/libavfilter/graphparser.c
> @@ -54,31 +54,36 @@ static int link_filter(AVFilterContext *src, int srcpad,
>  /**
>   * Parse the name of a link, which has the format "[linkname]".
>   *
> - * @return a pointer (that need to be freed after use) to the name
> - * between parenthesis
> + * @param link_name put here a pointer (that need to be freed after
> + * use) to the name between parenthesis, or NULL in case of failure
> + * @return 0 in case of success, or a negative AVERROR code in case of
> + * failure
>   */
> -static char *parse_link_name(const char **buf, AVClass *log_ctx)
> +static int parse_link_name(char **link_name, const char **buf, AVClass *log_ctx)
>  {
>      const char *start = *buf;
> -    char *name;
> +    int ret = 0;
>      (*buf)++;
>  
> -    name = av_get_token(buf, "]");
> +    *link_name = av_get_token(buf, "]");
>  
> -    if (!name[0]) {
> +    if (!*link_name[0]) {
>          av_log(log_ctx, AV_LOG_ERROR,
>                 "Bad (empty?) label found in the following: \"%s\".\n", start);
> +        ret = AVERROR(EINVAL);
>          goto fail;
>      }
>  
>      if (*(*buf)++ != ']') {
>          av_log(log_ctx, AV_LOG_ERROR,
>                 "Mismatched '[' found in the following: \"%s\".\n", start);
> +        ret = AVERROR(EINVAL);
>      fail:
> -        av_freep(&name);
> +        av_freep(link_name);
> +        return ret;
>      }
>  
> -    return name;
> +    return 0;
>  }

there is only one possible kind of error so this complexity is pointless
[...] 

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Complexity theory is the science of finding the exact solution to an
approximation. Benchmarking OTOH is finding an approximation of the exact
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20101106/f4a52ce5/attachment.pgp>



More information about the ffmpeg-devel mailing list