Fix `go vet` issues
Test: go vet ./... Change-Id: Ifb936ccc5e2b5a2c3fcbbbcb54f680e2973ea1b3
This commit is contained in:
parent
ee74203bfb
commit
59339a29e1
|
@ -50,7 +50,7 @@ func validateConfigAnnotations(configurable jsonConfigurable) (err error) {
|
|||
}
|
||||
|
||||
type configType struct {
|
||||
populateMe *bool `json:"omitempty"`
|
||||
PopulateMe *bool `json:"omitempty"`
|
||||
}
|
||||
|
||||
func (c *configType) SetDefaultConfig() {
|
||||
|
@ -60,7 +60,7 @@ func (c *configType) SetDefaultConfig() {
|
|||
func TestValidateConfigAnnotations(t *testing.T) {
|
||||
config := configType{}
|
||||
err := validateConfigAnnotations(&config)
|
||||
expectedError := `Field configType.populateMe has tag json:"omitempty" which specifies to change its json field name to "omitempty".
|
||||
expectedError := `Field configType.PopulateMe has tag json:"omitempty" which specifies to change its json field name to "omitempty".
|
||||
Did you mean to use an annotation of ",omitempty"?
|
||||
(Alternatively, to change the json name of the field, rename the field in source instead.)`
|
||||
if err.Error() != expectedError {
|
||||
|
|
|
@ -153,7 +153,7 @@ func (s *makeVarsSingleton) GenerateBuildActions(ctx SingletonContext) {
|
|||
func (s *makeVarsSingleton) writeVars(vars []makeVarsVariable) []byte {
|
||||
buf := &bytes.Buffer{}
|
||||
|
||||
fmt.Fprintln(buf, `# Autogenerated file
|
||||
fmt.Fprint(buf, `# Autogenerated file
|
||||
|
||||
# Compares SOONG_$(1) against $(1), and warns if they are not equal.
|
||||
#
|
||||
|
@ -201,7 +201,7 @@ my_check_failed := false
|
|||
fmt.Fprintf(buf, "$(eval $(call soong-compare-var,%s,%s,my_check_failed := true))\n\n", v.name, sort)
|
||||
}
|
||||
|
||||
fmt.Fprintln(buf, `
|
||||
fmt.Fprint(buf, `
|
||||
ifneq ($(my_check_failed),false)
|
||||
$(error Soong variable check failed)
|
||||
endif
|
||||
|
|
|
@ -94,10 +94,8 @@ type NameResolver struct {
|
|||
}
|
||||
|
||||
func NewNameResolver(namespaceExportFilter func(*Namespace) bool) *NameResolver {
|
||||
namespacesByDir := sync.Map{}
|
||||
|
||||
r := &NameResolver{
|
||||
namespacesByDir: namespacesByDir,
|
||||
namespacesByDir: sync.Map{},
|
||||
namespaceExportFilter: namespaceExportFilter,
|
||||
}
|
||||
r.rootNamespace = r.newNamespace(".")
|
||||
|
|
|
@ -141,7 +141,6 @@ func (f *Fixer) Fix(config FixRequest) (*parser.File, error) {
|
|||
i++
|
||||
if i >= maxNumIterations {
|
||||
return nil, fmt.Errorf("Applied fixes %d times and yet the tree continued to change. Is there an infinite loop?", i)
|
||||
break
|
||||
}
|
||||
}
|
||||
return f.tree, err
|
||||
|
|
41
cc/cc.go
41
cc/cc.go
|
@ -991,33 +991,41 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
|||
actx.AddVariationDependencies(nil, depTag, lib)
|
||||
}
|
||||
|
||||
actx.AddVariationDependencies([]blueprint.Variation{{"link", "static"}}, wholeStaticDepTag,
|
||||
deps.WholeStaticLibs...)
|
||||
actx.AddVariationDependencies([]blueprint.Variation{
|
||||
{Mutator: "link", Variation: "static"},
|
||||
}, wholeStaticDepTag, deps.WholeStaticLibs...)
|
||||
|
||||
for _, lib := range deps.StaticLibs {
|
||||
depTag := staticDepTag
|
||||
if inList(lib, deps.ReexportStaticLibHeaders) {
|
||||
depTag = staticExportDepTag
|
||||
}
|
||||
actx.AddVariationDependencies([]blueprint.Variation{{"link", "static"}}, depTag, lib)
|
||||
actx.AddVariationDependencies([]blueprint.Variation{
|
||||
{Mutator: "link", Variation: "static"},
|
||||
}, depTag, lib)
|
||||
}
|
||||
|
||||
actx.AddVariationDependencies([]blueprint.Variation{{"link", "static"}}, lateStaticDepTag,
|
||||
deps.LateStaticLibs...)
|
||||
actx.AddVariationDependencies([]blueprint.Variation{
|
||||
{Mutator: "link", Variation: "static"},
|
||||
}, lateStaticDepTag, deps.LateStaticLibs...)
|
||||
|
||||
for _, lib := range deps.SharedLibs {
|
||||
depTag := sharedDepTag
|
||||
if inList(lib, deps.ReexportSharedLibHeaders) {
|
||||
depTag = sharedExportDepTag
|
||||
}
|
||||
actx.AddVariationDependencies([]blueprint.Variation{{"link", "shared"}}, depTag, lib)
|
||||
actx.AddVariationDependencies([]blueprint.Variation{
|
||||
{Mutator: "link", Variation: "shared"},
|
||||
}, depTag, lib)
|
||||
}
|
||||
|
||||
actx.AddVariationDependencies([]blueprint.Variation{{"link", "shared"}}, lateSharedDepTag,
|
||||
deps.LateSharedLibs...)
|
||||
actx.AddVariationDependencies([]blueprint.Variation{
|
||||
{Mutator: "link", Variation: "shared"},
|
||||
}, lateSharedDepTag, deps.LateSharedLibs...)
|
||||
|
||||
actx.AddVariationDependencies([]blueprint.Variation{{"link", "shared"}}, runtimeDepTag,
|
||||
deps.RuntimeLibs...)
|
||||
actx.AddVariationDependencies([]blueprint.Variation{
|
||||
{Mutator: "link", Variation: "shared"},
|
||||
}, runtimeDepTag, deps.RuntimeLibs...)
|
||||
|
||||
actx.AddDependency(c, genSourceDepTag, deps.GeneratedSources...)
|
||||
|
||||
|
@ -1043,9 +1051,13 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
|||
|
||||
version := ctx.sdkVersion()
|
||||
actx.AddVariationDependencies([]blueprint.Variation{
|
||||
{"ndk_api", version}, {"link", "shared"}}, ndkStubDepTag, variantNdkLibs...)
|
||||
{Mutator: "ndk_api", Variation: version},
|
||||
{Mutator: "link", Variation: "shared"},
|
||||
}, ndkStubDepTag, variantNdkLibs...)
|
||||
actx.AddVariationDependencies([]blueprint.Variation{
|
||||
{"ndk_api", version}, {"link", "shared"}}, ndkLateStubDepTag, variantLateNdkLibs...)
|
||||
{Mutator: "ndk_api", Variation: version},
|
||||
{Mutator: "link", Variation: "shared"},
|
||||
}, ndkLateStubDepTag, variantLateNdkLibs...)
|
||||
|
||||
if vndkdep := c.vndkdep; vndkdep != nil {
|
||||
if vndkdep.isVndkExt() {
|
||||
|
@ -1054,8 +1066,9 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
|||
baseModuleMode = coreMode
|
||||
}
|
||||
actx.AddVariationDependencies([]blueprint.Variation{
|
||||
{"image", baseModuleMode}, {"link", "shared"}}, vndkExtDepTag,
|
||||
vndkdep.getVndkExtendsModuleName())
|
||||
{Mutator: "image", Variation: baseModuleMode},
|
||||
{Mutator: "link", Variation: "shared"},
|
||||
}, vndkExtDepTag, vndkdep.getVndkExtendsModuleName())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ type BaseCompilerProperties struct {
|
|||
|
||||
// list of directories relative to the Blueprints file that will
|
||||
// be added to the include path using -I
|
||||
Local_include_dirs []string `android:"arch_variant,variant_prepend",`
|
||||
Local_include_dirs []string `android:"arch_variant,variant_prepend"`
|
||||
|
||||
// list of generated sources to compile. These are the names of gensrcs or
|
||||
// genrule modules.
|
||||
|
|
|
@ -36,7 +36,6 @@ func FindToolchain(os android.OsType, arch android.Arch) Toolchain {
|
|||
factory := toolchainFactories[os][arch.ArchType]
|
||||
if factory == nil {
|
||||
panic(fmt.Errorf("Toolchain not found for %s arch %q", os.String(), arch.String()))
|
||||
return nil
|
||||
}
|
||||
return factory(arch)
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
package cc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
@ -154,7 +153,7 @@ func TestDataTests(t *testing.T) {
|
|||
path := filepath.Join(test.data[i].path, test.data[i].file)
|
||||
if test.data[i].file != got[i].Rel() ||
|
||||
path != got[i].String() {
|
||||
fmt.Errorf("expected %s:%s got %s:%s",
|
||||
t.Errorf("expected %s:%s got %s:%s",
|
||||
path, test.data[i].file,
|
||||
got[i].String(), got[i].Rel())
|
||||
}
|
||||
|
|
|
@ -159,7 +159,7 @@ func main() {
|
|||
stat.Finish()
|
||||
})
|
||||
|
||||
buildCtx := build.Context{&build.ContextImpl{
|
||||
buildCtx := build.Context{ContextImpl: &build.ContextImpl{
|
||||
Context: ctx,
|
||||
Logger: log,
|
||||
Tracer: trace,
|
||||
|
@ -297,7 +297,7 @@ func main() {
|
|||
productLog := logger.New(f)
|
||||
productLog.SetOutput(filepath.Join(productLogDir, "soong.log"))
|
||||
|
||||
productCtx := build.Context{&build.ContextImpl{
|
||||
productCtx := build.Context{ContextImpl: &build.ContextImpl{
|
||||
Context: ctx,
|
||||
Logger: productLog,
|
||||
Tracer: trace,
|
||||
|
|
|
@ -84,7 +84,7 @@ func main() {
|
|||
stat.Finish()
|
||||
})
|
||||
|
||||
buildCtx := build.Context{&build.ContextImpl{
|
||||
buildCtx := build.Context{ContextImpl: &build.ContextImpl{
|
||||
Context: ctx,
|
||||
Logger: log,
|
||||
Tracer: trace,
|
||||
|
|
|
@ -243,7 +243,6 @@ func (m *MockFs) followLinks(path string, followLastLink bool, count int) (canon
|
|||
if parentPath == path {
|
||||
err = fmt.Errorf("Internal error: %v yields itself as a parent", path)
|
||||
panic(err.Error())
|
||||
return "", fmt.Errorf("Internal error: %v yields itself as a parent", path)
|
||||
}
|
||||
|
||||
parentPath, err = m.followLinks(parentPath, true, count)
|
||||
|
|
|
@ -142,7 +142,7 @@ func (g *Module) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||
if g, ok := ctx.Module().(*Module); ok {
|
||||
if len(g.properties.Tools) > 0 {
|
||||
ctx.AddFarVariationDependencies([]blueprint.Variation{
|
||||
{"arch", ctx.Config().BuildOsVariant},
|
||||
{Mutator: "arch", Variation: ctx.Config().BuildOsVariant},
|
||||
}, hostToolDepTag, g.properties.Tools...)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -574,7 +574,7 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
|
|||
ctx.AddDependency(ctx.Module(), libTag, j.properties.Libs...)
|
||||
ctx.AddDependency(ctx.Module(), staticLibTag, j.properties.Static_libs...)
|
||||
ctx.AddFarVariationDependencies([]blueprint.Variation{
|
||||
{"arch", ctx.Config().BuildOsCommonVariant},
|
||||
{Mutator: "arch", Variation: ctx.Config().BuildOsCommonVariant},
|
||||
}, annoTag, j.properties.Annotation_processors...)
|
||||
android.ExtractSourcesDeps(ctx, j.properties.Srcs)
|
||||
android.ExtractSourcesDeps(ctx, j.properties.Exclude_srcs)
|
||||
|
|
|
@ -306,7 +306,7 @@ func (p *Module) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||
if p.bootstrapper != nil && p.isEmbeddedLauncherEnabled(pyVersion2) {
|
||||
ctx.AddVariationDependencies(nil, pythonLibTag, "py2-stdlib")
|
||||
ctx.AddFarVariationDependencies([]blueprint.Variation{
|
||||
{"arch", ctx.Target().String()},
|
||||
{Mutator: "arch", Variation: ctx.Target().String()},
|
||||
}, launcherTag, "py2-launcher")
|
||||
}
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ func (e *Environment) appendFromKati(reader io.Reader) error {
|
|||
if cmd[0] == "unset" {
|
||||
str, ok := singleUnquote(cmd[1])
|
||||
if !ok {
|
||||
fmt.Errorf("Failed to unquote kati line: %q", text)
|
||||
return fmt.Errorf("Failed to unquote kati line: %q", text)
|
||||
}
|
||||
e.Unset(str)
|
||||
} else if cmd[0] == "export" {
|
||||
|
|
|
@ -43,7 +43,7 @@ func NinjaReader(ctx logger.Logger, status ToolStatus, fifo string) {
|
|||
func ninjaReader(status ToolStatus, fifo string) {
|
||||
f, err := os.Open(fifo)
|
||||
if err != nil {
|
||||
status.Error(fmt.Sprintf("Failed to open fifo:", err))
|
||||
status.Error(fmt.Sprintf("Failed to open fifo: %v", err))
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
|
|
Loading…
Reference in New Issue