1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #1752 from aaronlehmann/sprintfs

all: Avoid trivial uses of Sprintf
This commit is contained in:
Flavio Crisciani 2017-08-23 15:49:46 -07:00 committed by GitHub
commit 38382fb29b
9 changed files with 15 additions and 15 deletions

View file

@ -476,7 +476,7 @@ func verifyV4INCEntries(networks map[string]*bridgeNetwork, numEntries int, t *t
if x == y { if x == y {
continue continue
} }
re := regexp.MustCompile(fmt.Sprintf("%s %s", x.config.BridgeName, y.config.BridgeName)) re := regexp.MustCompile(x.config.BridgeName + " " + y.config.BridgeName)
matches := re.FindAllString(string(out[:]), -1) matches := re.FindAllString(string(out[:]), -1)
if len(matches) != 1 { if len(matches) != 1 {
t.Fatalf("Cannot find expected inter-network isolation rules in IP Tables:\n%s", string(out[:])) t.Fatalf("Cannot find expected inter-network isolation rules in IP Tables:\n%s", string(out[:]))

View file

@ -201,5 +201,5 @@ func delDummyLink(linkName string) error {
// getDummyName returns the name of a dummy parent with truncated net ID and driver prefix // getDummyName returns the name of a dummy parent with truncated net ID and driver prefix
func getDummyName(netID string) string { func getDummyName(netID string) string {
return fmt.Sprintf("%s%s", dummyPrefix, netID) return dummyPrefix + netID
} }

View file

@ -205,5 +205,5 @@ func delDummyLink(linkName string) error {
// getDummyName returns the name of a dummy parent with truncated net ID and driver prefix // getDummyName returns the name of a dummy parent with truncated net ID and driver prefix
func getDummyName(netID string) string { func getDummyName(netID string) string {
return fmt.Sprintf("%s%s", dummyPrefix, netID) return dummyPrefix + netID
} }

View file

@ -494,7 +494,7 @@ func (n *network) restoreSubnetSandbox(s *subnet, brName, vxlanName string) erro
brIfaceOption := make([]osl.IfaceOption, 2) brIfaceOption := make([]osl.IfaceOption, 2)
brIfaceOption = append(brIfaceOption, sbox.InterfaceOptions().Address(s.gwIP)) brIfaceOption = append(brIfaceOption, sbox.InterfaceOptions().Address(s.gwIP))
brIfaceOption = append(brIfaceOption, sbox.InterfaceOptions().Bridge(true)) brIfaceOption = append(brIfaceOption, sbox.InterfaceOptions().Bridge(true))
Ifaces[fmt.Sprintf("%s+%s", brName, "br")] = brIfaceOption Ifaces[brName+"+br"] = brIfaceOption
err := sbox.Restore(Ifaces, nil, nil, nil) err := sbox.Restore(Ifaces, nil, nil, nil)
if err != nil { if err != nil {
@ -504,7 +504,7 @@ func (n *network) restoreSubnetSandbox(s *subnet, brName, vxlanName string) erro
Ifaces = make(map[string][]osl.IfaceOption) Ifaces = make(map[string][]osl.IfaceOption)
vxlanIfaceOption := make([]osl.IfaceOption, 1) vxlanIfaceOption := make([]osl.IfaceOption, 1)
vxlanIfaceOption = append(vxlanIfaceOption, sbox.InterfaceOptions().Master(brName)) vxlanIfaceOption = append(vxlanIfaceOption, sbox.InterfaceOptions().Master(brName))
Ifaces[fmt.Sprintf("%s+%s", vxlanName, "vxlan")] = vxlanIfaceOption Ifaces[vxlanName+"+vxlan"] = vxlanIfaceOption
err = sbox.Restore(Ifaces, nil, nil, nil) err = sbox.Restore(Ifaces, nil, nil, nil)
if err != nil { if err != nil {
return err return err

View file

@ -162,7 +162,7 @@ func (d *driver) restoreEndpoints() error {
Ifaces := make(map[string][]osl.IfaceOption) Ifaces := make(map[string][]osl.IfaceOption)
vethIfaceOption := make([]osl.IfaceOption, 1) vethIfaceOption := make([]osl.IfaceOption, 1)
vethIfaceOption = append(vethIfaceOption, n.sbox.InterfaceOptions().Master(s.brName)) vethIfaceOption = append(vethIfaceOption, n.sbox.InterfaceOptions().Master(s.brName))
Ifaces[fmt.Sprintf("%s+%s", "veth", "veth")] = vethIfaceOption Ifaces["veth+veth"] = vethIfaceOption
err := n.sbox.Restore(Ifaces, nil, nil, nil) err := n.sbox.Restore(Ifaces, nil, nil, nil)
if err != nil { if err != nil {
@ -270,7 +270,7 @@ func (d *driver) nodeJoin(advertiseAddress, bindAddress string, self bool) {
// If there is no cluster store there is no need to start serf. // If there is no cluster store there is no need to start serf.
if d.store != nil { if d.store != nil {
if err := validateSelf(advertiseAddress); err != nil { if err := validateSelf(advertiseAddress); err != nil {
logrus.Warnf("%s", err.Error()) logrus.Warn(err.Error())
} }
err := d.serfInit() err := d.serfInit()
if err != nil { if err != nil {

View file

@ -331,7 +331,7 @@ func (n *network) restoreSubnetSandbox(s *subnet, brName, vxlanName string) erro
brIfaceOption := make([]osl.IfaceOption, 2) brIfaceOption := make([]osl.IfaceOption, 2)
brIfaceOption = append(brIfaceOption, sbox.InterfaceOptions().Address(s.gwIP)) brIfaceOption = append(brIfaceOption, sbox.InterfaceOptions().Address(s.gwIP))
brIfaceOption = append(brIfaceOption, sbox.InterfaceOptions().Bridge(true)) brIfaceOption = append(brIfaceOption, sbox.InterfaceOptions().Bridge(true))
Ifaces[fmt.Sprintf("%s+%s", brName, "br")] = brIfaceOption Ifaces[brName+"+br"] = brIfaceOption
err := sbox.Restore(Ifaces, nil, nil, nil) err := sbox.Restore(Ifaces, nil, nil, nil)
if err != nil { if err != nil {
@ -341,7 +341,7 @@ func (n *network) restoreSubnetSandbox(s *subnet, brName, vxlanName string) erro
Ifaces = make(map[string][]osl.IfaceOption) Ifaces = make(map[string][]osl.IfaceOption)
vxlanIfaceOption := make([]osl.IfaceOption, 1) vxlanIfaceOption := make([]osl.IfaceOption, 1)
vxlanIfaceOption = append(vxlanIfaceOption, sbox.InterfaceOptions().Master(brName)) vxlanIfaceOption = append(vxlanIfaceOption, sbox.InterfaceOptions().Master(brName))
Ifaces[fmt.Sprintf("%s+%s", vxlanName, "vxlan")] = vxlanIfaceOption Ifaces[vxlanName+"+vxlan"] = vxlanIfaceOption
err = sbox.Restore(Ifaces, nil, nil, nil) err = sbox.Restore(Ifaces, nil, nil, nil)
if err != nil { if err != nil {
return err return err

View file

@ -141,7 +141,7 @@ func (d *driver) restoreEndpoints() error {
Ifaces := make(map[string][]osl.IfaceOption) Ifaces := make(map[string][]osl.IfaceOption)
vethIfaceOption := make([]osl.IfaceOption, 1) vethIfaceOption := make([]osl.IfaceOption, 1)
vethIfaceOption = append(vethIfaceOption, n.sbox.InterfaceOptions().Master(s.brName)) vethIfaceOption = append(vethIfaceOption, n.sbox.InterfaceOptions().Master(s.brName))
Ifaces[fmt.Sprintf("%s+%s", "veth", "veth")] = vethIfaceOption Ifaces["veth+veth"] = vethIfaceOption
err := n.sbox.Restore(Ifaces, nil, nil, nil) err := n.sbox.Restore(Ifaces, nil, nil, nil)
if err != nil { if err != nil {
@ -234,7 +234,7 @@ func (d *driver) nodeJoin(advertiseAddress, bindAddress string, self bool) {
// If there is no cluster store there is no need to start serf. // If there is no cluster store there is no need to start serf.
if d.store != nil { if d.store != nil {
if err := validateSelf(advertiseAddress); err != nil { if err := validateSelf(advertiseAddress); err != nil {
logrus.Warnf("%s", err.Error()) logrus.Warn(err.Error())
} }
err := d.serfInit() err := d.serfInit()
if err != nil { if err != nil {

View file

@ -579,7 +579,7 @@ func (a *Allocator) DumpDatabase() string {
s = fmt.Sprintf("\n\n%s Config", as) s = fmt.Sprintf("\n\n%s Config", as)
aSpace.Lock() aSpace.Lock()
for k, config := range aSpace.subnets { for k, config := range aSpace.subnets {
s = fmt.Sprintf("%s%s", s, fmt.Sprintf("\n%v: %v", k, config)) s += fmt.Sprintf("\n%v: %v", k, config)
if config.Range == nil { if config.Range == nil {
a.retrieveBitmask(k, config.Pool) a.retrieveBitmask(k, config.Pool)
} }
@ -589,7 +589,7 @@ func (a *Allocator) DumpDatabase() string {
s = fmt.Sprintf("%s\n\nBitmasks", s) s = fmt.Sprintf("%s\n\nBitmasks", s)
for k, bm := range a.addresses { for k, bm := range a.addresses {
s = fmt.Sprintf("%s%s", s, fmt.Sprintf("\n%s: %s", k, bm)) s += fmt.Sprintf("\n%s: %s", k, bm)
} }
return s return s

View file

@ -129,11 +129,11 @@ func (p *PortBinding) GetCopy() PortBinding {
func (p *PortBinding) String() string { func (p *PortBinding) String() string {
ret := fmt.Sprintf("%s/", p.Proto) ret := fmt.Sprintf("%s/", p.Proto)
if p.IP != nil { if p.IP != nil {
ret = fmt.Sprintf("%s%s", ret, p.IP.String()) ret += p.IP.String()
} }
ret = fmt.Sprintf("%s:%d/", ret, p.Port) ret = fmt.Sprintf("%s:%d/", ret, p.Port)
if p.HostIP != nil { if p.HostIP != nil {
ret = fmt.Sprintf("%s%s", ret, p.HostIP.String()) ret += p.HostIP.String()
} }
ret = fmt.Sprintf("%s:%d", ret, p.HostPort) ret = fmt.Sprintf("%s:%d", ret, p.HostPort)
return ret return ret