aboutsummaryrefslogtreecommitdiff
path: root/libctf/ctf-create.c
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2020-06-02 20:28:16 +0100
committerNick Alcock <nick.alcock@oracle.com>2020-07-22 17:57:27 +0100
commitab769488e75272c3cbea4626a346fd0c336b2de6 (patch)
treef8df0e4cc998210af7387454f4e72bdd2c55979c /libctf/ctf-create.c
parent2484ca436ac68716636a7aca3826bca3cda243a4 (diff)
downloadbinutils-ab769488e75272c3cbea4626a346fd0c336b2de6.zip
binutils-ab769488e75272c3cbea4626a346fd0c336b2de6.tar.gz
binutils-ab769488e75272c3cbea4626a346fd0c336b2de6.tar.bz2
libctf, create: member names of "" and NULL should be the same
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.
Diffstat (limited to 'libctf/ctf-create.c')
-rw-r--r--libctf/ctf-create.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/libctf/ctf-create.c b/libctf/ctf-create.c
index bc0ad80..848e725 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);