freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Git][freetype/freetype][master] 2 commits: Avoid undefined left-shifts.


From: Werner Lemberg (@wl)
Subject: [Git][freetype/freetype][master] 2 commits: Avoid undefined left-shifts.
Date: Sat, 20 Nov 2021 06:59:10 +0000

Werner Lemberg pushed to branch master at FreeType / FreeType

Commits:

7 changed files:

Changes:

  • include/freetype/config/public-macros.h
    ... ... @@ -120,11 +120,16 @@ FT_BEGIN_HEADER
    120 120
        * Support for casts in both C and C++.
    
    121 121
        */
    
    122 122
     #ifdef __cplusplus
    
    123
    -#define FT_STATIC_CAST( type )       static_cast<type>
    
    124
    -#define FT_REINTERPRET_CAST( type )  reinterpret_cast<type>
    
    123
    +#define FT_STATIC_CAST( type, var )       static_cast<type>(var)
    
    124
    +#define FT_REINTERPRET_CAST( type, var )  reinterpret_cast<type>(var)
    
    125
    +
    
    126
    +#define FT_STATIC_BYTE_CAST( type, var )                         \
    
    127
    +          static_cast<type>( static_cast<unsigned char>( var ) )
    
    125 128
     #else
    
    126
    -#define FT_STATIC_CAST( type )       (type)
    
    127
    -#define FT_REINTERPRET_CAST( type )  (type)
    
    129
    +#define FT_STATIC_CAST( type, var )       (type)(var)
    
    130
    +#define FT_REINTERPRET_CAST( type, var )  (type)(var)
    
    131
    +
    
    132
    +#define FT_STATIC_BYTE_CAST( type, var )  (type)(unsigned char)(var)
    
    128 133
     #endif
    
    129 134
     
    
    130 135
     
    

  • include/freetype/freetype.h
    ... ... @@ -617,11 +617,11 @@ FT_BEGIN_HEADER
    617 617
     
    
    618 618
     #ifndef FT_ENC_TAG
    
    619 619
     
    
    620
    -#define FT_ENC_TAG( value, a, b, c, d )                      \
    
    621
    -          value = ( ( FT_STATIC_CAST( FT_Byte )(a) << 24 ) | \
    
    622
    -                    ( FT_STATIC_CAST( FT_Byte )(b) << 16 ) | \
    
    623
    -                    ( FT_STATIC_CAST( FT_Byte )(c) <<  8 ) | \
    
    624
    -                      FT_STATIC_CAST( FT_Byte )(d)         )
    
    620
    +#define FT_ENC_TAG( value, a, b, c, d )                             \
    
    621
    +          value = ( ( FT_STATIC_BYTE_CAST( FT_UInt32, a ) << 24 ) | \
    
    622
    +                    ( FT_STATIC_BYTE_CAST( FT_UInt32, b ) << 16 ) | \
    
    623
    +                    ( FT_STATIC_BYTE_CAST( FT_UInt32, c ) <<  8 ) | \
    
    624
    +                      FT_STATIC_BYTE_CAST( FT_UInt32, d )         )
    
    625 625
     
    
    626 626
     #endif /* FT_ENC_TAG */
    
    627 627
     
    
    ... ... @@ -3182,7 +3182,7 @@ FT_BEGIN_HEADER
    3182 3182
        *   necessary to empty the cache after a mode switch to avoid false hits.
    
    3183 3183
        *
    
    3184 3184
        */
    
    3185
    -#define FT_LOAD_TARGET_( x )   ( FT_STATIC_CAST( FT_Int32 )( (x) & 15 ) << 16 )
    
    3185
    +#define FT_LOAD_TARGET_( x )   ( FT_STATIC_CAST( FT_Int32, (x) & 15 ) << 16 )
    
    3186 3186
     
    
    3187 3187
     #define FT_LOAD_TARGET_NORMAL  FT_LOAD_TARGET_( FT_RENDER_MODE_NORMAL )
    
    3188 3188
     #define FT_LOAD_TARGET_LIGHT   FT_LOAD_TARGET_( FT_RENDER_MODE_LIGHT  )
    
    ... ... @@ -3201,8 +3201,8 @@ FT_BEGIN_HEADER
    3201 3201
        *   @FT_LOAD_TARGET_XXX value.
    
    3202 3202
        *
    
    3203 3203
        */
    
    3204
    -#define FT_LOAD_TARGET_MODE( x )                                 \
    
    3205
    -          FT_STATIC_CAST( FT_Render_Mode )( ( (x) >> 16 ) & 15 )
    
    3204
    +#define FT_LOAD_TARGET_MODE( x )                               \
    
    3205
    +          FT_STATIC_CAST( FT_Render_Mode, ( (x) >> 16 ) & 15 )
    
    3206 3206
     
    
    3207 3207
     
    
    3208 3208
       /**************************************************************************
    

  • include/freetype/ftimage.h
    ... ... @@ -696,11 +696,11 @@ FT_BEGIN_HEADER
    696 696
        */
    
    697 697
     #ifndef FT_IMAGE_TAG
    
    698 698
     
    
    699
    -#define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 )                      \
    
    700
    -          value = ( ( FT_STATIC_CAST( unsigned char )( _x1 ) << 24 ) | \
    
    701
    -                    ( FT_STATIC_CAST( unsigned char )( _x2 ) << 16 ) | \
    
    702
    -                    ( FT_STATIC_CAST( unsigned char )( _x3 ) << 8  ) | \
    
    703
    -                      FT_STATIC_CAST( unsigned char )( _x4 )         )
    
    699
    +#define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 )                         \
    
    700
    +          value = ( ( FT_STATIC_BYTE_CAST( unsigned long, _x1 ) << 24 ) | \
    
    701
    +                    ( FT_STATIC_BYTE_CAST( unsigned long, _x2 ) << 16 ) | \
    
    702
    +                    ( FT_STATIC_BYTE_CAST( unsigned long, _x3 ) << 8  ) | \
    
    703
    +                      FT_STATIC_BYTE_CAST( unsigned long, _x4 )         )
    
    704 704
     
    
    705 705
     #endif /* FT_IMAGE_TAG */
    
    706 706
     
    

  • include/freetype/ftmodapi.h
    ... ... @@ -347,9 +347,9 @@ FT_BEGIN_HEADER
    347 347
        *   2.11
    
    348 348
        *
    
    349 349
        */
    
    350
    -#define FT_FACE_DRIVER_NAME( face )                     \
    
    351
    -          ( ( *FT_REINTERPRET_CAST( FT_Module_Class** ) \
    
    352
    -                 ( ( face )->driver ) )->module_name )
    
    350
    +#define FT_FACE_DRIVER_NAME( face )                                     \
    
    351
    +          ( ( *FT_REINTERPRET_CAST( FT_Module_Class**,                  \
    
    352
    +                                    ( face )->driver ) )->module_name )
    
    353 353
     
    
    354 354
     
    
    355 355
       /**************************************************************************
    

  • include/freetype/fttypes.h
    ... ... @@ -479,18 +479,19 @@ FT_BEGIN_HEADER
    479 479
        *
    
    480 480
        * @description:
    
    481 481
        *   This macro converts four-letter tags that are used to label TrueType
    
    482
    -   *   tables into an unsigned long, to be used within FreeType.
    
    482
    +   *   tables into an `FT_Tag` type, to be used within FreeType.
    
    483 483
        *
    
    484 484
        * @note:
    
    485 485
        *   The produced values **must** be 32-bit integers.  Don't redefine this
    
    486 486
        *   macro.
    
    487 487
        */
    
    488
    -#define FT_MAKE_TAG( _x1, _x2, _x3, _x4 )                \
    
    489
    -          FT_STATIC_CAST( FT_Tag )                       \
    
    490
    -          ( ( FT_STATIC_CAST( FT_Byte )( _x1 ) << 24 ) | \
    
    491
    -            ( FT_STATIC_CAST( FT_Byte )( _x2 ) << 16 ) | \
    
    492
    -            ( FT_STATIC_CAST( FT_Byte )( _x3 ) <<  8 ) | \
    
    493
    -              FT_STATIC_CAST( FT_Byte )( _x4 )         )
    
    488
    +#define FT_MAKE_TAG( _x1, _x2, _x3, _x4 )                      \
    
    489
    +          FT_STATIC_CAST(                                      \
    
    490
    +            FT_Tag,                                            \
    
    491
    +            ( ( FT_STATIC_BYTE_CAST( FT_Tag, _x1 ) << 24 ) |   \
    
    492
    +              ( FT_STATIC_BYTE_CAST( FT_Tag, _x2 ) << 16 ) |   \
    
    493
    +              ( FT_STATIC_BYTE_CAST( FT_Tag, _x3 ) <<  8 ) |   \
    
    494
    +                FT_STATIC_BYTE_CAST( FT_Tag, _x4 )         ) )
    
    494 495
     
    
    495 496
     
    
    496 497
       /*************************************************************************/
    
    ... ... @@ -588,7 +589,7 @@ FT_BEGIN_HEADER
    588 589
     
    
    589 590
     
    
    590 591
     #define FT_IS_EMPTY( list )  ( (list).head == 0 )
    
    591
    -#define FT_BOOL( x )         FT_STATIC_CAST( FT_Bool )( (x) != 0 )
    
    592
    +#define FT_BOOL( x )         FT_STATIC_CAST( FT_Bool, (x) != 0 )
    
    592 593
     
    
    593 594
       /* concatenate C tokens */
    
    594 595
     #define FT_ERR_XCAT( x, y )  x ## y
    

  • src/raster/ftmisc.h
    ... ... @@ -47,11 +47,8 @@
    47 47
       typedef signed long    FT_F26Dot6;
    
    48 48
       typedef int            FT_Error;
    
    49 49
     
    
    50
    -#define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
    
    51
    -          ( ( (FT_ULong)_x1 << 24 ) |     \
    
    52
    -            ( (FT_ULong)_x2 << 16 ) |     \
    
    53
    -            ( (FT_ULong)_x3 <<  8 ) |     \
    
    54
    -              (FT_ULong)_x4         )
    
    50
    +
    
    51
    +#define FT_STATIC_BYTE_CAST( type, var )  (type)(FT_Byte)(var)
    
    55 52
     
    
    56 53
     
    
    57 54
       /* from include/freetype/ftsystem.h */
    

  • src/smooth/ftgrays.c
    ... ... @@ -152,7 +152,7 @@
    152 152
     #define ADD_INT( a, b )                                  \
    
    153 153
               (int)( (unsigned int)(a) + (unsigned int)(b) )
    
    154 154
     
    
    155
    -#define FT_STATIC_CAST( type )  (type)
    
    155
    +#define FT_STATIC_BYTE_CAST( type, var )  (type)(unsigned char)(var)
    
    156 156
     
    
    157 157
     
    
    158 158
     #define ft_memset   memset
    
    ... ... @@ -239,10 +239,13 @@ typedef ptrdiff_t FT_PtrDist;
    239 239
     #define FT_ERROR( x )   do { } while ( 0 )     /* nothing */
    
    240 240
     #define FT_THROW( e )   FT_ERR_CAT( Smooth_Err_, e )
    
    241 241
     
    
    242
    -
    
    243 242
     #endif /* !FT_DEBUG_LEVEL_TRACE */
    
    244 243
     
    
    245 244
     
    
    245
    +#define FT_Trace_Enable()   do { } while ( 0 )  /* nothing */
    
    246
    +#define FT_Trace_Disable()  do { } while ( 0 )  /* nothing */
    
    247
    +
    
    248
    +
    
    246 249
     #define FT_DEFINE_OUTLINE_FUNCS( class_,               \
    
    247 250
                                      move_to_, line_to_,   \
    
    248 251
                                      conic_to_, cubic_to_, \
    


  • reply via email to

    [Prev in Thread] Current Thread [Next in Thread]