]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
libctf, create: member names of "" and NULL should be the same
authorNick Alcock <nick.alcock@oracle.com>
Tue, 2 Jun 2020 19:28:16 +0000 (20:28 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Wed, 22 Jul 2020 16:57:27 +0000 (17:57 +0100)
This matters for the case of unnamed bitfields, whose names are the null
string.  These are special in that they are the only members whose
"names" are allowed to be duplicated in a single struct, but we were
only handling this for the case where name == NULL.  Translate "" to
NULL to help callers.

libctf/
* ctf-create.c (ctf_add_member_offset): Support names of ""
as if they were the null pointer.

libctf/ChangeLog
libctf/ctf-create.c

index 61aebd1422efbc06e2f648ad22e1afcdf2b578ca..acff0b185a5ffa262a183b6322923ff4895f6b6c 100644 (file)
@@ -1,3 +1,8 @@
+2020-07-22  Nick Alcock  <nick.alcock@oracle.com>
+
+       * ctf-create.c (ctf_add_member_offset): Support names of ""
+       as if they were the null pointer.
+
 2020-07-22  Nick Alcock  <nick.alcock@oracle.com>
 
        * ctf-open.c (init_types): Remove typeless CTF_K_FORWARD
index bc0ad802dd2b944eabd25c0e224828378675817f..848e725ef242b66e2189579d8006db45327ceb46 100644 (file)
@@ -1371,6 +1371,9 @@ ctf_add_member_offset (ctf_file_t *fp, ctf_id_t souid, const char *name,
   if (dtd == NULL)
     return (ctf_set_errno (fp, ECTF_BADID));
 
+  if (name != NULL && name[0] == '\0')
+    name = NULL;
+
   kind = LCTF_INFO_KIND (fp, dtd->dtd_data.ctt_info);
   root = LCTF_INFO_ISROOT (fp, dtd->dtd_data.ctt_info);
   vlen = LCTF_INFO_VLEN (fp, dtd->dtd_data.ctt_info);