aboutsummaryrefslogtreecommitdiffstats
path: root/csource
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2015-12-23 13:50:02 +0100
committerDmitry Vyukov <dvyukov@google.com>2015-12-23 13:50:02 +0100
commitc896644ab8e21af0067cac5b4e92105ace9656ea (patch)
tree85799a0ebb5e7904934c14d9246b2a9a4c33571e /csource
parent28571fdc32cae829731e1a89418e91b91e80c700 (diff)
csource: reformat
Diffstat (limited to 'csource')
-rw-r--r--csource/csource.go27
1 files changed, 13 insertions, 14 deletions
diff --git a/csource/csource.go b/csource/csource.go
index 51e817884..03ce4b84c 100644
--- a/csource/csource.go
+++ b/csource/csource.go
@@ -7,9 +7,9 @@ import (
"bytes"
"fmt"
"io/ioutil"
- "strings"
"os"
"os/exec"
+ "strings"
"unsafe"
"github.com/google/syzkaller/prog"
@@ -48,7 +48,7 @@ func Write(p *prog.Prog, opts Options) []byte {
}
fmt.Fprintf(w, "\n")
- calls,nvar := generateCalls(exec)
+ calls, nvar := generateCalls(exec)
fmt.Fprintf(w, "long r[%v];\n\n", nvar)
if !opts.Threaded && !opts.Collide {
@@ -79,11 +79,11 @@ func Write(p *prog.Prog, opts Options) []byte {
fmt.Fprintf(w, "\t\tusleep(10000);\n")
fmt.Fprintf(w, "\t}\n")
if opts.Collide {
- fmt.Fprintf(w, "\tfor (i = 0; i < %v; i++) {\n", len(calls))
- fmt.Fprintf(w, "\t\tpthread_create(&th[i], 0, thr, (void*)i);\n")
- fmt.Fprintf(w, "\t\tif (i%%2==0)\n")
- fmt.Fprintf(w, "\t\t\tusleep(10000);\n")
- fmt.Fprintf(w, "\t}\n")
+ fmt.Fprintf(w, "\tfor (i = 0; i < %v; i++) {\n", len(calls))
+ fmt.Fprintf(w, "\t\tpthread_create(&th[i], 0, thr, (void*)i);\n")
+ fmt.Fprintf(w, "\t\tif (i%%2==0)\n")
+ fmt.Fprintf(w, "\t\t\tusleep(10000);\n")
+ fmt.Fprintf(w, "\t}\n")
}
fmt.Fprintf(w, "\tusleep(100000);\n")
fmt.Fprintf(w, "\treturn 0;\n}\n")
@@ -116,15 +116,15 @@ func generateCalls(exec []byte) ([]string, int) {
var calls []string
w := new(bytes.Buffer)
newCall := func() {
- if seenCall {
- seenCall = false
- calls = append(calls, w.String())
- w = new(bytes.Buffer)
- }
+ if seenCall {
+ seenCall = false
+ calls = append(calls, w.String())
+ w = new(bytes.Buffer)
+ }
}
n := 0
loop:
- for ;; n++ {
+ for ; ; n++ {
switch instr := read(); instr {
case prog.ExecInstrEOF:
break loop
@@ -199,7 +199,6 @@ loop:
return calls, n
}
-
// WriteTempFile writes data to a temp file and returns its name.
func WriteTempFile(data []byte) (string, error) {
f, err := ioutil.TempFile("", "syz-prog")