Skip to content

Commit

Permalink
Fix format string issues
Browse files Browse the repository at this point in the history
Fix issues caught by go vet.

Bug: 73724997
Test: m checkbuild
Change-Id: Ib8d740457c15432dabe1575a6707726ddaf93084
Merged-In: Ib8d740457c15432dabe1575a6707726ddaf93084
(cherry picked from commit f46e37f)
  • Loading branch information
colincross committed May 3, 2018
1 parent 8a32a05 commit a4ffa9a
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions androidmk/cmd/androidmk/android.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func classifyLocalOrGlobalPath(value bpparser.Expression) (string, bpparser.Expr
}
case *bpparser.Operator:
if v.Type() != bpparser.StringType {
return "", nil, fmt.Errorf("classifyLocalOrGlobalPath expected a string, got %s", value.Type)
return "", nil, fmt.Errorf("classifyLocalOrGlobalPath expected a string, got %s", v.Type())
}

if v.Operator != '+' {
Expand Down Expand Up @@ -290,7 +290,7 @@ func classifyLocalOrGlobalPath(value bpparser.Expression) (string, bpparser.Expr
case *bpparser.String:
return "global", value, nil
default:
return "", nil, fmt.Errorf("classifyLocalOrGlobalPath expected a string, got %s", value.Type)
return "", nil, fmt.Errorf("classifyLocalOrGlobalPath expected a string, got %s", v.Type())

}
}
Expand Down
2 changes: 1 addition & 1 deletion bpfix/bpfix/bpfix.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func FixTree(tree *parser.File, config FixRequest) error {
// detect infinite loop
i++
if i >= maxNumIterations {
return fmt.Errorf("Applied fixes %s times and yet the tree continued to change. Is there an infinite loop?", i)
return fmt.Errorf("Applied fixes %d times and yet the tree continued to change. Is there an infinite loop?", i)
break
}
}
Expand Down
2 changes: 1 addition & 1 deletion cc/cc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func checkVndkModule(t *testing.T, ctx *android.TestContext, name, subDir string

mod := ctx.ModuleForTests(name, vendorVariant).Module().(*Module)
if !mod.hasVendorVariant() {
t.Error("%q must have vendor variant", name)
t.Errorf("%q must have vendor variant", name)
}

// Check library properties.
Expand Down
8 changes: 4 additions & 4 deletions cmd/extract_linker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func main() {

ef, err := elf.NewFile(f)
if err != nil {
log.Fatal("Unable to read elf file: %v", err)
log.Fatalf("Unable to read elf file: %v", err)
}

asm := &bytes.Buffer{}
Expand Down Expand Up @@ -123,17 +123,17 @@ func main() {

if asmPath != "" {
if err := ioutil.WriteFile(asmPath, asm.Bytes(), 0777); err != nil {
log.Fatal("Unable to write %q: %v", asmPath, err)
log.Fatalf("Unable to write %q: %v", asmPath, err)
}
}

if scriptPath != "" {
buf := &bytes.Buffer{}
if err := linkerScriptTemplate.Execute(buf, sections); err != nil {
log.Fatal("Failed to create linker script: %v", err)
log.Fatalf("Failed to create linker script: %v", err)
}
if err := ioutil.WriteFile(scriptPath, buf.Bytes(), 0777); err != nil {
log.Fatal("Unable to write %q: %v", scriptPath, err)
log.Fatalf("Unable to write %q: %v", scriptPath, err)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/pom2mk/pom2mk.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ Usage: %s [--rewrite <regex>=<replace>] [-exclude <module>] [--extra-deps <modul
dir := flag.Arg(0)
absDir, err := filepath.Abs(dir)
if err != nil {
fmt.Println(os.Stderr, "Failed to get absolute directory:", err)
fmt.Fprintln(os.Stderr, "Failed to get absolute directory:", err)
os.Exit(1)
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/zipsync/zipsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ func main() {
}
}
if filepath.IsAbs(f.Name) {
log.Fatal("%q in %q is an absolute path", f.Name, input)
log.Fatalf("%q in %q is an absolute path", f.Name, input)
}

if prev, exists := seen[f.Name]; exists {
log.Fatal("%q found in both %q and %q", f.Name, prev, input)
log.Fatalf("%q found in both %q and %q", f.Name, prev, input)
}
seen[f.Name] = input

Expand Down
2 changes: 1 addition & 1 deletion ui/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func fileRotation(from, baseName, ext string, cur, max int) error {
}

if err := os.Rename(from, newName); err != nil {
return fmt.Errorf("Failed to rotate", from, "to", newName, ".", err)
return fmt.Errorf("Failed to rotate %s to %s. %s", from, newName, err)
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion ui/logger/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func TestPanic(t *testing.T) {
if p == panicValue {
os.Exit(42)
} else {
fmt.Fprintln(os.Stderr, "Expected %q, got %v", panicValue, p)
fmt.Fprintf(os.Stderr, "Expected %q, got %v\n", panicValue, p)
os.Exit(3)
}
}()
Expand Down

0 comments on commit a4ffa9a

Please sign in to comment.