Fix clang warnings.

* src/gxvalid/gxvcmmn.h (GXV_SET_ERR_IF_PARANOID): Use 'do' block.
* src/gxvalid/gxvmod.c (GXV_TABLE_LOAD, GXV_TABLE_VALIDATE): Ditto.

* src/smooth/ftgrays.c (gray_convert_glyph): Add cast.

* src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String): Remove cast.
* src/type1/t1load.c (read_binay_data): Use `FT_ULong` for `size` parameter.
(parse_subrs, parse_charstrings, parse_dict): Ditto; also add some casts.
This commit is contained in:
Werner Lemberg 2021-11-14 11:02:54 +01:00
parent 9597fd7b40
commit d31bafcb9c
5 changed files with 44 additions and 35 deletions

View File

@ -61,8 +61,11 @@ FT_BEGIN_HEADER
#undef GXV_LOAD_UNUSED_VARS /* debug purpose */
#define IS_PARANOID_VALIDATION ( gxvalid->root->level >= FT_VALIDATE_PARANOID )
#define GXV_SET_ERR_IF_PARANOID( err ) { if ( IS_PARANOID_VALIDATION ) ( err ); }
#define IS_PARANOID_VALIDATION \
( gxvalid->root->level >= FT_VALIDATE_PARANOID )
#define GXV_SET_ERR_IF_PARANOID( err ) \
do { if ( IS_PARANOID_VALIDATION ) ( err ); } while ( 0 )
/*************************************************************************/
/*************************************************************************/

View File

@ -76,27 +76,33 @@
FT_Byte* volatile _sfnt = NULL; \
FT_ULong len_ ## _sfnt = 0
#define GXV_TABLE_LOAD( _sfnt ) \
if ( ( FT_VALIDATE_ ## _sfnt ## _INDEX < table_count ) && \
( gx_flags & FT_VALIDATE_ ## _sfnt ) ) \
{ \
error = gxv_load_table( face, TTAG_ ## _sfnt, \
&_sfnt, &len_ ## _sfnt ); \
if ( error ) \
goto Exit; \
}
#define GXV_TABLE_LOAD( _sfnt ) \
do \
{ \
if ( ( FT_VALIDATE_ ## _sfnt ## _INDEX < table_count ) && \
( gx_flags & FT_VALIDATE_ ## _sfnt ) ) \
{ \
error = gxv_load_table( face, TTAG_ ## _sfnt, \
&_sfnt, &len_ ## _sfnt ); \
if ( error ) \
goto Exit; \
} \
} while ( 0 )
#define GXV_TABLE_VALIDATE( _sfnt ) \
if ( _sfnt ) \
{ \
ft_validator_init( &valid, _sfnt, _sfnt + len_ ## _sfnt, \
FT_VALIDATE_DEFAULT ); \
if ( ft_setjmp( valid.jump_buffer ) == 0 ) \
gxv_ ## _sfnt ## _validate( _sfnt, face, &valid ); \
error = valid.error; \
if ( error ) \
goto Exit; \
}
#define GXV_TABLE_VALIDATE( _sfnt ) \
do \
{ \
if ( _sfnt ) \
{ \
ft_validator_init( &valid, _sfnt, _sfnt + len_ ## _sfnt, \
FT_VALIDATE_DEFAULT ); \
if ( ft_setjmp( valid.jump_buffer ) == 0 ) \
gxv_ ## _sfnt ## _validate( _sfnt, face, &valid ); \
error = valid.error; \
if ( error ) \
goto Exit; \
} \
} while ( 0 )
#define GXV_TABLE_SET( _sfnt ) \
if ( FT_VALIDATE_ ## _sfnt ## _INDEX < table_count ) \

View File

@ -1986,8 +1986,8 @@ typedef ptrdiff_t FT_PtrDist;
ras.ycells[w] = ras.cell_null;
/* memory management: skip ycells */
n = ( width * sizeof ( PCell ) + sizeof ( TCell ) - 1 ) /
sizeof ( TCell );
n = ( (size_t)width * sizeof ( PCell ) + sizeof ( TCell ) - 1 ) /
sizeof ( TCell );
ras.cell_free = buffer + n;
ras.cell = ras.cell_null;

View File

@ -79,7 +79,7 @@
/* For ordinary fonts get the character data stored in the face record. */
{
char_string->pointer = type1->charstrings[glyph_index];
char_string->length = (FT_Int)type1->charstrings_len[glyph_index];
char_string->length = type1->charstrings_len[glyph_index];
}
if ( !error )

View File

@ -1346,7 +1346,7 @@
static int
read_binary_data( T1_Parser parser,
FT_Long* size,
FT_ULong* size,
FT_Byte** base,
FT_Bool incremental )
{
@ -1378,7 +1378,7 @@
if ( s >= 0 && s < limit - *base )
{
parser->root.cursor += s + 1;
*size = s;
*size = (FT_ULong)s;
return !parser->root.error;
}
}
@ -1803,7 +1803,7 @@
for ( count = 0; ; count++ )
{
FT_Long idx;
FT_Long size;
FT_ULong size;
FT_Byte* base;
@ -1861,7 +1861,7 @@
/* some fonts define empty subr records -- this is not totally */
/* compliant to the specification (which says they should at */
/* least contain a `return'), but we support them anyway */
if ( size < face->type1.private_dict.lenIV )
if ( size < (FT_ULong)face->type1.private_dict.lenIV )
{
error = FT_THROW( Invalid_File_Format );
goto Fail;
@ -1872,7 +1872,7 @@
goto Fail;
FT_MEM_COPY( temp, base, size );
psaux->t1_decrypt( temp, size, 4330 );
size -= face->type1.private_dict.lenIV;
size -= (FT_ULong)face->type1.private_dict.lenIV;
error = T1_Add_Table( table, (FT_Int)idx,
temp + face->type1.private_dict.lenIV, size );
FT_FREE( temp );
@ -1977,7 +1977,7 @@
for (;;)
{
FT_Long size;
FT_ULong size;
FT_Byte* base;
@ -2071,7 +2071,7 @@
FT_Byte* temp = NULL;
if ( size <= face->type1.private_dict.lenIV )
if ( size <= (FT_ULong)face->type1.private_dict.lenIV )
{
error = FT_THROW( Invalid_File_Format );
goto Fail;
@ -2082,7 +2082,7 @@
goto Fail;
FT_MEM_COPY( temp, base, size );
psaux->t1_decrypt( temp, size, 4330 );
size -= face->type1.private_dict.lenIV;
size -= (FT_ULong)face->type1.private_dict.lenIV;
error = T1_Add_Table( code_table, n,
temp + face->type1.private_dict.lenIV, size );
FT_FREE( temp );
@ -2334,7 +2334,7 @@
else if ( *cur == 'R' && cur + 6 < limit && *(cur + 1) == 'D' &&
have_integer )
{
FT_Long s;
FT_ULong s;
FT_Byte* b;
@ -2347,7 +2347,7 @@
else if ( *cur == '-' && cur + 6 < limit && *(cur + 1) == '|' &&
have_integer )
{
FT_Long s;
FT_ULong s;
FT_Byte* b;