Skip to content

Commit bd806d8

Browse files
committed
Fix linting issues
1 parent f6f961f commit bd806d8

5 files changed

Lines changed: 16 additions & 32 deletions

File tree

tpm/debug/bin.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ func NewBinTap(w io.Writer) Tap {
2222
return &binTap{w: w}
2323
}
2424

25-
func (w *binTap) Write(data []byte) (int, error) {
26-
w.Lock()
27-
defer w.Unlock()
25+
func (t *binTap) Write(data []byte) (int, error) {
26+
t.Lock()
27+
defer t.Unlock()
2828

29-
return w.w.Write(data)
29+
return t.w.Write(data)
3030
}

tpm/debug/pcap.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ var decodeOptions = gopacket.DecodeOptions{
9292
const snapLen = uint32(65536)
9393

9494
var once sync.Once
95-
var headerWriteError error
95+
var errHeaderWrite error
9696

97-
func write(w *pcapgo.Writer, data []byte, in bool, inSeq uint32, outSeq uint32) error {
97+
func write(w *pcapgo.Writer, data []byte, in bool, inSeq, outSeq uint32) error {
9898
var tcpLayer = &layers.TCP{Window: 16}
9999
if in {
100100
tcpLayer.SrcPort = layers.TCPPort(2321)
@@ -126,11 +126,11 @@ func write(w *pcapgo.Writer, data []byte, in bool, inSeq uint32, outSeq uint32)
126126
once.Do(func() {
127127
// TODO: do once on the very first write to the output; if it's a file, check there's no pcap header yet
128128
if err := w.WriteFileHeader(snapLen, layers.LinkTypeEthernet); err != nil {
129-
headerWriteError = err
129+
errHeaderWrite = err
130130
}
131131
})
132-
if headerWriteError != nil {
133-
return fmt.Errorf("failed writing pcap header: %w", headerWriteError)
132+
if errHeaderWrite != nil {
133+
return fmt.Errorf("failed writing pcap header: %w", errHeaderWrite)
134134
}
135135

136136
ci := p.Metadata().CaptureInfo

tpm/debug/tap.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ type tap struct {
1414
out io.Writer
1515
}
1616

17-
func (t tap) Rx() io.Writer {
17+
func (t *tap) Rx() io.Writer {
1818
return t.in
1919
}
2020

21-
func (t tap) Tx() io.Writer {
21+
func (t *tap) Tx() io.Writer {
2222
return t.out
2323
}
2424

25-
func NewTap(rx io.Writer, tx io.Writer) Tap {
25+
func NewTap(rx, tx io.Writer) Tap {
2626
return &tap{
2727
in: rx,
2828
out: tx,

tpm/debug/text.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"io"
66
)
77

8-
func NewTextTap(reads io.Writer, writes io.Writer) Tap {
8+
func NewTextTap(reads, writes io.Writer) Tap {
99
return &tap{
1010
in: &wrapper{reads, true},
1111
out: &wrapper{writes, false},
@@ -19,8 +19,8 @@ type wrapper struct {
1919

2020
func (w *wrapper) Write(data []byte) (int, error) {
2121
if w.in {
22-
return w.w.Write([]byte(fmt.Sprintf("<- %x\n", data)))
23-
} else {
24-
return w.w.Write([]byte(fmt.Sprintf("-> %x\n", data)))
22+
return fmt.Fprintf(w.w, "<- %x\n", data)
2523
}
24+
25+
return fmt.Fprintf(w.w, "-> %x\n", data)
2626
}

tpm/tpm.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -318,22 +318,6 @@ func (t *TPM) initializeCommandChannel() error {
318318
}
319319
}
320320

321-
// if t.tap != nil && runtime.GOOS != "windows" {
322-
// if t.commandChannel == nil {
323-
// rwc, err := open.TPM(t.deviceName)
324-
// if err != nil {
325-
// return fmt.Errorf("failed opening TPM: %w", err)
326-
// }
327-
// //cc := interceptor.RWCFromTap(t.tap).Wrap(rwc)
328-
// //at = inject.Inject(interceptor.RWCFromTap(t.tap).Wrap(rwc)) // TODO: can we circumvent inject?
329-
// //t.attestConfig.CommandChannel = cc
330-
// cc := &linuxCmdChannel{rwc}
331-
// t.tappedChannel = interceptor.CommandChannelFromTap(t.tap).Wrap(cc)
332-
// } else {
333-
// t.tappedChannel = interceptor.CommandChannelFromTap(t.tap).Wrap(t.commandChannel)
334-
// }
335-
// }
336-
337321
// update `attestConfig` with the command channel, so that it is used whenever
338322
// attestation operations are being performed. Note that the command channel can
339323
// still be nil. It simply won't be used (wrapped) by `go-attestation` in that case.

0 commit comments

Comments
 (0)