Skip to content

Commit

Permalink
all: fix errors reported by vet, golint
Browse files Browse the repository at this point in the history
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 <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Brad Fitzpatrick <[email protected]>
  • Loading branch information
kevinburke authored and bradfitz committed Nov 28, 2017
1 parent 48a5a65 commit e8f2298
Show file tree
Hide file tree
Showing 19 changed files with 158 additions and 160 deletions.
4 changes: 2 additions & 2 deletions bcrypt/bcrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,11 @@ func (p *hashed) Hash() []byte {
n = 3
}
arr[n] = '$'
n += 1
n++
copy(arr[n:], []byte(fmt.Sprintf("%02d", p.cost)))
n += 2
arr[n] = '$'
n += 1
n++
copy(arr[n:], p.salt)
n += encodedSaltSize
copy(arr[n:], p.hash)
Expand Down
16 changes: 8 additions & 8 deletions bn256/bn256.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ func RandomG1(r io.Reader) (*big.Int, *G1, error) {
return k, new(G1).ScalarBaseMult(k), nil
}

func (g *G1) String() string {
return "bn256.G1" + g.p.String()
func (e *G1) String() string {
return "bn256.G1" + e.p.String()
}

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

// Marshal converts n to a byte slice.
func (n *G1) Marshal() []byte {
n.p.MakeAffine(nil)
func (e *G1) Marshal() []byte {
e.p.MakeAffine(nil)

xBytes := new(big.Int).Mod(n.p.x, p).Bytes()
yBytes := new(big.Int).Mod(n.p.y, p).Bytes()
xBytes := new(big.Int).Mod(e.p.x, p).Bytes()
yBytes := new(big.Int).Mod(e.p.y, p).Bytes()

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

func (g *G2) String() string {
return "bn256.G2" + g.p.String()
func (e *G2) String() string {
return "bn256.G2" + e.p.String()
}

// ScalarBaseMult sets e to g*k where g is the generator of the group and
Expand Down
3 changes: 1 addition & 2 deletions openpgp/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,8 @@ func ReadEntity(packets *packet.Reader) (*Entity, error) {
if e.PrivateKey, ok = p.(*packet.PrivateKey); !ok {
packets.Unread(p)
return nil, errors.StructuralError("first packet was not a public/private key")
} else {
e.PrimaryKey = &e.PrivateKey.PublicKey
}
e.PrimaryKey = &e.PrivateKey.PublicKey
}

if !e.PrimaryKey.PubKeyAlgo.CanSign() {
Expand Down
12 changes: 6 additions & 6 deletions ssh/agent/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const (
agentAddIdentity = 17
agentRemoveIdentity = 18
agentRemoveAllIdentities = 19
agentAddIdConstrained = 25
agentAddIDConstrained = 25

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

// if constraints are present then the message type needs to be changed.
if len(constraints) != 0 {
req[0] = agentAddIdConstrained
req[0] = agentAddIDConstrained
}

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

if cert := key.Certificate; cert == nil {
cert := key.Certificate
if cert == nil {
return c.insertKey(key.PrivateKey, key.Comment, constraints)
} else {
return c.insertCert(key.PrivateKey, cert, key.Comment, constraints)
}
return c.insertCert(key.PrivateKey, cert, key.Comment, constraints)
}

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

// if constraints are present then the message type needs to be changed.
if len(constraints) != 0 {
req[0] = agentAddIdConstrained
req[0] = agentAddIDConstrained
}

signer, err := ssh.NewSignerFromKey(s)
Expand Down
2 changes: 1 addition & 1 deletion ssh/agent/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (s *server) processRequest(data []byte) (interface{}, error) {
}
return rep, nil

case agentAddIdConstrained, agentAddIdentity:
case agentAddIDConstrained, agentAddIdentity:
return nil, s.insertIdentity(data)
}

Expand Down
Loading

0 comments on commit e8f2298

Please sign in to comment.