From ab769488e75272c3cbea4626a346fd0c336b2de6 Mon Sep 17 00:00:00 2001 From: Nick Alcock Date: Tue, 2 Jun 2020 20:28:16 +0100 Subject: [PATCH] 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. --- libctf/ChangeLog | 5 +++++ libctf/ctf-create.c | 3 +++ 2 files changed, 8 insertions(+) diff --git a/libctf/ChangeLog b/libctf/ChangeLog index 61aebd1422e..acff0b185a5 100644 --- a/libctf/ChangeLog +++ b/libctf/ChangeLog @@ -1,3 +1,8 @@ +2020-07-22 Nick Alcock + + * ctf-create.c (ctf_add_member_offset): Support names of "" + as if they were the null pointer. + 2020-07-22 Nick Alcock * ctf-open.c (init_types): Remove typeless CTF_K_FORWARD 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.30.2