Skip to content

Commit

Permalink
Fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hslatman committed Jun 4, 2024
1 parent f6f961f commit 1d235c8
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 27 deletions.
8 changes: 4 additions & 4 deletions tpm/debug/bin.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ func NewBinTap(w io.Writer) Tap {
return &binTap{w: w}
}

func (w *binTap) Write(data []byte) (int, error) {
w.Lock()
defer w.Unlock()
func (t *binTap) Write(data []byte) (int, error) {
t.Lock()
defer t.Unlock()

return w.w.Write(data)
return t.w.Write(data)
}
2 changes: 1 addition & 1 deletion tpm/debug/pcap.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const snapLen = uint32(65536)
var once sync.Once
var headerWriteError error

Check failure on line 95 in tpm/debug/pcap.go

View workflow job for this annotation

GitHub Actions / ci / lint / lint

the variable name `headerWriteError` should conform to the `errXxx` format (errname)

func write(w *pcapgo.Writer, data []byte, in bool, inSeq uint32, outSeq uint32) error {
func write(w *pcapgo.Writer, data []byte, in bool, inSeq, outSeq uint32) error {
var tcpLayer = &layers.TCP{Window: 16}
if in {
tcpLayer.SrcPort = layers.TCPPort(2321)
Expand Down
6 changes: 3 additions & 3 deletions tpm/debug/tap.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ type tap struct {
out io.Writer
}

func (t tap) Rx() io.Writer {
func (t *tap) Rx() io.Writer {
return t.in
}

func (t tap) Tx() io.Writer {
func (t *tap) Tx() io.Writer {
return t.out
}

func NewTap(rx io.Writer, tx io.Writer) Tap {
func NewTap(rx, tx io.Writer) Tap {
return &tap{
in: rx,
out: tx,
Expand Down
6 changes: 3 additions & 3 deletions tpm/debug/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ type wrapper struct {

func (w *wrapper) Write(data []byte) (int, error) {
if w.in {
return w.w.Write([]byte(fmt.Sprintf("<- %x\n", data)))
} else {
return w.w.Write([]byte(fmt.Sprintf("-> %x\n", data)))
return fmt.Fprintf(w.w, "<- %x\n", data)
}

return fmt.Fprintf(w.w, "-> %x\n", data)
}
16 changes: 0 additions & 16 deletions tpm/tpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,22 +318,6 @@ func (t *TPM) initializeCommandChannel() error {
}
}

// if t.tap != nil && runtime.GOOS != "windows" {
// if t.commandChannel == nil {
// rwc, err := open.TPM(t.deviceName)
// if err != nil {
// return fmt.Errorf("failed opening TPM: %w", err)
// }
// //cc := interceptor.RWCFromTap(t.tap).Wrap(rwc)
// //at = inject.Inject(interceptor.RWCFromTap(t.tap).Wrap(rwc)) // TODO: can we circumvent inject?
// //t.attestConfig.CommandChannel = cc
// cc := &linuxCmdChannel{rwc}
// t.tappedChannel = interceptor.CommandChannelFromTap(t.tap).Wrap(cc)
// } else {
// t.tappedChannel = interceptor.CommandChannelFromTap(t.tap).Wrap(t.commandChannel)
// }
// }

// update `attestConfig` with the command channel, so that it is used whenever
// attestation operations are being performed. Note that the command channel can
// still be nil. It simply won't be used (wrapped) by `go-attestation` in that case.
Expand Down

0 comments on commit 1d235c8

Please sign in to comment.