diff mbox series

[FFmpeg-devel,4/5] avcodec/dovi_rpuenc: Initialize bl_compat_id

Message ID 20240503215502.1509887-4-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,1/5] avcodec/decode: decode_simple_internal() only implements audio and video | expand

Commit Message

Michael Niedermayer May 3, 2024, 9:55 p.m. UTC
Fixes: CID1596607 Uninitialized scalar variable

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/dovi_rpuenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andreas Rheinhardt May 3, 2024, 10:21 p.m. UTC | #1
Michael Niedermayer:
> Fixes: CID1596607 Uninitialized scalar variable
> 
> Sponsored-by: Sovereign Tech Fund
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/dovi_rpuenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/dovi_rpuenc.c b/libavcodec/dovi_rpuenc.c
> index 7e0292533bd..c5e452957b5 100644
> --- a/libavcodec/dovi_rpuenc.c
> +++ b/libavcodec/dovi_rpuenc.c
> @@ -57,7 +57,7 @@ int ff_dovi_configure(DOVIContext *s, AVCodecContext *avctx)
>      AVDOVIDecoderConfigurationRecord *cfg;
>      const AVDOVIRpuDataHeader *hdr = NULL;
>      const AVFrameSideData *sd;
> -    int dv_profile, dv_level, bl_compat_id;
> +    int dv_profile, dv_level, bl_compat_id = -1;
>      size_t cfg_size;
>      uint64_t pps;
>  

This is unnecessary, as the dv_profile switch is exhaustive (i.e. the
default case is never taken); but if you do this, then you can also
remove the other "bl_compat_id = -1" assignments (which conveys that
everything is treated as invalid unless we found it to have a valid
compatibility id).

- Andreas
Michael Niedermayer May 3, 2024, 11:38 p.m. UTC | #2
On Sat, May 04, 2024 at 12:21:03AM +0200, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > Fixes: CID1596607 Uninitialized scalar variable
> > 
> > Sponsored-by: Sovereign Tech Fund
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavcodec/dovi_rpuenc.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libavcodec/dovi_rpuenc.c b/libavcodec/dovi_rpuenc.c
> > index 7e0292533bd..c5e452957b5 100644
> > --- a/libavcodec/dovi_rpuenc.c
> > +++ b/libavcodec/dovi_rpuenc.c
> > @@ -57,7 +57,7 @@ int ff_dovi_configure(DOVIContext *s, AVCodecContext *avctx)
> >      AVDOVIDecoderConfigurationRecord *cfg;
> >      const AVDOVIRpuDataHeader *hdr = NULL;
> >      const AVFrameSideData *sd;
> > -    int dv_profile, dv_level, bl_compat_id;
> > +    int dv_profile, dv_level, bl_compat_id = -1;
> >      size_t cfg_size;
> >      uint64_t pps;
> >  
> 
> This is unnecessary, as the dv_profile switch is exhaustive (i.e. the
> default case is never taken); but if you do this, then you can also
> remove the other "bl_compat_id = -1" assignments (which conveys that
> everything is treated as invalid unless we found it to have a valid
> compatibility id).

i see
case AV_CODEC_ID_H264: dv_profile = 9;  break;

the dv_profile switch only contains 0 4 7 5 10 8 no 9

what am i missing ?

thx

[...]
Andreas Rheinhardt May 4, 2024, 9:50 a.m. UTC | #3
Michael Niedermayer:
> On Sat, May 04, 2024 at 12:21:03AM +0200, Andreas Rheinhardt wrote:
>> Michael Niedermayer:
>>> Fixes: CID1596607 Uninitialized scalar variable
>>>
>>> Sponsored-by: Sovereign Tech Fund
>>> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
>>> ---
>>>  libavcodec/dovi_rpuenc.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/libavcodec/dovi_rpuenc.c b/libavcodec/dovi_rpuenc.c
>>> index 7e0292533bd..c5e452957b5 100644
>>> --- a/libavcodec/dovi_rpuenc.c
>>> +++ b/libavcodec/dovi_rpuenc.c
>>> @@ -57,7 +57,7 @@ int ff_dovi_configure(DOVIContext *s, AVCodecContext *avctx)
>>>      AVDOVIDecoderConfigurationRecord *cfg;
>>>      const AVDOVIRpuDataHeader *hdr = NULL;
>>>      const AVFrameSideData *sd;
>>> -    int dv_profile, dv_level, bl_compat_id;
>>> +    int dv_profile, dv_level, bl_compat_id = -1;
>>>      size_t cfg_size;
>>>      uint64_t pps;
>>>  
>>
>> This is unnecessary, as the dv_profile switch is exhaustive (i.e. the
>> default case is never taken); but if you do this, then you can also
>> remove the other "bl_compat_id = -1" assignments (which conveys that
>> everything is treated as invalid unless we found it to have a valid
>> compatibility id).
> 
> i see
> case AV_CODEC_ID_H264: dv_profile = 9;  break;
> 
> the dv_profile switch only contains 0 4 7 5 10 8 no 9
> 
> what am i missing ?
> 

Ok, I was wrong. (Well, I could counter that ff_dovi_configure() is
currently not called for H.264 at all, but it would be a waste of time.)

- Andreas
Michael Niedermayer May 4, 2024, 6:26 p.m. UTC | #4
On Sat, May 04, 2024 at 12:21:03AM +0200, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > Fixes: CID1596607 Uninitialized scalar variable
> > 
> > Sponsored-by: Sovereign Tech Fund
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavcodec/dovi_rpuenc.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libavcodec/dovi_rpuenc.c b/libavcodec/dovi_rpuenc.c
> > index 7e0292533bd..c5e452957b5 100644
> > --- a/libavcodec/dovi_rpuenc.c
> > +++ b/libavcodec/dovi_rpuenc.c
> > @@ -57,7 +57,7 @@ int ff_dovi_configure(DOVIContext *s, AVCodecContext *avctx)
> >      AVDOVIDecoderConfigurationRecord *cfg;
> >      const AVDOVIRpuDataHeader *hdr = NULL;
> >      const AVFrameSideData *sd;
> > -    int dv_profile, dv_level, bl_compat_id;
> > +    int dv_profile, dv_level, bl_compat_id = -1;
> >      size_t cfg_size;
> >      uint64_t pps;
> >  
> 
[...]
> default case is never taken); but if you do this, then you can also
> remove the other "bl_compat_id = -1" assignments (which conveys that
> everything is treated as invalid unless we found it to have a valid
> compatibility id).

will apply with the other bl_compat_id = -1 removed

thx

[...]
diff mbox series

Patch

diff --git a/libavcodec/dovi_rpuenc.c b/libavcodec/dovi_rpuenc.c
index 7e0292533bd..c5e452957b5 100644
--- a/libavcodec/dovi_rpuenc.c
+++ b/libavcodec/dovi_rpuenc.c
@@ -57,7 +57,7 @@  int ff_dovi_configure(DOVIContext *s, AVCodecContext *avctx)
     AVDOVIDecoderConfigurationRecord *cfg;
     const AVDOVIRpuDataHeader *hdr = NULL;
     const AVFrameSideData *sd;
-    int dv_profile, dv_level, bl_compat_id;
+    int dv_profile, dv_level, bl_compat_id = -1;
     size_t cfg_size;
     uint64_t pps;