diff options
| author | Anton Lindqvist <anton@basename.se> | 2020-10-31 09:56:56 +0100 |
|---|---|---|
| committer | Anton Lindqvist <anton@basename.se> | 2020-10-31 10:23:26 +0100 |
| commit | 8bc4594f832068a30c0eff44d468311780057d1f (patch) | |
| tree | 7c58e0e66c680e57d83258cf8703e221903398f3 /pkg/compiler/const_file.go | |
| parent | 7928dd20b88207a7365cc2807b12f4ec891cddfe (diff) | |
pkg/compiler: fix handling of defines with a 0 value
While adding new syscall descriptions to OpenBSD I ran into the following problem:
$ gmake extract SOURCEDIR=/home/src && ./bin/syz-sysgen
fs.txt.const:15: failed to parse int: strconv.ParseUint: parsing "": invalid syntax
$ tail -n +15 sys/openbsd/fs.txt.const | head -1
O_RDONLY =
Note that `O_RDONLY` lacks a value and the same directive is defined as
0 on OpenBSD.
In `ConstFile.Serialize()`, if val is equal to the default value is has
only already been serialized if `max != 0`.
Diffstat (limited to 'pkg/compiler/const_file.go')
| -rw-r--r-- | pkg/compiler/const_file.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/pkg/compiler/const_file.go b/pkg/compiler/const_file.go index d64c15207..8f4bfe390 100644 --- a/pkg/compiler/const_file.go +++ b/pkg/compiler/const_file.go @@ -123,7 +123,7 @@ func (cf *ConstFile) Serialize() []byte { handled := make([]bool, len(arches)) for i, arch := range arches { val, ok := cv.vals[arch] - if ok && val == dflt || handled[i] { + if ok && (max != 0 && val == dflt) || handled[i] { // Default value or serialized on a previous iteration. continue } |
