summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWerner Lemberg <wl@gnu.org>2021-11-14 11:02:54 +0100
committerWerner Lemberg <wl@gnu.org>2021-11-14 11:02:54 +0100
commitd31bafcb9ce7dee7036089a394556ebf201221ec (patch)
tree5b3363fe340f0df4ffa87cfe2a6d1d4c712d06f9 /src
parent9597fd7b40179d7411b4a7443f2bc4cad8c4dfdf (diff)
downloadfreetype2-d31bafcb9ce7dee7036089a394556ebf201221ec.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/gxvalid/gxvcommn.h7
-rw-r--r--src/gxvalid/gxvmod.c48
-rw-r--r--src/smooth/ftgrays.c4
-rw-r--r--src/type1/t1gload.c2
-rw-r--r--src/type1/t1load.c20
5 files changed, 45 insertions, 36 deletions
diff --git a/src/gxvalid/gxvcommn.h b/src/gxvalid/gxvcommn.h
index 3e2322ebd..b79b64114 100644
--- a/src/gxvalid/gxvcommn.h
+++ b/src/gxvalid/gxvcommn.h
@@ -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 )
+
/*************************************************************************/
/*************************************************************************/
diff --git a/src/gxvalid/gxvmod.c b/src/gxvalid/gxvmod.c
index ad6dfb075..e51fc89d9 100644
--- a/src/gxvalid/gxvmod.c
+++ b/src/gxvalid/gxvmod.c
@@ -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_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_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 ) \
+ 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 ) \
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index 597834350..380aea3cb 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -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;
diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c
index 57ad39774..86649edf3 100644
--- a/src/type1/t1gload.c
+++ b/src/type1/t1gload.c
@@ -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 )
diff --git a/src/type1/t1load.c b/src/type1/t1load.c
index c757a5814..bb62c7990 100644
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -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;