[08/59] libctf, create: member names of "" and NULL should be the same

Message ID 20200630233146.338613-9-nick.alcock@oracle.com
State New
Headers show
  • Deduplicating CTF linker
Related show

Commit Message

Alan Modra via Binutils June 30, 2020, 11:30 p.m.
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.

	* ctf-create.c (ctf_add_member_offset): Support names of ""
	as if they were the null pointer.
 libctf/ctf-create.c | 3 +++
 1 file changed, 3 insertions(+)



diff --git a/libctf/ctf-create.c b/libctf/ctf-create.c
index bc0ad802dd2..848e725ef24 100644
--- a/libctf/ctf-create.c
+++ b/libctf/ctf-create.c
@@ -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);