From 76c878237ac7f4a1347e824d03948f51cab2939d Mon Sep 17 00:00:00 2001 From: Bas Westerbaan Date: Wed, 18 Sep 2024 16:14:27 +0200 Subject: [PATCH] Appease linter --- ca/ca.go | 5 ++++- ca/index.go | 2 -- cmd/mtc/main.go | 10 ++++++++-- mtc.go | 9 ++++++--- mtc_test.go | 2 +- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/ca/ca.go b/ca/ca.go index 2ebb733..b282d75 100644 --- a/ca/ca.go +++ b/ca/ca.go @@ -763,6 +763,9 @@ func (h *Handle) issueBatch(number uint32, empty bool) error { "index", }, ) + if err != nil { + return err + } h.batchNumbersCache = nil // Invalidate cache of existing batches @@ -1073,7 +1076,7 @@ func New(path string, opts NewOpts) (*Handle, error) { unlock := true defer func() { if unlock { - h.flock.Unlock() + _ = h.flock.Unlock() } }() diff --git a/ca/index.go b/ca/index.go index 2d7b68d..85a2aef 100644 --- a/ca/index.go +++ b/ca/index.go @@ -151,8 +151,6 @@ func (h *Index) Search(hash []byte) (*IndexSearchResult, error) { return nil, nil } } - - return nil, nil } type indexEntry struct { diff --git a/cmd/mtc/main.go b/cmd/mtc/main.go index a68adbc..f7d2acc 100644 --- a/cmd/mtc/main.go +++ b/cmd/mtc/main.go @@ -396,7 +396,10 @@ func handleCaShowQueue(cc *cli.Context) error { func handleCaNew(cc *cli.Context) error { if cc.Args().Len() != 2 { - cli.ShowSubcommandHelp(cc) + err := cli.ShowSubcommandHelp(cc) + if err != nil { + return err + } return errArgs } @@ -912,7 +915,10 @@ func main() { if err != nil { return fmt.Errorf("create(%s): %w", path, err) } - pprof.StartCPUProfile(fCpuProfile) + err = pprof.StartCPUProfile(fCpuProfile) + if err != nil { + return fmt.Errorf("StartCPUProfile: %w", err) + } } return nil }, diff --git a/mtc.go b/mtc.go index 24e68b9..c5173a9 100644 --- a/mtc.go +++ b/mtc.go @@ -326,6 +326,9 @@ func (c *BikeshedCertificate) MarshalBinary() ([]byte, error) { b.AddBytes(buf) buf, err = c.Proof.TrustAnchorIdentifier().MarshalBinary() + if err != nil { + return nil, fmt.Errorf("failed to marshal TAI: %w", err) + } b.AddBytes(buf) b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { b.AddBytes(c.Proof.Info()) @@ -616,7 +619,7 @@ func (p *CAParams) newTreeHeads(prevHeads, root []byte) ([]byte, error) { len(root), ) } - return append(prevHeads[HashLen:len(prevHeads)], root...), nil + return append(prevHeads[HashLen:], root...), nil } func (batch *Batch) Anchor() TrustAnchorIdentifier { @@ -989,7 +992,7 @@ func (batch *Batch) ComputeRootFromAuthenticationPath(index uint64, level++ index >>= 1 - batch.hashNode(h, left, right, index, level) + _ = batch.hashNode(h, left, right, index, level) } if index != 0 { @@ -1630,7 +1633,7 @@ func (oid *RelativeOID) Equal(rhs *RelativeOID) bool { } func (tai TrustAnchorIdentifier) MarshalBinary() ([]byte, error) { - if tai.Issuer == nil || len(tai.Issuer) == 0 { + if len(tai.Issuer) == 0 { return nil, errors.New("can't marshal uninitialized TrustAnchorIdentifier") } batch := RelativeOID{} diff --git a/mtc_test.go b/mtc_test.go index 90187d4..0d2457b 100644 --- a/mtc_test.go +++ b/mtc_test.go @@ -59,7 +59,7 @@ func createEd25519TestTLSSubject() (*TLSSubject, error) { h := sha3.NewShake128() h.Write([]byte("MTC Example")) - h.Read(seed[:]) + _, _ = h.Read(seed[:]) privEd := ed25519.NewKeyFromSeed(seed[:]) pubEd := privEd.Public()