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.
This commit is contained in:
Nick Alcock 2020-06-02 20:28:16 +01:00
parent 2484ca436a
commit ab769488e7
2 changed files with 8 additions and 0 deletions

View 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);