diff mbox series

[FFmpeg-devel] avcodec/mv30: fix warning: suggest braces around initialization of subobject [-Wmissing-braces]

Message ID 1589296159-30676-1-git-send-email-lance.lmwang@gmail.com
State Accepted
Commit b1cc6b9496ee6373f7ef46b825b886ffecc09d92
Headers show
Series [FFmpeg-devel] avcodec/mv30: fix warning: suggest braces around initialization of subobject [-Wmissing-braces] | expand

Checks

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

Commit Message

Lance Wang May 12, 2020, 3:09 p.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavcodec/mv30.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Lance Wang May 14, 2020, 1:14 a.m. UTC | #1
On Tue, May 12, 2020 at 11:09:19PM +0800, lance.lmwang@gmail.com wrote:
> From: Limin Wang <lance.lmwang@gmail.com>
> 
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  libavcodec/mv30.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/mv30.c b/libavcodec/mv30.c
> index fed9bcd..7e67133 100644
> --- a/libavcodec/mv30.c
> +++ b/libavcodec/mv30.c
> @@ -421,7 +421,7 @@ static int decode_intra(AVCodecContext *avctx, GetBitContext *gb, AVFrame *frame
>  
>      for (int y = 0; y < avctx->height; y += 16) {
>          GetByteContext gbyte;
> -        int pfill[3][1] = { 0 };
> +        int pfill[3][1] = { {0} };
>          int nb_codes = get_bits(gb, 16);
>  
>          av_fast_padded_malloc(&s->coeffs, &s->coeffs_size, nb_codes * sizeof(*s->coeffs));
> @@ -504,7 +504,7 @@ static int decode_inter(AVCodecContext *avctx, GetBitContext *gb,
>  
>      for (int y = 0; y < avctx->height; y += 16) {
>          GetByteContext gbyte;
> -        int pfill[3][1] = { 0 };
> +        int pfill[3][1] = { {0} };
>          int nb_codes = get_bits(gb, 16);
>  
>          skip_bits(gb, 8);
> -- 
> 1.8.3.1
> 

will apply.
Lance Wang May 30, 2020, 11:28 a.m. UTC | #2
On Tue, May 12, 2020 at 11:09:19PM +0800, lance.lmwang@gmail.com wrote:
> From: Limin Wang <lance.lmwang@gmail.com>
> 
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  libavcodec/mv30.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/mv30.c b/libavcodec/mv30.c
> index fed9bcd..7e67133 100644
> --- a/libavcodec/mv30.c
> +++ b/libavcodec/mv30.c
> @@ -421,7 +421,7 @@ static int decode_intra(AVCodecContext *avctx, GetBitContext *gb, AVFrame *frame
>  
>      for (int y = 0; y < avctx->height; y += 16) {
>          GetByteContext gbyte;
> -        int pfill[3][1] = { 0 };
> +        int pfill[3][1] = { {0} };
>          int nb_codes = get_bits(gb, 16);
>  
>          av_fast_padded_malloc(&s->coeffs, &s->coeffs_size, nb_codes * sizeof(*s->coeffs));
> @@ -504,7 +504,7 @@ static int decode_inter(AVCodecContext *avctx, GetBitContext *gb,
>  
>      for (int y = 0; y < avctx->height; y += 16) {
>          GetByteContext gbyte;
> -        int pfill[3][1] = { 0 };
> +        int pfill[3][1] = { {0} };
>          int nb_codes = get_bits(gb, 16);
>  
>          skip_bits(gb, 8);
> -- 
> 1.8.3.1
> 

will apply it tomorow if no objection.
Nicolas George May 30, 2020, 11:34 a.m. UTC | #3
lance.lmwang@gmail.com (12020-05-30):
> > -        int pfill[3][1] = { 0 };
> > +        int pfill[3][1] = { {0} };

> will apply it tomorow if no objection.

This warning is bogus, the code is valid and a common pattern in FFmpeg.
IIRC, we decided to keep it that way when it happens.

Regards,
Lance Wang May 30, 2020, 12:02 p.m. UTC | #4
On Sat, May 30, 2020 at 01:34:03PM +0200, Nicolas George wrote:
> lance.lmwang@gmail.com (12020-05-30):
> > > -        int pfill[3][1] = { 0 };
> > > +        int pfill[3][1] = { {0} };
> 
> > will apply it tomorow if no objection.
> 
> This warning is bogus, the code is valid and a common pattern in FFmpeg.
> IIRC, we decided to keep it that way when it happens.

Thanks for the explanation. It's difficult to know it's been discussed before.

> 
> Regards,
> 
> -- 
>   Nicolas George



> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Michael Niedermayer May 30, 2020, 6:54 p.m. UTC | #5
On Sat, May 30, 2020 at 01:34:03PM +0200, Nicolas George wrote:
> lance.lmwang@gmail.com (12020-05-30):
> > > -        int pfill[3][1] = { 0 };
> > > +        int pfill[3][1] = { {0} };
> 
> > will apply it tomorow if no objection.
> 
> This warning is bogus, the code is valid 

agree


> and a common pattern in FFmpeg.


> IIRC, we decided to keep it that way when it happens.

i do remember adding {} to these kind of cases so as to
eliminate the related warnings when i see one in code iam
working on at least

the reason why i tend to do that is so there are fewer meaningless
warnings, that way warnings pointing to real issues are easier to spot

if these warnings are not fixed, then ideally they should be suppressed
by some other means like compiler flags
so they do not distract from real issues

thx

[...]
Nicolas George May 30, 2020, 7:03 p.m. UTC | #6
Michael Niedermayer (12020-05-30):
> if these warnings are not fixed, then ideally they should be suppressed
> by some other means like compiler flags
> so they do not distract from real issues

That would be best. IIRC, the discussion arose when we considered adding
the braces but it actually depended on the system-dependant definition
of the structure. This warning is just bogus, ={0} is always valid.

Regards,
diff mbox series

Patch

diff --git a/libavcodec/mv30.c b/libavcodec/mv30.c
index fed9bcd..7e67133 100644
--- a/libavcodec/mv30.c
+++ b/libavcodec/mv30.c
@@ -421,7 +421,7 @@  static int decode_intra(AVCodecContext *avctx, GetBitContext *gb, AVFrame *frame
 
     for (int y = 0; y < avctx->height; y += 16) {
         GetByteContext gbyte;
-        int pfill[3][1] = { 0 };
+        int pfill[3][1] = { {0} };
         int nb_codes = get_bits(gb, 16);
 
         av_fast_padded_malloc(&s->coeffs, &s->coeffs_size, nb_codes * sizeof(*s->coeffs));
@@ -504,7 +504,7 @@  static int decode_inter(AVCodecContext *avctx, GetBitContext *gb,
 
     for (int y = 0; y < avctx->height; y += 16) {
         GetByteContext gbyte;
-        int pfill[3][1] = { 0 };
+        int pfill[3][1] = { {0} };
         int nb_codes = get_bits(gb, 16);
 
         skip_bits(gb, 8);