Commit a50c39aa8ec9dd90ae8f847e2e6ce3c5bfd36c3e

Werner Lemberg 2021-05-29T09:50:29

Fix compilation errors and (some) warnings for clang++. * src/autofit/afmodule.c (AF_GlyphHintsRec): Make it static. * src/cache/ftcache.c (FTC_Cache_NewNode), src/cache/ftcsbits.c (ftc_snode_compare): Remove semicolon. * src/cff/cffparse.c (cff_parser_run): Add `break` statement. * src/cid/cidload.c (cid_hex_to_binary): Add cast. * src/sdf/ftbsdf.c (CHECK_NEIGHBOR): Use `do {} while(0)` loop. (bsdf_init_distance_map, finalize_sdf, bsdf_raster_render): Add casts. * src/sdf/ftsdf.c (sdf_generate_bounding_box, sdf_generate_with_overlaps): Ditto. * src/sdf/ftsdfcommon.h (square_root): Ditto. * src/sdf/ftsdfrend.c (sdf_property_get, ft_sdf_render, ft_bsdf_render): Ditto. * src/sfnt/ttcolr.c (find_base_glyph_record, find_base_glyph_v1_record): Fix variable signedness. (read_color_line): Add cast. (read_paint): Add casts. Fix signedness issue. (tt_face_get_colorline_stops) Fix signedness issues. * src/sfnt/ttpost.c (load_format_20): Add casts. * src/truetype/ttsubpix.c (TWEAK_RULES, TWEAK_RULES_EXCEPTIONS): Remove final semicolons.

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
diff --git a/ChangeLog b/ChangeLog
index 9d74964..2f087c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,39 @@
 2021-05-29  Werner Lemberg  <wl@gnu.org>
 
+	Fix compilation errors and (some) warnings for clang++.
+
+	* src/autofit/afmodule.c (AF_GlyphHintsRec): Make it static.
+
+	* src/cache/ftcache.c (FTC_Cache_NewNode), src/cache/ftcsbits.c
+	(ftc_snode_compare): Remove semicolon.
+
+	* src/cff/cffparse.c (cff_parser_run): Add `break` statement.
+
+	* src/cid/cidload.c (cid_hex_to_binary): Add cast.
+
+	* src/sdf/ftbsdf.c (CHECK_NEIGHBOR): Use `do {} while(0)` loop.
+	(bsdf_init_distance_map, finalize_sdf, bsdf_raster_render): Add
+	casts.
+	* src/sdf/ftsdf.c (sdf_generate_bounding_box,
+	sdf_generate_with_overlaps): Ditto.
+	* src/sdf/ftsdfcommon.h (square_root): Ditto.
+	* src/sdf/ftsdfrend.c (sdf_property_get, ft_sdf_render,
+	ft_bsdf_render): Ditto.
+
+	* src/sfnt/ttcolr.c (find_base_glyph_record,
+	find_base_glyph_v1_record): Fix variable signedness.
+	(read_color_line): Add cast.
+	(read_paint): Add casts.
+	Fix signedness issue.
+	(tt_face_get_colorline_stops) Fix signedness issues.
+
+	* src/sfnt/ttpost.c (load_format_20): Add casts.
+
+	* src/truetype/ttsubpix.c (TWEAK_RULES, TWEAK_RULES_EXCEPTIONS):
+	Remove final semicolons.
+
+2021-05-29  Werner Lemberg  <wl@gnu.org>
+
 	[build] Allow overriding of `ANSIFLAGS` for GNU make build.
 
 	* builds/*: Implement it.
diff --git a/src/autofit/afmodule.c b/src/autofit/afmodule.c
index 551deb7..f892268 100644
--- a/src/autofit/afmodule.c
+++ b/src/autofit/afmodule.c
@@ -48,7 +48,7 @@
   int  _af_debug_disable_blue_hints;
 
   /* we use a global object instead of a local one for debugging */
-  AF_GlyphHintsRec  _af_debug_hints_rec[1];
+  static AF_GlyphHintsRec  _af_debug_hints_rec[1];
 
   void*  _af_debug_hints = _af_debug_hints_rec;
 #endif
diff --git a/src/cache/ftccache.c b/src/cache/ftccache.c
index 823faf8..4c03242 100644
--- a/src/cache/ftccache.c
+++ b/src/cache/ftccache.c
@@ -459,7 +459,7 @@
     {
       error = cache->clazz.node_new( &node, query, cache );
     }
-    FTC_CACHE_TRYLOOP_END( NULL );
+    FTC_CACHE_TRYLOOP_END( NULL )
 
     if ( error )
       node = NULL;
diff --git a/src/cache/ftcsbits.c b/src/cache/ftcsbits.c
index 723192f..7e24d81 100644
--- a/src/cache/ftcsbits.c
+++ b/src/cache/ftcsbits.c
@@ -395,7 +395,7 @@
         {
           error = ftc_snode_load( snode, cache->manager, gindex, &size );
         }
-        FTC_CACHE_TRYLOOP_END( list_changed );
+        FTC_CACHE_TRYLOOP_END( list_changed )
 
         ftcsnode->ref_count--;  /* unlock the node */
 
diff --git a/src/cff/cffparse.c b/src/cff/cffparse.c
index 129ecaa..dde55e9 100644
--- a/src/cff/cffparse.c
+++ b/src/cff/cffparse.c
@@ -1516,6 +1516,7 @@
 
               case cff_kind_fixed_thousand:
                 FT_TRACE4(( " %f\n", (double)val / 65536 / 1000 ));
+                break;
 
               default:
                 ; /* never reached */
diff --git a/src/cid/cidload.c b/src/cid/cidload.c
index 25dcfe6..ea53d6c 100644
--- a/src/cid/cidload.c
+++ b/src/cid/cidload.c
@@ -758,7 +758,7 @@
     error = FT_Err_Ok;
 
   Exit:
-    *data_written = d - data;
+    *data_written = FT_ULong( d - data );
     return error;
   }
 
diff --git a/src/sdf/ftbsdf.c b/src/sdf/ftbsdf.c
index af1e403..97e0438 100644
--- a/src/sdf/ftbsdf.c
+++ b/src/sdf/ftbsdf.c
@@ -289,19 +289,22 @@
 #undef CHECK_NEIGHBOR
 #endif
 
-#define CHECK_NEIGHBOR( x_offset, y_offset )            \
-          if ( x + x_offset >= 0 && x + x_offset < w && \
-               y + y_offset >= 0 && y + y_offset < r )  \
-          {                                             \
-            num_neighbors++;                            \
-                                                        \
-            to_check = dm + y_offset * w + x_offset;    \
-            if ( to_check->alpha == 0 )                 \
-            {                                           \
-              is_edge = 1;                              \
-              goto Done;                                \
-            }                                           \
-          }
+#define CHECK_NEIGHBOR( x_offset, y_offset )              \
+          do                                              \
+          {                                               \
+            if ( x + x_offset >= 0 && x + x_offset < w && \
+                 y + y_offset >= 0 && y + y_offset < r )  \
+            {                                             \
+              num_neighbors++;                            \
+                                                          \
+              to_check = dm + y_offset * w + x_offset;    \
+              if ( to_check->alpha == 0 )                 \
+              {                                           \
+                is_edge = 1;                              \
+                goto Done;                                \
+              }                                           \
+            }                                             \
+          } while ( 0 )
 
   static FT_Bool
   bsdf_is_edge( ED*     dm,   /* distance map              */
@@ -693,8 +696,8 @@
 
     /* Calculate the width and row differences */
     /* between target and source.              */
-    x_diff = worker->width - source->width;
-    y_diff = worker->rows - source->rows;
+    x_diff = worker->width - (int)source->width;
+    y_diff = worker->rows - (int)source->rows;
 
     x_diff /= 2;
     y_diff /= 2;
@@ -716,8 +719,8 @@
       {
         FT_Int  t_width = worker->width;
         FT_Int  t_rows  = worker->rows;
-        FT_Int  s_width = source->width;
-        FT_Int  s_rows  = source->rows;
+        FT_Int  s_width = (int)source->width;
+        FT_Int  s_rows  = (int)source->rows;
 
 
         for ( t_j = 0; t_j < t_rows; t_j++ )
@@ -750,7 +753,7 @@
             mod = 7 - s_i % 8;
 
             pixel = s[div];
-            byte  = 1 << mod;
+            byte  = (FT_Byte)( 1 << mod );
 
             t[t_index].alpha = pixel & byte ? 255 : 0;
 
@@ -764,8 +767,8 @@
       {
         FT_Int  t_width = worker->width;
         FT_Int  t_rows  = worker->rows;
-        FT_Int  s_width = source->width;
-        FT_Int  s_rows  = source->rows;
+        FT_Int  s_width = (int)source->width;
+        FT_Int  s_rows  = (int)source->rows;
 
 
         /* loop over all pixels and assign pixel values from source */
@@ -1103,8 +1106,8 @@
       goto Exit;
     }
 
-    w        = target->width;
-    r        = target->rows;
+    w        = (int)target->width;
+    r        = (int)target->rows;
     t_buffer = (FT_6D10*)target->buffer;
 
     if ( w != worker->width ||
@@ -1222,8 +1225,8 @@
     FT_Error   error  = FT_Err_Ok;
     FT_Memory  memory = NULL;
 
-    const FT_Bitmap*  source      = NULL;
-    const FT_Bitmap*  target      = NULL;
+    const FT_Bitmap*  source = NULL;
+    const FT_Bitmap*  target = NULL;
 
     BSDF_TRaster*  bsdf_raster = (BSDF_TRaster*)raster;
     BSDF_Worker    worker;
@@ -1247,8 +1250,8 @@
       goto Exit;
     }
 
-    source = sdf_params->root.source;
-    target = sdf_params->root.target;
+    source = (const FT_Bitmap*)sdf_params->root.source;
+    target = (const FT_Bitmap*)sdf_params->root.target;
 
     /* check source and target bitmap */
     if ( !source || !target )
@@ -1298,8 +1301,8 @@
                          target->width * sizeof ( *worker.distance_map ) ) )
       goto Exit;
 
-    worker.width  = target->width;
-    worker.rows   = target->rows;
+    worker.width  = (int)target->width;
+    worker.rows   = (int)target->rows;
     worker.params = *sdf_params;
 
     FT_CALL( bsdf_init_distance_map( source, &worker ) );
@@ -1309,7 +1312,7 @@
 
     FT_TRACE0(( "bsdf_raster_render: Total memory used = %ld\n",
                 worker.width * worker.rows *
-                  sizeof ( *worker.distance_map ) ));
+                  (long)sizeof ( *worker.distance_map ) ));
 
   Exit:
     if ( worker.distance_map )
diff --git a/src/sdf/ftsdf.c b/src/sdf/ftsdf.c
index a58d144..70c7a08 100644
--- a/src/sdf/ftsdf.c
+++ b/src/sdf/ftsdf.c
@@ -3222,18 +3222,19 @@
       goto Exit;
     }
 
+    if ( FT_ALLOC( dists,
+                   bitmap->width * bitmap->rows * sizeof ( *dists ) ) )
+      goto Exit;
+
     contours = shape->contours;
     width    = (FT_Int)bitmap->width;
     rows     = (FT_Int)bitmap->rows;
     buffer   = (FT_Short*)bitmap->buffer;
 
-    if ( FT_ALLOC( dists, width * rows * sizeof ( *dists ) ) )
-      goto Exit;
-
     if ( USE_SQUARED_DISTANCES )
-      sp_sq = FT_INT_16D16( spread * spread );
+      sp_sq = (FT_Int)FT_INT_16D16( spread * spread );
     else
-      sp_sq = FT_INT_16D16( spread );
+      sp_sq = (FT_Int)FT_INT_16D16( spread );
 
     if ( width == 0 || rows == 0 )
     {
@@ -3307,9 +3308,9 @@
               dist.distance = square_root( dist.distance );
 
             if ( internal_params.flip_y )
-              index = y * width + x;
+              index = FT_UInt( y * width + x );
             else
-              index = ( rows - y - 1 ) * width + x;
+              index = FT_UInt( ( rows - y - 1 ) * width + x );
 
             /* check whether the pixel is set or not */
             if ( dists[index].sign == 0 )
@@ -3341,7 +3342,7 @@
 
       for ( i = 0; i < width; i++ )
       {
-        index = j * width + i;
+        index = (FT_UInt)( j * width + i );
 
         /* if the pixel is not set                     */
         /* its shortest distance is more than `spread` */
@@ -3527,11 +3528,13 @@
     }
 
     /* allocate the bitmaps to generate SDF for separate contours */
-    if ( FT_ALLOC( bitmaps, num_contours * sizeof ( *bitmaps ) ) )
+    if ( FT_ALLOC( bitmaps,
+                   (FT_UInt)num_contours * sizeof ( *bitmaps ) ) )
       goto Exit;
 
     /* allocate array to hold orientation for all contours */
-    if ( FT_ALLOC( orientations, num_contours * sizeof ( *orientations ) ) )
+    if ( FT_ALLOC( orientations,
+                   (FT_UInt)num_contours * sizeof ( *orientations ) ) )
       goto Exit;
 
     /* Disable `flip_sign` to avoid extra complication */
@@ -3554,7 +3557,8 @@
       bitmaps[i].pixel_mode = bitmap->pixel_mode;
 
       /* allocate memory for the buffer */
-      if ( FT_ALLOC( bitmaps[i].buffer, bitmap->rows * bitmap->pitch ) )
+      if ( FT_ALLOC( bitmaps[i].buffer,
+                     bitmap->rows * (FT_UInt)bitmap->pitch ) )
         goto Exit;
 
       /* determine the orientation */
diff --git a/src/sdf/ftsdfcommon.h b/src/sdf/ftsdfcommon.h
index 7c55817..925a4dc 100644
--- a/src/sdf/ftsdfcommon.h
+++ b/src/sdf/ftsdfcommon.h
@@ -139,7 +139,7 @@ FT_BEGIN_HEADER
     FT_ULong  t, q, b, r;
 
 
-    r = val;
+    r = (FT_ULong)val;
     b = 0x40000000L;
     q = 0;
 
@@ -159,7 +159,7 @@ FT_BEGIN_HEADER
 
     q >>= 8;
 
-    return q;
+    return (FT_16D16)q;
   }
 
 
diff --git a/src/sdf/ftsdfrend.c b/src/sdf/ftsdfrend.c
index 3226bdc..fa2fd6d 100644
--- a/src/sdf/ftsdfrend.c
+++ b/src/sdf/ftsdfrend.c
@@ -142,7 +142,7 @@
 
     if ( ft_strcmp( property_name, "spread" ) == 0 )
     {
-      FT_Int*  val = (FT_Int*)value;
+      FT_UInt*  val = (FT_UInt*)value;
 
 
       *val = render->spread;
@@ -314,7 +314,7 @@
 
     /* ignore the pitch, pixel mode and set custom */
     bitmap->pixel_mode = FT_PIXEL_MODE_GRAY16;
-    bitmap->pitch      = bitmap->width * 2;
+    bitmap->pitch      = (int)( bitmap->width * 2 );
     bitmap->num_grays  = 65535;
 
     /* allocate new buffer */
@@ -525,7 +525,7 @@
 
     /* set up the target bitmap */
     target.pixel_mode = FT_PIXEL_MODE_GRAY16;
-    target.pitch      = target.width * 2;
+    target.pitch      = (int)( target.width * 2 );
     target.num_grays  = 65535;
 
     if ( FT_ALLOC_MULT( target.buffer, target.rows, target.pitch ) )
diff --git a/src/sfnt/ttcolr.c b/src/sfnt/ttcolr.c
index f3f396a..632547f 100644
--- a/src/sfnt/ttcolr.c
+++ b/src/sfnt/ttcolr.c
@@ -228,17 +228,17 @@
 
   static FT_Bool
   find_base_glyph_record( FT_Byte*          base_glyph_begin,
-                          FT_Int            num_base_glyph,
+                          FT_UInt           num_base_glyph,
                           FT_UInt           glyph_id,
                           BaseGlyphRecord*  record )
   {
-    FT_Int  min = 0;
-    FT_Int  max = num_base_glyph - 1;
+    FT_UInt  min = 0;
+    FT_UInt  max = num_base_glyph - 1;
 
 
     while ( min <= max )
     {
-      FT_Int    mid = min + ( max - min ) / 2;
+      FT_UInt   mid = min + ( max - min ) / 2;
       FT_Byte*  p   = base_glyph_begin + mid * BASE_GLYPH_SIZE;
 
       FT_UShort  gid = FT_NEXT_USHORT( p );
@@ -327,7 +327,7 @@
     FT_PaintExtend  paint_extend;
 
 
-    paint_extend = FT_NEXT_BYTE( p );
+    paint_extend = (FT_PaintExtend)FT_NEXT_BYTE( p );
     if ( paint_extend > FT_COLR_PAINT_EXTEND_REFLECT )
       return 0;
 
@@ -392,7 +392,7 @@
          p >= ( (FT_Byte*)colr->table + colr->table_size ) )
       return 0;
 
-    apaint->format = FT_NEXT_BYTE( p );
+    apaint->format = (FT_PaintFormat)FT_NEXT_BYTE( p );
 
     if ( apaint->format >= FT_COLR_PAINT_FORMAT_MAX )
       return 0;
@@ -425,8 +425,8 @@
 
     else if ( apaint->format == FT_COLR_PAINTFORMAT_SOLID )
     {
-      apaint->u.solid.color.palette_index = FT_NEXT_USHORT ( p );
-      apaint->u.solid.color.alpha         = FT_NEXT_USHORT ( p );
+      apaint->u.solid.color.palette_index = FT_NEXT_USHORT( p );
+      apaint->u.solid.color.alpha         = FT_NEXT_SHORT( p );
 
       return 1;
     }
@@ -454,12 +454,12 @@
                              &apaint->u.linear_gradient.colorline ) )
         return 0;
 
-      apaint->u.linear_gradient.p0.x = FT_NEXT_SHORT ( p );
-      apaint->u.linear_gradient.p0.y = FT_NEXT_SHORT ( p );
-      apaint->u.linear_gradient.p1.x = FT_NEXT_SHORT ( p );
-      apaint->u.linear_gradient.p1.y = FT_NEXT_SHORT ( p );
-      apaint->u.linear_gradient.p2.x = FT_NEXT_SHORT ( p );
-      apaint->u.linear_gradient.p2.y = FT_NEXT_SHORT ( p );
+      apaint->u.linear_gradient.p0.x = FT_NEXT_SHORT( p );
+      apaint->u.linear_gradient.p0.y = FT_NEXT_SHORT( p );
+      apaint->u.linear_gradient.p1.x = FT_NEXT_SHORT( p );
+      apaint->u.linear_gradient.p1.y = FT_NEXT_SHORT( p );
+      apaint->u.linear_gradient.p2.x = FT_NEXT_SHORT( p );
+      apaint->u.linear_gradient.p2.y = FT_NEXT_SHORT( p );
 
       return 1;
     }
@@ -470,15 +470,15 @@
                              &apaint->u.radial_gradient.colorline ) )
         return 0;
 
-      apaint->u.radial_gradient.c0.x = FT_NEXT_SHORT ( p );
-      apaint->u.radial_gradient.c0.y = FT_NEXT_SHORT ( p );
+      apaint->u.radial_gradient.c0.x = FT_NEXT_SHORT( p );
+      apaint->u.radial_gradient.c0.y = FT_NEXT_SHORT( p );
 
-      apaint->u.radial_gradient.r0 = FT_NEXT_USHORT ( p );
+      apaint->u.radial_gradient.r0 = FT_NEXT_USHORT( p );
 
-      apaint->u.radial_gradient.c1.x = FT_NEXT_SHORT ( p );
-      apaint->u.radial_gradient.c1.y = FT_NEXT_SHORT ( p );
+      apaint->u.radial_gradient.c1.x = FT_NEXT_SHORT( p );
+      apaint->u.radial_gradient.c1.y = FT_NEXT_SHORT( p );
 
-      apaint->u.radial_gradient.r1 = FT_NEXT_USHORT ( p );
+      apaint->u.radial_gradient.r1 = FT_NEXT_USHORT( p );
 
       return 1;
     }
@@ -489,8 +489,8 @@
                              &apaint->u.sweep_gradient.colorline ) )
         return 0;
 
-      apaint->u.sweep_gradient.center.x = FT_NEXT_SHORT ( p );
-      apaint->u.sweep_gradient.center.y = FT_NEXT_SHORT ( p );
+      apaint->u.sweep_gradient.center.x = FT_NEXT_SHORT( p );
+      apaint->u.sweep_gradient.center.y = FT_NEXT_SHORT( p );
 
       apaint->u.sweep_gradient.start_angle = FT_NEXT_LONG( p );
       apaint->u.sweep_gradient.end_angle = FT_NEXT_LONG( p );
@@ -572,7 +572,7 @@
       if ( composite_mode >= FT_COLR_COMPOSITE_MAX )
         return 0;
 
-      apaint->u.composite.composite_mode = composite_mode;
+      apaint->u.composite.composite_mode = (FT_Composite_Mode)composite_mode;
 
       if ( !get_child_table_pointer( colr, paint_base, &p, &child_table_p ) )
          return 0;
@@ -591,17 +591,17 @@
 
   static FT_Bool
   find_base_glyph_v1_record ( FT_Byte *           base_glyph_begin,
-                              FT_Int              num_base_glyph,
+                              FT_UInt             num_base_glyph,
                               FT_UInt             glyph_id,
                               BaseGlyphV1Record  *record )
   {
-    FT_Int  min = 0;
-    FT_Int  max = num_base_glyph - 1;
+    FT_UInt  min = 0;
+    FT_UInt  max = num_base_glyph - 1;
 
 
     while ( min <= max )
     {
-      FT_Int  mid = min + ( max - min ) / 2;
+      FT_UInt  mid = min + ( max - min ) / 2;
 
       /*
        * `base_glyph_begin` is the beginning of `BaseGlyphV1List`;
@@ -763,11 +763,11 @@
     /* Iterator points at first `ColorStop` of `ColorLine`. */
     p = iterator->p;
 
-    color_stop->stop_offset = FT_NEXT_USHORT ( p );
+    color_stop->stop_offset = FT_NEXT_SHORT( p );
 
-    color_stop->color.palette_index = FT_NEXT_USHORT ( p );
+    color_stop->color.palette_index = FT_NEXT_USHORT( p );
 
-    color_stop->color.alpha = FT_NEXT_USHORT ( p );
+    color_stop->color.alpha = FT_NEXT_SHORT( p );
 
     iterator->p = p;
     iterator->current_color_stop++;
diff --git a/src/sfnt/ttpost.c b/src/sfnt/ttpost.c
index 5ce7706..427c3f4 100644
--- a/src/sfnt/ttpost.c
+++ b/src/sfnt/ttpost.c
@@ -180,8 +180,8 @@
     /* There already exist fonts which have more than 32768 glyph names */
     /* in this table, so the test for this threshold has been dropped.  */
 
-    if ( num_glyphs > face->max_profile.numGlyphs ||
-         num_glyphs * 2UL > post_len - 2          )
+    if ( num_glyphs > face->max_profile.numGlyphs  ||
+         (FT_ULong)num_glyphs * 2UL > post_len - 2 )
     {
       error = FT_THROW( Invalid_File_Format );
       goto Exit;
@@ -231,7 +231,7 @@
       FT_ULong   p;
 
 
-      post_len -= num_glyphs * 2UL + 2;
+      post_len -= (FT_ULong)num_glyphs * 2UL + 2;
 
       if ( FT_QALLOC( strings, post_len + 1 )       ||
            FT_STREAM_READ( strings, post_len )      ||
diff --git a/src/truetype/ttsubpix.c b/src/truetype/ttsubpix.c
index 460f712..e3b523e 100644
--- a/src/truetype/ttsubpix.c
+++ b/src/truetype/ttsubpix.c
@@ -891,12 +891,12 @@
 #define TWEAK_RULES( x )                                       \
   if ( sph_test_tweak( face, family, ppem, style, glyph_index, \
                        x##_Rules, x##_RULES_SIZE ) )           \
-    loader->exec->sph_tweak_flags |= SPH_TWEAK_##x;
+    loader->exec->sph_tweak_flags |= SPH_TWEAK_##x
 
 #define TWEAK_RULES_EXCEPTIONS( x )                                        \
   if ( sph_test_tweak( face, family, ppem, style, glyph_index,             \
                        x##_Rules_Exceptions, x##_RULES_EXCEPTIONS_SIZE ) ) \
-    loader->exec->sph_tweak_flags &= ~SPH_TWEAK_##x;
+    loader->exec->sph_tweak_flags &= ~SPH_TWEAK_##x
 
 
   FT_LOCAL_DEF( void )