aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2021-12-13 10:56:22 +0100
committerDmitry Vyukov <dvyukov@google.com>2021-12-13 11:50:08 +0100
commitbe3c96d30e70cbe08ccce6b6f734b6eac2125563 (patch)
tree14b1b752106dcf4b8ba4afa63e774fa261581d86
parente46390ef02fc48613bdcbaa50910f7ec44d10ee5 (diff)
tools/syz-kconf: better handle whitespaces for verbatim blocks
When we appended verbatim blocks we added '\n' for each of them, (for every config file effectively). Even for empty verbatim blocks. This worked fine because we had only 1 verbatim block and we do TrimSpace for the resulting concatenated verbatim block (so all excessive '\n' were removed). But this does not work for multiple verbatim blocks because excessive '\n' will be in the middle and won't be removed by TrimSpace. Don't add '\n' for empty verbatim blocks.
-rw-r--r--tools/syz-kconf/parser.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/syz-kconf/parser.go b/tools/syz-kconf/parser.go
index 3419ea859..8b8a074c7 100644
--- a/tools/syz-kconf/parser.go
+++ b/tools/syz-kconf/parser.go
@@ -9,6 +9,7 @@ import (
"io/ioutil"
"path/filepath"
"strconv"
+ "strings"
"github.com/google/syzkaller/pkg/kconfig"
"github.com/google/syzkaller/pkg/vcs"
@@ -190,7 +191,9 @@ func mergeFile(inst *Instance, raw *rawFile, file string, errs *Errors) {
Constraints: constraints,
})
}
- inst.Verbatim = append(append(inst.Verbatim, raw.Verbatim...), '\n')
+ if raw.Verbatim != "" {
+ inst.Verbatim = append(append(inst.Verbatim, strings.TrimSpace(raw.Verbatim)...), '\n')
+ }
for _, node := range raw.Config {
mergeConfig(inst, file, node, false, errs)
}