Print this page
rm code review
12259 CTF shouldn't assume enum size

@@ -23,11 +23,11 @@
 /*
  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 /*
- * Copyright 2018 Joyent, Inc.
+ * Copyright 2020 Joyent, Inc.
  */
 
 #include <ctf_impl.h>
 #include <sys/debug.h>
 

@@ -52,10 +52,22 @@
                 *incrementp = increment;
 
         return (size);
 }
 
+void
+ctf_set_ctt_size(ctf_type_t *tp, ssize_t size)
+{
+        if (size > CTF_MAX_SIZE) {
+                tp->ctt_size = CTF_LSIZE_SENT;
+                tp->ctt_lsizehi = CTF_SIZE_TO_LSIZE_HI(size);
+                tp->ctt_lsizelo = CTF_SIZE_TO_LSIZE_LO(size);
+        } else {
+                tp->ctt_size = (ushort_t)size;
+        }
+}
+
 /*
  * Iterate over the members of a STRUCT or UNION.  We pass the name, member
  * type, and offset of each member to the specified callback function.
  */
 int

@@ -479,11 +491,11 @@
 
         case CTF_K_FORWARD:
                 return (0);
 
         case CTF_K_ENUM:
-                return (fp->ctf_dmodel->ctd_int);
+                return (ctf_get_ctt_size(fp, tp, NULL, NULL));
 
         case CTF_K_ARRAY:
                 /*
                  * Array size is not directly returned by stabs data.  Instead,
                  * it defines the element type and requires the user to perform

@@ -576,12 +588,10 @@
 
                 return (align);
         }
 
         case CTF_K_ENUM:
-                return (fp->ctf_dmodel->ctd_int);
-
         default:
                 return (ctf_get_ctt_size(fp, tp, NULL, NULL));
         }
 }