diff mbox series

[FFmpeg-devel,2/3] avfilter/signature_lookup: Initialize bestmatch

Message ID 20240421230701.4178782-2-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,1/3] avfilter/signature_lookup: Fix 2 differences to the refernce SW | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Michael Niedermayer April 21, 2024, 11:07 p.m. UTC
Fixes: CID1500345 Uninitialized scalar variable

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavfilter/signature_lookup.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Andreas Rheinhardt April 21, 2024, 11:10 p.m. UTC | #1
Michael Niedermayer:
> Fixes: CID1500345 Uninitialized scalar variable
> 
> Sponsored-by: Sovereign Tech Fund
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavfilter/signature_lookup.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/libavfilter/signature_lookup.c b/libavfilter/signature_lookup.c
> index a3086b38cca..dc0a2ef2b24 100644
> --- a/libavfilter/signature_lookup.c
> +++ b/libavfilter/signature_lookup.c
> @@ -535,16 +535,14 @@ static MatchingInfo lookup_signatures(AVFilterContext *ctx, SignatureContext *sc
>  {
>      CoarseSignature *cs, *cs2;
>      MatchingInfo *infos;
> -    MatchingInfo bestmatch;
> +    MatchingInfo bestmatch = {0};
>      MatchingInfo *i;
>  
>      cs = first->coarsesiglist;
>      cs2 = second->coarsesiglist;
>  
>      /* score of bestmatch is 0, if no match is found */
> -    bestmatch.score = 0;
>      bestmatch.meandist = 99999;
> -    bestmatch.whole = 0;
>  
>      fill_l1distlut(sc->l1distlut);
>  

Does this fix an actual bug or just suppress a Coverity warning?

- Andreas
Michael Niedermayer April 22, 2024, 2:09 a.m. UTC | #2
On Mon, Apr 22, 2024 at 01:10:47AM +0200, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > Fixes: CID1500345 Uninitialized scalar variable
> > 
> > Sponsored-by: Sovereign Tech Fund
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavfilter/signature_lookup.c | 4 +---
> >  1 file changed, 1 insertion(+), 3 deletions(-)
> > 
> > diff --git a/libavfilter/signature_lookup.c b/libavfilter/signature_lookup.c
> > index a3086b38cca..dc0a2ef2b24 100644
> > --- a/libavfilter/signature_lookup.c
> > +++ b/libavfilter/signature_lookup.c
> > @@ -535,16 +535,14 @@ static MatchingInfo lookup_signatures(AVFilterContext *ctx, SignatureContext *sc
> >  {
> >      CoarseSignature *cs, *cs2;
> >      MatchingInfo *infos;
> > -    MatchingInfo bestmatch;
> > +    MatchingInfo bestmatch = {0};
> >      MatchingInfo *i;
> >  
> >      cs = first->coarsesiglist;
> >      cs2 = second->coarsesiglist;
> >  
> >      /* score of bestmatch is 0, if no match is found */
> > -    bestmatch.score = 0;
> >      bestmatch.meandist = 99999;
> > -    bestmatch.whole = 0;
> >  
> >      fill_l1distlut(sc->l1distlut);
> >  
> 
> Does this fix an actual bug or just suppress a Coverity warning?

returning partially initialized structs is IMHO bad practice
it is strictly not a bug i guess.
But its similar to not initializing pointers to NULL and then
having to track if all paths initialize them before freeing.

This is similar. With passing partially initialized structs around,
one would have to ensure that nothing is touched that isnt initialized.
Ive marked the issue as false positive now as that is in fact more
correct.

thx

[...]
diff mbox series

Patch

diff --git a/libavfilter/signature_lookup.c b/libavfilter/signature_lookup.c
index a3086b38cca..dc0a2ef2b24 100644
--- a/libavfilter/signature_lookup.c
+++ b/libavfilter/signature_lookup.c
@@ -535,16 +535,14 @@  static MatchingInfo lookup_signatures(AVFilterContext *ctx, SignatureContext *sc
 {
     CoarseSignature *cs, *cs2;
     MatchingInfo *infos;
-    MatchingInfo bestmatch;
+    MatchingInfo bestmatch = {0};
     MatchingInfo *i;
 
     cs = first->coarsesiglist;
     cs2 = second->coarsesiglist;
 
     /* score of bestmatch is 0, if no match is found */
-    bestmatch.score = 0;
     bestmatch.meandist = 99999;
-    bestmatch.whole = 0;
 
     fill_l1distlut(sc->l1distlut);