Another round of cppcheck nitpicks.

The call was (from the top-level of the FreeType tree):

  cppcheck --force \
           --enable=all \
           -I /usr/include \
           -I /usr/local/include \
           -I /usr/lib/gcc/i586-suse-linux/4.7/include \
           -I include \
           -I include/freetype \
           -I include/freetype/config \
           -I include/freetype/internal \
           -DFT2_BUILD_LIBRARY \
           . &> cppcheck.log

using cppcheck git commit f7e93f99.

Note that cppcheck still can't handle `#include FOO' (with `FOO' a
macro).

*/* Improve variable scopes.
*/* Remove redundant initializations which get overwritten.

* src/gxvalid/*: Comment out redundant code or guard it with
FT_DEBUG_LEVEL_TRACE.
This commit is contained in:
Werner Lemberg 2013-08-01 12:20:20 +02:00
parent 72f5ff5bbb
commit e8ed2d621e
22 changed files with 128 additions and 81 deletions

View File

@ -1,3 +1,32 @@
2013-08-01 Werner Lemberg <wl@gnu.org>
Another round of cppcheck nitpicks.
The call was (from the top-level of the FreeType tree):
cppcheck --force \
--enable=all \
-I /usr/include \
-I /usr/local/include \
-I /usr/lib/gcc/i586-suse-linux/4.7/include \
-I include \
-I include/freetype \
-I include/freetype/config \
-I include/freetype/internal \
-DFT2_BUILD_LIBRARY \
. &> cppcheck.log
using cppcheck git commit f7e93f99.
Note that cppcheck still can't handle `#include FOO' (with `FOO' a
macro).
*/* Improve variable scopes.
*/* Remove redundant initializations which get overwritten.
* src/gxvalid/*: Comment out redundant code or guard it with
FT_DEBUG_LEVEL_TRACE.
2013-07-30 Werner Lemberg <wl@gnu.org>
[autofit] Introduce `writing systems'.
@ -723,7 +752,7 @@
*/* Improve variable scopes.
*/* Remove redundant initializations which get overwritten.
* src/base/ftmac.c ,builds/mac/ftmac.c (count_faces_scalable):
* src/base/ftmac.c, builds/mac/ftmac.c (count_faces_scalable):
Remove unused variable.
* src/base/ftdbgmem.c (ft_mem_table_destroy): `table' can't be zero.

View File

@ -1392,7 +1392,6 @@ typedef short ResourceIndex;
if ( !pathname )
return FT_THROW( Invalid_Argument );
error = FT_Err_Ok;
*aface = NULL;
/* try resourcefork based font: LWFN, FFIL */

View File

@ -424,15 +424,16 @@
FT_Matrix* matrix,
FT_Vector* delta )
{
const FT_Glyph_Class* clazz;
FT_Error error = FT_Err_Ok;
FT_Error error = FT_Err_Ok;
if ( !glyph || !glyph->clazz )
error = FT_THROW( Invalid_Argument );
else
{
clazz = glyph->clazz;
const FT_Glyph_Class* clazz = glyph->clazz;
if ( clazz->glyph_transform )
{
/* transform glyph image */
@ -466,38 +467,33 @@
if ( !glyph || !glyph->clazz )
return;
else
clazz = glyph->clazz;
if ( !clazz->glyph_bbox )
return;
/* retrieve bbox in 26.6 coordinates */
clazz->glyph_bbox( glyph, acbox );
/* perform grid fitting if needed */
if ( bbox_mode == FT_GLYPH_BBOX_GRIDFIT ||
bbox_mode == FT_GLYPH_BBOX_PIXELS )
{
clazz = glyph->clazz;
if ( !clazz->glyph_bbox )
return;
else
{
/* retrieve bbox in 26.6 coordinates */
clazz->glyph_bbox( glyph, acbox );
/* perform grid fitting if needed */
if ( bbox_mode == FT_GLYPH_BBOX_GRIDFIT ||
bbox_mode == FT_GLYPH_BBOX_PIXELS )
{
acbox->xMin = FT_PIX_FLOOR( acbox->xMin );
acbox->yMin = FT_PIX_FLOOR( acbox->yMin );
acbox->xMax = FT_PIX_CEIL( acbox->xMax );
acbox->yMax = FT_PIX_CEIL( acbox->yMax );
}
/* convert to integer pixels if needed */
if ( bbox_mode == FT_GLYPH_BBOX_TRUNCATE ||
bbox_mode == FT_GLYPH_BBOX_PIXELS )
{
acbox->xMin >>= 6;
acbox->yMin >>= 6;
acbox->xMax >>= 6;
acbox->yMax >>= 6;
}
}
acbox->xMin = FT_PIX_FLOOR( acbox->xMin );
acbox->yMin = FT_PIX_FLOOR( acbox->yMin );
acbox->xMax = FT_PIX_CEIL( acbox->xMax );
acbox->yMax = FT_PIX_CEIL( acbox->yMax );
}
/* convert to integer pixels if needed */
if ( bbox_mode == FT_GLYPH_BBOX_TRUNCATE ||
bbox_mode == FT_GLYPH_BBOX_PIXELS )
{
acbox->xMin >>= 6;
acbox->yMin >>= 6;
acbox->xMax >>= 6;
acbox->yMax >>= 6;
}
return;
}

View File

@ -963,7 +963,6 @@
if ( !pathname )
return FT_THROW( Invalid_Argument );
error = FT_Err_Ok;
*aface = NULL;
/* try resourcefork based font: LWFN, FFIL */

View File

@ -576,11 +576,13 @@
{
char* p = outline->tags + first;
char* q = outline->tags + last;
char swap;
while ( p < q )
{
char swap;
swap = *p;
*p = *q;
*q = swap;

View File

@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services (body). */
/* */
/* Copyright 2009 by */
/* Copyright 2009, 2013 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -29,7 +29,7 @@
ft_pic_container_init( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Error error = FT_Err_Ok;
FT_Error error;
FT_MEM_SET( pic_container, 0, sizeof ( *pic_container ) );

View File

@ -86,11 +86,13 @@
size_t i;
CF2_Fixed emBoxBottom, emBoxTop;
#if 0
CF2_Int unitsPerEm = font->unitsPerEm;
if ( unitsPerEm == 0 )
unitsPerEm = 1000;
#endif
FT_ZERO( blues );
blues->scale = font->innerTransform.d;

View File

@ -150,8 +150,6 @@
cid_parse_font_matrix( CID_Face face,
CID_Parser* parser )
{
FT_Matrix* matrix;
FT_Vector* offset;
CID_FaceDict dict;
FT_Face root = (FT_Face)&face->root;
FT_Fixed temp[6];
@ -160,6 +158,10 @@
if ( parser->num_dict >= 0 && parser->num_dict < face->cid.num_dicts )
{
FT_Matrix* matrix;
FT_Vector* offset;
dict = face->cid.font_dicts + parser->num_dict;
matrix = &dict->font_matrix;
offset = &dict->font_offset;

View File

@ -1288,7 +1288,9 @@
valid );
else
{
#if 0
maxState = 1; /* 0:start of text, 1:start of line are predefined */
#endif
maxEntry = 0;
}
@ -1621,8 +1623,10 @@
gxv_LookupTable_validate( table + classTable,
table + classTable + classTable_length,
valid );
#if 0
if ( valid->subtable_length < classTable_length )
classTable_length = valid->subtable_length;
#endif
}
else
{
@ -1641,7 +1645,9 @@
valid );
else
{
#if 0
maxState = 1; /* 0:start of text, 1:start of line are predefined */
#endif
maxEntry = 0;
}
@ -1727,6 +1733,7 @@
odtect->range[j].start,
odtect->range[j].length ) )
{
#ifdef FT_DEBUG_LEVEL_TRACE
if ( odtect->range[i].name || odtect->range[j].name )
GXV_TRACE(( "found overlap between range %d and range %d\n",
i, j ));
@ -1734,6 +1741,7 @@
GXV_TRACE(( "found overlap between `%s' and `%s\'\n",
odtect->range[i].name,
odtect->range[j].name ));
#endif
FT_INVALID_OFFSET;
}

View File

@ -318,7 +318,7 @@ FT_BEGIN_HEADER
FT_BEGIN_STMNT \
{ \
if ( (a) & 3 ) \
FT_INVALID_OFFSET ; \
FT_INVALID_OFFSET; \
} \
FT_END_STMNT

View File

@ -123,6 +123,7 @@
{
FT_UNUSED( valid );
#ifdef FT_DEBUG_LEVEL_TRACE
if ( coverage & 0x8000U )
GXV_TRACE(( " this subtable is for vertical text only\n" ));
else
@ -141,6 +142,7 @@
if ( coverage & 0x1FF8 )
GXV_TRACE(( " coverage has non-zero bits in reserved area\n" ));
#endif
}

View File

@ -5,7 +5,7 @@
/* TrueTypeGX/AAT morx table validation */
/* body for type2 (Ligature Substitution) subtable. */
/* */
/* Copyright 2005 by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* Copyright 2005, 2013 by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -317,7 +317,9 @@
gxv_XStateTable_validate( p, limit, valid );
#if 0
p += valid->subtable_length;
#endif
gxv_morx_subtable_type2_ligatureTable_validate( table, valid );
GXV_EXIT;

View File

@ -218,25 +218,24 @@ THE SOFTWARE.
FT_FREE( face->metrics );
/* free properties */
if ( face->properties )
{
PCF_Property prop;
FT_Int i;
FT_Int i;
if ( face->properties )
for ( i = 0; i < face->nprops; i++ )
{
for ( i = 0; i < face->nprops; i++ )
{
prop = &face->properties[i];
PCF_Property prop = &face->properties[i];
if ( prop )
{
FT_FREE( prop->name );
if ( prop->isString )
FT_FREE( prop->value.atom );
}
if ( prop )
{
FT_FREE( prop->name );
if ( prop->isString )
FT_FREE( prop->value.atom );
}
}
FT_FREE( face->properties );
}
@ -264,7 +263,7 @@ THE SOFTWARE.
FT_Parameter* params )
{
PCF_Face face = (PCF_Face)pcfface;
FT_Error error = FT_Err_Ok;
FT_Error error;
FT_UNUSED( num_params );
FT_UNUSED( params );

View File

@ -1096,7 +1096,7 @@ THE SOFTWARE.
pcf_load_font( FT_Stream stream,
PCF_Face face )
{
FT_Error error = FT_Err_Ok;
FT_Error error;
FT_Memory memory = FT_FACE( face )->memory;
FT_Bool hasBDFAccelerators;

View File

@ -66,11 +66,11 @@ in this Software without prior written authorization from The Open Group.
TwoByteSwap( unsigned char* buf,
size_t nbytes )
{
unsigned char c;
for ( ; nbytes >= 2; nbytes -= 2, buf += 2 )
{
unsigned char c;
c = buf[0];
buf[0] = buf[1];
buf[1] = c;
@ -85,11 +85,11 @@ in this Software without prior written authorization from The Open Group.
FourByteSwap( unsigned char* buf,
size_t nbytes )
{
unsigned char c;
for ( ; nbytes >= 4; nbytes -= 4, buf += 4 )
{
unsigned char c;
c = buf[0];
buf[0] = buf[3];
buf[3] = c;

View File

@ -67,14 +67,16 @@
pfr_cmap_char_index( PFR_CMap cmap,
FT_UInt32 char_code )
{
FT_UInt min = 0;
FT_UInt max = cmap->num_chars;
FT_UInt mid;
PFR_Char gchar;
FT_UInt min = 0;
FT_UInt max = cmap->num_chars;
while ( min < max )
{
PFR_Char gchar;
FT_UInt mid;
mid = min + ( max - min ) / 2;
gchar = cmap->chars + mid;

View File

@ -5,7 +5,7 @@
/* PostScript hinter global hinting management (body). */
/* Inspired by the new auto-hinter module. */
/* */
/* Copyright 2001-2004, 2006, 2010, 2012 by */
/* Copyright 2001-2004, 2006, 2010, 2012, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@ -757,7 +757,7 @@
FT_Fixed x_delta,
FT_Fixed y_delta )
{
PSH_Dimension dim = &globals->dimension[0];
PSH_Dimension dim;
dim = &globals->dimension[0];

View File

@ -320,9 +320,8 @@
/* parse sub-headers */
for ( n = 0; n <= max_subs; n++ )
{
FT_UInt first_code, code_count, offset;
FT_Int delta;
FT_Byte* ids;
FT_UInt first_code, code_count, offset;
FT_Int delta;
first_code = TT_NEXT_USHORT( p );
@ -344,6 +343,9 @@
/* check offset */
if ( offset != 0 )
{
FT_Byte* ids;
ids = p - 2 + offset;
if ( ids < glyph_ids || ids + code_count*2 > table + length )
FT_INVALID_OFFSET;
@ -3208,7 +3210,6 @@
{
FT_Byte *p = tt_cmap14_find_variant( cmap->data + 6,
variantSelector );
FT_UInt32 *ret;
FT_Int i;
FT_ULong defOff;
FT_ULong nondefOff;
@ -3242,6 +3243,8 @@
FT_Byte* dp;
FT_UInt di, ni, k;
FT_UInt32 *ret;
p = cmap->data + nondefOff;
dp = cmap->data + defOff;

View File

@ -5,7 +5,7 @@
/* Load the basic TrueType kerning table. This doesn't handle */
/* kerning data within the GPOS table at the moment. */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by */
/* Copyright 1996-2007, 2009, 2010, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -183,7 +183,7 @@
FT_UInt right_glyph )
{
FT_Int result = 0;
FT_UInt count, mask = 1;
FT_UInt count, mask;
FT_Byte* p = face->kern_table;
FT_Byte* p_limit = p + face->kern_table_size;
@ -196,7 +196,7 @@
count--, mask <<= 1 )
{
FT_Byte* base = p;
FT_Byte* next = base;
FT_Byte* next;
FT_UInt version = FT_NEXT_USHORT( p );
FT_UInt length = FT_NEXT_USHORT( p );
FT_UInt coverage = FT_NEXT_USHORT( p );

View File

@ -46,7 +46,7 @@
tt_face_load_sbit( TT_Face face,
FT_Stream stream )
{
FT_Error error = FT_Err_Ok;
FT_Error error;
FT_ULong table_size;
@ -260,7 +260,7 @@
TT_HoriHeader *hori;
FT_ULong table_size;
FT_Error error = FT_Err_Ok;
FT_Error error;
FT_Byte* p;
@ -1224,7 +1224,7 @@
FT_Tag graphicType;
FT_Int recurse_depth = 0;
FT_Error error = FT_Err_Ok;
FT_Error error;
FT_Byte* p;
FT_UNUSED( map );

View File

@ -2209,7 +2209,6 @@
if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY )
{
FT_Int charcode, idx, min_char, max_char;
FT_Byte* char_name;
FT_Byte* glyph_name;
@ -2224,6 +2223,9 @@
charcode = 0;
for ( ; charcode < loader.encoding_table.max_elems; charcode++ )
{
FT_Byte* char_name;
type1->encoding.char_index[charcode] = 0;
type1->encoding.char_name [charcode] = (char *)".notdef";

View File

@ -507,7 +507,7 @@
FT_Face face = size->face;
T42_Face t42face = (T42_Face)face;
FT_Size ttsize;
FT_Error error = FT_Err_Ok;
FT_Error error;
error = FT_New_Size( t42face->ttf_face, &ttsize );