[15/22] libctf: improve handling of type dumping errors

Message ID 20240417202018.34966-16-nick.alcock@oracle.com
State New
Series more modifiable CTF dicts (and a few bugfixes) |


Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 fail Patch failed to apply

Commit Message

Nick Alcock April 17, 2024, 8:20 p.m. UTC
  When dumping a type fails with an error, we want to emit a warning noting
this: a warning because it's not fatal and we can continue.  But warnings
don't automatically print out the ctf_errno (because not all cases causing
warnings set the errno at all), so we must do it at warning-emission time or
lose track of what's gone wrong.


	* ctf-dump.c (ctf_dump_format_type): Dump the underlying error on
	type dump failure.
 libctf/ctf-dump.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)


diff --git a/libctf/ctf-dump.c b/libctf/ctf-dump.c
index 2213d09dc29..80a3b265297 100644
--- a/libctf/ctf-dump.c
+++ b/libctf/ctf-dump.c
@@ -239,7 +239,8 @@  ctf_dump_format_type (ctf_dict_t *fp, ctf_id_t id, int flag)
   ctf_set_errno (fp, errno);
-  ctf_err_warn (fp, 1, 0, _("cannot format name dumping type 0x%lx"), id);
+  ctf_err_warn (fp, 1, ctf_errno (fp), _("cannot format name dumping type 0x%lx"),
+		id);
   free (buf);
   free (str);
   free (bit);