Skip to content

Commit

Permalink
staticcheck: unify receiver names
Browse files Browse the repository at this point in the history
Signed-off-by: Siarhiej Siemianczuk <[email protected]>
  • Loading branch information
binjip978 committed Sep 18, 2024
1 parent 17b6cb3 commit e49481e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ linters-settings:
staticcheck:
checks: ["all", "-SA1019"]
stylecheck:
checks: ["all", "-ST1003", "-ST1012", "-ST1016"]
checks: ["all", "-ST1003", "-ST1012"]
32 changes: 16 additions & 16 deletions pkg/cbfs/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ func NewPayloadRecord(f *File) (ReadWriter, error) {
return p, nil
}

func (p *PayloadRecord) Read(in io.ReadSeeker) error {
func (r *PayloadRecord) Read(in io.ReadSeeker) error {
for {
var h PayloadHeader
if err := Read(in, &h); err != nil {
Debug("PayloadHeader read: %v", err)
return err
}
Debug("Got PayloadHeader %s", h.String())
p.Segs = append(p.Segs, h)
r.Segs = append(r.Segs, h)
if h.Type == SegEntry {
break
}
Expand All @@ -40,8 +40,8 @@ func (p *PayloadRecord) Read(in io.ReadSeeker) error {
if err != nil {
return fmt.Errorf("finding location in stream: %w", err)
}
bodySize := int64(p.Size) - offset
Debug("Payload size: %v, body size: %v, offset: %v", p.Size, bodySize, offset)
bodySize := int64(r.Size) - offset
Debug("Payload size: %v, body size: %v, offset: %v", r.Size, bodySize, offset)
if bodySize < 0 {
// This should not happen. Tolerate a potential error.
return nil
Expand All @@ -51,8 +51,8 @@ func (p *PayloadRecord) Read(in io.ReadSeeker) error {
Debug("Payload empty, nothing to read")
return nil
}
p.FData = make([]byte, bodySize)
n, err := in.Read(p.FData)
r.FData = make([]byte, bodySize)
n, err := in.Read(r.FData)
if err != nil {
return err
}
Expand Down Expand Up @@ -81,9 +81,9 @@ func (r *PayloadRecord) MarshalJSON() ([]byte, error) {
})
}

func (h *PayloadRecord) String() string {
s := recString(h.File.Name, h.RecordStart, h.Type.String(), h.Size, "none")
for i, seg := range h.Segs {
func (r *PayloadRecord) String() string {
s := recString(r.File.Name, r.RecordStart, r.Type.String(), r.Size, "none")
for i, seg := range r.Segs {
s += "\n"
s += recString(fmt.Sprintf(" Seg #%d", i), seg.Offset, seg.Type.String(), seg.Size, seg.Compression.String())
}
Expand Down Expand Up @@ -111,14 +111,14 @@ func (h *PayloadHeader) MarshalJSON() ([]byte, error) {
})
}

func (r *PayloadHeader) String() string {
func (h *PayloadHeader) String() string {
return fmt.Sprintf("Type %#x Compression %#x Offset %#x LoadAddress %#x Size %#x MemSize %#x",
r.Type,
r.Compression,
r.Offset,
r.LoadAddress,
r.Size,
r.MemSize)
h.Type,
h.Compression,
h.Offset,
h.LoadAddress,
h.Size,
h.MemSize)
}

func (r *PayloadRecord) Write(w io.Writer) error {
Expand Down
8 changes: 4 additions & 4 deletions pkg/cbfs/stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ func (h *StageHeader) String() string {
h.MemSize)
}

func (h *LegacyStageRecord) String() string {
return recString(h.File.Name, h.RecordStart, h.Type.String(), h.Size, h.File.Compression().String())
func (r *LegacyStageRecord) String() string {
return recString(r.File.Name, r.RecordStart, r.Type.String(), r.Size, r.File.Compression().String())
}

func (r *LegacyStageRecord) Write(w io.Writer) error {
Expand Down Expand Up @@ -81,8 +81,8 @@ func (h *FileAttrStageHeader) String() string {
h.MemSize)
}

func (h *StageRecord) String() string {
return recString(h.File.Name, h.RecordStart, h.Type.String(), h.File.Size, h.File.Compression().String())
func (r *StageRecord) String() string {
return recString(r.File.Name, r.RecordStart, r.Type.String(), r.File.Size, r.File.Compression().String())
}

func (r *StageRecord) Write(w io.Writer) error {
Expand Down
6 changes: 3 additions & 3 deletions pkg/intel/metadata/bg/key_signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ type KeySignature struct {
}

// Verify verifies the builtin signature with the builtin public key.
func (m *KeySignature) Verify(signedData []byte) error {
sig, err := m.Signature.SignatureData()
func (ks *KeySignature) Verify(signedData []byte) error {
sig, err := ks.Signature.SignatureData()
if err != nil {
return fmt.Errorf("invalid signature: %w", err)
}
pk, err := m.Key.PubKey()
pk, err := ks.Key.PubKey()
if err != nil {
return fmt.Errorf("invalid public key: %w", err)
}
Expand Down

0 comments on commit e49481e

Please sign in to comment.