all: fix printf(var) mistakes detected by latest printf checker
There's some similarity here to the situation in CL 610676. The calls that now look like g.Printf("%s", something) would perhaps be better expressed like g.Print(something) or g.WriteString(something), but that's a bigger potential change to consider. This is a minimal fix. For golang/go#69267. Change-Id: I9cf23aef7bf2b9d9c7e9dcf3b48ecb23231016dd Reviewed-on: https://go-review.googlesource.com/c/mobile/+/610800 Reviewed-by: Tim King <taking@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
This commit is contained in:
Родитель
81131f6468
Коммит
7c4916698c
|
@ -381,7 +381,7 @@ func (g *ClassGen) genCMethodBody(cls *java.Class, f *java.Func, virtual bool) {
|
|||
g.Printf("Nonvirtual")
|
||||
}
|
||||
if f.Ret != nil {
|
||||
g.Printf(f.Ret.JNICallType())
|
||||
g.Printf("%s", f.Ret.JNICallType())
|
||||
} else {
|
||||
g.Printf("Void")
|
||||
}
|
||||
|
@ -430,7 +430,7 @@ func (g *ClassGen) genFuncDecl(local bool, fs *java.FuncSet) {
|
|||
if i == len(fs.Params)-1 && fs.Variadic {
|
||||
g.Printf("...")
|
||||
}
|
||||
g.Printf(g.goType(a, local))
|
||||
g.Printf("%s", g.goType(a, local))
|
||||
}
|
||||
g.Printf(")")
|
||||
if fs.Throws {
|
||||
|
@ -879,7 +879,7 @@ func (g *ClassGen) genInterface(cls *java.Class) {
|
|||
if !g.isFuncSetSupported(fs) {
|
||||
continue
|
||||
}
|
||||
g.Printf(fs.GoName)
|
||||
g.Printf("%s", fs.GoName)
|
||||
g.genFuncDecl(true, fs)
|
||||
g.Printf("\n")
|
||||
}
|
||||
|
@ -904,7 +904,7 @@ func flattenName(n string) string {
|
|||
return strings.Replace(strings.Replace(n, ".", "_", -1), "$", "_", -1)
|
||||
}
|
||||
|
||||
var (
|
||||
const (
|
||||
classesPkgHeader = gobindPreamble + `
|
||||
package Java
|
||||
|
||||
|
|
|
@ -341,7 +341,7 @@ func (g *goGen) genInterface(obj *types.TypeName) {
|
|||
g.Printf(") ")
|
||||
|
||||
if res.Len() == 1 {
|
||||
g.Printf(g.typeString(res.At(0).Type()))
|
||||
g.Printf("%s", g.typeString(res.At(0).Type()))
|
||||
} else if res.Len() == 2 {
|
||||
g.Printf("(%s, error)", g.typeString(res.At(0).Type()))
|
||||
}
|
||||
|
|
|
@ -437,7 +437,7 @@ func (g *JavaGen) genConstructor(f *types.Func, n string, jcls bool) {
|
|||
if i > 0 {
|
||||
g.Printf(", ")
|
||||
}
|
||||
g.Printf(g.paramName(params, i))
|
||||
g.Printf("%s", g.paramName(params, i))
|
||||
}
|
||||
g.Printf(");\n")
|
||||
}
|
||||
|
@ -447,7 +447,7 @@ func (g *JavaGen) genConstructor(f *types.Func, n string, jcls bool) {
|
|||
if i > 0 {
|
||||
g.Printf(", ")
|
||||
}
|
||||
g.Printf(g.paramName(params, i))
|
||||
g.Printf("%s", g.paramName(params, i))
|
||||
}
|
||||
g.Printf(");\n")
|
||||
g.Printf("Seq.trackGoRef(refnum, this);\n")
|
||||
|
@ -757,21 +757,21 @@ func (g *JavaGen) genJNIFuncSignature(o *types.Func, sName string, jm *java.Func
|
|||
g.Printf("Java_%s_", g.jniPkgName())
|
||||
if sName != "" {
|
||||
if proxy {
|
||||
g.Printf(java.JNIMangle(g.className()))
|
||||
g.Printf("%s", java.JNIMangle(g.className()))
|
||||
// 0024 is the mangled form of $, for naming inner classes.
|
||||
g.Printf("_00024proxy%s", sName)
|
||||
} else {
|
||||
g.Printf(java.JNIMangle(g.javaTypeName(sName)))
|
||||
g.Printf("%s", java.JNIMangle(g.javaTypeName(sName)))
|
||||
}
|
||||
} else {
|
||||
g.Printf(java.JNIMangle(g.className()))
|
||||
g.Printf("%s", java.JNIMangle(g.className()))
|
||||
}
|
||||
g.Printf("_")
|
||||
if jm != nil {
|
||||
g.Printf(jm.JNIName)
|
||||
g.Printf("%s", jm.JNIName)
|
||||
} else {
|
||||
oName := javaNameReplacer(lowerFirst(o.Name()))
|
||||
g.Printf(java.JNIMangle(oName))
|
||||
g.Printf("%s", java.JNIMangle(oName))
|
||||
}
|
||||
g.Printf("(JNIEnv* env, ")
|
||||
if sName != "" {
|
||||
|
@ -839,9 +839,9 @@ func (g *JavaGen) genFuncSignature(o *types.Func, jm *java.Func, hasThis bool) {
|
|||
|
||||
g.Printf("%s ", ret)
|
||||
if jm != nil {
|
||||
g.Printf(jm.Name)
|
||||
g.Printf("%s", jm.Name)
|
||||
} else {
|
||||
g.Printf(javaNameReplacer(lowerFirst(o.Name())))
|
||||
g.Printf("%s", javaNameReplacer(lowerFirst(o.Name())))
|
||||
}
|
||||
g.Printf("(")
|
||||
g.genFuncArgs(o, jm, hasThis)
|
||||
|
|
|
@ -1060,7 +1060,7 @@ func (g *ObjcGen) genStructH(obj *types.TypeName, t *types.Struct) {
|
|||
if oinf != nil {
|
||||
for _, sup := range oinf.supers {
|
||||
if !sup.Protocol {
|
||||
g.Printf(sup.Name)
|
||||
g.Printf("%s", sup.Name)
|
||||
} else {
|
||||
prots = append(prots, sup.Name)
|
||||
}
|
||||
|
|
|
@ -286,14 +286,13 @@ func (g *ObjcWrapper) genCFuncDecl(prefix, name string, f *objc.Func) {
|
|||
case ret != nil && returnsErr:
|
||||
g.Printf("ret_%s", strings.Replace(g.cType(ret), " ", "_", -1))
|
||||
case ret != nil:
|
||||
g.Printf(g.cType(ret))
|
||||
g.Printf("%s", g.cType(ret))
|
||||
case returnsErr:
|
||||
g.Printf("int")
|
||||
default:
|
||||
g.Printf("void")
|
||||
}
|
||||
g.Printf(" ")
|
||||
g.Printf(prefix)
|
||||
g.Printf(" %s", prefix)
|
||||
if f.Static {
|
||||
g.Printf("_s")
|
||||
}
|
||||
|
@ -397,8 +396,7 @@ func (g *ObjcWrapper) genFuncBody(n *objc.Named, f *objc.Func, prefix string) {
|
|||
if ret != nil || errParam != nil {
|
||||
g.Printf("res := ")
|
||||
}
|
||||
g.Printf("C.")
|
||||
g.Printf(prefix)
|
||||
g.Printf("C.%s", prefix)
|
||||
if f.Static {
|
||||
g.Printf("_s")
|
||||
}
|
||||
|
@ -575,7 +573,7 @@ func (g *ObjcWrapper) genInterface(n *objc.Named) {
|
|||
if !g.isFuncSupported(f) {
|
||||
continue
|
||||
}
|
||||
g.Printf(f.GoName)
|
||||
g.Printf("%s", f.GoName)
|
||||
g.genFuncDecl(true, f)
|
||||
g.Printf("\n")
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"bytes"
|
||||
"encoding"
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
|
@ -103,7 +104,7 @@ func compareBytes(a, b []byte) error {
|
|||
fmt.Fprint(buf, "... output truncated.\n")
|
||||
}
|
||||
}
|
||||
return fmt.Errorf(buf.String())
|
||||
return errors.New(buf.String())
|
||||
}
|
||||
|
||||
func TestBootstrap(t *testing.T) {
|
||||
|
@ -329,7 +330,7 @@ func compareElements(have, want *XML) error {
|
|||
}
|
||||
}
|
||||
if buf.Len() > 0 {
|
||||
return fmt.Errorf(buf.String())
|
||||
return errors.New(buf.String())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче