The result of the last check in code like if (p) foo else p = av_mallocz(sizeof(*p));
if (p->ptr) bar else bar2 is known in advance if the else branch of the first check was taken because av_mallocz() returns zeroed buffers. Therefore the above snippet can be simplified by moving the check and bar into the foo block. Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@gmail.com> --- libavfilter/graphparser.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/libavfilter/graphparser.c b/libavfilter/graphparser.c index a52916a146..f55737f8c7 100644 --- a/libavfilter/graphparser.c +++ b/libavfilter/graphparser.c @@ -266,20 +266,20 @@ static int link_filter_inouts(AVFilterContext *filt_ctx, if (p) { *curr_inputs = (*curr_inputs)->next; p->next = NULL; + if (p->filter_ctx) { + ret = link_filter(p->filter_ctx, p->pad_idx, filt_ctx, pad, log_ctx); + av_freep(&p->name); + av_freep(&p); + if (ret < 0) + return ret; + continue; + } } else if (!(p = av_mallocz(sizeof(*p)))) return AVERROR(ENOMEM); - if (p->filter_ctx) { - ret = link_filter(p->filter_ctx, p->pad_idx, filt_ctx, pad, log_ctx); - av_freep(&p->name); - av_freep(&p); - if (ret < 0) - return ret; - } else { - p->filter_ctx = filt_ctx; - p->pad_idx = pad; - append_inout(open_inputs, &p); - } + p->filter_ctx = filt_ctx; + p->pad_idx = pad; + append_inout(open_inputs, &p); } if (*curr_inputs) { -- 2.20.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".