core: Fix cu__for_each_struct and cu__for_each_type

To cover the case where there aren't structs or even any type at all.

It looks now just like cu__for_each_function, so its more consistent as a bonus
:-)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2009-04-01 13:46:11 -03:00
parent 6025d4ce38
commit 3c94ff34ec

View File

@ -176,10 +176,8 @@ static inline void cu__cache_symtab(struct cu *self)
* the NULL test (hint: CTF Unknown types)
*/
#define cu__for_each_type(cu, id, pos) \
for (id = 1, pos = cu->types_table.entries[id]; \
id < cu->types_table.nr_entries; \
pos = cu->types_table.entries[++id]) \
if (pos == NULL) \
for (id = 1; id < cu->types_table.nr_entries; ++id) \
if (!(pos = cu->types_table.entries[id])) \
continue; \
else
@ -190,10 +188,8 @@ static inline void cu__cache_symtab(struct cu *self)
* @id: uint16_t tag id
*/
#define cu__for_each_struct(cu, id, pos) \
for (id = 0, pos = tag__class(cu->types_table.entries[id]); \
id < cu->types_table.nr_entries; \
pos = tag__class(cu->types_table.entries[++id])) \
if (pos == NULL || \
for (id = 1; id < cu->types_table.nr_entries; ++id) \
if (!(pos = tag__class(cu->types_table.entries[id])) || \
!tag__is_struct(class__tag(pos))) \
continue; \
else