const char *name;
if (ctf_dynhash_insert (fp->ctf_dthash, (void *) (uintptr_t) dtd->dtd_type,
dtd) < 0)
- {
- ctf_set_errno (fp, ENOMEM);
- return -1;
- }
+ return ctf_set_errno (fp, ENOMEM);
if (flag == CTF_ADD_ROOT && dtd->dtd_data.ctt_name
&& (name = ctf_strraw (fp, dtd->dtd_data.ctt_name)) != NULL)
{
ctf_dynhash_remove (fp->ctf_dthash, (void *) (uintptr_t)
dtd->dtd_type);
- ctf_set_errno (fp, ENOMEM);
- return -1;
+ return ctf_set_errno (fp, ENOMEM);
}
}
ctf_list_append (&fp->ctf_dtdefs, dtd);
ctf_dvd_insert (ctf_dict_t *fp, ctf_dvdef_t *dvd)
{
if (ctf_dynhash_insert (fp->ctf_dvhash, dvd->dvd_name, dvd) < 0)
- {
- ctf_set_errno (fp, ENOMEM);
- return -1;
- }
+ return ctf_set_errno (fp, ENOMEM);
ctf_list_append (&fp->ctf_dvdefs, dvd);
return 0;
}
ctf_id_t type;
if (flag != CTF_ADD_NONROOT && flag != CTF_ADD_ROOT)
- return (ctf_set_errno (fp, EINVAL));
+ return (ctf_set_typed_errno (fp, EINVAL));
if (!(fp->ctf_flags & LCTF_RDWR))
- return (ctf_set_errno (fp, ECTF_RDONLY));
+ return (ctf_set_typed_errno (fp, ECTF_RDONLY));
if (LCTF_INDEX_TO_TYPE (fp, fp->ctf_typemax, 1) >= CTF_MAX_TYPE)
- return (ctf_set_errno (fp, ECTF_FULL));
+ return (ctf_set_typed_errno (fp, ECTF_FULL));
if (LCTF_INDEX_TO_TYPE (fp, fp->ctf_typemax, 1) == (CTF_MAX_PTYPE - 1))
- return (ctf_set_errno (fp, ECTF_FULL));
+ return (ctf_set_typed_errno (fp, ECTF_FULL));
/* Make sure ptrtab always grows to be big enough for all types. */
if (ctf_grow_ptrtab (fp) < 0)
return CTF_ERR; /* errno is set for us. */
if ((dtd = calloc (1, sizeof (ctf_dtdef_t))) == NULL)
- return (ctf_set_errno (fp, EAGAIN));
+ return (ctf_set_typed_errno (fp, EAGAIN));
dtd->dtd_vlen_alloc = vlen;
if (vlen > 0)
uint32_t encoding;
if (ep == NULL)
- return (ctf_set_errno (fp, EINVAL));
+ return (ctf_set_typed_errno (fp, EINVAL));
if (name == NULL || name[0] == '\0')
- return (ctf_set_errno (fp, ECTF_NONAME));
+ return (ctf_set_typed_errno (fp, ECTF_NONAME));
if (!ctf_assert (fp, kind == CTF_K_INTEGER || kind == CTF_K_FLOAT))
- return -1; /* errno is set for us. */
+ return CTF_ERR; /* errno is set for us. */
if ((type = ctf_add_generic (fp, flag, name, kind, sizeof (uint32_t),
&dtd)) == CTF_ERR)
int child = fp->ctf_flags & LCTF_CHILD;
if (ref == CTF_ERR || ref > CTF_MAX_TYPE)
- return (ctf_set_errno (fp, EINVAL));
+ return (ctf_set_typed_errno (fp, EINVAL));
if (ref != 0 && ctf_lookup_by_id (&tmp, ref) == NULL)
return CTF_ERR; /* errno is set for us. */
ctf_dict_t *tmp = fp;
if (ep == NULL)
- return (ctf_set_errno (fp, EINVAL));
+ return (ctf_set_typed_errno (fp, EINVAL));
if ((ep->cte_bits > 255) || (ep->cte_offset > 255))
- return (ctf_set_errno (fp, ECTF_SLICEOVERFLOW));
+ return (ctf_set_typed_errno (fp, ECTF_SLICEOVERFLOW));
if (ref == CTF_ERR || ref > CTF_MAX_TYPE)
- return (ctf_set_errno (fp, EINVAL));
+ return (ctf_set_typed_errno (fp, EINVAL));
if (ref != 0 && ((tp = ctf_lookup_by_id (&tmp, ref)) == NULL))
return CTF_ERR; /* errno is set for us. */
if ((kind != CTF_K_INTEGER) && (kind != CTF_K_FLOAT) &&
(kind != CTF_K_ENUM)
&& (ref != 0))
- return (ctf_set_errno (fp, ECTF_NOTINTFP));
+ return (ctf_set_typed_errno (fp, ECTF_NOTINTFP));
if ((type = ctf_add_generic (fp, flag, NULL, CTF_K_SLICE,
sizeof (ctf_slice_t), &dtd)) == CTF_ERR)
ctf_dict_t *tmp = fp;
if (arp == NULL)
- return (ctf_set_errno (fp, EINVAL));
+ return (ctf_set_typed_errno (fp, EINVAL));
if (arp->ctr_contents != 0
&& ctf_lookup_by_id (&tmp, arp->ctr_contents) == NULL)
ctf_err_warn (fp, 1, ECTF_INCOMPLETE,
_("ctf_add_array: index type %lx is incomplete"),
arp->ctr_contents);
- return (ctf_set_errno (fp, ECTF_INCOMPLETE));
+ return (ctf_set_typed_errno (fp, ECTF_INCOMPLETE));
}
if ((type = ctf_add_generic (fp, flag, NULL, CTF_K_ARRAY,
size_t i;
if (!(fp->ctf_flags & LCTF_RDWR))
- return (ctf_set_errno (fp, ECTF_RDONLY));
+ return (ctf_set_typed_errno (fp, ECTF_RDONLY));
if (ctc == NULL || (ctc->ctc_flags & ~CTF_FUNC_VARARG) != 0
|| (ctc->ctc_argc != 0 && argv == NULL))
- return (ctf_set_errno (fp, EINVAL));
+ return (ctf_set_typed_errno (fp, EINVAL));
vlen = ctc->ctc_argc;
if (ctc->ctc_flags & CTF_FUNC_VARARG)
return CTF_ERR; /* errno is set for us. */
if (vlen > CTF_MAX_VLEN)
- return (ctf_set_errno (fp, EOVERFLOW));
+ return (ctf_set_typed_errno (fp, EOVERFLOW));
/* One word extra allocated for padding for 4-byte alignment if need be.
Not reflected in vlen: we don't want to copy anything into it, and
if (dtd->dtd_vlen_alloc == 0)
{
if ((dtd->dtd_vlen = calloc (1, initial_vlen)) == NULL)
- return (ctf_set_errno (fp, ENOMEM));
+ return (ctf_set_typed_errno (fp, ENOMEM));
dtd->dtd_vlen_alloc = initial_vlen;
}
if (dtd->dtd_vlen_alloc == 0)
{
if ((dtd->dtd_vlen = calloc (1, initial_vlen)) == NULL)
- return (ctf_set_errno (fp, ENOMEM));
+ return (ctf_set_typed_errno (fp, ENOMEM));
dtd->dtd_vlen_alloc = initial_vlen;
}
if (dtd->dtd_vlen_alloc == 0)
{
if ((dtd->dtd_vlen = calloc (1, initial_vlen)) == NULL)
- return (ctf_set_errno (fp, ENOMEM));
+ return (ctf_set_typed_errno (fp, ENOMEM));
dtd->dtd_vlen_alloc = initial_vlen;
}
{
if ((ctf_type_kind (fp, type) != CTF_K_FORWARD) &&
(ctf_type_kind_unsliced (fp, type) != CTF_K_ENUM))
- return (ctf_set_errno (fp, ECTF_NOTINTFP));
+ return (ctf_set_typed_errno (fp, ECTF_NOTINTFP));
}
else if ((type = ctf_add_enum (fp, flag, name)) == CTF_ERR)
return CTF_ERR; /* errno is set for us. */
ctf_id_t type = 0;
if (!ctf_forwardable_kind (kind))
- return (ctf_set_errno (fp, ECTF_NOTSUE));
+ return (ctf_set_typed_errno (fp, ECTF_NOTSUE));
if (name == NULL || name[0] == '\0')
- return (ctf_set_errno (fp, ECTF_NONAME));
+ return (ctf_set_typed_errno (fp, ECTF_NONAME));
/* If the type is already defined or exists as a forward tag, just
return the ctf_id_t of the existing definition. */
_("ctf_add_unknown: cannot add unknown type "
"named %s: type of this name already defined"),
name ? name : _("(unnamed type)"));
- return (ctf_set_errno (fp, ECTF_CONFLICT));
+ return (ctf_set_typed_errno (fp, ECTF_CONFLICT));
}
}
ctf_dict_t *tmp = fp;
if (ref == CTF_ERR || ref > CTF_MAX_TYPE)
- return (ctf_set_errno (fp, EINVAL));
+ return (ctf_set_typed_errno (fp, EINVAL));
if (name == NULL || name[0] == '\0')
- return (ctf_set_errno (fp, ECTF_NONAME));
+ return (ctf_set_typed_errno (fp, ECTF_NONAME));
if (ref != 0 && ctf_lookup_by_id (&tmp, ref) == NULL)
return CTF_ERR; /* errno is set for us. */
ctf_id_t orig_src_type = src_type;
if (!(dst_fp->ctf_flags & LCTF_RDWR))
- return (ctf_set_errno (dst_fp, ECTF_RDONLY));
+ return (ctf_set_typed_errno (dst_fp, ECTF_RDONLY));
if ((src_tp = ctf_lookup_by_id (&src_fp, src_type)) == NULL)
- return (ctf_set_errno (dst_fp, ctf_errno (src_fp)));
+ return (ctf_set_typed_errno (dst_fp, ctf_errno (src_fp)));
if ((ctf_type_resolve (src_fp, src_type) == CTF_ERR)
&& (ctf_errno (src_fp) == ECTF_NONREPRESENTABLE))
- return (ctf_set_errno (dst_fp, ECTF_NONREPRESENTABLE));
+ return (ctf_set_typed_errno (dst_fp, ECTF_NONREPRESENTABLE));
name = ctf_strptr (src_fp, src_tp->ctt_name);
kind = LCTF_INFO_KIND (src_fp, src_tp->ctt_info);
_("ctf_add_type: conflict for type %s: "
"kinds differ, new: %i; old (ID %lx): %i"),
name, kind, dst_type, dst_kind);
- return (ctf_set_errno (dst_fp, ECTF_CONFLICT));
+ return (ctf_set_typed_errno (dst_fp, ECTF_CONFLICT));
}
}
if (kind == CTF_K_INTEGER || kind == CTF_K_FLOAT || kind == CTF_K_SLICE)
{
if (ctf_type_encoding (src_fp, src_type, &src_en) != 0)
- return (ctf_set_errno (dst_fp, ctf_errno (src_fp)));
+ return (ctf_set_typed_errno (dst_fp, ctf_errno (src_fp)));
if (dst_type != CTF_ERR)
{
}
else
{
- return (ctf_set_errno (dst_fp, ECTF_CONFLICT));
+ return (ctf_set_typed_errno (dst_fp, ECTF_CONFLICT));
}
}
else
if (ctf_dynhash_insert (proc_tracking_fp->ctf_add_processing,
(void *) (uintptr_t) src_type, (void *) 1) < 0)
- return ctf_set_errno (dst_fp, ENOMEM);
+ return ctf_set_typed_errno (dst_fp, ENOMEM);
switch (kind)
{
case CTF_K_ARRAY:
if (ctf_array_info (src_fp, src_type, &src_ar) != 0)
- return (ctf_set_errno (dst_fp, ctf_errno (src_fp)));
+ return (ctf_set_typed_errno (dst_fp, ctf_errno (src_fp)));
src_ar.ctr_contents =
ctf_add_type_internal (dst_fp, src_fp, src_ar.ctr_contents,
src_ar.ctr_index, src_ar.ctr_nelems,
dst_ar.ctr_contents, dst_ar.ctr_index,
dst_ar.ctr_nelems);
- return (ctf_set_errno (dst_fp, ECTF_CONFLICT));
+ return (ctf_set_typed_errno (dst_fp, ECTF_CONFLICT));
}
}
else
"size differs, old %li, new %li"), name,
dst_type, (long) ctf_type_size (src_fp, src_type),
(long) ctf_type_size (dst_fp, dst_type));
- return (ctf_set_errno (dst_fp, ECTF_CONFLICT));
+ return (ctf_set_typed_errno (dst_fp, ECTF_CONFLICT));
}
if (ctf_member_iter (src_fp, src_type, membcmp, &dst))
ctf_err_warn (dst_fp, 1, ECTF_CONFLICT,
_("conflict for type %s against ID %lx: members "
"differ, see above"), name, dst_type);
- return (ctf_set_errno (dst_fp, ECTF_CONFLICT));
+ return (ctf_set_typed_errno (dst_fp, ECTF_CONFLICT));
}
break;
ctf_err_warn (dst_fp, 1, ECTF_CONFLICT,
_("conflict for enum %s against ID %lx: members "
"differ, see above"), name, dst_type);
- return (ctf_set_errno (dst_fp, ECTF_CONFLICT));
+ return (ctf_set_typed_errno (dst_fp, ECTF_CONFLICT));
}
}
else
break;
default:
- return (ctf_set_errno (dst_fp, ECTF_CORRUPT));
+ return (ctf_set_typed_errno (dst_fp, ECTF_CORRUPT));
}
if (dst_type != CTF_ERR)
/* We store the hash on the source, because it contains only source type IDs:
but callers will invariably expect errors to appear on the dest. */
if (!src_fp->ctf_add_processing)
- return (ctf_set_errno (dst_fp, ENOMEM));
+ return (ctf_set_typed_errno (dst_fp, ENOMEM));
id = ctf_add_type_internal (dst_fp, src_fp, src_type, src_fp);
ctf_dynhash_empty (src_fp->ctf_add_processing);
if (ctf_dynset_cinsert (d->cd_conflicting_types, hval) < 0)
{
ctf_dprintf ("Out of memory marking %s as conflicted\n", hval);
- ctf_set_errno (fp, errno);
- return -1;
+ return ctf_set_errno (fp, errno);
}
/* If any types cite this type, mark them conflicted too. */
{
if ((emitted_forward = ctf_add_forward (target, CTF_ADD_ROOT, name,
fwdkind)) == CTF_ERR)
- {
- ctf_set_errno (output, ctf_errno (target));
- return CTF_ERR;
- }
+ return ctf_set_typed_errno (output, ctf_errno (target));
if (ctf_dynhash_cinsert (td->cd_output_emission_conflicted_forwards,
decorated, (void *) (uintptr_t)
emitted_forward) < 0)
- {
- ctf_set_errno (output, ENOMEM);
- return CTF_ERR;
- }
+ return ctf_set_typed_errno (output, ENOMEM);
}
else
emitted_forward = (ctf_id_t) (uintptr_t) v;
if ((input->ctf_flags & LCTF_CHILD) && (LCTF_TYPE_ISPARENT (input, id)))
{
if (!ctf_assert (output, parents[input_num] <= ninputs))
- return -1;
+ return CTF_ERR;
input = inputs[parents[input_num]];
input_num = parents[input_num];
}
CTF_DEDUP_GID (output, input_num, id));
if (!ctf_assert (output, hval && td->cd_output_emission_hashes))
- return -1;
+ return CTF_ERR;
/* If this type is a conflicted tagged structure, union, or forward,
substitute a synthetic forward instead, emitting it if need be. Only do
ctf_set_errno (err_fp, ctf_errno (output));
ctf_err_warn (err_fp, 0, 0, _("cannot add synthetic forward for type "
"%i/%lx"), input_num, id);
- return -1;
+ return CTF_ERR;
default:
return emitted_forward;
}
ctf_dprintf ("Checking shared parent for target\n");
if (!ctf_assert (output, (target != output)
&& (target->ctf_flags & LCTF_CHILD)))
- return -1;
+ return CTF_ERR;
target_id = ctf_dynhash_lookup (od->cd_output_emission_hashes, hval);
ctf_err_warn (err_fp, 0, ctf_errno (output),
_("cannot add synthetic forward for type %i/%lx"),
input_num, id);
- return ctf_set_errno (err_fp, ctf_errno (output));
+ return ctf_set_typed_errno (err_fp, ctf_errno (output));
default:
return emitted_forward;
}
}
if (!ctf_assert (output, target_id))
- return -1;
+ return CTF_ERR;
return (ctf_id_t) (uintptr_t) target_id;
}
extern void ctf_arc_close_internal (struct ctf_archive *);
extern const ctf_preamble_t *ctf_arc_bufpreamble (const ctf_sect_t *);
extern void *ctf_set_open_errno (int *, int);
-extern unsigned long ctf_set_errno (ctf_dict_t *, int);
extern void ctf_flip_header (ctf_header_t *);
extern int ctf_flip (ctf_dict_t *, ctf_header_t *, unsigned char *, int);
return expr;
}
+static inline int
+ctf_set_errno (ctf_dict_t *fp, int err)
+{
+ fp->ctf_errno = err;
+ /* Don't rely on CTF_ERR here as it will not properly sign extend on 64-bit
+ Windows ABI. */
+ return -1;
+}
+
+static inline ctf_id_t
+ctf_set_typed_errno (ctf_dict_t *fp, int err)
+{
+ fp->ctf_errno = err;
+ return CTF_ERR;
+}
+
+
#ifdef __cplusplus
}
#endif
#else
ctf_err_warn (fp, 0, ECTF_NEEDSBFD, _("cannot open %s lazily"),
input->clin_filename);
- ctf_set_errno (fp, ECTF_NEEDSBFD);
- return -1;
+ return ctf_set_errno (fp, ECTF_NEEDSBFD);
#endif
/* Having no CTF sections is not an error. We just don't need to do
ctf_err_warn (fp, 0, err, _("opening CTF %s failed"),
input->clin_filename);
- ctf_set_errno (fp, err);
- return -1;
+ return ctf_set_errno (fp, err);
}
if ((count = ctf_archive_count (input->clin_arc)) == 0)
{
ctf_err_warn (fp, 0, err, _("iteration error counting deduplicating "
"CTF link inputs"));
- ctf_set_errno (fp, err);
- return -1;
+ return ctf_set_errno (fp, err);
}
if (!count)
{
fp->ctf_flags &= ~LCTF_LINKING;
ctf_err_warn (fp, 1, err, _("iteration error removing old outputs"));
- ctf_set_errno (fp, err);
- return -1;
+ return ctf_set_errno (fp, err);
}
return 0;
}
{
fp->ctf_flags &= ~LCTF_LINKING;
ctf_err_warn (fp, 1, err, _("iteration error creating empty CUs"));
- ctf_set_errno (fp, err);
- return -1;
+ return ctf_set_errno (fp, err);
}
}
ctf_id_t ntype, ptype;
if (name == NULL)
- return (ctf_set_errno (fp, EINVAL));
+ return (ctf_set_typed_errno (fp, EINVAL));
for (p = name, end = name + strlen (name); *p != '\0'; p = q)
{
free (fp->ctf_tmp_typeslice);
fp->ctf_tmp_typeslice = xstrndup (p, (size_t) (q - p));
if (fp->ctf_tmp_typeslice == NULL)
- {
- ctf_set_errno (fp, ENOMEM);
- return CTF_ERR;
- }
+ return ctf_set_typed_errno (fp, ENOMEM);
}
if ((type = ctf_lookup_by_rawhash (fp, lp->ctl_hash,
}
if (*p != '\0' || type == 0)
- return (ctf_set_errno (fp, ECTF_SYNTAX));
+ return (ctf_set_typed_errno (fp, ECTF_SYNTAX));
return type;
if (fp->ctf_pptrtab_typemax < fp->ctf_typemax)
{
if (refresh_pptrtab (fp, fp->ctf_parent) < 0)
- return -1; /* errno is set for us. */
+ return CTF_ERR; /* errno is set for us. */
}
if ((ptype = ctf_lookup_by_name_internal (fp->ctf_parent, fp,
name)) != CTF_ERR)
return ptype;
- return (ctf_set_errno (fp, ctf_errno (fp->ctf_parent)));
+ return (ctf_set_typed_errno (fp, ctf_errno (fp->ctf_parent)));
}
return CTF_ERR;
if ((ptype = ctf_lookup_variable (fp->ctf_parent, name)) != CTF_ERR)
return ptype;
- return (ctf_set_errno (fp, ctf_errno (fp->ctf_parent)));
+ return (ctf_set_typed_errno (fp, ctf_errno (fp->ctf_parent)));
}
- return (ctf_set_errno (fp, ECTF_NOTYPEDAT));
+ return (ctf_set_typed_errno (fp, ECTF_NOTYPEDAT));
}
return ent->ctv_type;
if (!i)
{
if ((i = ctf_next_create ()) == NULL)
- return ctf_set_errno (fp, ENOMEM);
+ return ctf_set_typed_errno (fp, ENOMEM);
i->cu.ctn_fp = fp;
i->ctn_iter_fun = (void (*) (void)) ctf_symbol_next;
}
if ((void (*) (void)) ctf_symbol_next != i->ctn_iter_fun)
- return (ctf_set_errno (fp, ECTF_NEXT_WRONGFUN));
+ return (ctf_set_typed_errno (fp, ECTF_NEXT_WRONGFUN));
if (fp != i->cu.ctn_fp)
- return (ctf_set_errno (fp, ECTF_NEXT_WRONGFP));
+ return (ctf_set_typed_errno (fp, ECTF_NEXT_WRONGFP));
/* We intentionally use raw access, not ctf_lookup_by_symbol, to avoid
incurring additional sorting cost for unsorted symtypetabs coming from the
if (!dynh)
{
ctf_next_destroy (i);
- return (ctf_set_errno (fp, ECTF_NEXT_END));
+ return (ctf_set_typed_errno (fp, ECTF_NEXT_END));
}
err = ctf_dynhash_next (dynh, &i->ctn_next, &dyn_name, &dyn_value);
{
ctf_next_destroy (i);
*it = NULL;
- return ctf_set_errno (fp, err);
+ return ctf_set_typed_errno (fp, err);
}
*name = dyn_name;
end:
ctf_next_destroy (i);
*it = NULL;
- return (ctf_set_errno (fp, ECTF_NEXT_END));
+ return (ctf_set_typed_errno (fp, ECTF_NEXT_END));
}
/* A bsearch function for function and object index names. */
"indexed symtypetab\n", symidx, symname);
if (symname[0] == '\0')
- return -1; /* errno is set for us. */
+ return CTF_ERR; /* errno is set for us. */
if (is_function)
{
== NULL)
{
ctf_err_warn (fp, 0, 0, _("cannot sort function symidx"));
- return -1; /* errno is set for us. */
+ return CTF_ERR; /* errno is set for us. */
}
}
symtypetab = (uint32_t *) (fp->ctf_buf + hp->cth_funcoff);
== NULL)
{
ctf_err_warn (fp, 0, 0, _("cannot sort object symidx"));
- return -1; /* errno is set for us. */
+ return CTF_ERR; /* errno is set for us. */
}
}
/* Should be impossible, but be paranoid. */
if ((idx - sxlate) > (ptrdiff_t) nidx)
- return (ctf_set_errno (fp, ECTF_CORRUPT));
+ return (ctf_set_typed_errno (fp, ECTF_CORRUPT));
ctf_dprintf ("Symbol %lx (%s) is of type %x\n", symidx, symname,
symtypetab[*idx]);
return ret;
}
else
- return (ctf_set_errno (fp, err));
+ return (ctf_set_typed_errno (fp, err));
}
/* Given a symbol table index, return the type of the function or data object
if (!i)
{
if ((i = ctf_next_create ()) == NULL)
- return ctf_set_errno (fp, ENOMEM);
+ return ctf_set_typed_errno (fp, ENOMEM);
i->cu.ctn_fp = fp;
i->ctn_type = 1;
}
if ((void (*) (void)) ctf_type_next != i->ctn_iter_fun)
- return (ctf_set_errno (fp, ECTF_NEXT_WRONGFUN));
+ return (ctf_set_typed_errno (fp, ECTF_NEXT_WRONGFUN));
if (fp != i->cu.ctn_fp)
- return (ctf_set_errno (fp, ECTF_NEXT_WRONGFP));
+ return (ctf_set_typed_errno (fp, ECTF_NEXT_WRONGFP));
while (i->ctn_type <= fp->ctf_typemax)
{
}
ctf_next_destroy (i);
*it = NULL;
- return ctf_set_errno (fp, ECTF_NEXT_END);
+ return ctf_set_typed_errno (fp, ECTF_NEXT_END);
}
/* Iterate over every variable in the given CTF dict, in arbitrary order.
ctf_next_t *i = *it;
if ((fp->ctf_flags & LCTF_CHILD) && (fp->ctf_parent == NULL))
- return (ctf_set_errno (fp, ECTF_NOPARENT));
+ return (ctf_set_typed_errno (fp, ECTF_NOPARENT));
if (!i)
{
if ((i = ctf_next_create ()) == NULL)
- return ctf_set_errno (fp, ENOMEM);
+ return ctf_set_typed_errno (fp, ENOMEM);
i->cu.ctn_fp = fp;
i->ctn_iter_fun = (void (*) (void)) ctf_variable_next;
}
if ((void (*) (void)) ctf_variable_next != i->ctn_iter_fun)
- return (ctf_set_errno (fp, ECTF_NEXT_WRONGFUN));
+ return (ctf_set_typed_errno (fp, ECTF_NEXT_WRONGFUN));
if (fp != i->cu.ctn_fp)
- return (ctf_set_errno (fp, ECTF_NEXT_WRONGFP));
+ return (ctf_set_typed_errno (fp, ECTF_NEXT_WRONGFP));
if (!(fp->ctf_flags & LCTF_RDWR))
{
end_iter:
ctf_next_destroy (i);
*it = NULL;
- return ctf_set_errno (fp, ECTF_NEXT_END);
+ return ctf_set_typed_errno (fp, ECTF_NEXT_END);
}
/* Follow a given type through the graph for TYPEDEF, VOLATILE, CONST, and
const ctf_type_t *tp;
if (type == 0)
- return (ctf_set_errno (ofp, ECTF_NONREPRESENTABLE));
+ return (ctf_set_typed_errno (ofp, ECTF_NONREPRESENTABLE));
while ((tp = ctf_lookup_by_id (&fp, type)) != NULL)
{
{
ctf_err_warn (ofp, 0, ECTF_CORRUPT, _("type %lx cycle detected"),
otype);
- return (ctf_set_errno (ofp, ECTF_CORRUPT));
+ return (ctf_set_typed_errno (ofp, ECTF_CORRUPT));
}
prev = type;
type = tp->ctt_type;
break;
case CTF_K_UNKNOWN:
- return (ctf_set_errno (ofp, ECTF_NONREPRESENTABLE));
+ return (ctf_set_typed_errno (ofp, ECTF_NONREPRESENTABLE));
default:
return type;
}
if (type == 0)
- return (ctf_set_errno (ofp, ECTF_NONREPRESENTABLE));
+ return (ctf_set_typed_errno (ofp, ECTF_NONREPRESENTABLE));
}
return CTF_ERR; /* errno is set for us. */
ctf_id_t ret;
if ((ret = ctf_type_reference (fp, type)) == CTF_ERR)
- return (ctf_set_errno (ofp, ctf_errno (fp)));
+ return (ctf_set_typed_errno (ofp, ctf_errno (fp)));
return ret;
}
return type;
size_t slen;
if (str == NULL)
- return CTF_ERR; /* errno is set for us. */
+ return -1; /* errno is set for us. */
slen = strlen (str);
snprintf (buf, len, "%s", str);
return sp->cts_type;
}
default:
- return (ctf_set_errno (ofp, ECTF_NOTREF));
+ return (ctf_set_typed_errno (ofp, ECTF_NOTREF));
}
}
return (LCTF_INDEX_TO_TYPE (fp, ntype, (fp->ctf_flags & LCTF_CHILD)));
if ((type = ctf_type_resolve (fp, type)) == CTF_ERR)
- return (ctf_set_errno (ofp, ECTF_NOTYPE));
+ return (ctf_set_typed_errno (ofp, ECTF_NOTYPE));
if (ctf_lookup_by_id (&fp, type) == NULL)
- return (ctf_set_errno (ofp, ECTF_NOTYPE));
+ return (ctf_set_typed_errno (ofp, ECTF_NOTYPE));
if ((ntype = fp->ctf_ptrtab[LCTF_TYPE_TO_INDEX (fp, type)]) != 0)
return (LCTF_INDEX_TO_TYPE (fp, ntype, (fp->ctf_flags & LCTF_CHILD)));
- return (ctf_set_errno (ofp, ECTF_NOTYPE));
+ return (ctf_set_typed_errno (ofp, ECTF_NOTYPE));
}
/* Return the encoding for the specified INTEGER, FLOAT, or ENUM. */
return -1; /* errno is set for us. */
if (LCTF_INFO_KIND (fp, tp->ctt_info) != CTF_K_ENUM)
- {
- (void) ctf_set_errno (ofp, ECTF_NOTENUM);
- return -1;
- }
+ return ctf_set_errno (ofp, ECTF_NOTENUM);
ctf_get_ctt_size (fp, tp, NULL, &increment);
}
}
- ctf_set_errno (ofp, ECTF_NOENUMNAM);
- return -1;
+ return ctf_set_errno (ofp, ECTF_NOENUMNAM);
}
/* Given a type ID relating to a function type, return info on return types and
return NULL;
}
-/* Store the specified error code into the CTF dict, and then return CTF_ERR /
- -1 for the benefit of the caller. */
-
-unsigned long
-ctf_set_errno (ctf_dict_t *fp, int err)
-{
- fp->ctf_errno = err;
- return CTF_ERR;
-}
-
/* Create a ctf_next_t. */
ctf_next_t *