aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/csource/csource.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/csource/csource.go')
-rw-r--r--pkg/csource/csource.go22
1 files changed, 14 insertions, 8 deletions
diff --git a/pkg/csource/csource.go b/pkg/csource/csource.go
index 7d3b133bf..df35b54b8 100644
--- a/pkg/csource/csource.go
+++ b/pkg/csource/csource.go
@@ -28,6 +28,7 @@ import (
"fmt"
"regexp"
"sort"
+ "strconv"
"strings"
"time"
@@ -58,6 +59,18 @@ type context struct {
calls map[string]uint64 // CallName -> NR
}
+func generateSandboxFunctionSignature(sandboxName string, sandboxArg int) string {
+ if sandboxName == "" {
+ return "loop();"
+ }
+
+ arguments := "();"
+ if sandboxName == "android" {
+ arguments = "(" + strconv.Itoa(sandboxArg) + ");"
+ }
+ return "do_sandbox_" + sandboxName + arguments
+}
+
func (ctx *context) generateSource() ([]byte, error) {
ctx.filterCalls()
calls, vars, err := ctx.generateProgCalls(ctx.p, ctx.opts.Trace)
@@ -94,14 +107,7 @@ func (ctx *context) generateSource() ([]byte, error) {
fmt.Fprintf(varsBuf, "};\n")
}
- sandboxFunc := "loop();"
- if ctx.opts.Sandbox != "" {
- arguments := "();"
- if ctx.opts.Sandbox == "android" {
- arguments = "(0);"
- }
- sandboxFunc = "do_sandbox_" + ctx.opts.Sandbox + arguments
- }
+ sandboxFunc := generateSandboxFunctionSignature(ctx.opts.Sandbox, ctx.opts.SandboxArg)
replacements := map[string]string{
"PROCS": fmt.Sprint(ctx.opts.Procs),
"REPEAT_TIMES": fmt.Sprint(ctx.opts.RepeatTimes),