Skip to content

Commit

Permalink
Merge pull request #1752 from aaronlehmann/sprintfs
Browse files Browse the repository at this point in the history
all: Avoid trivial uses of Sprintf
  • Loading branch information
Flavio Crisciani committed Aug 23, 2017
2 parents f0c3686 + dbd2925 commit b53529d
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion drivers/bridge/bridge_test.go
Expand Up @@ -476,7 +476,7 @@ func verifyV4INCEntries(networks map[string]*bridgeNetwork, numEntries int, t *t
if x == y {
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)
if len(matches) != 1 {
t.Fatalf("Cannot find expected inter-network isolation rules in IP Tables:\n%s", string(out[:]))
Expand Down
2 changes: 1 addition & 1 deletion drivers/ipvlan/ipvlan_setup.go
Expand Up @@ -201,5 +201,5 @@ func delDummyLink(linkName string) error {

// getDummyName returns the name of a dummy parent with truncated net ID and driver prefix
func getDummyName(netID string) string {
return fmt.Sprintf("%s%s", dummyPrefix, netID)
return dummyPrefix + netID
}
2 changes: 1 addition & 1 deletion drivers/macvlan/macvlan_setup.go
Expand Up @@ -205,5 +205,5 @@ func delDummyLink(linkName string) error {

// getDummyName returns the name of a dummy parent with truncated net ID and driver prefix
func getDummyName(netID string) string {
return fmt.Sprintf("%s%s", dummyPrefix, netID)
return dummyPrefix + netID
}
4 changes: 2 additions & 2 deletions drivers/overlay/ov_network.go
Expand Up @@ -494,7 +494,7 @@ func (n *network) restoreSubnetSandbox(s *subnet, brName, vxlanName string) erro
brIfaceOption := make([]osl.IfaceOption, 2)
brIfaceOption = append(brIfaceOption, sbox.InterfaceOptions().Address(s.gwIP))
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)
if err != nil {
Expand All @@ -504,7 +504,7 @@ func (n *network) restoreSubnetSandbox(s *subnet, brName, vxlanName string) erro
Ifaces = make(map[string][]osl.IfaceOption)
vxlanIfaceOption := make([]osl.IfaceOption, 1)
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)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions drivers/overlay/overlay.go
Expand Up @@ -162,7 +162,7 @@ func (d *driver) restoreEndpoints() error {
Ifaces := make(map[string][]osl.IfaceOption)
vethIfaceOption := make([]osl.IfaceOption, 1)
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)
if err != nil {
Expand Down Expand Up @@ -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 d.store != nil {
if err := validateSelf(advertiseAddress); err != nil {
logrus.Warnf("%s", err.Error())
logrus.Warn(err.Error())
}
err := d.serfInit()
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions drivers/solaris/overlay/ov_network.go
Expand Up @@ -331,7 +331,7 @@ func (n *network) restoreSubnetSandbox(s *subnet, brName, vxlanName string) erro
brIfaceOption := make([]osl.IfaceOption, 2)
brIfaceOption = append(brIfaceOption, sbox.InterfaceOptions().Address(s.gwIP))
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)
if err != nil {
Expand All @@ -341,7 +341,7 @@ func (n *network) restoreSubnetSandbox(s *subnet, brName, vxlanName string) erro
Ifaces = make(map[string][]osl.IfaceOption)
vxlanIfaceOption := make([]osl.IfaceOption, 1)
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)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions drivers/solaris/overlay/overlay.go
Expand Up @@ -141,7 +141,7 @@ func (d *driver) restoreEndpoints() error {
Ifaces := make(map[string][]osl.IfaceOption)
vethIfaceOption := make([]osl.IfaceOption, 1)
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)
if err != nil {
Expand Down Expand Up @@ -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 d.store != nil {
if err := validateSelf(advertiseAddress); err != nil {
logrus.Warnf("%s", err.Error())
logrus.Warn(err.Error())
}
err := d.serfInit()
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions ipam/allocator.go
Expand Up @@ -579,7 +579,7 @@ func (a *Allocator) DumpDatabase() string {
s = fmt.Sprintf("\n\n%s Config", as)
aSpace.Lock()
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 {
a.retrieveBitmask(k, config.Pool)
}
Expand All @@ -589,7 +589,7 @@ func (a *Allocator) DumpDatabase() string {

s = fmt.Sprintf("%s\n\nBitmasks", s)
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
Expand Down
4 changes: 2 additions & 2 deletions types/types.go
Expand Up @@ -129,11 +129,11 @@ func (p *PortBinding) GetCopy() PortBinding {
func (p *PortBinding) String() string {
ret := fmt.Sprintf("%s/", p.Proto)
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)
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)
return ret
Expand Down

0 comments on commit b53529d

Please sign in to comment.