summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Lemberg <wl@gnu.org>2021-07-24 20:32:16 +0200
committerWerner Lemberg <wl@gnu.org>2021-07-24 20:32:16 +0200
commitc2fa51d9bd350c55427b62982bf464ffd5e0a068 (patch)
tree879980c78ed4d13a641aec2d744773f035c55119
parent28c2d7f31c0758e69dded02acfa32af080774e91 (diff)
downloadfreetype2-c2fa51d9bd350c55427b62982bf464ffd5e0a068.tar.gz
Fix some `cppcheck` warnings.
* src/bzip2/ftbzip2.c (ft_bzip2_file_skip_output), src/gzip/ftgzip.c (ft_gzip_file_skip_output): Reduce scope of `delta`. * src/psaux/psintrp.c, src/psaux/psintrp.h (cf2_interpT2CharString): Add `const` to `buf` parameter. * src/raster/ftraster.c (DelOld): Add `const` to `profile` parameter. (Vertical_Sweep_Span): Reduce scope of `target`. (FT_Outline_Get_CBox): Reduce scope of `xMin`, `xMax`, `yMin`, `yMax`. * src/smooth/ftgrays.c (gray_render_conic): Reduce scope of `split`. (gray_sweep, gray_sweep_direct): Reduce scope of `area`. * src/tools/apinames.c (names_dump) <OUTPUT_WATCOM_LBC>: Reduce scope of `temp`.
-rw-r--r--src/bzip2/ftbzip2.c5
-rw-r--r--src/gzip/ftgzip.c5
-rw-r--r--src/psaux/psintrp.c2
-rw-r--r--src/psaux/psintrp.h2
-rw-r--r--src/raster/ftraster.c15
-rw-r--r--src/smooth/ftgrays.c24
-rw-r--r--src/tools/apinames.c4
7 files changed, 34 insertions, 23 deletions
diff --git a/src/bzip2/ftbzip2.c b/src/bzip2/ftbzip2.c
index 3df7496a6..b7c270259 100644
--- a/src/bzip2/ftbzip2.c
+++ b/src/bzip2/ftbzip2.c
@@ -327,12 +327,13 @@
FT_ULong count )
{
FT_Error error = FT_Err_Ok;
- FT_ULong delta;
for (;;)
{
- delta = (FT_ULong)( zip->limit - zip->cursor );
+ FT_ULong delta = (FT_ULong)( zip->limit - zip->cursor );
+
+
if ( delta >= count )
delta = count;
diff --git a/src/gzip/ftgzip.c b/src/gzip/ftgzip.c
index 788a37b31..42b7543a8 100644
--- a/src/gzip/ftgzip.c
+++ b/src/gzip/ftgzip.c
@@ -467,12 +467,13 @@
FT_ULong count )
{
FT_Error error = FT_Err_Ok;
- FT_ULong delta;
for (;;)
{
- delta = (FT_ULong)( zip->limit - zip->cursor );
+ FT_ULong delta = (FT_ULong)( zip->limit - zip->cursor );
+
+
if ( delta >= count )
delta = count;
diff --git a/src/psaux/psintrp.c b/src/psaux/psintrp.c
index 40e927663..112936e21 100644
--- a/src/psaux/psintrp.c
+++ b/src/psaux/psintrp.c
@@ -469,7 +469,7 @@
*/
FT_LOCAL_DEF( void )
cf2_interpT2CharString( CF2_Font font,
- CF2_Buffer buf,
+ const CF2_Buffer buf,
CF2_OutlineCallbacks callbacks,
const FT_Vector* translation,
FT_Bool doingSeac,
diff --git a/src/psaux/psintrp.h b/src/psaux/psintrp.h
index 669c09c0a..d8b9342ec 100644
--- a/src/psaux/psintrp.h
+++ b/src/psaux/psintrp.h
@@ -65,7 +65,7 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
cf2_interpT2CharString( CF2_Font font,
- CF2_Buffer charstring,
+ const CF2_Buffer buf,
CF2_OutlineCallbacks callbacks,
const FT_Vector* translation,
FT_Bool doingSeac,
diff --git a/src/raster/ftraster.c b/src/raster/ftraster.c
index fbcf8d22a..4c1709726 100644
--- a/src/raster/ftraster.c
+++ b/src/raster/ftraster.c
@@ -2095,8 +2095,8 @@
* Removes an old profile from a linked list.
*/
static void
- DelOld( PProfileList list,
- PProfile profile )
+ DelOld( PProfileList list,
+ const PProfile profile )
{
PProfile *old, current;
@@ -2206,8 +2206,7 @@
PProfile left,
PProfile right )
{
- Long e1, e2;
- Byte* target;
+ Long e1, e2;
Int dropOutControl = left->flags & 7;
@@ -2240,6 +2239,8 @@
if ( e2 >= 0 && e1 < ras.bWidth )
{
+ Byte* target;
+
Int c1, c2;
Byte f1, f2;
@@ -2949,11 +2950,11 @@
FT_Outline_Get_CBox( const FT_Outline* outline,
FT_BBox *acbox )
{
- Long xMin, yMin, xMax, yMax;
-
-
if ( outline && acbox )
{
+ Long xMin, yMin, xMax, yMax;
+
+
if ( outline->n_points == 0 )
{
xMin = 0;
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index 86118fb36..131b86c3e 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -658,8 +658,8 @@ typedef ptrdiff_t FT_PtrDist;
return;
}
- fx1 = FRACT( x1 );
- fx2 = FRACT( x2 );
+ fx1 = FRACT( x1 );
+ fx2 = FRACT( x2 );
/* everything is located in a single cell. That is easy! */
/* */
@@ -1256,7 +1256,7 @@ typedef ptrdiff_t FT_PtrDist;
FT_Vector bez_stack[16 * 2 + 1]; /* enough to accommodate bisections */
FT_Vector* arc = bez_stack;
TPos dx, dy;
- int draw, split;
+ int draw;
arc[0].x = UPSCALE( to->x );
@@ -1299,7 +1299,9 @@ typedef ptrdiff_t FT_PtrDist;
/* many times as there are trailing zeros in the counter. */
do
{
- split = draw & ( -draw ); /* isolate the rightmost 1-bit */
+ int split = draw & ( -draw ); /* isolate the rightmost 1-bit */
+
+
while ( ( split >>= 1 ) )
{
gray_split_conic( arc );
@@ -1466,7 +1468,8 @@ typedef ptrdiff_t FT_PtrDist;
static void
gray_sweep( RAS_ARG )
{
- int fill = ras.outline.flags & FT_OUTLINE_EVEN_ODD_FILL ? 0x100 : INT_MIN;
+ int fill = ( ras.outline.flags & FT_OUTLINE_EVEN_ODD_FILL ) ? 0x100
+ : INT_MIN;
int coverage;
int y;
@@ -1476,13 +1479,15 @@ typedef ptrdiff_t FT_PtrDist;
PCell cell = ras.ycells[y - ras.min_ey];
TCoord x = ras.min_ex;
TArea cover = 0;
- TArea area;
unsigned char* line = ras.target.origin - ras.target.pitch * y;
for ( ; !CELL_IS_NULL( cell ); cell = cell->next )
{
+ TArea area;
+
+
if ( cover != 0 && cell->x > x )
{
FT_FILL_RULE( coverage, cover, fill );
@@ -1513,7 +1518,8 @@ typedef ptrdiff_t FT_PtrDist;
static void
gray_sweep_direct( RAS_ARG )
{
- int fill = ras.outline.flags & FT_OUTLINE_EVEN_ODD_FILL ? 0x100 : INT_MIN;
+ int fill = ( ras.outline.flags & FT_OUTLINE_EVEN_ODD_FILL ) ? 0x100
+ : INT_MIN;
int coverage;
int y;
@@ -1526,11 +1532,13 @@ typedef ptrdiff_t FT_PtrDist;
PCell cell = ras.ycells[y - ras.min_ey];
TCoord x = ras.min_ex;
TArea cover = 0;
- TArea area;
for ( ; !CELL_IS_NULL( cell ); cell = cell->next )
{
+ TArea area;
+
+
if ( cover != 0 && cell->x > x )
{
FT_FILL_RULE( coverage, cover, fill );
diff --git a/src/tools/apinames.c b/src/tools/apinames.c
index aeecf88d2..ff5380771 100644
--- a/src/tools/apinames.c
+++ b/src/tools/apinames.c
@@ -167,7 +167,6 @@ names_dump( FILE* out,
case OUTPUT_WATCOM_LBC:
{
const char* dot;
- char temp[512];
if ( !dll_name )
@@ -181,7 +180,8 @@ names_dump( FILE* out,
dot = strchr( dll_name, '.' );
if ( dot )
{
- int len = dot - dll_name;
+ char temp[512];
+ int len = dot - dll_name;
if ( len > (int)( sizeof ( temp ) - 1 ) )