Skip to content

Commit

Permalink
Fix type alignment handling for enums
Browse files Browse the repository at this point in the history
The type alignment handling code used to determine the alignment size
for a given datatype was treating enums as if they were integers, but
that is incorrect.  It should (just like integers and pointers) have
its alignment set to match its size, but it should avoid the explicit
void-checking that is done for integers.

Without this patch, libdtrace linked with newer versions of libctf
will see a test failure in unittest/sizeof/tst.SizeofDataTypes.d for
datatype 'new_enum'.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
  • Loading branch information
kvanhees committed Aug 25, 2021
1 parent 6dbeee8 commit f4b2863
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libdtrace/dt_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1630,7 +1630,6 @@ dt_node_decl(void)
size = ctf_type_size(dtt.dtt_ctfp, dtt.dtt_type);

switch (kind) {
case CTF_K_ENUM:
case CTF_K_INTEGER:
if (ctf_type_encoding(dtt.dtt_ctfp, type,
&cte) == 0 &&
Expand All @@ -1639,6 +1638,7 @@ dt_node_decl(void)
"cannot have void object: %s\n",
dsp->ds_ident);
/*FALLTHRU*/
case CTF_K_ENUM:
case CTF_K_POINTER:
alignment = size;
break;
Expand Down

0 comments on commit f4b2863

Please sign in to comment.