diff mbox series

[FFmpeg-devel,2/6] avutil/common: add parenthesis around GET_16BIT in GET_UTF16

Message ID 20200129233235.3325-2-cus@passwd.hu
State New
Headers show
Series [FFmpeg-devel,1/6] avutil/common: use unsigned int in GET_UTF8
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Marton Balint Jan. 29, 2020, 11:32 p.m. UTC
Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavutil/common.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Paul B Mahol Jan. 30, 2020, 10:43 a.m. UTC | #1
why?

On 1/30/20, Marton Balint <cus@passwd.hu> wrote:
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
>  libavutil/common.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libavutil/common.h b/libavutil/common.h
> index 5568754bb9..02671190a6 100644
> --- a/libavutil/common.h
> +++ b/libavutil/common.h
> @@ -408,11 +408,11 @@ static av_always_inline av_const int
> av_parity_c(uint32_t v)
>   *                  typically a goto statement.
>   */
>  #define GET_UTF16(val, GET_16BIT, ERROR)\
> -    val = GET_16BIT;\
> +    val = (GET_16BIT);\
>      {\
>          unsigned int hi = val - 0xD800;\
>          if (hi < 0x800) {\
> -            val = GET_16BIT - 0xDC00;\
> +            val = (GET_16BIT) - 0xDC00;\
>              if (val > 0x3FFU || hi > 0x3FFU)\
>                  ERROR\
>              val += (hi<<10) + 0x10000;\
> --
> 2.16.4
>
> _______________________________________________
> 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".
Marton Balint Jan. 30, 2020, 5:12 p.m. UTC | #2
On Thu, 30 Jan 2020, Paul B Mahol wrote:

> why?

Because it is a macro and otherwise operator precedence might 
interfere with what the user would expect. In the second GET_16BIT you 
can't use bitwise operators because their precedence is lower than 
substraction which is used there.

>
> On 1/30/20, Marton Balint <cus@passwd.hu> wrote:
>> Signed-off-by: Marton Balint <cus@passwd.hu>
>> ---
>>  libavutil/common.h | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/libavutil/common.h b/libavutil/common.h
>> index 5568754bb9..02671190a6 100644
>> --- a/libavutil/common.h
>> +++ b/libavutil/common.h
>> @@ -408,11 +408,11 @@ static av_always_inline av_const int
>> av_parity_c(uint32_t v)
>>   *                  typically a goto statement.
>>   */
>>  #define GET_UTF16(val, GET_16BIT, ERROR)\
>> -    val = GET_16BIT;\
>> +    val = (GET_16BIT);\
>>      {\
>>          unsigned int hi = val - 0xD800;\
>>          if (hi < 0x800) {\
>> -            val = GET_16BIT - 0xDC00;\
>> +            val = (GET_16BIT) - 0xDC00;\
>>              if (val > 0x3FFU || hi > 0x3FFU)\
>>                  ERROR\
>>              val += (hi<<10) + 0x10000;\
>> --
>> 2.16.4
>>
>> _______________________________________________
>> 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".
>
Paul B Mahol Jan. 30, 2020, 5:29 p.m. UTC | #3
On 1/30/20, Marton Balint <cus@passwd.hu> wrote:
>
>
> On Thu, 30 Jan 2020, Paul B Mahol wrote:
>
>> why?
>
> Because it is a macro and otherwise operator precedence might
> interfere with what the user would expect. In the second GET_16BIT you
> can't use bitwise operators because their precedence is lower than
> substraction which is used there.

patch lgtm

>
>>
>> On 1/30/20, Marton Balint <cus@passwd.hu> wrote:
>>> Signed-off-by: Marton Balint <cus@passwd.hu>
>>> ---
>>>  libavutil/common.h | 4 ++--
>>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/libavutil/common.h b/libavutil/common.h
>>> index 5568754bb9..02671190a6 100644
>>> --- a/libavutil/common.h
>>> +++ b/libavutil/common.h
>>> @@ -408,11 +408,11 @@ static av_always_inline av_const int
>>> av_parity_c(uint32_t v)
>>>   *                  typically a goto statement.
>>>   */
>>>  #define GET_UTF16(val, GET_16BIT, ERROR)\
>>> -    val = GET_16BIT;\
>>> +    val = (GET_16BIT);\
>>>      {\
>>>          unsigned int hi = val - 0xD800;\
>>>          if (hi < 0x800) {\
>>> -            val = GET_16BIT - 0xDC00;\
>>> +            val = (GET_16BIT) - 0xDC00;\
>>>              if (val > 0x3FFU || hi > 0x3FFU)\
>>>                  ERROR\
>>>              val += (hi<<10) + 0x10000;\
>>> --
>>> 2.16.4
>>>
>>> _______________________________________________
>>> 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".
>>
> _______________________________________________
> 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".
diff mbox series

Patch

diff --git a/libavutil/common.h b/libavutil/common.h
index 5568754bb9..02671190a6 100644
--- a/libavutil/common.h
+++ b/libavutil/common.h
@@ -408,11 +408,11 @@  static av_always_inline av_const int av_parity_c(uint32_t v)
  *                  typically a goto statement.
  */
 #define GET_UTF16(val, GET_16BIT, ERROR)\
-    val = GET_16BIT;\
+    val = (GET_16BIT);\
     {\
         unsigned int hi = val - 0xD800;\
         if (hi < 0x800) {\
-            val = GET_16BIT - 0xDC00;\
+            val = (GET_16BIT) - 0xDC00;\
             if (val > 0x3FFU || hi > 0x3FFU)\
                 ERROR\
             val += (hi<<10) + 0x10000;\