diff mbox series

[FFmpeg-devel,2/4] avcodec/movtextdec: add () to CMP() macro to avoid unexpected behavior

Message ID 20220214193934.22315-2-michael@niedermayer.cc
State Accepted
Commit c182c706589de2b513331c61a8597fa863d4e97f
Headers show
Series [FFmpeg-devel,1/4] avformat/matroskadec: Check duration | 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
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Michael Niedermayer Feb. 14, 2022, 7:39 p.m. UTC
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/movtextdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andreas Rheinhardt Feb. 14, 2022, 7:52 p.m. UTC | #1
Michael Niedermayer:
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/movtextdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
> index 825632ca9b..dc30fdc698 100644
> --- a/libavcodec/movtextdec.c
> +++ b/libavcodec/movtextdec.c
> @@ -263,7 +263,7 @@ static int decode_hclr(const uint8_t *tsmb, MovTextContext *m, uint64_t size)
>  
>  static int styles_equivalent(const StyleBox *a, const StyleBox *b)
>  {
> -#define CMP(field) a->field == b->field
> +#define CMP(field) ((a)->field == (b)->field)
>      return CMP(bold)  && CMP(italic)   && CMP(underline) && CMP(color) &&
>             CMP(alpha) && CMP(fontsize) && CMP(font_id);
>  #undef CMP

LGTM.
(Did you find the issues in patches 2-4 by code inspection or by a
static analyzer?)

- Andreas
Michael Niedermayer Feb. 15, 2022, 1:37 p.m. UTC | #2
On Mon, Feb 14, 2022 at 08:52:52PM +0100, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavcodec/movtextdec.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
> > index 825632ca9b..dc30fdc698 100644
> > --- a/libavcodec/movtextdec.c
> > +++ b/libavcodec/movtextdec.c
> > @@ -263,7 +263,7 @@ static int decode_hclr(const uint8_t *tsmb, MovTextContext *m, uint64_t size)
> >  
> >  static int styles_equivalent(const StyleBox *a, const StyleBox *b)
> >  {
> > -#define CMP(field) a->field == b->field
> > +#define CMP(field) ((a)->field == (b)->field)
> >      return CMP(bold)  && CMP(italic)   && CMP(underline) && CMP(color) &&
> >             CMP(alpha) && CMP(fontsize) && CMP(font_id);
> >  #undef CMP
> 
> LGTM.
> (Did you find the issues in patches 2-4 by code inspection or by a
> static analyzer?)

some old grep commands

[...]
Michael Niedermayer Feb. 25, 2022, 9:21 p.m. UTC | #3
On Mon, Feb 14, 2022 at 08:52:52PM +0100, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavcodec/movtextdec.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
> > index 825632ca9b..dc30fdc698 100644
> > --- a/libavcodec/movtextdec.c
> > +++ b/libavcodec/movtextdec.c
> > @@ -263,7 +263,7 @@ static int decode_hclr(const uint8_t *tsmb, MovTextContext *m, uint64_t size)
> >  
> >  static int styles_equivalent(const StyleBox *a, const StyleBox *b)
> >  {
> > -#define CMP(field) a->field == b->field
> > +#define CMP(field) ((a)->field == (b)->field)
> >      return CMP(bold)  && CMP(italic)   && CMP(underline) && CMP(color) &&
> >             CMP(alpha) && CMP(fontsize) && CMP(font_id);
> >  #undef CMP
> 
> LGTM.

will apply

thx

[...]
diff mbox series

Patch

diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
index 825632ca9b..dc30fdc698 100644
--- a/libavcodec/movtextdec.c
+++ b/libavcodec/movtextdec.c
@@ -263,7 +263,7 @@  static int decode_hclr(const uint8_t *tsmb, MovTextContext *m, uint64_t size)
 
 static int styles_equivalent(const StyleBox *a, const StyleBox *b)
 {
-#define CMP(field) a->field == b->field
+#define CMP(field) ((a)->field == (b)->field)
     return CMP(bold)  && CMP(italic)   && CMP(underline) && CMP(color) &&
            CMP(alpha) && CMP(fontsize) && CMP(font_id);
 #undef CMP