Commit 96fb73efd5c69c2c34ebe2a4d7096774c87da145

Werner Lemberg 2020-07-07T16:58:14

Fix clang warnings. * include/freetype/internal/autohint.h (FT_DECLARE_AUTOHINTER_INTERFACE): New macro. * src/autofit/afmodule.h: Use it to declare `af_autofitter_interface'. * include/freetype/internal/ftobjs.h (FT_DECLARE_GLYPH): New macro. * src/base/ftbase.h: Use it to declare `ft_bitmap_glyph_class' and `ft_outline_glyph_class'. * src/base/ftglyph.c: Include `ftbase.h'. * src/cff/cffparse.c (cff_parser_run): Fix type of `t2_size'. * src/pcf/pcfdrivr.c (pcf_cmap_char_next): Fix type of `result'. * src/psaux/psauxmod.c (psaux_module_class): Use `FT_DEFINE_MODULE'. * src/psaux/psauxmod.h: Declare `afm_parser_funcs', `t1_cmap_classes', `cff_decoder_funcs', and `psaux_module_class'. * src/pshinter/pshmod.c: Include `pshmod.h'. * src/sfnt/sfwoff2.c (ROUND4, WRITE_SHORT): Fix implicit sign conversion. (compute_ULong_sum): Fix return type. Fix implicit sign conversion. (store_points): Fix type of `last_flag', `repeat_count', and `flag'. Use casts to avoid warnings. (reconstruct_glyf): Fix implicit sign conversion. Use cast to avoid warning. (get_x_mins): Fix implicit sign conversion. * src/sfnt/ttcmap.c: Undef `TTCMAPCITEM'. * src/sfnt/ttcmap.h: Define `TTCMAPCITEM' and include `ttcmapc.h' to declare cmap classes. * src/smooth/ftsmooth.c (ft_smooth_overlap_spans): Use cast. * src/truetype/ttinterp.c (Ins_MIAP): Fix typo.

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
diff --git a/ChangeLog b/ChangeLog
index 39d2e89..c305860 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,45 @@
+2020-07-07  Werner Lemberg  <wl@gnu.org>
+
+	Fix clang warnings.
+
+	* include/freetype/internal/autohint.h
+	(FT_DECLARE_AUTOHINTER_INTERFACE): New macro.
+	* src/autofit/afmodule.h: Use it to declare
+	`af_autofitter_interface'.
+
+	* include/freetype/internal/ftobjs.h (FT_DECLARE_GLYPH): New macro.
+	* src/base/ftbase.h: Use it to declare `ft_bitmap_glyph_class' and
+	`ft_outline_glyph_class'.
+
+	* src/base/ftglyph.c: Include `ftbase.h'.
+
+	* src/cff/cffparse.c (cff_parser_run): Fix type of `t2_size'.
+
+	* src/pcf/pcfdrivr.c (pcf_cmap_char_next): Fix type of `result'.
+
+	* src/psaux/psauxmod.c (psaux_module_class): Use `FT_DEFINE_MODULE'.
+	* src/psaux/psauxmod.h: Declare `afm_parser_funcs',
+	`t1_cmap_classes', `cff_decoder_funcs', and `psaux_module_class'.
+
+	* src/pshinter/pshmod.c: Include `pshmod.h'.
+
+	* src/sfnt/sfwoff2.c (ROUND4, WRITE_SHORT): Fix implicit sign
+	conversion.
+	(compute_ULong_sum): Fix return type.
+	Fix implicit sign conversion.
+	(store_points): Fix type of `last_flag', `repeat_count', and `flag'.
+	Use casts to avoid warnings.
+	(reconstruct_glyf): Fix implicit sign conversion.
+	Use cast to avoid warning.
+	(get_x_mins): Fix implicit sign conversion.
+	* src/sfnt/ttcmap.c: Undef `TTCMAPCITEM'.
+	* src/sfnt/ttcmap.h: Define `TTCMAPCITEM' and include `ttcmapc.h' to
+	declare cmap classes.
+
+	* src/smooth/ftsmooth.c (ft_smooth_overlap_spans): Use cast.
+
+	* src/truetype/ttinterp.c (Ins_MIAP): Fix typo.
+
 2020-07-07  David Turner  <david@freetype.org>
 
 	[build] Really fix multi and C++ builds.
diff --git a/include/freetype/internal/autohint.h b/include/freetype/internal/autohint.h
index d4220a2..2a472e2 100644
--- a/include/freetype/internal/autohint.h
+++ b/include/freetype/internal/autohint.h
@@ -207,6 +207,9 @@ FT_BEGIN_HEADER
   } FT_AutoHinter_InterfaceRec, *FT_AutoHinter_Interface;
 
 
+#define FT_DECLARE_AUTOHINTER_INTERFACE( class_ )            \
+  FT_CALLBACK_TABLE const FT_AutoHinter_InterfaceRec  class_;
+
 #define FT_DEFINE_AUTOHINTER_INTERFACE(       \
           class_,                             \
           reset_face_,                        \
diff --git a/include/freetype/internal/ftobjs.h b/include/freetype/internal/ftobjs.h
index 07c5e70..25db2c4 100644
--- a/include/freetype/internal/ftobjs.h
+++ b/include/freetype/internal/ftobjs.h
@@ -226,8 +226,8 @@ FT_BEGIN_HEADER
   } FT_CMap_ClassRec;
 
 
-#define FT_DECLARE_CMAP_CLASS( class_ )              \
-  FT_CALLBACK_TABLE const  FT_CMap_ClassRec class_;
+#define FT_DECLARE_CMAP_CLASS( class_ )            \
+  FT_CALLBACK_TABLE const FT_CMap_ClassRec  class_;
 
 #define FT_DEFINE_CMAP_CLASS(       \
           class_,                   \
@@ -1057,6 +1057,9 @@ FT_BEGIN_HEADER
    *   The struct will be allocated in the global scope (or the scope where
    *   the macro is used).
    */
+#define FT_DECLARE_GLYPH( class_ )                \
+  FT_CALLBACK_TABLE const FT_Glyph_Class  class_;
+
 #define FT_DEFINE_GLYPH(          \
           class_,                 \
           size_,                  \
diff --git a/src/autofit/afmodule.c b/src/autofit/afmodule.c
index 95d58b8..f52b2b2 100644
--- a/src/autofit/afmodule.c
+++ b/src/autofit/afmodule.c
@@ -550,8 +550,8 @@
     NULL,                                                    /* reset_face */
     NULL,                                              /* get_global_hints */
     NULL,                                             /* done_global_hints */
-    (FT_AutoHinter_GlyphLoadFunc)af_autofitter_load_glyph )  /* load_glyph */
-
+    (FT_AutoHinter_GlyphLoadFunc)af_autofitter_load_glyph    /* load_glyph */
+  )
 
   FT_DEFINE_MODULE(
     autofit_module_class,
diff --git a/src/autofit/afmodule.h b/src/autofit/afmodule.h
index 74c4ff6..e8fe4a9 100644
--- a/src/autofit/afmodule.h
+++ b/src/autofit/afmodule.h
@@ -46,6 +46,7 @@ FT_BEGIN_HEADER
   } AF_ModuleRec, *AF_Module;
 
 
+FT_DECLARE_AUTOHINTER_INTERFACE( af_autofitter_interface )
 FT_DECLARE_MODULE( autofit_module_class )
 
 
diff --git a/src/base/ftbase.h b/src/base/ftbase.h
index b03922a..25afa9b 100644
--- a/src/base/ftbase.h
+++ b/src/base/ftbase.h
@@ -26,6 +26,10 @@
 FT_BEGIN_HEADER
 
 
+  FT_DECLARE_GLYPH( ft_bitmap_glyph_class )
+  FT_DECLARE_GLYPH( ft_outline_glyph_class )
+
+
 #ifdef FT_CONFIG_OPTION_MAC_FONTS
 
   /* MacOS resource fork cannot exceed 16MB at least for Carbon code; */
diff --git a/src/base/ftglyph.c b/src/base/ftglyph.c
index 78dff7f..825eba2 100644
--- a/src/base/ftglyph.c
+++ b/src/base/ftglyph.c
@@ -35,6 +35,8 @@
 #include <freetype/ftbitmap.h>
 #include <freetype/internal/ftobjs.h>
 
+#include "ftbase.h"
+
 
   /**************************************************************************
    *
diff --git a/src/cff/cffcmap.h b/src/cff/cffcmap.h
index fc6bd90..69fab8d 100644
--- a/src/cff/cffcmap.h
+++ b/src/cff/cffcmap.h
@@ -43,7 +43,7 @@ FT_BEGIN_HEADER
   } CFF_CMapStdRec;
 
 
-  FT_DECLARE_CMAP_CLASS(cff_cmap_encoding_class_rec)
+  FT_DECLARE_CMAP_CLASS( cff_cmap_encoding_class_rec )
 
 
   /*************************************************************************/
@@ -56,7 +56,7 @@ FT_BEGIN_HEADER
 
   /* unicode (synthetic) cmaps */
 
-  FT_DECLARE_CMAP_CLASS(cff_cmap_unicode_class_rec)
+  FT_DECLARE_CMAP_CLASS( cff_cmap_unicode_class_rec )
 
 
 FT_END_HEADER
diff --git a/src/cff/cffparse.c b/src/cff/cffparse.c
index 25c90d2..758788e 100644
--- a/src/cff/cffparse.c
+++ b/src/cff/cffparse.c
@@ -1263,11 +1263,11 @@
         FT_Byte*     charstring_base;
         FT_ULong     charstring_len;
 
-        FT_Fixed*     stack;
-        FT_ListNode   node;
-        CFF_T2_String t2;
-        size_t        t2_size;
-        FT_Byte*      q;
+        FT_Fixed*      stack;
+        FT_ListNode    node;
+        CFF_T2_String  t2;
+        FT_Fixed       t2_size;
+        FT_Byte*       q;
 
 
         charstring_base = ++p;
diff --git a/src/pcf/pcfdrivr.c b/src/pcf/pcfdrivr.c
index b0b5ee4..f68e60e 100644
--- a/src/pcf/pcfdrivr.c
+++ b/src/pcf/pcfdrivr.c
@@ -136,7 +136,7 @@ THE SOFTWARE.
     FT_UInt32  charcode  = *acharcode;
     FT_UShort  charcodeRow;
     FT_UShort  charcodeCol;
-    FT_Int     result = 0;
+    FT_UInt    result = 0;
 
 
     while ( charcode < (FT_UInt32)( enc->lastRow * 256 + enc->lastCol ) )
diff --git a/src/psaux/psauxmod.c b/src/psaux/psauxmod.c
index bfc507c..e73ba22 100644
--- a/src/psaux/psauxmod.c
+++ b/src/psaux/psauxmod.c
@@ -170,9 +170,9 @@
   };
 
 
-  FT_CALLBACK_TABLE_DEF
-  const FT_Module_Class  psaux_module_class =
-  {
+  FT_DEFINE_MODULE(
+    psaux_module_class,
+
     0,
     sizeof ( FT_ModuleRec ),
     "psaux",
@@ -184,7 +184,7 @@
     (FT_Module_Constructor)NULL,  /* module_init   */
     (FT_Module_Destructor) NULL,  /* module_done   */
     (FT_Module_Requester)  NULL   /* get_interface */
-  };
+  )
 
 
 /* END */
diff --git a/src/psaux/psauxmod.h b/src/psaux/psauxmod.h
index 400d0ea..a6bebe4 100644
--- a/src/psaux/psauxmod.h
+++ b/src/psaux/psauxmod.h
@@ -34,10 +34,24 @@ FT_BEGIN_HEADER
   FT_CALLBACK_TABLE
   const PS_Builder_FuncsRec   ps_builder_funcs;
 
+#ifndef T1_CONFIG_OPTION_NO_AFM
+  FT_CALLBACK_TABLE
+  const AFM_Parser_FuncsRec  afm_parser_funcs;
+#endif
+
+  FT_CALLBACK_TABLE
+  const T1_CMap_ClassesRec  t1_cmap_classes;
+
+  FT_CALLBACK_TABLE
+  const CFF_Decoder_FuncsRec  cff_decoder_funcs;
+
 
   FT_EXPORT_VAR( const FT_Module_Class )  psaux_driver_class;
 
 
+  FT_DECLARE_MODULE( psaux_module_class )
+
+
 FT_END_HEADER
 
 #endif /* PSAUXMOD_H_ */
diff --git a/src/pshinter/pshmod.c b/src/pshinter/pshmod.c
index 801bf92..e0abd38 100644
--- a/src/pshinter/pshmod.c
+++ b/src/pshinter/pshmod.c
@@ -19,6 +19,7 @@
 #include <freetype/internal/ftobjs.h>
 #include "pshrec.h"
 #include "pshalgo.h"
+#include "pshmod.h"
 
 
   /* the Postscript Hinter module structure */
diff --git a/src/sfnt/sfwoff2.c b/src/sfnt/sfwoff2.c
index 781b932..895d6cf 100644
--- a/src/sfnt/sfwoff2.c
+++ b/src/sfnt/sfwoff2.c
@@ -43,7 +43,8 @@
 
 #define READ_BASE128( var )    FT_SET_ERROR( ReadBase128( stream, &var ) )
 
-#define ROUND4( var )          ( ( var + 3 ) & ~3 )
+  /* `var' should be FT_ULong */
+#define ROUND4( var )          ( ( var + 3 ) & ~3UL )
 
 #define WRITE_USHORT( p, v )                \
           do                                \
@@ -63,12 +64,12 @@
                                              \
           } while ( 0 )
 
-#define WRITE_SHORT( p, v )        \
-          do                       \
-          {                        \
-            *(p)++ = ( (v) >> 8 ); \
-            *(p)++ = ( (v) >> 0 ); \
-                                   \
+#define WRITE_SHORT( p, v )                 \
+          do                                \
+          {                                 \
+            *(p)++ = (FT_Byte)( (v) >> 8 ); \
+            *(p)++ = (FT_Byte)( (v) >> 0 ); \
+                                            \
           } while ( 0 )
 
 #define WRITE_SFNT_BUF( buf, s ) \
@@ -280,12 +281,12 @@
 
 
   /* Calculate table checksum of `buf'. */
-  static FT_Long
+  static FT_ULong
   compute_ULong_sum( FT_Byte*  buf,
                      FT_ULong  size )
   {
     FT_ULong  checksum     = 0;
-    FT_ULong  aligned_size = size & ~3;
+    FT_ULong  aligned_size = size & ~3UL;
     FT_ULong  i;
     FT_ULong  v;
 
@@ -536,12 +537,12 @@
                 FT_ULong*          glyph_size )
   {
     FT_UInt   flag_offset  = 10 + ( 2 * n_contours ) + 2 + instruction_len;
-    FT_Int    last_flag    = -1;
-    FT_Int    repeat_count =  0;
-    FT_Int    last_x       =  0;
-    FT_Int    last_y       =  0;
-    FT_UInt   x_bytes      =  0;
-    FT_UInt   y_bytes      =  0;
+    FT_Byte   last_flag    = 0xFFU;
+    FT_Byte   repeat_count = 0;
+    FT_Int    last_x       = 0;
+    FT_Int    last_y       = 0;
+    FT_UInt   x_bytes      = 0;
+    FT_UInt   y_bytes      = 0;
     FT_UInt   xy_bytes;
     FT_UInt   i;
     FT_UInt   x_offset;
@@ -553,9 +554,9 @@
     {
       const WOFF2_PointRec  point = points[i];
 
-      FT_Int  flag = point.on_curve ? GLYF_ON_CURVE : 0;
-      FT_Int  dx   = point.x - last_x;
-      FT_Int  dy   = point.y - last_y;
+      FT_Byte  flag = point.on_curve ? GLYF_ON_CURVE : 0;
+      FT_Int   dx   = point.x - last_x;
+      FT_Int   dy   = point.y - last_y;
 
 
       if ( dx == 0 )
@@ -632,7 +633,7 @@
       if ( dx == 0 )
         ;
       else if ( dx > -256 && dx < 256 )
-        dst[x_offset++] = FT_ABS( dx );
+        dst[x_offset++] = (FT_Byte)FT_ABS( dx );
       else
       {
         pointer = dst + x_offset;
@@ -645,7 +646,7 @@
       if ( dy == 0 )
         ;
       else if ( dy > -256 && dy < 256 )
-        dst[y_offset++] = FT_ABS( dy );
+        dst[y_offset++] = (FT_Byte)FT_ABS( dy );
       else
       {
         pointer = dst + y_offset;
@@ -917,7 +918,7 @@
     bbox_bitmap_offset = substreams[BBOX_STREAM].offset;
 
     /* Size of bboxBitmap = 4 * floor((numGlyphs + 31) / 32) */
-    bitmap_length                   = ( ( num_glyphs + 31 ) >> 5 ) << 2;
+    bitmap_length                   = ( ( num_glyphs + 31U ) >> 5 ) << 2;
     substreams[BBOX_STREAM].offset += bitmap_length;
 
     glyph_buf_size = WOFF2_DEFAULT_GLYPH_BUF;
@@ -1195,7 +1196,7 @@
 
       /* Store x_mins, may be required to reconstruct `hmtx'. */
       if ( n_contours > 0 )
-        info->x_mins[i] = x_min;
+        info->x_mins[i] = (FT_Short)x_min;
     }
 
     info->glyf_table->dst_length = dest_offset - info->glyf_table->dst_offset;
@@ -1343,7 +1344,7 @@
       if ( FT_STREAM_SEEK( glyf_offset ) || FT_STREAM_SKIP( 2 ) )
         return error;
 
-      if ( FT_READ_USHORT( info->x_mins[i] ) )
+      if ( FT_READ_SHORT( info->x_mins[i] ) )
         return error;
     }
 
diff --git a/src/sfnt/ttcmap.c b/src/sfnt/ttcmap.c
index e54baf9..556a712 100644
--- a/src/sfnt/ttcmap.c
+++ b/src/sfnt/ttcmap.c
@@ -3751,6 +3751,7 @@
 
   static const TT_CMap_Class  tt_cmap_classes[] =
   {
+#undef  TTCMAPCITEM
 #define TTCMAPCITEM( a )  &a,
 #include "ttcmapc.h"
     NULL,
diff --git a/src/sfnt/ttcmap.h b/src/sfnt/ttcmap.h
index 428ad21..c7d7c21 100644
--- a/src/sfnt/ttcmap.h
+++ b/src/sfnt/ttcmap.h
@@ -90,6 +90,11 @@ FT_BEGIN_HEADER
   };
 
 
+#undef  TTCMAPCITEM
+#define TTCMAPCITEM( a )  FT_CALLBACK_TABLE  const TT_CMap_ClassRec  a;
+#include "ttcmapc.h"
+
+
   typedef struct  TT_ValidatorRec_
   {
     FT_ValidatorRec  validator;
diff --git a/src/smooth/ftsmooth.c b/src/smooth/ftsmooth.c
index b326292..3ce1cea 100644
--- a/src/smooth/ftsmooth.c
+++ b/src/smooth/ftsmooth.c
@@ -358,8 +358,8 @@
       cover = ( spans->coverage + SCALE * SCALE / 2 ) / ( SCALE * SCALE );
       for ( x = 0; x < spans->len; x++ )
       {
-        sum = dst[ ( spans->x + x ) / SCALE ] + cover;
-        dst[ ( spans->x + x ) / SCALE ] = sum - ( sum >> 8 );
+        sum                           = dst[( spans->x + x ) / SCALE] + cover;
+        dst[( spans->x + x ) / SCALE] = (unsigned char)( sum - ( sum >> 8 ) );
       }
     }
   }
diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c
index 6aecfb4..41b174e 100644
--- a/src/truetype/ttinterp.c
+++ b/src/truetype/ttinterp.c
@@ -6081,7 +6081,7 @@
         exc->zp0.org[point].x = TT_MulFix14( distance,
                                              exc->GS.freeVector.x );
       exc->zp0.org[point].y = TT_MulFix14( distance,
-                                           exc->GS.freeVector.y ),
+                                           exc->GS.freeVector.y );
       exc->zp0.cur[point]   = exc->zp0.org[point];
     }
 #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY