[cache] Fix Savannah bug #27441, cleanup Redhat bugzilla #513582.
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
diff --git a/ChangeLog b/ChangeLog
index 4d981d1..f5cfeda 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,44 @@
+2009-09-27 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
+
+ [cache] Fix Savannah bug #27441, cleanup Redhat bugzilla #513582.
+ Tricky casts in FTC_{CACHE,GCACHE,MRULIST}_LOOKUP_CMP()
+ are removed. Now these functions should be called with
+ FTC_Node or FTC_MruNode variable, and the caller should
+ cast them to appropriate pointers to concrete data.
+ These tricky casts can GCC-4.4 optimizer (-O2) confused
+ and the crashing binaries are generated.
+
+ * src/cache/ftcmru.h (FTC_MRULIST_LOOKUP_CMP): Drop tricky
+ cast. Now the 4th argument `node' of this function should
+ be typed as FTC_MruNode.
+
+ * src/cache/ftcglyph.h (FTC_GCACHE_LOOKUP_CMP): For inline
+ implementation, new temporal variable FTC_MruNode `_mrunode'
+ to take the pointer from FTC_MRULIST_LOOKUP_CMP(). For non
+ inline implementation, tricky cast is dropped.
+
+ * src/cache/ftcmanag.c (FTC_SIZE_NODE): New macro casting
+ to FTC_SizeNode.
+ (FTC_Manager_LookupSize): Replace FTC_SizeNode `node' by
+ FTC_MruNode `mrunode', and FTC_SIZE_NODE() is inserted.
+ (FTC_FACE_NODE): New macro casting to FTC_FaceNode.
+ (FTC_Manager_LookupFace) Replace FTC_FaceNode `node' by
+ FTC_MruNode `mrunode', and FTC_FACE_NODE() is inserted.
+
+ * src/cache/ftcbasic.c (FTC_ImageCache_Lookup): Change
+ the type of `node' from FTC_INode to FTC_Node. Extra
+ casting macro FTC_NODE() is dropped.
+ (FTC_ImageCache_LookupScaler): Ditto.
+ (FTC_SBitCache_Lookup): Change the type of `node' from
+ FTC_SNode to FTC_Node. Extra casting macro FTC_NODE()
+ is dropped. FTC_SNODE() is inserted.
+ (FTC_SBitCache_LookupScaler): Ditto.
+
+ * src/cache/ftccmap.c (FTC_CMapCache_Lookup): Change
+ the type of `node' from FTC_CMapNode to FTC_Node. Extra
+ casting macro FTC_NODE() is dropped, FTC_CMAP_NODE() is
+ inserted.
+
2009-09-25 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
[cache, psaux, type1] Fix for multi build.
diff --git a/src/cache/ftcbasic.c b/src/cache/ftcbasic.c
index f9c75f3..1042644 100644
--- a/src/cache/ftcbasic.c
+++ b/src/cache/ftcbasic.c
@@ -316,7 +316,7 @@
FTC_Node *anode )
{
FTC_BasicQueryRec query;
- FTC_INode node = 0; /* make compiler happy */
+ FTC_Node node = 0; /* make compiler happy */
FT_Error error;
FT_UInt32 hash;
@@ -383,7 +383,7 @@
error = FTC_GCache_Lookup( FTC_GCACHE( cache ),
hash, gindex,
FTC_GQUERY( &query ),
- (FTC_Node*) &node );
+ &node );
#endif
if ( !error )
{
@@ -391,8 +391,8 @@
if ( anode )
{
- *anode = FTC_NODE( node );
- FTC_NODE( node )->ref_count++;
+ *anode = node;
+ node->ref_count++;
}
}
@@ -412,7 +412,7 @@
FTC_Node *anode )
{
FTC_BasicQueryRec query;
- FTC_INode node = 0; /* make compiler happy */
+ FTC_Node node = 0; /* make compiler happy */
FT_Error error;
FT_UInt32 hash;
@@ -453,8 +453,8 @@
if ( anode )
{
- *anode = FTC_NODE( node );
- FTC_NODE( node )->ref_count++;
+ *anode = node;
+ node->ref_count++;
}
}
@@ -655,7 +655,7 @@
{
FT_Error error;
FTC_BasicQueryRec query;
- FTC_SNode node = 0; /* make compiler happy */
+ FTC_Node node = 0; /* make compiler happy */
FT_UInt32 hash;
@@ -721,17 +721,17 @@
hash,
gindex,
FTC_GQUERY( &query ),
- (FTC_Node*)&node );
+ &node );
#endif
if ( error )
goto Exit;
- *ansbit = node->sbits + ( gindex - FTC_GNODE( node )->gindex );
+ *ansbit = FTC_SNODE( node )->sbits + ( gindex - FTC_GNODE( node )->gindex );
if ( anode )
{
- *anode = FTC_NODE( node );
- FTC_NODE( node )->ref_count++;
+ *anode = node;
+ node->ref_count++;
}
Exit:
@@ -751,7 +751,7 @@
{
FT_Error error;
FTC_BasicQueryRec query;
- FTC_SNode node = 0; /* make compiler happy */
+ FTC_Node node = 0; /* make compiler happy */
FT_UInt32 hash;
@@ -788,12 +788,12 @@
if ( error )
goto Exit;
- *ansbit = node->sbits + ( gindex - FTC_GNODE( node )->gindex );
+ *ansbit = FTC_SNODE( node )->sbits + ( gindex - FTC_GNODE( node )->gindex );
if ( anode )
{
- *anode = FTC_NODE( node );
- FTC_NODE( node )->ref_count++;
+ *anode = node;
+ node->ref_count++;
}
Exit:
diff --git a/src/cache/ftccmap.c b/src/cache/ftccmap.c
index 50a6189..428cebb 100644
--- a/src/cache/ftccmap.c
+++ b/src/cache/ftccmap.c
@@ -283,7 +283,7 @@
{
FTC_Cache cache = FTC_CACHE( cmap_cache );
FTC_CMapQueryRec query;
- FTC_CMapNode node;
+ FTC_Node node;
FT_Error error;
FT_UInt gindex = 0;
FT_UInt32 hash;
@@ -373,18 +373,18 @@
FTC_CACHE_LOOKUP_CMP( cache, ftc_cmap_node_compare, hash, &query,
node, error );
#else
- error = FTC_Cache_Lookup( cache, hash, &query, (FTC_Node*) &node );
+ error = FTC_Cache_Lookup( cache, hash, &query, &node );
#endif
if ( error )
goto Exit;
- FT_ASSERT( (FT_UInt)( char_code - node->first ) < FTC_CMAP_INDICES_MAX );
+ FT_ASSERT( (FT_UInt)( char_code - FTC_CMAP_NODE( node )->first ) < FTC_CMAP_INDICES_MAX );
/* something rotten can happen with rogue clients */
- if ( (FT_UInt)( char_code - node->first >= FTC_CMAP_INDICES_MAX ) )
+ if ( (FT_UInt)( char_code - FTC_CMAP_NODE( node )->first >= FTC_CMAP_INDICES_MAX ) )
return 0;
- gindex = node->indices[char_code - node->first];
+ gindex = FTC_CMAP_NODE( node )->indices[char_code - FTC_CMAP_NODE( node )->first];
if ( gindex == FTC_CMAP_UNKNOWN )
{
FT_Face face;
@@ -392,7 +392,7 @@
gindex = 0;
- error = FTC_Manager_LookupFace( cache->manager, node->face_id, &face );
+ error = FTC_Manager_LookupFace( cache->manager, FTC_CMAP_NODE( node )->face_id, &face );
if ( error )
goto Exit;
@@ -413,7 +413,7 @@
FT_Set_Charmap( face, old );
}
- node->indices[char_code - node->first] = (FT_UShort)gindex;
+ FTC_CMAP_NODE( node )->indices[char_code - FTC_CMAP_NODE( node )->first] = (FT_UShort)gindex;
}
Exit:
diff --git a/src/cache/ftcglyph.h b/src/cache/ftcglyph.h
index 87a4199..c18f9c3 100644
--- a/src/cache/ftcglyph.h
+++ b/src/cache/ftcglyph.h
@@ -277,12 +277,14 @@ FT_BEGIN_HEADER
FTC_GCache _gcache = FTC_GCACHE( cache ); \
FTC_GQuery _gquery = (FTC_GQuery)( query ); \
FTC_MruNode_CompareFunc _fcompare = (FTC_MruNode_CompareFunc)(famcmp); \
+ FTC_MruNode _mrunode; \
\
\
_gquery->gindex = (gindex); \
\
FTC_MRULIST_LOOKUP_CMP( &_gcache->families, _gquery, _fcompare, \
- _gquery->family, error ); \
+ _mrunode, error ); \
+ _gquery->family = FTC_FAMILY( _mrunode ); \
if ( !error ) \
{ \
FTC_Family _gqfamily = _gquery->family; \
@@ -303,11 +305,10 @@ FT_BEGIN_HEADER
#define FTC_GCACHE_LOOKUP_CMP( cache, famcmp, nodecmp, hash, \
gindex, query, node, error ) \
FT_BEGIN_STMNT \
- void* _n = &(node); \
- \
\
error = FTC_GCache_Lookup( FTC_GCACHE( cache ), hash, gindex, \
- FTC_GQUERY( query ), (FTC_Node*)_n ); \
+ FTC_GQUERY( query ), node ); \
+ \
FT_END_STMNT
#endif /* !FTC_INLINE */
diff --git a/src/cache/ftcmanag.c b/src/cache/ftcmanag.c
index 8436bd0..f2a298e 100644
--- a/src/cache/ftcmanag.c
+++ b/src/cache/ftcmanag.c
@@ -82,6 +82,8 @@
} FTC_SizeNodeRec, *FTC_SizeNode;
+#define FTC_SIZE_NODE( x ) ( (FTC_SizeNode)( x ) )
+
FT_CALLBACK_DEF( void )
ftc_size_node_done( FTC_MruNode ftcnode,
@@ -180,8 +182,8 @@
FTC_Scaler scaler,
FT_Size *asize )
{
- FT_Error error;
- FTC_SizeNode node;
+ FT_Error error;
+ FTC_MruNode mrunode;
if ( asize == NULL )
@@ -195,14 +197,14 @@
#ifdef FTC_INLINE
FTC_MRULIST_LOOKUP_CMP( &manager->sizes, scaler, ftc_size_node_compare,
- node, error );
+ mrunode, error );
#else
- error = FTC_MruList_Lookup( &manager->sizes, scaler, (FTC_MruNode*)&node );
+ error = FTC_MruList_Lookup( &manager->sizes, scaler, &mrunode );
#endif
if ( !error )
- *asize = node->size;
+ *asize = FTC_SIZE_NODE( mrunode )->size;
return error;
}
@@ -224,6 +226,8 @@
} FTC_FaceNodeRec, *FTC_FaceNode;
+#define FTC_FACE_NODE( x ) ( ( FTC_FaceNode )( x ) )
+
FT_CALLBACK_DEF( FT_Error )
ftc_face_node_init( FTC_MruNode ftcnode,
@@ -305,8 +309,8 @@
FTC_FaceID face_id,
FT_Face *aface )
{
- FT_Error error;
- FTC_FaceNode node;
+ FT_Error error;
+ FTC_MruNode mrunode;
if ( aface == NULL )
@@ -321,14 +325,14 @@
#ifdef FTC_INLINE
FTC_MRULIST_LOOKUP_CMP( &manager->faces, face_id, ftc_face_node_compare,
- node, error );
+ mrunode, error );
#else
- error = FTC_MruList_Lookup( &manager->faces, face_id, (FTC_MruNode*)&node );
+ error = FTC_MruList_Lookup( &manager->faces, face_id, &mrunode );
#endif
if ( !error )
- *aface = node->face;
+ *aface = FTC_FACE_NODE( mrunode )->face;
return error;
}
diff --git a/src/cache/ftcmru.h b/src/cache/ftcmru.h
index 0cda76e..5739439 100644
--- a/src/cache/ftcmru.h
+++ b/src/cache/ftcmru.h
@@ -163,7 +163,7 @@ FT_BEGIN_HEADER
FT_BEGIN_STMNT \
FTC_MruNode* _pfirst = &(list)->nodes; \
FTC_MruNode_CompareFunc _compare = (FTC_MruNode_CompareFunc)(compare); \
- FTC_MruNode _first, _node, *_pnode; \
+ FTC_MruNode _first, _node; \
\
\
error = 0; \
@@ -180,8 +180,7 @@ FT_BEGIN_HEADER
if ( _node != _first ) \
FTC_MruNode_Up( _pfirst, _node ); \
\
- _pnode = (FTC_MruNode*)(void*)&(node); \
- *_pnode = _node; \
+ node = _node; \
goto _MruOk; \
} \
_node = _node->next; \