diff mbox series

[FFmpeg-devel,3/3] avfilter/formats: Remove pointless checks

Message ID 20200910234911.12891-3-andreas.rheinhardt@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,1/3] avfilter/formats: Don't typedef structure a second time
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Sept. 10, 2020, 11:49 p.m. UTC
ff_formats_ref() takes a pointer to an AVFilterFormats and a pointer to
a pointer to an AVFilterFormats as arguments and adds the latter as an
owner to the list pointed to by the former; the latter is hereby always
the address of a list contained in an AVFilterFormatsConfig and can
therefore not be NULL. So remove the check for whether it is NULL; also
do the same for ff_channel_layouts_ref().

Also do the same for the unref functions where argument is never NULL
because it is always the address of an existing lvalue.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavfilter/formats.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Nicolas George Sept. 11, 2020, 9:25 a.m. UTC | #1
Andreas Rheinhardt (12020-09-11):
> ff_formats_ref() takes a pointer to an AVFilterFormats and a pointer to
> a pointer to an AVFilterFormats as arguments and adds the latter as an
> owner to the list pointed to by the former; the latter is hereby always
> the address of a list contained in an AVFilterFormatsConfig and can
> therefore not be NULL. So remove the check for whether it is NULL; also
> do the same for ff_channel_layouts_ref().
> 
> Also do the same for the unref functions where argument is never NULL
> because it is always the address of an existing lvalue.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavfilter/formats.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

LGTM.

Regards,
diff mbox series

Patch

diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 98ff82a887..43c90b9a27 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -269,7 +269,7 @@  do {                                        \
 do {                                                               \
     int idx = -1;                                                  \
                                                                    \
-    if (!ref || !*ref)                                             \
+    if (!*ref)                                                     \
         return;                                                    \
                                                                    \
     FIND_REF_INDEX(ref, idx);                                      \
@@ -495,7 +495,7 @@  AVFilterChannelLayouts *ff_all_channel_counts(void)
 #define FORMATS_REF(f, ref, unref_fn)                                           \
     void *tmp;                                                                  \
                                                                                 \
-    if (!f || !ref)                                                             \
+    if (!f)                                                                     \
         return AVERROR(ENOMEM);                                                 \
                                                                                 \
     tmp = av_realloc_array(f->refs, sizeof(*f->refs), f->refcount + 1);         \