[DTrace-devel] [PATCH] Fix type alignment handling for enums

Kris Van Hees kris.van.hees at oracle.com
Thu Aug 19 23:47:27 PDT 2021


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.

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
---
 libdtrace/dt_parser.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libdtrace/dt_parser.c b/libdtrace/dt_parser.c
index e9dcff98..bac895a2 100644
--- a/libdtrace/dt_parser.c
+++ b/libdtrace/dt_parser.c
@@ -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 &&
@@ -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;
-- 
2.33.0




More information about the DTrace-devel mailing list