File: sou_too_many_values.diff

package info (click to toggle)
ctfutils 10.3~svn297264-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 3,492 kB
  • sloc: ansic: 60,377; makefile: 225
file content (49 lines) | stat: -rw-r--r-- 1,401 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Date: Sun, 10 Apr 2016 21:54:27 +0100
From: Steven Chamberlain <steven@pyro.eu.org>
Subject: encode first CTF_MAX_VLEN members of struct/union

Turn a "sou %s has too many values" error into a warning;
encode only the first CTF_MAX_VLEN members.

--- a/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c
@@ -383,8 +383,9 @@
 			i++; /* count up struct or union members */
 
 		if (i > CTF_MAX_VLEN) {
-			terminate("sou %s has too many members: %d > %d\n",
+			warning("sou %s has too many members: %d > %d\n",
 			    tdesc_name(tp), i, CTF_MAX_VLEN);
+			i = CTF_MAX_VLEN;
 		}
 
 		if (tp->t_type == STRUCT)
@@ -395,7 +396,7 @@
 		write_sized_type_rec(b, &ctt, tp->t_size);
 
 		if (tp->t_size < CTF_LSTRUCT_THRESH) {
-			for (mp = tp->t_members; mp != NULL; mp = mp->ml_next) {
+			for (mp = tp->t_members; mp != NULL && i > 0; mp = mp->ml_next) {
 				offset = strtab_insert(&b->ctb_strtab,
 				    mp->ml_name);
 
@@ -409,9 +410,10 @@
 					SWAP_16(ctm.ctm_offset);
 				}
 				ctf_buf_write(b, &ctm, sizeof (ctm));
+				i--;
 			}
 		} else {
-			for (mp = tp->t_members; mp != NULL; mp = mp->ml_next) {
+			for (mp = tp->t_members; mp != NULL && i > 0; mp = mp->ml_next) {
 				offset = strtab_insert(&b->ctb_strtab,
 				    mp->ml_name);
 
@@ -431,6 +433,7 @@
 				}
 
 				ctf_buf_write(b, &ctlm, sizeof (ctlm));
+				i--;
 			}
 		}
 		break;