ソースを参照

Merge pull request #98 from rauls5382/vet

Fix issues reported by govet
Alexey Alexandrov 8 年 前
コミット
d4639bf00a

+ 6
- 6
driver/driver.go ファイルの表示

42
 		sym = &internalSymbolizer{o.Sym}
42
 		sym = &internalSymbolizer{o.Sym}
43
 	}
43
 	}
44
 	return &plugin.Options{
44
 	return &plugin.Options{
45
-		o.Writer,
46
-		o.Flagset,
47
-		o.Fetch,
48
-		sym,
49
-		obj,
50
-		o.UI,
45
+		Writer: o.Writer,
46
+		Flagset: o.Flagset,
47
+		Fetch: o.Fetch,
48
+		Sym: sym,
49
+		Obj: obj,
50
+		UI: o.UI,
51
 	}
51
 	}
52
 }
52
 }
53
 
53
 

+ 4
- 1
internal/binutils/addr2liner.go ファイルの表示

164
 		}
164
 		}
165
 	}
165
 	}
166
 
166
 
167
-	return plugin.Frame{funcname, fileline, linenumber}, false
167
+	return plugin.Frame{
168
+		Func: funcname,
169
+		File: fileline,
170
+		Line: linenumber}, false
168
 }
171
 }
169
 
172
 
170
 // addrInfo returns the stack frame information for a specific program
173
 // addrInfo returns the stack frame information for a specific program

+ 2
- 2
internal/binutils/addr2liner_llvm.go ファイルの表示

121
 
121
 
122
 	fileline, err := d.readString()
122
 	fileline, err := d.readString()
123
 	if err != nil {
123
 	if err != nil {
124
-		return plugin.Frame{funcname, "", 0}, true
124
+		return plugin.Frame{Func: funcname}, true
125
 	}
125
 	}
126
 
126
 
127
 	linenumber := 0
127
 	linenumber := 0
144
 		}
144
 		}
145
 	}
145
 	}
146
 
146
 
147
-	return plugin.Frame{funcname, fileline, linenumber}, false
147
+	return plugin.Frame{Func: funcname, File: fileline, Line: linenumber}, false
148
 }
148
 }
149
 
149
 
150
 // addrInfo returns the stack frame information for a specific program
150
 // addrInfo returns the stack frame information for a specific program

+ 1
- 1
internal/binutils/binutils_test.go ファイルの表示

49
 		}
49
 		}
50
 		for l, f := range s {
50
 		for l, f := range s {
51
 			level := (len(s) - l) * 1000
51
 			level := (len(s) - l) * 1000
52
-			want := plugin.Frame{functionName(level), fmt.Sprintf("file%d", level), level}
52
+			want := plugin.Frame{Func: functionName(level), File: fmt.Sprintf("file%d", level), Line: level}
53
 
53
 
54
 			if f != want {
54
 			if f != want {
55
 				t.Errorf("AddrInfo(%#x)[%d]: = %+v, want %+v", addr, l, f, want)
55
 				t.Errorf("AddrInfo(%#x)[%d]: = %+v, want %+v", addr, l, f, want)

+ 1
- 1
internal/binutils/disasm.go ファイルの表示

46
 			continue
46
 			continue
47
 		}
47
 		}
48
 		if match := matchSymbol(names, start, symAddr-1, r, address); match != nil {
48
 		if match := matchSymbol(names, start, symAddr-1, r, address); match != nil {
49
-			symbols = append(symbols, &plugin.Sym{match, file, start, symAddr - 1})
49
+			symbols = append(symbols, &plugin.Sym{Name: match, File: file, Start: start, End: symAddr - 1})
50
 		}
50
 		}
51
 		names, start = []string{name}, symAddr
51
 		names, start = []string{name}, symAddr
52
 	}
52
 	}

+ 6
- 6
internal/binutils/disasm_test.go ファイルの表示

46
 			"line.*[AC]",
46
 			"line.*[AC]",
47
 			testsyms,
47
 			testsyms,
48
 			[]plugin.Sym{
48
 			[]plugin.Sym{
49
-				{[]string{"lineA001"}, "object.o", 0x1000, 0x1FFF},
50
-				{[]string{"line200A"}, "object.o", 0x2000, 0x2FFF},
51
-				{[]string{"lineB00C"}, "object.o", 0x3000, 0x3FFF},
49
+				{Name: []string{"lineA001"}, File: "object.o", Start: 0x1000, End: 0x1FFF},
50
+				{Name: []string{"line200A"}, File: "object.o", Start: 0x2000, End: 0x2FFF},
51
+				{Name: []string{"lineB00C"}, File: "object.o", Start: 0x3000, End: 0x3FFF},
52
 			},
52
 			},
53
 		},
53
 		},
54
 		{
54
 		{
55
 			"Dumb::operator",
55
 			"Dumb::operator",
56
 			testsyms,
56
 			testsyms,
57
 			[]plugin.Sym{
57
 			[]plugin.Sym{
58
-				{[]string{"Dumb::operator()(char const*) const"}, "object.o", 0x3000, 0x3FFF},
58
+				{Name: []string{"Dumb::operator()(char const*) const"}, File: "object.o", Start: 0x3000, End: 0x3FFF},
59
 			},
59
 			},
60
 		},
60
 		},
61
 	}
61
 	}
109
 	}
109
 	}
110
 	testcases := []testcase{
110
 	testcases := []testcase{
111
 		{
111
 		{
112
-			plugin.Sym{[]string{"symbol1"}, "", 0x1000, 0x1FFF},
112
+			plugin.Sym{Name: []string{"symbol1"}, Start: 0x1000, End: 0x1FFF},
113
 			`  1000: instruction one
113
 			`  1000: instruction one
114
   1001: instruction two
114
   1001: instruction two
115
   1002: instruction three
115
   1002: instruction three
123
 			},
123
 			},
124
 		},
124
 		},
125
 		{
125
 		{
126
-			plugin.Sym{[]string{"symbol2"}, "", 0x2000, 0x2FFF},
126
+			plugin.Sym{Name: []string{"symbol2"}, Start: 0x2000, End: 0x2FFF},
127
 			`  2000: instruction one
127
 			`  2000: instruction one
128
   2001: instruction two
128
   2001: instruction two
129
 `,
129
 `,

+ 1
- 1
internal/driver/fetch_test.go ファイルの表示

105
 		}
105
 		}
106
 		got := collectMappingSources(p, url)
106
 		got := collectMappingSources(p, url)
107
 		if !reflect.DeepEqual(got, tc.want) {
107
 		if !reflect.DeepEqual(got, tc.want) {
108
-			t.Errorf("%s:%s, want %s, got %s", tc.file, tc.buildID, tc.want, got)
108
+			t.Errorf("%s:%s, want %v, got %v", tc.file, tc.buildID, tc.want, got)
109
 		}
109
 		}
110
 	}
110
 	}
111
 }
111
 }

+ 1
- 1
internal/driver/options.go ファイルの表示

47
 		d.UI = &stdUI{r: bufio.NewReader(os.Stdin)}
47
 		d.UI = &stdUI{r: bufio.NewReader(os.Stdin)}
48
 	}
48
 	}
49
 	if d.Sym == nil {
49
 	if d.Sym == nil {
50
-		d.Sym = &symbolizer.Symbolizer{d.Obj, d.UI}
50
+		d.Sym = &symbolizer.Symbolizer{Obj: d.Obj, UI: d.UI}
51
 	}
51
 	}
52
 	return d
52
 	return d
53
 }
53
 }

+ 1
- 1
internal/report/report_test.go ファイルの表示

230
 		sibling: "sibling",
230
 		sibling: "sibling",
231
 	}
231
 	}
232
 
232
 
233
-	g := &graph.Graph{n}
233
+	g := &graph.Graph{Nodes: n}
234
 
234
 
235
 	names := getDisambiguatedNames(g)
235
 	names := getDisambiguatedNames(g)
236
 
236
 

+ 12
- 5
internal/symbolizer/symbolizer_test.go ファイルの表示

207
 }
207
 }
208
 
208
 
209
 var mockAddresses = map[uint64][]plugin.Frame{
209
 var mockAddresses = map[uint64][]plugin.Frame{
210
-	1000: []plugin.Frame{{"fun11", "file11.src", 10}},
211
-	2000: []plugin.Frame{{"fun21", "file21.src", 20}, {"fun22", "file22.src", 20}},
212
-	3000: []plugin.Frame{{"fun31", "file31.src", 30}, {"fun32", "file32.src", 30}, {"fun33", "file33.src", 30}},
213
-	4000: []plugin.Frame{{"fun41", "file41.src", 40}, {"fun42", "file42.src", 40}, {"fun43", "file43.src", 40}, {"fun44", "file44.src", 40}},
214
-	5000: []plugin.Frame{{"fun51", "file51.src", 50}, {"fun52", "file52.src", 50}, {"fun53", "file53.src", 50}, {"fun54", "file54.src", 50}, {"fun55", "file55.src", 50}},
210
+	1000: []plugin.Frame{frame("fun11", "file11.src", 10)},
211
+	2000: []plugin.Frame{frame("fun21", "file21.src", 20), frame("fun22", "file22.src", 20)},
212
+	3000: []plugin.Frame{frame("fun31", "file31.src", 30), frame("fun32", "file32.src", 30), frame("fun33", "file33.src", 30)},
213
+	4000: []plugin.Frame{frame("fun41", "file41.src", 40), frame("fun42", "file42.src", 40), frame("fun43", "file43.src", 40), frame("fun44", "file44.src", 40)},
214
+	5000: []plugin.Frame{frame("fun51", "file51.src", 50), frame("fun52", "file52.src", 50), frame("fun53", "file53.src", 50), frame("fun54", "file54.src", 50), frame("fun55", "file55.src", 50)},
215
+}
216
+
217
+func frame(fname, file string, line int) plugin.Frame {
218
+	return plugin.Frame{
219
+		Func: fname,
220
+		File: file,
221
+		Line: line}
215
 }
222
 }
216
 
223
 
217
 type mockObjTool struct{}
224
 type mockObjTool struct{}