Remove pointless casts (#895)
* Remove pointless casts These are all casts where the value was already of the same type. * Use var style for zero-value not cast style
This commit is contained in:
parent
513c1ff221
commit
29b9bf368b
|
@ -320,7 +320,7 @@ func (co *Conn) Read(p []byte) (n int, err error) {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
if l > len(p) {
|
if l > len(p) {
|
||||||
return int(l), io.ErrShortBuffer
|
return l, io.ErrShortBuffer
|
||||||
}
|
}
|
||||||
return tcpRead(r, p[:l])
|
return tcpRead(r, p[:l])
|
||||||
}
|
}
|
||||||
|
|
|
@ -555,7 +555,7 @@ func (k *DNSKEY) publicKeyRSA() *rsa.PublicKey {
|
||||||
|
|
||||||
pubkey := new(rsa.PublicKey)
|
pubkey := new(rsa.PublicKey)
|
||||||
|
|
||||||
expo := uint64(0)
|
var expo uint64
|
||||||
for i := 0; i < int(explen); i++ {
|
for i := 0; i < int(explen); i++ {
|
||||||
expo <<= 8
|
expo <<= 8
|
||||||
expo |= uint64(keybuf[keyoff+i])
|
expo |= uint64(keybuf[keyoff+i])
|
||||||
|
|
4
edns.go
4
edns.go
|
@ -183,7 +183,7 @@ func (e *EDNS0_NSID) pack() ([]byte, error) {
|
||||||
// Option implements the EDNS0 interface.
|
// Option implements the EDNS0 interface.
|
||||||
func (e *EDNS0_NSID) Option() uint16 { return EDNS0NSID } // Option returns the option code.
|
func (e *EDNS0_NSID) Option() uint16 { return EDNS0NSID } // Option returns the option code.
|
||||||
func (e *EDNS0_NSID) unpack(b []byte) error { e.Nsid = hex.EncodeToString(b); return nil }
|
func (e *EDNS0_NSID) unpack(b []byte) error { e.Nsid = hex.EncodeToString(b); return nil }
|
||||||
func (e *EDNS0_NSID) String() string { return string(e.Nsid) }
|
func (e *EDNS0_NSID) String() string { return e.Nsid }
|
||||||
|
|
||||||
// EDNS0_SUBNET is the subnet option that is used to give the remote nameserver
|
// EDNS0_SUBNET is the subnet option that is used to give the remote nameserver
|
||||||
// an idea of where the client lives. See RFC 7871. It can then give back a different
|
// an idea of where the client lives. See RFC 7871. It can then give back a different
|
||||||
|
@ -411,7 +411,7 @@ func (e *EDNS0_LLQ) unpack(b []byte) error {
|
||||||
|
|
||||||
func (e *EDNS0_LLQ) String() string {
|
func (e *EDNS0_LLQ) String() string {
|
||||||
s := strconv.FormatUint(uint64(e.Version), 10) + " " + strconv.FormatUint(uint64(e.Opcode), 10) +
|
s := strconv.FormatUint(uint64(e.Version), 10) + " " + strconv.FormatUint(uint64(e.Opcode), 10) +
|
||||||
" " + strconv.FormatUint(uint64(e.Error), 10) + " " + strconv.FormatUint(uint64(e.Id), 10) +
|
" " + strconv.FormatUint(uint64(e.Error), 10) + " " + strconv.FormatUint(e.Id, 10) +
|
||||||
" " + strconv.FormatUint(uint64(e.LeaseLife), 10)
|
" " + strconv.FormatUint(uint64(e.LeaseLife), 10)
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,14 +177,14 @@ func unpackUint8(msg []byte, off int) (i uint8, off1 int, err error) {
|
||||||
if off+1 > len(msg) {
|
if off+1 > len(msg) {
|
||||||
return 0, len(msg), &Error{err: "overflow unpacking uint8"}
|
return 0, len(msg), &Error{err: "overflow unpacking uint8"}
|
||||||
}
|
}
|
||||||
return uint8(msg[off]), off + 1, nil
|
return msg[off], off + 1, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func packUint8(i uint8, msg []byte, off int) (off1 int, err error) {
|
func packUint8(i uint8, msg []byte, off int) (off1 int, err error) {
|
||||||
if off+1 > len(msg) {
|
if off+1 > len(msg) {
|
||||||
return len(msg), &Error{err: "overflow packing uint8"}
|
return len(msg), &Error{err: "overflow packing uint8"}
|
||||||
}
|
}
|
||||||
msg[off] = byte(i)
|
msg[off] = i
|
||||||
return off + 1, nil
|
return off + 1, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,7 +399,7 @@ func packStringTxt(s []string, msg []byte, off int) (int, error) {
|
||||||
func unpackDataOpt(msg []byte, off int) ([]EDNS0, int, error) {
|
func unpackDataOpt(msg []byte, off int) ([]EDNS0, int, error) {
|
||||||
var edns []EDNS0
|
var edns []EDNS0
|
||||||
Option:
|
Option:
|
||||||
code := uint16(0)
|
var code uint16
|
||||||
if off+4 > len(msg) {
|
if off+4 > len(msg) {
|
||||||
return nil, len(msg), &Error{err: "overflow unpacking opt"}
|
return nil, len(msg), &Error{err: "overflow unpacking opt"}
|
||||||
}
|
}
|
||||||
|
|
3
scan.go
3
scan.go
|
@ -1173,8 +1173,7 @@ func typeToInt(token string) (uint16, bool) {
|
||||||
|
|
||||||
// stringToTTL parses things like 2w, 2m, etc, and returns the time in seconds.
|
// stringToTTL parses things like 2w, 2m, etc, and returns the time in seconds.
|
||||||
func stringToTTL(token string) (uint32, bool) {
|
func stringToTTL(token string) (uint32, bool) {
|
||||||
s := uint32(0)
|
var s, i uint32
|
||||||
i := uint32(0)
|
|
||||||
for _, c := range token {
|
for _, c := range token {
|
||||||
switch c {
|
switch c {
|
||||||
case 's', 'S':
|
case 's', 'S':
|
||||||
|
|
|
@ -1399,7 +1399,7 @@ func setEUI64(h RR_Header, c *zlexer, o, f string) (RR, *ParseError) {
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return nil, &ParseError{f, "bad EUI68 Address", l}
|
return nil, &ParseError{f, "bad EUI68 Address", l}
|
||||||
}
|
}
|
||||||
rr.Address = uint64(i)
|
rr.Address = i
|
||||||
return rr, nil
|
return rr, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
8
tsig.go
8
tsig.go
|
@ -113,13 +113,13 @@ func TsigGenerate(m *Msg, secret, requestMAC string, timersOnly bool) ([]byte, s
|
||||||
var h hash.Hash
|
var h hash.Hash
|
||||||
switch strings.ToLower(rr.Algorithm) {
|
switch strings.ToLower(rr.Algorithm) {
|
||||||
case HmacMD5:
|
case HmacMD5:
|
||||||
h = hmac.New(md5.New, []byte(rawsecret))
|
h = hmac.New(md5.New, rawsecret)
|
||||||
case HmacSHA1:
|
case HmacSHA1:
|
||||||
h = hmac.New(sha1.New, []byte(rawsecret))
|
h = hmac.New(sha1.New, rawsecret)
|
||||||
case HmacSHA256:
|
case HmacSHA256:
|
||||||
h = hmac.New(sha256.New, []byte(rawsecret))
|
h = hmac.New(sha256.New, rawsecret)
|
||||||
case HmacSHA512:
|
case HmacSHA512:
|
||||||
h = hmac.New(sha512.New, []byte(rawsecret))
|
h = hmac.New(sha512.New, rawsecret)
|
||||||
default:
|
default:
|
||||||
return nil, "", ErrKeyAlg
|
return nil, "", ErrKeyAlg
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ func TestTsig(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
binary.BigEndian.PutUint16(buf[0:2], uint16(42))
|
binary.BigEndian.PutUint16(buf[0:2], 42)
|
||||||
err = TsigVerify(buf, "pRZgBrBvI4NAHZYhxmhs/Q==", "", false)
|
err = TsigVerify(buf, "pRZgBrBvI4NAHZYhxmhs/Q==", "", false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
|
2
xfr.go
2
xfr.go
|
@ -117,7 +117,7 @@ func (t *Transfer) inAxfr(q *Msg, c chan *Envelope) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Transfer) inIxfr(q *Msg, c chan *Envelope) {
|
func (t *Transfer) inIxfr(q *Msg, c chan *Envelope) {
|
||||||
serial := uint32(0) // The first serial seen is the current server serial
|
var serial uint32 // The first serial seen is the current server serial
|
||||||
axfr := true
|
axfr := true
|
||||||
n := 0
|
n := 0
|
||||||
qser := q.Ns[0].(*SOA).Serial
|
qser := q.Ns[0].(*SOA).Serial
|
||||||
|
|
Loading…
Reference in New Issue