[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] master d235ea9 1/2: [ftbench] Fix clang warnings.
From: |
Werner Lemberg |
Subject: |
[freetype2-demos] master d235ea9 1/2: [ftbench] Fix clang warnings. |
Date: |
Mon, 15 Nov 2021 11:16:39 -0500 (EST) |
branch: master
commit d235ea9448f99938172beed0eb594ff934795f22
Author: Werner Lemberg <wl@gnu.org>
Commit: Werner Lemberg <wl@gnu.org>
[ftbench] Fix clang warnings.
* src/ftbench.c (first_index, last_index): Make these two global variables
signed, to be of the same type as `incr_index` (which can be positive or
negative).
Update all related code.
---
src/ftbench.c | 124 ++++++++++++++++++++++++++++++----------------------------
1 file changed, 64 insertions(+), 60 deletions(-)
diff --git a/src/ftbench.c b/src/ftbench.c
index e245f59..b1bc8da 100644
--- a/src/ftbench.c
+++ b/src/ftbench.c
@@ -16,6 +16,7 @@
#include <stdlib.h>
#include <stdio.h>
+#include <limits.h>
#include <string.h>
#include <time.h>
#include <ft2build.h>
@@ -148,9 +149,9 @@
static int preload;
static char* filename;
- static unsigned int first_index = 0U;
- static unsigned int last_index = ~0U;
- static int incr_index = 1;
+ static int first_index = 0;
+ static int last_index = INT_MAX;
+ static int incr_index = 1;
#define FOREACH( i ) for ( i = first_index ; \
( first_index <= i && i <= last_index ) || \
@@ -316,8 +317,7 @@
FT_Face face,
void* user_data )
{
- unsigned int i;
- int done = 0;
+ int i, done = 0;
FT_UNUSED( user_data );
@@ -326,7 +326,7 @@
FOREACH( i )
{
- if ( !FT_Load_Glyph( face, i, load_flags ) )
+ if ( !FT_Load_Glyph( face, (FT_UInt)i, load_flags ) )
done++;
}
@@ -344,7 +344,7 @@
int done = 0;
FT_Fixed* advances;
FT_ULong flags = *((FT_ULong*)user_data);
- FT_UInt start, count;
+ FT_Int start, count;
if ( incr_index > 0 )
@@ -362,7 +362,9 @@
TIMER_START( timer );
- FT_Get_Advances( face, start, count, (FT_Int32)flags, advances );
+ FT_Get_Advances( face,
+ (FT_UInt)start, (FT_UInt)count,
+ (FT_Int32)flags, advances );
done += (int)count;
TIMER_STOP( timer );
@@ -378,15 +380,14 @@
FT_Face face,
void* user_data )
{
- unsigned int i;
- int done = 0;
+ int i, done = 0;
FT_UNUSED( user_data );
FOREACH( i )
{
- if ( FT_Load_Glyph( face, i, load_flags ) )
+ if ( FT_Load_Glyph( face, (FT_UInt)i, load_flags ) )
continue;
TIMER_START( timer );
@@ -404,15 +405,14 @@
FT_Face face,
void* user_data )
{
- unsigned int i;
- int done = 0;
+ int i, done = 0;
FT_UNUSED( user_data );
FOREACH( i )
{
- if ( FT_Load_Glyph( face, i, load_flags ) )
+ if ( FT_Load_Glyph( face, (FT_UInt)i, load_flags ) )
continue;
TIMER_START( timer );
@@ -430,10 +430,10 @@
FT_Face face,
void* user_data )
{
- FT_Glyph glyph;
- FT_Stroker stroker;
- unsigned int i;
- int done = 0;
+ FT_Glyph glyph;
+ FT_Stroker stroker;
+
+ int i, done = 0;
FT_UNUSED( user_data );
@@ -446,7 +446,7 @@
FOREACH( i )
{
- if ( FT_Load_Glyph( face, i, load_flags ) )
+ if ( FT_Load_Glyph( face, (FT_UInt)i, load_flags ) )
continue;
if ( FT_Get_Glyph( face->glyph, &glyph ) )
@@ -469,16 +469,16 @@
FT_Face face,
void* user_data )
{
- FT_Glyph glyph;
- unsigned int i;
- int done = 0;
+ FT_Glyph glyph;
+
+ int i, done = 0;
FT_UNUSED( user_data );
FOREACH( i )
{
- if ( FT_Load_Glyph( face, i, load_flags ) )
+ if ( FT_Load_Glyph( face, (FT_UInt)i, load_flags ) )
continue;
TIMER_START( timer );
@@ -499,17 +499,17 @@
FT_Face face,
void* user_data )
{
- FT_Glyph glyph;
- FT_BBox bbox;
- unsigned int i;
- int done = 0;
+ FT_Glyph glyph;
+ FT_BBox bbox;
+
+ int i, done = 0;
FT_UNUSED( user_data );
FOREACH( i )
{
- if ( FT_Load_Glyph( face, i, load_flags ) )
+ if ( FT_Load_Glyph( face, (FT_UInt)i, load_flags ) )
continue;
if ( FT_Get_Glyph( face->glyph, &glyph ) )
@@ -532,10 +532,10 @@
FT_Face face,
void* user_data )
{
- FT_BBox bbox;
- unsigned int i;
- int done = 0;
- FT_Matrix rot30 = { 0xDDB4, -0x8000, 0x8000, 0xDDB4 };
+ FT_BBox bbox;
+ FT_Matrix rot30 = { 0xDDB4, -0x8000, 0x8000, 0xDDB4 };
+
+ int i, done = 0;
FT_UNUSED( user_data );
@@ -545,7 +545,7 @@
FT_Outline* outline;
- if ( FT_Load_Glyph( face, i, load_flags ) )
+ if ( FT_Load_Glyph( face, (FT_UInt)i, load_flags ) )
continue;
outline = &face->glyph->outline;
@@ -626,9 +626,9 @@
FT_Face face,
void* user_data )
{
- FT_Glyph glyph;
- unsigned int i;
- int done = 0;
+ FT_Glyph glyph;
+
+ int i, done = 0;
FT_UNUSED( face );
FT_UNUSED( user_data );
@@ -646,7 +646,7 @@
{
if ( !FTC_ImageCache_Lookup( image_cache,
&font_type,
- i,
+ (FT_UInt)i,
&glyph,
NULL ) )
done++;
@@ -663,9 +663,9 @@
FT_Face face,
void* user_data )
{
- FTC_SBit glyph;
- unsigned int i;
- int done = 0;
+ FTC_SBit glyph;
+
+ int i, done = 0;
FT_UNUSED( face );
FT_UNUSED( user_data );
@@ -683,7 +683,7 @@
{
if ( !FTC_SBitCache_Lookup( sbit_cache,
&font_type,
- i,
+ (FT_UInt)i,
&glyph,
NULL ) )
done++;
@@ -747,8 +747,7 @@
{
FT_Face bench_face;
- unsigned int i;
- int done = 0;
+ int i, done = 0;
FT_UNUSED( face );
FT_UNUSED( user_data );
@@ -760,7 +759,7 @@
{
FOREACH( i )
{
- if ( !FT_Load_Glyph( bench_face, i, load_flags ) )
+ if ( !FT_Load_Glyph( bench_face, (FT_UInt)i, load_flags ) )
done++;
}
@@ -782,7 +781,6 @@
bcharset_t* charset )
{
FT_ULong charcode;
- FT_UInt gindex;
int i = 0;
@@ -793,27 +791,33 @@
if ( face->charmap )
{
- charcode = FT_Get_First_Char( face, &gindex );
+ FT_UInt idx;
+
+
+ charcode = FT_Get_First_Char( face, &idx );
/* certain fonts contain a broken charmap that will map character */
/* codes to out-of-bounds glyph indices. Take care of that here. */
/* */
- while ( gindex && i < face->num_glyphs )
+ while ( idx && i < face->num_glyphs )
{
+ FT_Int gindex = (FT_Int)idx;
+
+
if ( ( first_index <= gindex && gindex <= last_index ) ||
( first_index >= gindex && gindex >= last_index ) )
charset->code[i++] = charcode;
- charcode = FT_Get_Next_Char( face, charcode, &gindex );
+ charcode = FT_Get_Next_Char( face, charcode, &idx );
}
}
else
{
- unsigned int j;
+ int j;
/* no charmap, do an identity mapping */
FOREACH( j )
- charset->code[i++] = j;
+ charset->code[i++] = (FT_ULong)j;
}
charset->size = i;
@@ -1134,12 +1138,12 @@
case 'i':
{
- unsigned int fi, li;
+ int fi, li;
- if ( sscanf( optarg, "%u%*[,:-]%u", &fi, &li ) == 2 )
+ if ( sscanf( optarg, "%d%*[,:-]%d", &fi, &li ) == 2 )
{
- first_index = fi;
- last_index = li;
+ first_index = fi < 0 ? 0 : fi;
+ last_index = li < 0 ? 0 : li;
}
}
break;
@@ -1238,11 +1242,11 @@
if ( get_face( &face ) )
goto Exit;
- if ( first_index >= (unsigned int)face->num_glyphs )
- first_index = (unsigned int)face->num_glyphs - 1;
- if ( last_index >= (unsigned int)face->num_glyphs )
- last_index = (unsigned int)face->num_glyphs - 1;
- incr_index = last_index > first_index ? 1 : -1;
+ if ( first_index >= face->num_glyphs )
+ first_index = face->num_glyphs - 1;
+ if ( last_index >= face->num_glyphs )
+ last_index = face->num_glyphs - 1;
+ incr_index = last_index > first_index ? 1 : -1;
if ( size )
{
@@ -1300,7 +1304,7 @@
max_time );
printf( "\n"
- "glyph indices: from %u to %u\n"
+ "glyph indices: from %d to %d\n"
"face size: %uppem\n"
"font preloading into memory: %s\n",
first_index,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] master d235ea9 1/2: [ftbench] Fix clang warnings.,
Werner Lemberg <=