Fixed code smells
Some checks failed
Run tests / test (1.25) (push) Failing after 15s
Run tests / test (stable) (push) Failing after 17s

This commit is contained in:
2026-02-22 21:14:58 +01:00
parent 3bcbaf2135
commit 32f6c38c13
17 changed files with 1593 additions and 22 deletions

View File

@@ -53,7 +53,7 @@ func (priv *PrivateKey) Sign(_ io.Reader, digest []byte, _ crypto.SignerOpts) (s
func (priv *PrivateKey) Public() crypto.PublicKey {
p := &PublicKey{}
newPublicKey(p, priv.pub[:])
_, _ = newPublicKey(p, priv.pub[:])
return p
}
@@ -118,7 +118,9 @@ func GenerateKey() (*PublicKey, *PrivateKey, error) {
}
func generateKey(priv *PrivateKey) (*PrivateKey, error) {
rand.Read(priv.seed[:])
if _, err := rand.Read(priv.seed[:]); err != nil {
return nil, err
}
precomputePrivateKey(priv)
return priv, nil
}

View File

@@ -357,15 +357,6 @@ func (drv *companionDriver) wait(expect ...byte) ([]byte, error) {
return wait.Wait()
}
func bytesContains(b byte, slice []byte) bool {
for _, v := range slice {
if v == b {
return true
}
}
return false
}
func (drv *companionDriver) handlePushFrame(b []byte) {
if len(b) < 1 {
return // illegal

View File

@@ -10,10 +10,7 @@ import (
"git.maze.io/go/ham/protocol/meshcore/crypto"
)
var (
zeroTime time.Time
zeroPositionBytes = []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
)
var zeroPositionBytes = []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
type Payload interface {
fmt.Stringer

View File

@@ -47,10 +47,6 @@ func decodeTime(b []byte) time.Time {
return time.Unix(int64(binary.LittleEndian.Uint32(b)), 0).UTC()
}
func encodeFrequency(b []byte, f float64) {
binary.LittleEndian.PutUint32(b, uint32(f*1e3))
}
func decodeFrequency(b []byte) float64 {
return float64(int64(binary.LittleEndian.Uint32(b))) / 1e3
}