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

Nick Alcock nick.alcock@oracle.com
Tue Jun 30 23:30:55 GMT 2020


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/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);
-- 
2.27.0.247.g3dff7de930



More information about the Binutils mailing list