[04/19] libctf, dump: correctly dump non-root-visible types

Message ID 20240730153707.168357-5-nick.alcock@oracle.com
State New
Headers
Series libctf: various bugfixes (including a write into freed memory), and loosen constraints on enums |

Checks

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 July 30, 2024, 3:36 p.m. UTC
  The flag test when dumping non-root-visible tyeps was doubly wrong: the
flags word is a *bitfield* containing CTF_ADD_ROOT as one possible
value, so needs | and & testing, not just ==, and CTF_ADD_NONROOT is 0,
so cannot be tested for this way: one must check for the non-presence of
CTF_ADD_ROOT.

libctf/
	* ctf-dump.c (ctf_dump_format_type): Fix non-root flag test.
---
 libctf/ctf-dump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Patch

diff --git a/libctf/ctf-dump.c b/libctf/ctf-dump.c
index 80a3b265297..cd41996084d 100644
--- a/libctf/ctf-dump.c
+++ b/libctf/ctf-dump.c
@@ -106,7 +106,7 @@  ctf_dump_format_type (ctf_dict_t *fp, ctf_id_t id, int flag)
       const char *idstr = "";
 
       id = new_id;
-      if (flag == CTF_ADD_NONROOT)
+      if (!(flag & CTF_ADD_ROOT))
 	{
 	  nonroot_leader = "{";
 	  nonroot_trailer = "}";