[binutils-gdb] libctf: create: check the right root-visible flag when adding enumerands

Nick Alcock nix@sourceware.org
Tue Jul 1 15:02:07 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d54eea875046b46002d1c915b7a388e560140112

commit d54eea875046b46002d1c915b7a388e560140112
Author: Nick Alcock <nick.alcock@oracle.com>
Date:   Thu Jun 26 15:47:25 2025 +0100

    libctf: create: check the right root-visible flag when adding enumerands
    
    The root-visible flag we're dealing with here is directly out of the dict,
    not a flag passed in to the API, so it does not have the values CTF_ADD_ROOT
    or CTF_ADD_NONROOT: instead it's simply zero for non-root-visible, nonzero
    otherwise.  Fix the test.
    
    libctf/
            * ctf-create.c (ctf_add_enumerator): Fix root-visibility test.

Diff:
---
 libctf/ctf-create.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libctf/ctf-create.c b/libctf/ctf-create.c
index ca984e81b51..5820830f086 100644
--- a/libctf/ctf-create.c
+++ b/libctf/ctf-create.c
@@ -1073,7 +1073,7 @@ ctf_add_enumerator (ctf_dict_t *fp, ctf_id_t enid, const char *name,
   /* Enumeration constant names are only added, and only checked for duplicates,
      if the enum they are part of is a root-visible type.  */
 
-  if (root == CTF_ADD_ROOT && ctf_dynhash_lookup (fp->ctf_names, name))
+  if (root && ctf_dynhash_lookup (fp->ctf_names, name))
     {
       if (fp->ctf_flags & LCTF_STRICT_NO_DUP_ENUMERATORS)
 	return (ctf_set_errno (ofp, ECTF_DUPLICATE));


More information about the Binutils-cvs mailing list