[vlc-devel] [PATCH 4/7] text_renderer: avoid 0xff << 24 with an int type

Felix Abecassis felix.abecassis at gmail.com
Tue May 6 22:45:17 CEST 2014


2014-05-06 22:13 GMT+02:00 Rémi Denis-Courmont <remi at remlab.net>:
> Le mardi 6 mai 2014, 19:08:28 Felix Abecassis a écrit :
>> ---
>>  modules/text_renderer/text_renderer.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/modules/text_renderer/text_renderer.c
>> b/modules/text_renderer/text_renderer.c index 3648581..4119c34 100644
>> --- a/modules/text_renderer/text_renderer.c
>> +++ b/modules/text_renderer/text_renderer.c
>> @@ -398,7 +398,7 @@ int HandleFontAttributes( xml_reader_t *p_xml_reader,
>>      rv = PushFont( p_fonts,
>>                     psz_fontname,
>>                     i_font_size,
>> -                   (i_font_color & 0xffffff) | ((i_font_alpha & 0xff) <<
>> 24),
>> +                   (i_font_color & 0xffffff) |
>> ((uint32_t)(i_font_alpha & 0xff) << 24), i_karaoke_bg_color );
>
> Won't this still fail if uint32_t has a lower rank than int?
> Missing 'u' postfix maybe?
If int has a larger rank that uint32_t I guess it would mean that int
has more precision than uint32_t and thus the left shift operation
should be fine, no?

>
>>
>>      free( psz_fontname );
>> @@ -572,7 +572,7 @@ int ProcessNodes( filter_t *p_filter,
>>                         p_default_style->psz_fontname,
>>                         i_font_size,
>>                         (i_font_color & 0xffffff) |
>> -                          ((i_font_alpha & 0xff) << 24),
>> +                       ((uint32_t)(i_font_alpha & 0xff) << 24),
>>                         0x00ffffff );
>>      }
>>      if( p_default_style->i_style_flags & STYLE_BOLD )
>
> --
> Rémi Denis-Courmont
> http://www.remlab.net/
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel



-- 
Félix Abecassis
http://felix.abecassis.me



More information about the vlc-devel mailing list