Commit 82235d0474567d8d1f85d23462a3223571d4c424

Werner Lemberg 2015-02-16T19:35:16

Next round of minor compiler warning fixes. * include/internal/ftrfork.h (FT_RFork_Ref): Change `offset' member type to `FT_Long'. (CONST_FT_RFORK_RULE_ARRAY_BEGIN): Add `static' keyword. * include/internal/ftstream.h (FT_Stream_Pos): Return `FT_ULong'. * src/base/ftoutln.c, src/base/ftrfork.c, src/base/ftstream.c: Signedess fixes.

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
diff --git a/ChangeLog b/ChangeLog
index e5700dc..7c6a52c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 2015-02-16  Werner Lemberg  <wl@gnu.org>
 
+	Next round of minor compiler warning fixes.
+
+	* include/internal/ftrfork.h (FT_RFork_Ref): Change `offset' member
+	type to `FT_Long'.
+	(CONST_FT_RFORK_RULE_ARRAY_BEGIN): Add `static' keyword.
+
+	* include/internal/ftstream.h (FT_Stream_Pos): Return `FT_ULong'. 
+
+	* src/base/ftoutln.c, src/base/ftrfork.c, src/base/ftstream.c:
+	Signedess fixes.
+
+2015-02-16  Werner Lemberg  <wl@gnu.org>
+
 	Various minor signedness fixes.
 
 	* include/ftadvanc.h, include/internal/ftobjs.h,
diff --git a/include/internal/ftrfork.h b/include/internal/ftrfork.h
index 5885dcd..da61ca7 100644
--- a/include/internal/ftrfork.h
+++ b/include/internal/ftrfork.h
@@ -44,7 +44,7 @@ FT_BEGIN_HEADER
   typedef struct  FT_RFork_Ref_
   {
     FT_UShort  res_id;
-    FT_ULong   offset;
+    FT_Long    offset;
 
   } FT_RFork_Ref;
 
@@ -83,7 +83,7 @@ FT_BEGIN_HEADER
 
   /* this array is a storage in non-PIC mode, so ; is needed in END */
 #define CONST_FT_RFORK_RULE_ARRAY_BEGIN( name, type )  \
-          const type name[] = {
+          static const type name[] = {
 #define CONST_FT_RFORK_RULE_ARRAY_ENTRY( func_suffix, type_suffix )  \
           { raccess_guess_ ## func_suffix,                           \
             FT_RFork_Rule_ ## type_suffix },
diff --git a/include/internal/ftstream.h b/include/internal/ftstream.h
index b37e7fa..384e5df 100644
--- a/include/internal/ftstream.h
+++ b/include/internal/ftstream.h
@@ -361,7 +361,7 @@ FT_BEGIN_HEADER
                   FT_Long    distance );
 
   /* return current stream position */
-  FT_BASE( FT_Long )
+  FT_BASE( FT_ULong )
   FT_Stream_Pos( FT_Stream  stream );
 
   /* read bytes from a stream into a user-allocated buffer, returns an */
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index d6853b9..33d23bf 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -1495,7 +1495,7 @@
     FT_UNUSED( params );
 
 
-    pos = (FT_ULong)FT_Stream_Pos( stream );
+    pos = FT_STREAM_POS();
 
     error = ft_lookup_PS_in_sfnt_stream( stream,
                                          face_index,
diff --git a/src/base/ftoutln.c b/src/base/ftoutln.c
index c2b2029..3762d36 100644
--- a/src/base/ftoutln.c
+++ b/src/base/ftoutln.c
@@ -279,7 +279,7 @@
       if ( error )
         goto Exit;
 
-      first = last + 1;
+      first = (FT_UInt)last + 1;
     }
 
     FT_TRACE5(( "FT_Outline_Decompose: Done\n", n ));
@@ -320,7 +320,7 @@
          FT_NEW_ARRAY( anoutline->contours, numContours ) )
       goto Fail;
 
-    anoutline->n_points    = (FT_UShort)numPoints;
+    anoutline->n_points    = (FT_Short)numPoints;
     anoutline->n_contours  = (FT_Short)numContours;
     anoutline->flags      |= FT_OUTLINE_OWNER;
 
@@ -1043,7 +1043,7 @@
     /* We use the nonzero winding rule to find the orientation.       */
     /* Since glyph outlines behave much more `regular' than arbitrary */
     /* cubic or quadratic curves, this test deals with the polygon    */
-    /* only which is spanned up by the control points.                */
+    /* only that is spanned up by the control points.                 */
 
     FT_Outline_Get_CBox( outline, &cbox );
 
@@ -1051,10 +1051,11 @@
     if ( cbox.xMin == cbox.xMax || cbox.yMin == cbox.yMax )
       return FT_ORIENTATION_NONE;
 
-    xshift = FT_MSB( FT_ABS( cbox.xMax ) | FT_ABS( cbox.xMin ) ) - 14;
+    xshift = FT_MSB( (FT_UInt32)( FT_ABS( cbox.xMax ) |
+                                  FT_ABS( cbox.xMin ) ) ) - 14;
     xshift = FT_MAX( xshift, 0 );
 
-    yshift = FT_MSB( cbox.yMax - cbox.yMin ) - 14;
+    yshift = FT_MSB( (FT_UInt32)( cbox.yMax - cbox.yMin ) ) - 14;
     yshift = FT_MAX( yshift, 0 );
 
     points = outline->points;
diff --git a/src/base/ftrfork.c b/src/base/ftrfork.c
index 4ee0ba3..82d54f8 100644
--- a/src/base/ftrfork.c
+++ b/src/base/ftrfork.c
@@ -63,7 +63,7 @@
     FT_UNUSED( library );
 
 
-    error = FT_Stream_Seek( stream, rfork_offset );
+    error = FT_Stream_Seek( stream, (FT_ULong)rfork_offset );
     if ( error )
       return error;
 
@@ -89,7 +89,7 @@
     if ( *rdata_pos + rdata_len != map_pos || map_pos == rfork_offset )
       return FT_THROW( Unknown_File_Format );
 
-    error = FT_Stream_Seek( stream, map_pos );
+    error = FT_Stream_Seek( stream, (FT_ULong)map_pos );
     if ( error )
       return error;
 
@@ -124,7 +124,7 @@
     if ( type_list == -1 )
       return FT_THROW( Unknown_File_Format );
 
-    error = FT_Stream_Seek( stream, map_pos + type_list );
+    error = FT_Stream_Seek( stream, (FT_ULong)( map_pos + type_list ) );
     if ( error )
       return error;
 
@@ -166,7 +166,7 @@
 
 
     FT_TRACE3(( "\n" ));
-    error = FT_Stream_Seek( stream, map_offset );
+    error = FT_Stream_Seek( stream, (FT_ULong)map_offset );
     if ( error )
       return error;
 
@@ -194,7 +194,7 @@
         *count = subcnt + 1;
         rpos  += map_offset;
 
-        error = FT_Stream_Seek( stream, rpos );
+        error = FT_Stream_Seek( stream, (FT_ULong)rpos );
         if ( error )
           return error;
 
@@ -220,7 +220,7 @@
 
         if (sort_by_res_id)
         {
-          ft_qsort( ref, *count, sizeof ( FT_RFork_Ref ),
+          ft_qsort( ref, (size_t)*count, sizeof ( FT_RFork_Ref ),
                     ( int(*)(const void*, const void*) )
                     ft_raccess_sort_ref_by_id );
 
@@ -713,9 +713,9 @@
     FT_UShort  n_of_entries;
 
     int        i;
-    FT_UInt32  entry_id, entry_offset, entry_length = 0;
+    FT_Int32   entry_id, entry_offset, entry_length = 0;
 
-    const FT_UInt32  resource_fork_entry_id = 0x2;
+    const FT_Int32  resource_fork_entry_id = 0x2;
 
     FT_UNUSED( library );
     FT_UNUSED( base_file_name );
@@ -813,7 +813,9 @@
     tmp = ft_strrchr( original_name, '/' );
     if ( tmp )
     {
-      ft_strncpy( new_name, original_name, tmp - original_name + 1 );
+      ft_strncpy( new_name,
+                  original_name,
+                  (size_t)( tmp - original_name + 1 ) );
       new_name[tmp - original_name + 1] = '\0';
       slash = tmp + 1;
     }
diff --git a/src/base/ftstream.c b/src/base/ftstream.c
index e115674..408dbf8 100644
--- a/src/base/ftstream.c
+++ b/src/base/ftstream.c
@@ -95,11 +95,11 @@
     if ( distance < 0 )
       return FT_THROW( Invalid_Stream_Operation );
 
-    return FT_Stream_Seek( stream, (FT_ULong)( stream->pos + distance ) );
+    return FT_Stream_Seek( stream, stream->pos + (FT_ULong)distance );
   }
 
 
-  FT_BASE_DEF( FT_Long )
+  FT_BASE_DEF( FT_ULong )
   FT_Stream_Pos( FT_Stream  stream )
   {
     return stream->pos;
@@ -260,7 +260,9 @@
 
 #ifdef FT_DEBUG_MEMORY
       /* assume _ft_debug_file and _ft_debug_lineno are already set */
-      stream->base = (unsigned char*)ft_mem_qalloc( memory, count, &error );
+      stream->base = (unsigned char*)ft_mem_qalloc( memory,
+                                                    (FT_Long)count,
+                                                    &error );
       if ( error )
         goto Exit;
 #else
@@ -348,7 +350,7 @@
 
     result = 0;
     if ( stream->cursor < stream->limit )
-      result = *stream->cursor++;
+      result = (FT_Char)*stream->cursor++;
 
     return result;
   }
@@ -357,8 +359,8 @@
   FT_BASE_DEF( FT_UShort )
   FT_Stream_GetUShort( FT_Stream  stream )
   {
-    FT_Byte*  p;
-    FT_Short  result;
+    FT_Byte*   p;
+    FT_UShort  result;
 
 
     FT_ASSERT( stream && stream->cursor );
@@ -376,8 +378,8 @@
   FT_BASE_DEF( FT_UShort )
   FT_Stream_GetUShortLE( FT_Stream  stream )
   {
-    FT_Byte*  p;
-    FT_Short  result;
+    FT_Byte*   p;
+    FT_UShort  result;
 
 
     FT_ASSERT( stream && stream->cursor );
@@ -396,7 +398,7 @@
   FT_Stream_GetUOffset( FT_Stream  stream )
   {
     FT_Byte*  p;
-    FT_Long   result;
+    FT_ULong  result;
 
 
     FT_ASSERT( stream && stream->cursor );
@@ -414,7 +416,7 @@
   FT_Stream_GetULong( FT_Stream  stream )
   {
     FT_Byte*  p;
-    FT_Long   result;
+    FT_ULong  result;
 
 
     FT_ASSERT( stream && stream->cursor );
@@ -432,7 +434,7 @@
   FT_Stream_GetULongLE( FT_Stream  stream )
   {
     FT_Byte*  p;
-    FT_Long   result;
+    FT_ULong  result;
 
 
     FT_ASSERT( stream && stream->cursor );
@@ -471,7 +473,7 @@
     }
     stream->pos++;
 
-    return result;
+    return (FT_Char)result;
 
   Fail:
     *error = FT_THROW( Invalid_Stream_Operation );
@@ -485,11 +487,11 @@
 
   FT_BASE_DEF( FT_UShort )
   FT_Stream_ReadUShort( FT_Stream  stream,
-                       FT_Error*  error )
+                        FT_Error*  error )
   {
-    FT_Byte   reads[2];
-    FT_Byte*  p = 0;
-    FT_Short  result = 0;
+    FT_Byte    reads[2];
+    FT_Byte*   p      = 0;
+    FT_UShort  result = 0;
 
 
     FT_ASSERT( stream );
@@ -506,9 +508,7 @@
         p = reads;
       }
       else
-      {
         p = stream->base + stream->pos;
-      }
 
       if ( p )
         result = FT_NEXT_USHORT( p );
@@ -532,11 +532,11 @@
 
   FT_BASE_DEF( FT_UShort )
   FT_Stream_ReadUShortLE( FT_Stream  stream,
-                         FT_Error*  error )
+                          FT_Error*  error )
   {
-    FT_Byte   reads[2];
-    FT_Byte*  p = 0;
-    FT_Short  result = 0;
+    FT_Byte    reads[2];
+    FT_Byte*   p      = 0;
+    FT_UShort  result = 0;
 
 
     FT_ASSERT( stream );
@@ -553,9 +553,7 @@
         p = reads;
       }
       else
-      {
         p = stream->base + stream->pos;
-      }
 
       if ( p )
         result = FT_NEXT_USHORT_LE( p );
@@ -579,11 +577,11 @@
 
   FT_BASE_DEF( FT_ULong )
   FT_Stream_ReadUOffset( FT_Stream  stream,
-                        FT_Error*  error )
+                         FT_Error*  error )
   {
     FT_Byte   reads[3];
-    FT_Byte*  p = 0;
-    FT_Long   result = 0;
+    FT_Byte*  p      = 0;
+    FT_ULong  result = 0;
 
 
     FT_ASSERT( stream );
@@ -600,9 +598,7 @@
         p = reads;
       }
       else
-      {
         p = stream->base + stream->pos;
-      }
 
       if ( p )
         result = FT_NEXT_UOFF3( p );
@@ -626,11 +622,11 @@
 
   FT_BASE_DEF( FT_ULong )
   FT_Stream_ReadULong( FT_Stream  stream,
-                      FT_Error*  error )
+                       FT_Error*  error )
   {
     FT_Byte   reads[4];
-    FT_Byte*  p = 0;
-    FT_Long   result = 0;
+    FT_Byte*  p      = 0;
+    FT_ULong  result = 0;
 
 
     FT_ASSERT( stream );
@@ -647,9 +643,7 @@
         p = reads;
       }
       else
-      {
         p = stream->base + stream->pos;
-      }
 
       if ( p )
         result = FT_NEXT_ULONG( p );
@@ -673,11 +667,11 @@
 
   FT_BASE_DEF( FT_ULong )
   FT_Stream_ReadULongLE( FT_Stream  stream,
-                        FT_Error*  error )
+                         FT_Error*  error )
   {
     FT_Byte   reads[4];
-    FT_Byte*  p = 0;
-    FT_Long   result = 0;
+    FT_Byte*  p      = 0;
+    FT_ULong  result = 0;
 
 
     FT_ASSERT( stream );
@@ -694,9 +688,7 @@
         p = reads;
       }
       else
-      {
         p = stream->base + stream->pos;
-      }
 
       if ( p )
         result = FT_NEXT_ULONG_LE( p );
diff --git a/src/truetype/ttpload.c b/src/truetype/ttpload.c
index caf6cf1..491fa39 100644
--- a/src/truetype/ttpload.c
+++ b/src/truetype/ttpload.c
@@ -124,7 +124,7 @@
         TT_Table  entry = face->dir_tables;
         TT_Table  limit = entry + face->num_tables;
 
-        FT_Long   pos  = FT_Stream_Pos( stream );
+        FT_Long   pos  = (FT_Long)FT_STREAM_POS();
         FT_Long   dist = 0x7FFFFFFFL;