aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-02-01 20:08:32 +0100
committerDmitry Vyukov <dvyukov@google.com>2018-02-01 20:18:51 +0100
commite86ddaca2eac4d5b854e7e2ec4b315302ff0e13f (patch)
tree50ed41a93458987feb750426942622d1360b4c19 /pkg
parentad2c9da9fbaeee1d362730714d0a01e895ed2e20 (diff)
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.
Diffstat (limited to 'pkg')
-rw-r--r--pkg/compiler/consts.go23
1 files changed, 13 insertions, 10 deletions
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()
}