[FFmpeg-devel] lavc/qsv: suppress code scan complain

Submitted by Zhong Li on May 9, 2018, 6:13 a.m.

Details

Message ID 1525846430-23194-1-git-send-email-zhong.li@intel.com
State New
Headers show

Commit Message

Zhong Li May 9, 2018, 6:13 a.m.
Suppress the complain "variables 'type' is used but maybe uninitialized".

Signed-off-by: Zhong Li <zhong.li@intel.com>
---
 libavcodec/qsv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Mark Thompson May 9, 2018, 2:38 p.m.
On 09/05/18 07:13, Zhong Li wrote:
> Suppress the complain "variables 'type' is used but maybe uninitialized".
> 
> Signed-off-by: Zhong Li <zhong.li@intel.com>
> ---
>  libavcodec/qsv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
> index 45e1c25..b578da0 100644
> --- a/libavcodec/qsv.c
> +++ b/libavcodec/qsv.c
> @@ -197,7 +197,7 @@ int ff_qsv_find_surface_idx(QSVFramesContext *ctx, QSVFrame *frame)
>  
>  enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type)
>  {
> -    enum AVPictureType type;
> +    enum AVPictureType type = AV_PICTURE_TYPE_NONE;
>      switch (mfx_pic_type & 0x7) {
>      case MFX_FRAMETYPE_I:
>          if (mfx_pic_type & MFX_FRAMETYPE_S)
> 

Might it be better to add a default case to the switch and assert that it's never reached?  I think if the pic type doesn't hit one of the existing cases then something must be very broken.

- Mark
Zhong Li May 24, 2018, 2:22 a.m.
> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf

> Of Mark Thompson

> Sent: Wednesday, May 9, 2018 10:39 PM

> To: ffmpeg-devel@ffmpeg.org

> Subject: Re: [FFmpeg-devel] [PATCH] lavc/qsv: suppress code scan complain

> 

> On 09/05/18 07:13, Zhong Li wrote:

> > Suppress the complain "variables 'type' is used but maybe uninitialized".

> >

> > Signed-off-by: Zhong Li <zhong.li@intel.com>

> > ---

> >  libavcodec/qsv.c | 2 +-

> >  1 file changed, 1 insertion(+), 1 deletion(-)

> >

> > diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index

> > 45e1c25..b578da0 100644

> > --- a/libavcodec/qsv.c

> > +++ b/libavcodec/qsv.c

> > @@ -197,7 +197,7 @@ int ff_qsv_find_surface_idx(QSVFramesContext

> *ctx,

> > QSVFrame *frame)

> >

> >  enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type)  {

> > -    enum AVPictureType type;

> > +    enum AVPictureType type = AV_PICTURE_TYPE_NONE;

> >      switch (mfx_pic_type & 0x7) {

> >      case MFX_FRAMETYPE_I:

> >          if (mfx_pic_type & MFX_FRAMETYPE_S)

> >

> 

> Might it be better to add a default case to the switch and assert that it's

> never reached?  I think if the pic type doesn't hit one of the existing cases

> then something must be very broken.


Agree, I've updated it. Thanks for review and sorry for late reply.

> 

> - Mark

Patch hide | download patch | download mbox

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 45e1c25..b578da0 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -197,7 +197,7 @@  int ff_qsv_find_surface_idx(QSVFramesContext *ctx, QSVFrame *frame)
 
 enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type)
 {
-    enum AVPictureType type;
+    enum AVPictureType type = AV_PICTURE_TYPE_NONE;
     switch (mfx_pic_type & 0x7) {
     case MFX_FRAMETYPE_I:
         if (mfx_pic_type & MFX_FRAMETYPE_S)