Skip to content

Commit

Permalink
midi: fixed lint warning (cf. #1004 (comment))
Browse files Browse the repository at this point in the history
  • Loading branch information
twystd committed Aug 28, 2024
1 parent 462ae15 commit f424936
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion format/midi/midi.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,15 @@ func peekEvent(d *decode.D) (uint64, uint8, uint8) {
}
}

// Big endian varint
func vlq(d *decode.D) uint64 {
vlq := uint64(0)

for {
b := d.U8()

vlq <<= 7
vlq += uint64(b & 0x7f)
vlq += b & 0x7f

if b&0x80 == 0 {
break
Expand All @@ -180,6 +181,7 @@ func vlq(d *decode.D) uint64 {
return vlq
}

// Variable length with a big endian varint length
func vlf(d *decode.D) ([]uint8, error) {
N := int(vlq(d))

Expand All @@ -190,6 +192,7 @@ func vlf(d *decode.D) ([]uint8, error) {
}
}

// Variable length string with a big endian varint length
func vlstring(d *decode.D) string {
if data, err := vlf(d); err != nil {
d.Errorf("%v", err)
Expand Down
3 changes: 3 additions & 0 deletions format/midi/testdata/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ debug: build
test: build
go test ./format -run TestFormats/midi

lint: test
make -f Makefile lint

regenerate: build
go test ./format -run TestFormats/midi -update

Expand Down

0 comments on commit f424936

Please sign in to comment.