Browse Source

Merge pull request #98 from rauls5382/vet

Fix issues reported by govet
Alexey Alexandrov 8 years ago
parent
commit
d4639bf00a

+ 6
- 6
driver/driver.go View File

@@ -42,12 +42,12 @@ func (o *Options) InternalOptions() *plugin.Options {
42 42
 		sym = &internalSymbolizer{o.Sym}
43 43
 	}
44 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 View File

@@ -164,7 +164,10 @@ func (d *addr2Liner) readFrame() (plugin.Frame, bool) {
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 173
 // addrInfo returns the stack frame information for a specific program

+ 2
- 2
internal/binutils/addr2liner_llvm.go View File

@@ -121,7 +121,7 @@ func (d *llvmSymbolizer) readFrame() (plugin.Frame, bool) {
121 121
 
122 122
 	fileline, err := d.readString()
123 123
 	if err != nil {
124
-		return plugin.Frame{funcname, "", 0}, true
124
+		return plugin.Frame{Func: funcname}, true
125 125
 	}
126 126
 
127 127
 	linenumber := 0
@@ -144,7 +144,7 @@ func (d *llvmSymbolizer) readFrame() (plugin.Frame, bool) {
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 150
 // addrInfo returns the stack frame information for a specific program

+ 1
- 1
internal/binutils/binutils_test.go View File

@@ -49,7 +49,7 @@ func TestAddr2Liner(t *testing.T) {
49 49
 		}
50 50
 		for l, f := range s {
51 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 54
 			if f != want {
55 55
 				t.Errorf("AddrInfo(%#x)[%d]: = %+v, want %+v", addr, l, f, want)

+ 1
- 1
internal/binutils/disasm.go View File

@@ -46,7 +46,7 @@ func findSymbols(syms []byte, file string, r *regexp.Regexp, address uint64) ([]
46 46
 			continue
47 47
 		}
48 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 51
 		names, start = []string{name}, symAddr
52 52
 	}

+ 6
- 6
internal/binutils/disasm_test.go View File

@@ -46,16 +46,16 @@ func TestFindSymbols(t *testing.T) {
46 46
 			"line.*[AC]",
47 47
 			testsyms,
48 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 55
 			"Dumb::operator",
56 56
 			testsyms,
57 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,7 +109,7 @@ func TestFunctionAssembly(t *testing.T) {
109 109
 	}
110 110
 	testcases := []testcase{
111 111
 		{
112
-			plugin.Sym{[]string{"symbol1"}, "", 0x1000, 0x1FFF},
112
+			plugin.Sym{Name: []string{"symbol1"}, Start: 0x1000, End: 0x1FFF},
113 113
 			`  1000: instruction one
114 114
   1001: instruction two
115 115
   1002: instruction three
@@ -123,7 +123,7 @@ func TestFunctionAssembly(t *testing.T) {
123 123
 			},
124 124
 		},
125 125
 		{
126
-			plugin.Sym{[]string{"symbol2"}, "", 0x2000, 0x2FFF},
126
+			plugin.Sym{Name: []string{"symbol2"}, Start: 0x2000, End: 0x2FFF},
127 127
 			`  2000: instruction one
128 128
   2001: instruction two
129 129
 `,

+ 1
- 1
internal/driver/fetch_test.go View File

@@ -105,7 +105,7 @@ func TestCollectMappingSources(t *testing.T) {
105 105
 		}
106 106
 		got := collectMappingSources(p, url)
107 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 View File

@@ -47,7 +47,7 @@ func setDefaults(o *plugin.Options) *plugin.Options {
47 47
 		d.UI = &stdUI{r: bufio.NewReader(os.Stdin)}
48 48
 	}
49 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 52
 	return d
53 53
 }

+ 1
- 1
internal/report/report_test.go View File

@@ -230,7 +230,7 @@ func TestDisambiguation(t *testing.T) {
230 230
 		sibling: "sibling",
231 231
 	}
232 232
 
233
-	g := &graph.Graph{n}
233
+	g := &graph.Graph{Nodes: n}
234 234
 
235 235
 	names := getDisambiguatedNames(g)
236 236
 

+ 12
- 5
internal/symbolizer/symbolizer_test.go View File

@@ -207,11 +207,18 @@ func checkSymbolizedLocation(a uint64, got []profile.Line) error {
207 207
 }
208 208
 
209 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 224
 type mockObjTool struct{}