summaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorAdin Scannell <ascannell@google.com>2021-01-12 12:36:17 -0800
committergVisor bot <gvisor-bot@google.com>2021-01-12 12:38:22 -0800
commit4e03e87547853523d4ff941935a6ef1712518c61 (patch)
treee930ce0e5f15f7041e7b74daca05acc7afbd2558 /tools
parenta20da708291e2e5bdece5176dce61c1b4b10b7d9 (diff)
Fix simple mistakes identified by goreportcard.
These are primarily simplification and lint mistakes. However, minor fixes are also included and tests added where appropriate. PiperOrigin-RevId: 351425971
Diffstat (limited to 'tools')
-rw-r--r--tools/checkescape/checkescape.go42
-rw-r--r--tools/github/nogo/nogo.go4
-rw-r--r--tools/go_generics/tests/all_stmts/input.go2
-rw-r--r--tools/go_generics/tests/all_stmts/output.go2
-rw-r--r--tools/go_generics/tests/all_types/lib/lib.go1
-rw-r--r--tools/go_marshal/analysis/analysis_unsafe.go2
-rw-r--r--tools/go_marshal/gomarshal/generator.go2
-rw-r--r--tools/go_marshal/gomarshal/generator_interfaces_struct.go2
8 files changed, 31 insertions, 26 deletions
diff --git a/tools/checkescape/checkescape.go b/tools/checkescape/checkescape.go
index 011b8fee8..8eeabbc3d 100644
--- a/tools/checkescape/checkescape.go
+++ b/tools/checkescape/checkescape.go
@@ -404,27 +404,27 @@ func loadObjdump() (map[string][]string, error) {
// This is because some of the functions (duffzero) may have
// jump targets in the middle of the function itself.
funcsAllowed := map[string]struct{}{
- "runtime.duffzero": struct{}{},
- "runtime.duffcopy": struct{}{},
- "runtime.racefuncenter": struct{}{},
- "runtime.gcWriteBarrier": struct{}{},
- "runtime.retpolineAX": struct{}{},
- "runtime.retpolineBP": struct{}{},
- "runtime.retpolineBX": struct{}{},
- "runtime.retpolineCX": struct{}{},
- "runtime.retpolineDI": struct{}{},
- "runtime.retpolineDX": struct{}{},
- "runtime.retpolineR10": struct{}{},
- "runtime.retpolineR11": struct{}{},
- "runtime.retpolineR12": struct{}{},
- "runtime.retpolineR13": struct{}{},
- "runtime.retpolineR14": struct{}{},
- "runtime.retpolineR15": struct{}{},
- "runtime.retpolineR8": struct{}{},
- "runtime.retpolineR9": struct{}{},
- "runtime.retpolineSI": struct{}{},
- "runtime.stackcheck": struct{}{},
- "runtime.settls": struct{}{},
+ "runtime.duffzero": {},
+ "runtime.duffcopy": {},
+ "runtime.racefuncenter": {},
+ "runtime.gcWriteBarrier": {},
+ "runtime.retpolineAX": {},
+ "runtime.retpolineBP": {},
+ "runtime.retpolineBX": {},
+ "runtime.retpolineCX": {},
+ "runtime.retpolineDI": {},
+ "runtime.retpolineDX": {},
+ "runtime.retpolineR10": {},
+ "runtime.retpolineR11": {},
+ "runtime.retpolineR12": {},
+ "runtime.retpolineR13": {},
+ "runtime.retpolineR14": {},
+ "runtime.retpolineR15": {},
+ "runtime.retpolineR8": {},
+ "runtime.retpolineR9": {},
+ "runtime.retpolineSI": {},
+ "runtime.stackcheck": {},
+ "runtime.settls": {},
}
addrsAllowed := make(map[string]struct{})
diff --git a/tools/github/nogo/nogo.go b/tools/github/nogo/nogo.go
index 27ab1b8eb..894a0e7c3 100644
--- a/tools/github/nogo/nogo.go
+++ b/tools/github/nogo/nogo.go
@@ -84,7 +84,7 @@ func (p *FindingsPoster) Walk(paths []string) error {
func (p *FindingsPoster) Post() error {
// Just show results?
if p.dryRun {
- for finding, _ := range p.findings {
+ for finding := range p.findings {
// Pretty print, so that this is useful for debugging.
fmt.Printf("%s: (%s+%d) %s\n", finding.Category, finding.Position.Filename, finding.Position.Line, finding.Message)
}
@@ -114,7 +114,7 @@ func (p *FindingsPoster) Post() error {
},
}
annotationLevel := "failure" // Always.
- for finding, _ := range p.findings {
+ for finding := range p.findings {
title := string(finding.Category)
opts.Output.Annotations = append(opts.Output.Annotations, &github.CheckRunAnnotation{
Path: &finding.Position.Filename,
diff --git a/tools/go_generics/tests/all_stmts/input.go b/tools/go_generics/tests/all_stmts/input.go
index 4791d1ff1..7ebe7c40e 100644
--- a/tools/go_generics/tests/all_stmts/input.go
+++ b/tools/go_generics/tests/all_stmts/input.go
@@ -118,8 +118,10 @@ R:
_ = v
} else if T := T(0); T != 1 {
T++
+ _ = T
} else {
T--
+ _ = T
}
if a := T(0); a != T(1) {
diff --git a/tools/go_generics/tests/all_stmts/output.go b/tools/go_generics/tests/all_stmts/output.go
index a53d84535..a33944d85 100644
--- a/tools/go_generics/tests/all_stmts/output.go
+++ b/tools/go_generics/tests/all_stmts/output.go
@@ -116,8 +116,10 @@ R:
_ = v
} else if T := Q(0); T != 1 {
T++
+ _ = T
} else {
T--
+ _ = T
}
if a := Q(0); a != Q(1) {
diff --git a/tools/go_generics/tests/all_types/lib/lib.go b/tools/go_generics/tests/all_types/lib/lib.go
index 988786496..99edb371f 100644
--- a/tools/go_generics/tests/all_types/lib/lib.go
+++ b/tools/go_generics/tests/all_types/lib/lib.go
@@ -14,4 +14,5 @@
package lib
+// T is a test type.
type T int32
diff --git a/tools/go_marshal/analysis/analysis_unsafe.go b/tools/go_marshal/analysis/analysis_unsafe.go
index cd55cf5cb..7a3d6bbea 100644
--- a/tools/go_marshal/analysis/analysis_unsafe.go
+++ b/tools/go_marshal/analysis/analysis_unsafe.go
@@ -81,7 +81,7 @@ func RandomizeValue(x interface{}) {
// This is used for zeroing padding fields after calling RandomizeValue.
func reflectZeroPaddingFields(r reflect.Type, data []byte, zero bool) {
if zero {
- for i, _ := range data {
+ for i := range data {
data[i] = 0
}
}
diff --git a/tools/go_marshal/gomarshal/generator.go b/tools/go_marshal/gomarshal/generator.go
index 28ae6c4ef..fa642c88a 100644
--- a/tools/go_marshal/gomarshal/generator.go
+++ b/tools/go_marshal/gomarshal/generator.go
@@ -148,7 +148,7 @@ func (g *Generator) writeTypeChecks(ms map[string]struct{}) error {
}
msl := make([]string, 0, len(ms))
- for m, _ := range ms {
+ for m := range ms {
msl = append(msl, m)
}
sort.Strings(msl)
diff --git a/tools/go_marshal/gomarshal/generator_interfaces_struct.go b/tools/go_marshal/gomarshal/generator_interfaces_struct.go
index fe76d3785..5f6306b8f 100644
--- a/tools/go_marshal/gomarshal/generator_interfaces_struct.go
+++ b/tools/go_marshal/gomarshal/generator_interfaces_struct.go
@@ -38,7 +38,7 @@ func (g *interfaceGenerator) areFieldsPackedExpression() (string, bool) {
}
cs := make([]string, 0, len(g.as))
- for accessor, _ := range g.as {
+ for accessor := range g.as {
cs = append(cs, fmt.Sprintf("%s.Packed()", accessor))
}
// Sort expressions for determinstic build outputs.