libctf: drop LCTF_TYPE_ISPARENT/LCTF_TYPE_ISCHILD

Parent/child determination is about to become rather more complex, making a
macro impractical.  Use the ctf_type_isparent/ischild function calls
everywhere and remove the macro.  Make them more const-correct too, to
make them more widely usable.

While we're about it, change several places that hand-implemented
ctf_get_dict() to call it instead, and armour several functions against
the null returns that were always possible in this case (but previously
unprotected-against).
This commit is contained in:
Nick Alcock
2025-01-29 12:30:58 +00:00
parent 9835747b21
commit b875301e74
7 changed files with 51 additions and 46 deletions

View File

@@ -2087,7 +2087,7 @@ ctf_dedup_rwalk_one_output_mapping (ctf_dict_t *output,
const char *hashval; \
int cited_type_input_num = input_num; \
\
if ((fp->ctf_flags & LCTF_CHILD) && (LCTF_TYPE_ISPARENT (fp, type))) \
if ((fp->ctf_flags & LCTF_CHILD) && (ctf_type_isparent (fp, type))) \
cited_type_input_num = parents[input_num]; \
\
type_id = CTF_DEDUP_GID (output, cited_type_input_num, type); \
@@ -2549,7 +2549,7 @@ ctf_dedup_id_to_target (ctf_dict_t *output, ctf_dict_t *target,
/* If the input type is in the parent type space, and this is a child, reset
the input to the parent (which must already have been emitted, since
emission of parent dicts happens before children). */
if ((input->ctf_flags & LCTF_CHILD) && (LCTF_TYPE_ISPARENT (input, id)))
if ((input->ctf_flags & LCTF_CHILD) && (ctf_type_isparent (input, id)))
{
if (!ctf_assert (output, parents[input_num] <= ninputs))
return CTF_ERR;