From e86ddaca2eac4d5b854e7e2ec4b315302ff0e13f Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 1 Feb 2018 20:08:32 +0100 Subject: sys/syz-extract: save unsupported consts to the const files We currently print unsupported consts to console during make extract. But this is not very useful as there are too many output now. This also does not allow to understand what's unsupported in newly checked-in descriptions, or what's unsupported in all current decriptions. Save unsupported consts to the const files instead. This solves all of the above problems. --- pkg/compiler/consts.go | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'pkg') diff --git a/pkg/compiler/consts.go b/pkg/compiler/consts.go index 46a781f39..b4f674124 100644 --- a/pkg/compiler/consts.go +++ b/pkg/compiler/consts.go @@ -213,11 +213,6 @@ func (comp *compiler) patchIntConst(pos ast.Pos, val *uint64, id *string, } v, ok := consts[*id] if !ok { - name := "const " + *id - if !comp.unsupported[name] { - comp.unsupported[name] = true - comp.warning(pos, "unsupported const: %v", *id) - } if missing != nil && *missing == "" { *missing = *id } @@ -226,14 +221,18 @@ func (comp *compiler) patchIntConst(pos ast.Pos, val *uint64, id *string, return ok } -func SerializeConsts(consts map[string]uint64) []byte { +func SerializeConsts(consts map[string]uint64, undeclared map[string]bool) []byte { type nameValuePair struct { - name string - val uint64 + declared bool + name string + val uint64 } var nv []nameValuePair for k, v := range consts { - nv = append(nv, nameValuePair{k, v}) + nv = append(nv, nameValuePair{true, k, v}) + } + for k := range undeclared { + nv = append(nv, nameValuePair{false, k, 0}) } sort.Slice(nv, func(i, j int) bool { return nv[i].name < nv[j].name @@ -242,7 +241,11 @@ func SerializeConsts(consts map[string]uint64) []byte { buf := new(bytes.Buffer) fmt.Fprintf(buf, "# AUTOGENERATED FILE\n") for _, x := range nv { - fmt.Fprintf(buf, "%v = %v\n", x.name, x.val) + if x.declared { + fmt.Fprintf(buf, "%v = %v\n", x.name, x.val) + } else { + fmt.Fprintf(buf, "# %v is not set\n", x.name) + } } return buf.Bytes() } -- cgit mrf-deployment