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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632
diff --git a/ChangeLog b/ChangeLog
index 8de2ab8..f07d658 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/builds/mac/ftmac.c b/builds/mac/ftmac.c
index 16d50e8..40f6bd2 100644
--- a/builds/mac/ftmac.c
+++ b/builds/mac/ftmac.c
@@ -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 */
diff --git a/src/base/ftglyph.c b/src/base/ftglyph.c
index 5dd28a8..c62b3db 100644
--- a/src/base/ftglyph.c
+++ b/src/base/ftglyph.c
@@ -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;
}
diff --git a/src/base/ftmac.c b/src/base/ftmac.c
index 5b5aae6..9b49da8 100644
--- a/src/base/ftmac.c
+++ b/src/base/ftmac.c
@@ -963,7 +963,6 @@
if ( !pathname )
return FT_THROW( Invalid_Argument );
- error = FT_Err_Ok;
*aface = NULL;
/* try resourcefork based font: LWFN, FFIL */
diff --git a/src/base/ftoutln.c b/src/base/ftoutln.c
index 54ca5cd..177a4ca 100644
--- a/src/base/ftoutln.c
+++ b/src/base/ftoutln.c
@@ -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;
diff --git a/src/base/ftpic.c b/src/base/ftpic.c
index 1c87101..9bd92f7 100644
--- a/src/base/ftpic.c
+++ b/src/base/ftpic.c
@@ -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 ) );
diff --git a/src/cff/cf2blues.c b/src/cff/cf2blues.c
index 5b34839..eec589e 100644
--- a/src/cff/cf2blues.c
+++ b/src/cff/cf2blues.c
@@ -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;
diff --git a/src/cid/cidload.c b/src/cid/cidload.c
index f2a18ea..46def71 100644
--- a/src/cid/cidload.c
+++ b/src/cid/cidload.c
@@ -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;
diff --git a/src/gxvalid/gxvcommn.c b/src/gxvalid/gxvcommn.c
index 2ac80be..7af5234 100644
--- a/src/gxvalid/gxvcommn.c
+++ b/src/gxvalid/gxvcommn.c
@@ -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;
}
diff --git a/src/gxvalid/gxvcommn.h b/src/gxvalid/gxvcommn.h
index 1ff87e4..2f44a75 100644
--- a/src/gxvalid/gxvcommn.h
+++ b/src/gxvalid/gxvcommn.h
@@ -318,7 +318,7 @@ FT_BEGIN_HEADER
FT_BEGIN_STMNT \
{ \
if ( (a) & 3 ) \
- FT_INVALID_OFFSET ; \
+ FT_INVALID_OFFSET; \
} \
FT_END_STMNT
diff --git a/src/gxvalid/gxvmort.c b/src/gxvalid/gxvmort.c
index 5356e67..c4d49b3 100644
--- a/src/gxvalid/gxvmort.c
+++ b/src/gxvalid/gxvmort.c
@@ -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
}
diff --git a/src/gxvalid/gxvmorx2.c b/src/gxvalid/gxvmorx2.c
index 9d2b0bc..95b8ea4 100644
--- a/src/gxvalid/gxvmorx2.c
+++ b/src/gxvalid/gxvmorx2.c
@@ -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;
diff --git a/src/pcf/pcfdrivr.c b/src/pcf/pcfdrivr.c
index df25a64..9ceff7f 100644
--- a/src/pcf/pcfdrivr.c
+++ b/src/pcf/pcfdrivr.c
@@ -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++ )
+ PCF_Property prop = &face->properties[i];
+
+
+ if ( prop )
{
- prop = &face->properties[i];
-
- if ( prop )
- {
- FT_FREE( prop->name );
- if ( prop->isString )
- FT_FREE( prop->value.atom );
- }
+ 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 );
diff --git a/src/pcf/pcfread.c b/src/pcf/pcfread.c
index 3c1bb7d..ee41c5d 100644
--- a/src/pcf/pcfread.c
+++ b/src/pcf/pcfread.c
@@ -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;
diff --git a/src/pcf/pcfutil.c b/src/pcf/pcfutil.c
index b91274f..0451ee8 100644
--- a/src/pcf/pcfutil.c
+++ b/src/pcf/pcfutil.c
@@ -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;
diff --git a/src/pfr/pfrcmap.c b/src/pfr/pfrcmap.c
index 740c433..1f05640 100644
--- a/src/pfr/pfrcmap.c
+++ b/src/pfr/pfrcmap.c
@@ -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;
diff --git a/src/pshinter/pshglob.c b/src/pshinter/pshglob.c
index 9285efc..f75bae4 100644
--- a/src/pshinter/pshglob.c
+++ b/src/pshinter/pshglob.c
@@ -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];
diff --git a/src/sfnt/ttcmap.c b/src/sfnt/ttcmap.c
index 1507202..9b7856b 100644
--- a/src/sfnt/ttcmap.c
+++ b/src/sfnt/ttcmap.c
@@ -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;
diff --git a/src/sfnt/ttkern.c b/src/sfnt/ttkern.c
index 60ee546..32c4008 100644
--- a/src/sfnt/ttkern.c
+++ b/src/sfnt/ttkern.c
@@ -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 );
diff --git a/src/sfnt/ttsbit.c b/src/sfnt/ttsbit.c
index 7d56851..8258f79 100644
--- a/src/sfnt/ttsbit.c
+++ b/src/sfnt/ttsbit.c
@@ -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 );
diff --git a/src/type1/t1load.c b/src/type1/t1load.c
index 1c834a1..4b5026b 100644
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -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";
diff --git a/src/type42/t42objs.c b/src/type42/t42objs.c
index 18e2c0b..c9a1c47 100644
--- a/src/type42/t42objs.c
+++ b/src/type42/t42objs.c
@@ -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 );