Skip to content

Commit e8f2298

Browse files
kevinburkebradfitz
authored andcommitted
all: fix errors reported by vet, golint
None are "wrong" per se, but there are a lot of good suggestions and in one case a docstring that was not present in godoc due to the presence of an extra newline. Changed "Id" in struct properties to "ID" in some non-exported structs. Removed a trailing period from some error messages; I believe the exact contents of error strings are not covered by the Go compatibility promise. Change-Id: I7c620582dc247396f72c52d38c909ccc0ec87b83 Reviewed-on: https://go-review.googlesource.com/80145 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
1 parent 48a5a65 commit e8f2298

File tree

19 files changed

+158
-160
lines changed

19 files changed

+158
-160
lines changed

bcrypt/bcrypt.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,11 @@ func (p *hashed) Hash() []byte {
241241
n = 3
242242
}
243243
arr[n] = '$'
244-
n += 1
244+
n++
245245
copy(arr[n:], []byte(fmt.Sprintf("%02d", p.cost)))
246246
n += 2
247247
arr[n] = '$'
248-
n += 1
248+
n++
249249
copy(arr[n:], p.salt)
250250
n += encodedSaltSize
251251
copy(arr[n:], p.hash)

bn256/bn256.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ func RandomG1(r io.Reader) (*big.Int, *G1, error) {
4949
return k, new(G1).ScalarBaseMult(k), nil
5050
}
5151

52-
func (g *G1) String() string {
53-
return "bn256.G1" + g.p.String()
52+
func (e *G1) String() string {
53+
return "bn256.G1" + e.p.String()
5454
}
5555

5656
// ScalarBaseMult sets e to g*k where g is the generator of the group and
@@ -92,11 +92,11 @@ func (e *G1) Neg(a *G1) *G1 {
9292
}
9393

9494
// Marshal converts n to a byte slice.
95-
func (n *G1) Marshal() []byte {
96-
n.p.MakeAffine(nil)
95+
func (e *G1) Marshal() []byte {
96+
e.p.MakeAffine(nil)
9797

98-
xBytes := new(big.Int).Mod(n.p.x, p).Bytes()
99-
yBytes := new(big.Int).Mod(n.p.y, p).Bytes()
98+
xBytes := new(big.Int).Mod(e.p.x, p).Bytes()
99+
yBytes := new(big.Int).Mod(e.p.y, p).Bytes()
100100

101101
// Each value is a 256-bit number.
102102
const numBytes = 256 / 8
@@ -166,8 +166,8 @@ func RandomG2(r io.Reader) (*big.Int, *G2, error) {
166166
return k, new(G2).ScalarBaseMult(k), nil
167167
}
168168

169-
func (g *G2) String() string {
170-
return "bn256.G2" + g.p.String()
169+
func (e *G2) String() string {
170+
return "bn256.G2" + e.p.String()
171171
}
172172

173173
// ScalarBaseMult sets e to g*k where g is the generator of the group and

openpgp/keys.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,8 @@ func ReadEntity(packets *packet.Reader) (*Entity, error) {
325325
if e.PrivateKey, ok = p.(*packet.PrivateKey); !ok {
326326
packets.Unread(p)
327327
return nil, errors.StructuralError("first packet was not a public/private key")
328-
} else {
329-
e.PrimaryKey = &e.PrivateKey.PublicKey
330328
}
329+
e.PrimaryKey = &e.PrivateKey.PublicKey
331330
}
332331

333332
if !e.PrimaryKey.PubKeyAlgo.CanSign() {

ssh/agent/client.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ const (
9898
agentAddIdentity = 17
9999
agentRemoveIdentity = 18
100100
agentRemoveAllIdentities = 19
101-
agentAddIdConstrained = 25
101+
agentAddIDConstrained = 25
102102

103103
// 3.3 Key-type independent requests from client to agent
104104
agentAddSmartcardKey = 20
@@ -515,7 +515,7 @@ func (c *client) insertKey(s interface{}, comment string, constraints []byte) er
515515

516516
// if constraints are present then the message type needs to be changed.
517517
if len(constraints) != 0 {
518-
req[0] = agentAddIdConstrained
518+
req[0] = agentAddIDConstrained
519519
}
520520

521521
resp, err := c.call(req)
@@ -577,11 +577,11 @@ func (c *client) Add(key AddedKey) error {
577577
constraints = append(constraints, agentConstrainConfirm)
578578
}
579579

580-
if cert := key.Certificate; cert == nil {
580+
cert := key.Certificate
581+
if cert == nil {
581582
return c.insertKey(key.PrivateKey, key.Comment, constraints)
582-
} else {
583-
return c.insertCert(key.PrivateKey, cert, key.Comment, constraints)
584583
}
584+
return c.insertCert(key.PrivateKey, cert, key.Comment, constraints)
585585
}
586586

587587
func (c *client) insertCert(s interface{}, cert *ssh.Certificate, comment string, constraints []byte) error {
@@ -633,7 +633,7 @@ func (c *client) insertCert(s interface{}, cert *ssh.Certificate, comment string
633633

634634
// if constraints are present then the message type needs to be changed.
635635
if len(constraints) != 0 {
636-
req[0] = agentAddIdConstrained
636+
req[0] = agentAddIDConstrained
637637
}
638638

639639
signer, err := ssh.NewSignerFromKey(s)

ssh/agent/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func (s *server) processRequest(data []byte) (interface{}, error) {
148148
}
149149
return rep, nil
150150

151-
case agentAddIdConstrained, agentAddIdentity:
151+
case agentAddIDConstrained, agentAddIdentity:
152152
return nil, s.insertIdentity(data)
153153
}
154154

0 commit comments

Comments
 (0)