diff --git a/.golangci.yml b/.golangci.yml index e00d3670..1db28d8e 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,44 +1,43 @@ linters: - enable: - - revive - - errname - - goimports - - nilerr - - forcetypeassert - - asciicheck - - bodyclose - - durationcheck - - errorlint - - noctx - - misspell - - exportloopref - - unconvert - - unparam - - wastedassign - - makezero - - exhaustive - - gosec - - nolintlint - - nakedret - - predeclared - - tagliatelle - -run: - skip-dirs: - - dev - - doc - + enable: + - asciicheck + - bodyclose + - durationcheck + - errname + - errorlint + - exhaustive + - exportloopref + - forcetypeassert + - goimports + - gosec + - makezero + - misspell + - nakedret + - nilerr + - noctx + - nolintlint + - nosprintfhostport + - predeclared + - revive + - tagliatelle + - unconvert + - unparam + - wastedassign linters-settings: - misspell: - ignore-words: - # elf RELA - - rela - - equalisation - - synchronisation - exhaustive: - default-signifies-exhaustive: true - gosec: - excludes: - # allow md5 - - G401 - - G501 + exhaustive: + default-signifies-exhaustive: true + gosec: + excludes: + - G401 + - G501 + misspell: + ignore-words: + # elf RELA + - rela + - equalisation + - synchronisation +run: + skip-dirs: + # allow md5 + - dev + - doc diff --git a/doc/presentations/bts2022/mp3.go b/doc/presentations/bts2022/mp3.go index b4d35f43..b57e02d1 100644 --- a/doc/presentations/bts2022/mp3.go +++ b/doc/presentations/bts2022/mp3.go @@ -1,4 +1,4 @@ -func decode(d *decode.D, in any) any { +func decode(d *decode.D, _ any) any { d.FieldArray("headers", func(d *decode.D) { for !d.End() { d.TryFieldFormat("header", headerGroup) diff --git a/format/ape/apev2.go b/format/ape/apev2.go index 3c688f1a..4fde1414 100644 --- a/format/ape/apev2.go +++ b/format/ape/apev2.go @@ -21,7 +21,7 @@ func init() { }) } -func apev2Decode(d *decode.D, in any) any { +func apev2Decode(d *decode.D, _ any) any { d.Endian = decode.LittleEndian headerFooterFn := func(d *decode.D, name string) uint64 { diff --git a/format/ar/ar.go b/format/ar/ar.go index bf718145..9a2d085e 100644 --- a/format/ar/ar.go +++ b/format/ar/ar.go @@ -21,7 +21,7 @@ func init() { }) } -func decodeAr(d *decode.D, in any) any { +func decodeAr(d *decode.D, _ any) any { d.FieldUTF8("signature", 8, d.AssertStr("!\n")) d.FieldArray("files", func(d *decode.D) { for !d.End() { diff --git a/format/asn1/asn1_ber.go b/format/asn1/asn1_ber.go index 7ef55876..91753f14 100644 --- a/format/asn1/asn1_ber.go +++ b/format/asn1/asn1_ber.go @@ -414,7 +414,7 @@ func decodeASN1BERValue(d *decode.D, bib *bitio.Buffer, sb *strings.Builder, par }) } -func decodeASN1BER(d *decode.D, in any) any { +func decodeASN1BER(d *decode.D, _ any) any { decodeASN1BERValue(d, nil, nil, formConstructed, universalTypeSequence) return nil } diff --git a/format/av1/av1_ccr.go b/format/av1/av1_ccr.go index 63c2c1a2..b4f82aa3 100644 --- a/format/av1/av1_ccr.go +++ b/format/av1/av1_ccr.go @@ -19,7 +19,7 @@ func init() { }) } -func ccrDecode(d *decode.D, in any) any { +func ccrDecode(d *decode.D, _ any) any { d.FieldU1("marker") d.FieldU7("version") d.FieldU3("seq_profile") diff --git a/format/av1/av1_frame.go b/format/av1/av1_frame.go index 15dff863..635ca64d 100644 --- a/format/av1/av1_frame.go +++ b/format/av1/av1_frame.go @@ -25,7 +25,7 @@ func init() { }) } -func frameDecode(d *decode.D, in any) any { +func frameDecode(d *decode.D, _ any) any { for d.NotEnd() { d.FieldFormat("obu", obuFormat, nil) } diff --git a/format/av1/av1_obu.go b/format/av1/av1_obu.go index 8de61356..ccada750 100644 --- a/format/av1/av1_obu.go +++ b/format/av1/av1_obu.go @@ -52,7 +52,7 @@ func decodeLeb128(d *decode.D) uint64 { return v } -func obuDecode(d *decode.D, in any) any { +func obuDecode(d *decode.D, _ any) any { var obuType uint64 var obuSize int64 hasExtension := false diff --git a/format/avro/avro_ocf.go b/format/avro/avro_ocf.go index c98e106a..25f1142d 100644 --- a/format/avro/avro_ocf.go +++ b/format/avro/avro_ocf.go @@ -124,7 +124,7 @@ func decodeBlockCodec(d *decode.D, dataSize int64, codec string) *bytes.Buffer { return bb } -func decodeAvroOCF(d *decode.D, in any) any { +func decodeAvroOCF(d *decode.D, _ any) any { header := decodeHeader(d) decodeFn, err := decoders.DecodeFnForSchema(header.Schema) diff --git a/format/bencode/bencode.go b/format/bencode/bencode.go index 0a54b3c1..abaa4a0b 100644 --- a/format/bencode/bencode.go +++ b/format/bencode/bencode.go @@ -90,7 +90,7 @@ func decodeBencodeValue(d *decode.D) { } } -func decodeBencode(d *decode.D, in any) any { +func decodeBencode(d *decode.D, _ any) any { decodeBencodeValue(d) return nil } diff --git a/format/bson/bson.go b/format/bson/bson.go index 18bc1ee6..246d5db2 100644 --- a/format/bson/bson.go +++ b/format/bson/bson.go @@ -110,7 +110,7 @@ func decodeBSONDocument(d *decode.D) { }) } -func decodeBSON(d *decode.D, in any) any { +func decodeBSON(d *decode.D, _ any) any { d.Endian = decode.LittleEndian decodeBSONDocument(d) diff --git a/format/bzip2/bzip2.go b/format/bzip2/bzip2.go index efb0a1be..39082e88 100644 --- a/format/bzip2/bzip2.go +++ b/format/bzip2/bzip2.go @@ -48,7 +48,7 @@ func (bfr bitFlipReader) Read(p []byte) (n int, err error) { return n, err } -func bzip2Decode(d *decode.D, in any) any { +func bzip2Decode(d *decode.D, _ any) any { // moreStreams := true // d.FieldArray("streams", func(d *decode.D) { diff --git a/format/cbor/cbor.go b/format/cbor/cbor.go index 34e9ee3d..3502a17e 100644 --- a/format/cbor/cbor.go +++ b/format/cbor/cbor.go @@ -262,7 +262,7 @@ func decodeCBORValue(d *decode.D) any { panic("unreachable") } -func decodeCBOR(d *decode.D, in any) any { +func decodeCBOR(d *decode.D, _ any) any { decodeCBORValue(d) return nil } diff --git a/format/elf/elf.go b/format/elf/elf.go index 4daf4217..565847dd 100644 --- a/format/elf/elf.go +++ b/format/elf/elf.go @@ -903,7 +903,7 @@ func elfDecodeSectionHeaders(d *decode.D, ec elfContext) { } } -func elfDecode(d *decode.D, in any) any { +func elfDecode(d *decode.D, _ any) any { var ec elfContext d.FieldStruct("header", func(d *decode.D) { elfDecodeHeader(d, &ec) }) diff --git a/format/fairplay/fairplay.go b/format/fairplay/fairplay.go index e728943a..13d6fce3 100644 --- a/format/fairplay/fairplay.go +++ b/format/fairplay/fairplay.go @@ -16,7 +16,7 @@ func init() { }) } -func fairPlaySPCDecode(d *decode.D, in any) any { +func fairPlaySPCDecode(d *decode.D, _ any) any { d.FieldU32("version") d.FieldRawLen("reserved", 32) d.FieldRawLen("iv", 16*8) diff --git a/format/flac/flac.go b/format/flac/flac.go index d18a4961..cd84bb0e 100644 --- a/format/flac/flac.go +++ b/format/flac/flac.go @@ -35,7 +35,7 @@ func init() { }) } -func flacDecode(d *decode.D, in any) any { +func flacDecode(d *decode.D, _ any) any { d.FieldUTF8("magic", 4, d.AssertStr("fLaC")) var streamInfo format.FlacStreamInfo diff --git a/format/flac/flac_metadatablock.go b/format/flac/flac_metadatablock.go index e050f50c..9265df3a 100644 --- a/format/flac/flac_metadatablock.go +++ b/format/flac/flac_metadatablock.go @@ -49,7 +49,7 @@ var metadataBlockNames = scalar.UToSymStr{ MetadataBlockPicture: "picture", } -func metadatablockDecode(d *decode.D, in any) any { +func metadatablockDecode(d *decode.D, _ any) any { var hasStreamInfo bool var streamInfo format.FlacStreamInfo diff --git a/format/flac/flac_metadatablocks.go b/format/flac/flac_metadatablocks.go index 0536f2b1..538a2dd2 100644 --- a/format/flac/flac_metadatablocks.go +++ b/format/flac/flac_metadatablocks.go @@ -23,7 +23,7 @@ func init() { }) } -func metadatablocksDecode(d *decode.D, in any) any { +func metadatablocksDecode(d *decode.D, _ any) any { flacMetadatablocksOut := format.FlacMetadatablocksOut{} isLastBlock := false diff --git a/format/flac/flac_picture.go b/format/flac/flac_picture.go index eabbd38d..9659c020 100644 --- a/format/flac/flac_picture.go +++ b/format/flac/flac_picture.go @@ -44,7 +44,7 @@ func init() { }) } -func pictureDecode(d *decode.D, in any) any { +func pictureDecode(d *decode.D, _ any) any { lenStr := func(name string) string { l := d.FieldU32(name + "_length") return d.FieldUTF8(name, int(l)) diff --git a/format/flac/flac_streaminfo.go b/format/flac/flac_streaminfo.go index 78aec834..1e353efc 100644 --- a/format/flac/flac_streaminfo.go +++ b/format/flac/flac_streaminfo.go @@ -15,7 +15,7 @@ func init() { }) } -func streaminfoDecode(d *decode.D, in any) any { +func streaminfoDecode(d *decode.D, _ any) any { d.FieldU16("minimum_block_size") d.FieldU16("maximum_block_size") d.FieldU24("minimum_frame_size") diff --git a/format/flv/flv.go b/format/flv/flv.go index 9b0fa019..fbb77ab8 100644 --- a/format/flv/flv.go +++ b/format/flv/flv.go @@ -65,7 +65,7 @@ var typeNames = scalar.UToSymStr{ typeLongString: "LongString", } -func flvDecode(d *decode.D, in any) any { +func flvDecode(d *decode.D, _ any) any { var fieldScriptDataObject func() var fieldScriptDataVariable func(d *decode.D, name string) diff --git a/format/gif/gif.go b/format/gif/gif.go index 3d34d794..a3890cf4 100644 --- a/format/gif/gif.go +++ b/format/gif/gif.go @@ -51,7 +51,7 @@ func fieldColorMap(d *decode.D, name string, bitDepth int) { }) } -func gifDecode(d *decode.D, in any) any { +func gifDecode(d *decode.D, _ any) any { d.Endian = decode.LittleEndian d.FieldUTF8("header", 6, d.AssertStr("GIF87a", "GIF89a")) diff --git a/format/gzip/gzip.go b/format/gzip/gzip.go index eb9dd5cb..040c157c 100644 --- a/format/gzip/gzip.go +++ b/format/gzip/gzip.go @@ -57,7 +57,7 @@ var deflateExtraFlagsNames = scalar.UToSymStr{ 4: "fast", } -func gzDecode(d *decode.D, in any) any { +func gzDecode(d *decode.D, _ any) any { d.Endian = decode.LittleEndian d.FieldRawLen("identification", 2*8, d.AssertBitBuf([]byte("\x1f\x8b"))) diff --git a/format/icc/icc_profile.go b/format/icc/icc_profile.go index 182780a8..015cddc2 100644 --- a/format/icc/icc_profile.go +++ b/format/icc/icc_profile.go @@ -81,7 +81,7 @@ func decodeBCDU8(d *decode.D) uint64 { return (n>>4)*10 + n&0xf } -func iccProfileDecode(d *decode.D, in any) any { +func iccProfileDecode(d *decode.D, _ any) any { /* 0..3 Profile size uInt32Number 4..7 CMM Type signature see below diff --git a/format/id3/id3v1.go b/format/id3/id3v1.go index 47ee0149..179014e0 100644 --- a/format/id3/id3v1.go +++ b/format/id3/id3v1.go @@ -18,7 +18,7 @@ func init() { } // Decode ID3v1 tag -func id3v1Decode(d *decode.D, in any) any { +func id3v1Decode(d *decode.D, _ any) any { d.AssertAtLeastBitsLeft(128 * 8) d.FieldUTF8("magic", 3, d.AssertStr("TAG")) if d.PeekBits(8) == uint64('+') { diff --git a/format/id3/id3v11.go b/format/id3/id3v11.go index 0a5e31a3..ac0751a4 100644 --- a/format/id3/id3v11.go +++ b/format/id3/id3v11.go @@ -15,7 +15,7 @@ func init() { }) } -func id3v11Decode(d *decode.D, in any) any { +func id3v11Decode(d *decode.D, _ any) any { d.AssertAtLeastBitsLeft(128 * 8) d.FieldUTF8("magic", 4, d.AssertStr("TAG+")) d.FieldUTF8("title", 60) diff --git a/format/id3/id3v2.go b/format/id3/id3v2.go index 234c1f25..47de0d13 100644 --- a/format/id3/id3v2.go +++ b/format/id3/id3v2.go @@ -545,7 +545,7 @@ func decodeFrame(d *decode.D, version int) uint64 { // TODO: DecodeFn // TODO: unknown after frame decode unsyncedBR := d.NewBitBufFromReader(unsyncReader{Reader: bitio.NewIOReader(d.BitBufRange(d.Pos(), int64(dataSize)*8))}) - d.FieldFormatBitBuf("unsync", unsyncedBR, decode.FormatFn(func(d *decode.D, in any) any { + d.FieldFormatBitBuf("unsync", unsyncedBR, decode.FormatFn(func(d *decode.D, _ any) any { if fn, ok := frames[idNormalized]; ok { fn(d) } else { @@ -586,7 +586,7 @@ func decodeFrames(d *decode.D, version int, size uint64) { } } -func id3v2Decode(d *decode.D, in any) any { +func id3v2Decode(d *decode.D, _ any) any { d.AssertAtLeastBitsLeft(4 * 8) d.FieldUTF8("magic", 3, d.AssertStr("ID3")) version := int(d.FieldU8("version")) diff --git a/format/jpeg/jpeg.go b/format/jpeg/jpeg.go index dbf1dbc4..f4f65072 100644 --- a/format/jpeg/jpeg.go +++ b/format/jpeg/jpeg.go @@ -164,7 +164,7 @@ var markers = scalar.UToScalar{ TEM: {Sym: "tem", Description: "For temporary private use in arithmetic coding"}, } -func jpegDecode(d *decode.D, in any) any { +func jpegDecode(d *decode.D, _ any) any { d.AssertLeastBytesLeft(2) if !bytes.Equal(d.PeekBytes(2), []byte{0xff, SOI}) { d.Errorf("no SOI marker") diff --git a/format/json/json.go b/format/json/json.go index 2cd3269c..deaa8e83 100644 --- a/format/json/json.go +++ b/format/json/json.go @@ -25,7 +25,7 @@ func init() { }) } -func decodeJSON(d *decode.D, in any) any { +func decodeJSON(d *decode.D, _ any) any { br := d.RawLen(d.Len()) jd := stdjson.NewDecoder(bitio.NewIOReader(br)) var s scalar.S diff --git a/format/macho/macho.go b/format/macho/macho.go index e5735264..ae316463 100644 --- a/format/macho/macho.go +++ b/format/macho/macho.go @@ -355,7 +355,7 @@ var sectionTypes = scalar.UToSymStr{ 0x15: "thread_local_init_function_pointers", } -func machoDecode(d *decode.D, in any) any { +func machoDecode(d *decode.D, _ any) any { ofileDecode(d) return nil } diff --git a/format/matroska/matroska.go b/format/matroska/matroska.go index 883d954c..9268d170 100644 --- a/format/matroska/matroska.go +++ b/format/matroska/matroska.go @@ -308,7 +308,7 @@ func decodeMaster(d *decode.D, bitsLimit int64, tag ebml.Tag, dc *decodeContext) } -func matroskaDecode(d *decode.D, in any) any { +func matroskaDecode(d *decode.D, _ any) any { ebmlHeaderID := uint64(0x1a45dfa3) if d.PeekBits(32) != ebmlHeaderID { d.Errorf("no EBML header found") diff --git a/format/mp3/xing.go b/format/mp3/xing.go index 70945832..4a4cbc2c 100644 --- a/format/mp3/xing.go +++ b/format/mp3/xing.go @@ -16,7 +16,7 @@ func init() { }) } -func xingDecode(d *decode.D, in any) any { +func xingDecode(d *decode.D, _ any) any { // TODO: info has lame extension? hasLameExtension := false switch d.FieldUTF8("header", 4) { diff --git a/format/mp4/pssh_playready.go b/format/mp4/pssh_playready.go index 966a3dde..3f5a0889 100644 --- a/format/mp4/pssh_playready.go +++ b/format/mp4/pssh_playready.go @@ -25,7 +25,7 @@ var recordTypeNames = scalar.UToSymStr{ recordTypeLicenseStore: "License store", } -func playreadyPsshDecode(d *decode.D, in any) any { +func playreadyPsshDecode(d *decode.D, _ any) any { d.Endian = decode.LittleEndian d.FieldU32("size") diff --git a/format/mpeg/adts.go b/format/mpeg/adts.go index 444afe41..fe214027 100644 --- a/format/mpeg/adts.go +++ b/format/mpeg/adts.go @@ -22,7 +22,7 @@ func init() { }) } -func adtsDecoder(d *decode.D, in any) any { +func adtsDecoder(d *decode.D, _ any) any { validFrames := 0 for !d.End() { if dv, _, _ := d.TryFieldFormat("frame", adtsFrame, nil); dv == nil { diff --git a/format/mpeg/adts_frame.go b/format/mpeg/adts_frame.go index 77d03d66..f11292f9 100644 --- a/format/mpeg/adts_frame.go +++ b/format/mpeg/adts_frame.go @@ -29,7 +29,7 @@ var protectionAbsentNames = scalar.BoolToDescription{ false: "Has CRC", } -func adtsFrameDecoder(d *decode.D, in any) any { +func adtsFrameDecoder(d *decode.D, _ any) any { /* adts_frame() { diff --git a/format/mpeg/avc_dcr.go b/format/mpeg/avc_dcr.go index a13ec30b..3b7e507a 100644 --- a/format/mpeg/avc_dcr.go +++ b/format/mpeg/avc_dcr.go @@ -116,7 +116,7 @@ func avcDcrParameterSet(d *decode.D, numParamSets uint64) { } } -func avcDcrDecode(d *decode.D, in any) any { +func avcDcrDecode(d *decode.D, _ any) any { d.FieldU8("configuration_version") d.FieldU8("profile_indication", avcProfileNames) d.FieldU8("profile_compatibility") diff --git a/format/mpeg/avc_nalu.go b/format/mpeg/avc_nalu.go index dc5eb45a..42de822d 100644 --- a/format/mpeg/avc_nalu.go +++ b/format/mpeg/avc_nalu.go @@ -98,7 +98,7 @@ var sliceNames = scalar.UToSymStr{ 9: "si", } -func avcNALUDecode(d *decode.D, in any) any { +func avcNALUDecode(d *decode.D, _ any) any { d.FieldBool("forbidden_zero_bit") d.FieldU2("nal_ref_idc") nalType := d.FieldU5("nal_unit_type", avcNALNames) diff --git a/format/mpeg/avc_pps.go b/format/mpeg/avc_pps.go index e6ad29da..45d54b21 100644 --- a/format/mpeg/avc_pps.go +++ b/format/mpeg/avc_pps.go @@ -20,7 +20,7 @@ func moreRBSPData(d *decode.D) bool { return l >= 8 && d.PeekBits(8) != 0b1000_0000 } -func avcPPSDecode(d *decode.D, in any) any { +func avcPPSDecode(d *decode.D, _ any) any { d.FieldUFn("pic_parameter_set_id", uEV) d.FieldUFn("seq_parameter_set_id", uEV) d.FieldBool("entropy_coding_mode_flag") diff --git a/format/mpeg/avc_sei.go b/format/mpeg/avc_sei.go index b3187116..5c2e0b99 100644 --- a/format/mpeg/avc_sei.go +++ b/format/mpeg/avc_sei.go @@ -101,7 +101,7 @@ func ffSum(d *decode.D) uint64 { return s } -func avcSEIDecode(d *decode.D, in any) any { +func avcSEIDecode(d *decode.D, _ any) any { payloadType := d.FieldUFn("payload_type", func(d *decode.D) uint64 { return ffSum(d) }, seiNames) payloadSize := d.FieldUFn("payload_size", func(d *decode.D) uint64 { return ffSum(d) }) diff --git a/format/mpeg/avc_sps.go b/format/mpeg/avc_sps.go index 3d130d91..af921ee4 100644 --- a/format/mpeg/avc_sps.go +++ b/format/mpeg/avc_sps.go @@ -134,7 +134,7 @@ func avcHdrParameters(d *decode.D) { d.FieldU5("time_offset_length") } -func avcSPSDecode(d *decode.D, in any) any { +func avcSPSDecode(d *decode.D, _ any) any { profileIdc := d.FieldU8("profile_idc", avcProfileNames) d.FieldBool("constraint_set0_flag") d.FieldBool("constraint_set1_flag") diff --git a/format/mpeg/hevc_dcr.go b/format/mpeg/hevc_dcr.go index 2a11d921..f080b24b 100644 --- a/format/mpeg/hevc_dcr.go +++ b/format/mpeg/hevc_dcr.go @@ -20,7 +20,7 @@ func init() { }) } -func hevcDcrDecode(d *decode.D, in any) any { +func hevcDcrDecode(d *decode.D, _ any) any { d.FieldU8("configuration_version") d.FieldU2("general_profile_space") d.FieldU1("general_tier_flag") diff --git a/format/mpeg/hevc_nalu.go b/format/mpeg/hevc_nalu.go index cbf3ae67..86dff61a 100644 --- a/format/mpeg/hevc_nalu.go +++ b/format/mpeg/hevc_nalu.go @@ -82,7 +82,7 @@ var hevcNALNames = scalar.UToSymStr{ 47: "RSV_NVCL47", } -func hevcNALUDecode(d *decode.D, in any) any { +func hevcNALUDecode(d *decode.D, _ any) any { d.FieldBool("forbidden_zero_bit") nalType := d.FieldU6("nal_unit_type", hevcNALNames) d.FieldU6("nuh_layer_id") diff --git a/format/mpeg/hevc_pps.go b/format/mpeg/hevc_pps.go index 239a667c..1184f83f 100644 --- a/format/mpeg/hevc_pps.go +++ b/format/mpeg/hevc_pps.go @@ -17,7 +17,7 @@ func init() { } // H.265 page 36 -func hevcPPSDecode(d *decode.D, in any) any { +func hevcPPSDecode(d *decode.D, _ any) any { d.FieldUFn("pps_pic_parameter_set_id", uEV) d.FieldUFn("pps_seq_parameter_set_id", uEV) d.FieldBool("dependent_slice_segments_enabled_flag") diff --git a/format/mpeg/hevc_sps.go b/format/mpeg/hevc_sps.go index 5a8e4895..7c5d587a 100644 --- a/format/mpeg/hevc_sps.go +++ b/format/mpeg/hevc_sps.go @@ -241,7 +241,7 @@ func hevcVuiParameters(d *decode.D, spsMaxSubLayersMinus1 uint64) { } // H.265 page 34 -func hevcSPSDecode(d *decode.D, in any) any { +func hevcSPSDecode(d *decode.D, _ any) any { d.FieldU4("sps_video_parameter_set_id") spsMaxSubLayersMinus1 := d.FieldU3("sps_max_sub_layers_minus1") d.FieldBool("sps_temporal_id_nesting_flag") diff --git a/format/mpeg/hevc_vps.go b/format/mpeg/hevc_vps.go index e2a13e6f..5176e8b8 100644 --- a/format/mpeg/hevc_vps.go +++ b/format/mpeg/hevc_vps.go @@ -17,7 +17,7 @@ func init() { } // H.265 page 33 -func hevcVPSDecode(d *decode.D, in any) any { +func hevcVPSDecode(d *decode.D, _ any) any { d.FieldU4("vps_video_parameter_set_id") d.FieldBool("vps_base_layer_internal_flag") d.FieldBool("vps_base_layer_available_flag") diff --git a/format/mpeg/mp3_frame.go b/format/mpeg/mp3_frame.go index 3e2d590a..a2eba631 100644 --- a/format/mpeg/mp3_frame.go +++ b/format/mpeg/mp3_frame.go @@ -140,7 +140,7 @@ var protectionNames = scalar.BoolToDescription{ false: "Has CRC", } -func frameDecode(d *decode.D, in any) any { +func frameDecode(d *decode.D, _ any) any { const headerBytes = 4 var sideInfoBytes int64 var isStereo bool diff --git a/format/mpeg/mpeg_asc.go b/format/mpeg/mpeg_asc.go index f9adedeb..d2bb576e 100644 --- a/format/mpeg/mpeg_asc.go +++ b/format/mpeg/mpeg_asc.go @@ -44,7 +44,7 @@ var channelConfigurationNames = scalar.UToDescription{ 7: "front-center, front-left, front-right, side-left, side-right, back-left, back-right, LFE-channel", } -func ascDecoder(d *decode.D, in any) any { +func ascDecoder(d *decode.D, _ any) any { objectType := d.FieldUFn("object_type", decodeEscapeValueCarryFn(5, 6, 0), format.MPEGAudioObjectTypeNames) d.FieldUFn("sampling_frequency", decodeEscapeValueAbsFn(4, 24, 0), frequencyIndexHzMap) d.FieldU4("channel_configuration", channelConfigurationNames) diff --git a/format/mpeg/mpeg_es.go b/format/mpeg/mpeg_es.go index cef1242e..2092f9f1 100644 --- a/format/mpeg/mpeg_es.go +++ b/format/mpeg/mpeg_es.go @@ -172,7 +172,7 @@ type esDecodeContext struct { decoderConfigs []format.MpegDecoderConfig } -func odDecodeTag(d *decode.D, edc *esDecodeContext, expectedTagID int, fn func(d *decode.D)) { +func odDecodeTag(d *decode.D, edc *esDecodeContext, _ int, fn func(d *decode.D)) { odDecoders := map[uint64]func(d *decode.D){ ES_DescrTag: func(d *decode.D) { d.FieldU16("es_id") @@ -276,7 +276,7 @@ func odDecodeTag(d *decode.D, edc *esDecodeContext, expectedTagID int, fn func(d } } -func esDecode(d *decode.D, in any) any { +func esDecode(d *decode.D, _ any) any { var edc esDecodeContext odDecodeTag(d, &edc, -1, nil) return format.MpegEsOut{DecoderConfigs: edc.decoderConfigs} diff --git a/format/mpeg/mpeg_pes.go b/format/mpeg/mpeg_pes.go index a6afdb07..6554aae8 100644 --- a/format/mpeg/mpeg_pes.go +++ b/format/mpeg/mpeg_pes.go @@ -33,7 +33,7 @@ type subStream struct { l int } -func pesDecode(d *decode.D, in any) any { +func pesDecode(d *decode.D, _ any) any { substreams := map[int]*subStream{} prefix := d.PeekBits(24) diff --git a/format/mpeg/mpeg_pes_packet.go b/format/mpeg/mpeg_pes_packet.go index 1b4c8df9..5a3c500f 100644 --- a/format/mpeg/mpeg_pes_packet.go +++ b/format/mpeg/mpeg_pes_packet.go @@ -69,7 +69,7 @@ var mpegVersion = scalar.UToDescription{ 0b10: "MPEG1", } -func pesPacketDecode(d *decode.D, in any) any { +func pesPacketDecode(d *decode.D, _ any) any { var v any d.FieldU24("prefix", d.AssertU(0b0000_0000_0000_0000_0000_0001), scalar.ActualBin) diff --git a/format/mpeg/mpeg_spu.go b/format/mpeg/mpeg_spu.go index dbd62852..8ef82253 100644 --- a/format/mpeg/mpeg_spu.go +++ b/format/mpeg/mpeg_spu.go @@ -99,7 +99,7 @@ func decodeLines(d *decode.D, lines int, width int) []string { return ls } -func spuDecode(d *decode.D, in any) any { +func spuDecode(d *decode.D, _ any) any { d.FieldU16("size") dcsqtOffset := d.FieldU16("dcsqt_offset") diff --git a/format/mpeg/mpeg_ts.go b/format/mpeg/mpeg_ts.go index 19541a1d..69575da3 100644 --- a/format/mpeg/mpeg_ts.go +++ b/format/mpeg/mpeg_ts.go @@ -19,7 +19,7 @@ func init() { // TODO: ts_packet -func tsDecode(d *decode.D, in any) any { +func tsDecode(d *decode.D, _ any) any { d.FieldU8("sync", d.AssertU(0x47), scalar.ActualHex) d.FieldBool("transport_error_indicator") d.FieldBool("payload_unit_start") diff --git a/format/mpeg/shared.go b/format/mpeg/shared.go index f7a02372..4f6185f1 100644 --- a/format/mpeg/shared.go +++ b/format/mpeg/shared.go @@ -17,7 +17,7 @@ func init() { // transform to binary using fn func makeBinaryTransformFn(fn func(r io.Reader) (io.Reader, error)) func(i *interp.Interp, c any) any { - return func(i *interp.Interp, c any) any { + return func(_ *interp.Interp, c any) any { inBR, err := interp.ToBitReader(c) if err != nil { return err diff --git a/format/msgpack/msgpack.go b/format/msgpack/msgpack.go index 0dbf14f4..917f0cdd 100644 --- a/format/msgpack/msgpack.go +++ b/format/msgpack/msgpack.go @@ -153,7 +153,7 @@ func decodeMsgPackValue(d *decode.D) { } } -func decodeMsgPack(d *decode.D, in any) any { +func decodeMsgPack(d *decode.D, _ any) any { decodeMsgPackValue(d) return nil } diff --git a/format/ogg/ogg.go b/format/ogg/ogg.go index f6073786..5e5752ff 100644 --- a/format/ogg/ogg.go +++ b/format/ogg/ogg.go @@ -57,7 +57,7 @@ type stream struct { flacStreamInfo format.FlacStreamInfo } -func decodeOgg(d *decode.D, in any) any { +func decodeOgg(d *decode.D, _ any) any { validPages := 0 streams := map[uint32]*stream{} streamsD := d.FieldArrayValue("streams") diff --git a/format/ogg/ogg_page.go b/format/ogg/ogg_page.go index 4e83eaab..61048585 100644 --- a/format/ogg/ogg_page.go +++ b/format/ogg/ogg_page.go @@ -19,7 +19,7 @@ func init() { }) } -func pageDecode(d *decode.D, in any) any { +func pageDecode(d *decode.D, _ any) any { p := format.OggPageOut{} startPos := d.Pos() diff --git a/format/opus/opus_packet.go b/format/opus/opus_packet.go index b3bc836a..92aa234e 100644 --- a/format/opus/opus_packet.go +++ b/format/opus/opus_packet.go @@ -23,7 +23,7 @@ func init() { }) } -func opusDecode(d *decode.D, in any) any { +func opusDecode(d *decode.D, _ any) any { d.Endian = decode.LittleEndian var prefix []byte diff --git a/format/pcap/pcap.go b/format/pcap/pcap.go index 2ca0452d..ca65aca7 100644 --- a/format/pcap/pcap.go +++ b/format/pcap/pcap.go @@ -39,7 +39,7 @@ func init() { }) } -func decodePcap(d *decode.D, in any) any { +func decodePcap(d *decode.D, _ any) any { endian := d.FieldU32("magic", d.AssertU(bigEndian, littleEndian), endianMap, scalar.ActualHex) switch endian { case bigEndian: diff --git a/format/pcap/pcapng.go b/format/pcap/pcapng.go index 2e9f2720..646e31fa 100644 --- a/format/pcap/pcapng.go +++ b/format/pcap/pcapng.go @@ -361,7 +361,7 @@ type decodeContext struct { flowDecoder *flowsdecoder.Decoder } -func decodePcapng(d *decode.D, in any) any { +func decodePcapng(d *decode.D, _ any) any { sectionHeaders := 0 for !d.End() { fd := flowsdecoder.New() diff --git a/format/png/png.go b/format/png/png.go index ba022bc4..28e7928e 100644 --- a/format/png/png.go +++ b/format/png/png.go @@ -77,7 +77,7 @@ var colorTypeMap = scalar.UToSymStr{ colorTypeRGBA: "rgba", } -func pngDecode(d *decode.D, in any) any { +func pngDecode(d *decode.D, _ any) any { iEndFound := false var colorType uint64 @@ -127,7 +127,7 @@ func pngDecode(d *decode.D, in any) any { switch compressionMethod { case compressionDeflate: - d.FieldFormatReaderLen("uncompressed", dataLen, zlib.NewReader, decode.FormatFn(func(d *decode.D, in any) any { + d.FieldFormatReaderLen("uncompressed", dataLen, zlib.NewReader, decode.FormatFn(func(d *decode.D, _ any) any { d.FieldUTF8("text", int(d.BitsLeft()/8)) return nil })) diff --git a/format/protobuf/protobuf_widevine.go b/format/protobuf/protobuf_widevine.go index 14aae4e5..968fd20f 100644 --- a/format/protobuf/protobuf_widevine.go +++ b/format/protobuf/protobuf_widevine.go @@ -22,7 +22,7 @@ func init() { }) } -func widevineDecode(d *decode.D, in any) any { +func widevineDecode(d *decode.D, _ any) any { widewinePb := format.ProtoBufMessage{ 1: {Type: format.ProtoBufTypeEnum, Name: "algorithm", Enums: scalar.UToSymStr{ 0: "unencrypted", diff --git a/format/raw/raw.go b/format/raw/raw.go index d6e254b5..bb07e860 100644 --- a/format/raw/raw.go +++ b/format/raw/raw.go @@ -10,6 +10,6 @@ func init() { interp.RegisterFormat(decode.Format{ Name: format.RAW, Description: "Raw bits", - DecodeFn: func(d *decode.D, in any) any { return nil }, + DecodeFn: func(d *decode.D, _ any) any { return nil }, }) } diff --git a/format/rtmp/amf0.go b/format/rtmp/amf0.go index 4b4e94b3..896b3baf 100644 --- a/format/rtmp/amf0.go +++ b/format/rtmp/amf0.go @@ -144,7 +144,7 @@ func amf0DecodeValue(d *decode.D) { } } -func amf0Decode(d *decode.D, in any) any { +func amf0Decode(d *decode.D, _ any) any { amf0DecodeValue(d) return nil } diff --git a/format/tar/tar.go b/format/tar/tar.go index f0f28cf0..e6ed845b 100644 --- a/format/tar/tar.go +++ b/format/tar/tar.go @@ -26,7 +26,7 @@ func init() { }) } -func tarDecode(d *decode.D, in any) any { +func tarDecode(d *decode.D, _ any) any { const blockBytes = 512 const blockBits = blockBytes * 8 diff --git a/format/tiff/tiff.go b/format/tiff/tiff.go index bfb09f39..70b7e01f 100644 --- a/format/tiff/tiff.go +++ b/format/tiff/tiff.go @@ -201,7 +201,7 @@ func decodeIfd(d *decode.D, s *strips, tagNames scalar.UToSymStr) int64 { return nextIfdOffset } -func tiffDecode(d *decode.D, in any) any { +func tiffDecode(d *decode.D, _ any) any { endian := d.FieldU32("endian", endianNames, scalar.ActualHex) switch endian { diff --git a/format/vorbis/vorbis_comment.go b/format/vorbis/vorbis_comment.go index e55d3a0b..0cb6b889 100644 --- a/format/vorbis/vorbis_comment.go +++ b/format/vorbis/vorbis_comment.go @@ -23,7 +23,7 @@ func init() { }) } -func commentDecode(d *decode.D, in any) any { +func commentDecode(d *decode.D, _ any) any { d.Endian = decode.LittleEndian vendorLen := d.FieldU32("vendor_length") diff --git a/format/vorbis/vorbis_packet.go b/format/vorbis/vorbis_packet.go index a6dc9b3f..2e7102a4 100644 --- a/format/vorbis/vorbis_packet.go +++ b/format/vorbis/vorbis_packet.go @@ -38,7 +38,7 @@ var packetTypeNames = map[uint]string{ packetTypeSetup: "Setup", } -func vorbisDecode(d *decode.D, in any) any { +func vorbisDecode(d *decode.D, _ any) any { d.Endian = decode.LittleEndian packetType := d.FieldUScalarFn("packet_type", func(d *decode.D) scalar.S { diff --git a/format/vpx/vp8_frame.go b/format/vpx/vp8_frame.go index cf075ed9..a9cc954d 100644 --- a/format/vpx/vp8_frame.go +++ b/format/vpx/vp8_frame.go @@ -19,7 +19,7 @@ func init() { }) } -func vp8Decode(d *decode.D, in any) any { +func vp8Decode(d *decode.D, _ any) any { var isKeyFrame bool versions := map[uint64]struct { diff --git a/format/vpx/vp9_cfm.go b/format/vpx/vp9_cfm.go index 802c36f1..78a492ac 100644 --- a/format/vpx/vp9_cfm.go +++ b/format/vpx/vp9_cfm.go @@ -18,7 +18,7 @@ func init() { }) } -func vp9CFMDecode(d *decode.D, in any) any { +func vp9CFMDecode(d *decode.D, _ any) any { for d.NotEnd() { d.FieldStruct("feature", func(d *decode.D) { id := d.FieldU8("id", vp9FeatureIDNames) diff --git a/format/vpx/vp9_frame.go b/format/vpx/vp9_frame.go index 3ec29609..cb54753d 100644 --- a/format/vpx/vp9_frame.go +++ b/format/vpx/vp9_frame.go @@ -107,7 +107,7 @@ func vp9DecodeFrameSize(d *decode.D) { d.FieldUFn("frame_height", func(d *decode.D) uint64 { return d.U16() + 1 }) } -func vp9Decode(d *decode.D, in any) any { +func vp9Decode(d *decode.D, _ any) any { // TODO: header_size at end? even for show_existing_frame? diff --git a/format/vpx/vpx_ccr.go b/format/vpx/vpx_ccr.go index 0d9be10c..e51a1f27 100644 --- a/format/vpx/vpx_ccr.go +++ b/format/vpx/vpx_ccr.go @@ -16,7 +16,7 @@ func init() { }) } -func vpxCCRDecode(d *decode.D, in any) any { +func vpxCCRDecode(d *decode.D, _ any) any { d.FieldU8("profile") d.FieldU8("level", vpxLevelNames) d.FieldU4("bit_depth") diff --git a/format/wav/wav.go b/format/wav/wav.go index a3590eae..1f9bffdf 100644 --- a/format/wav/wav.go +++ b/format/wav/wav.go @@ -201,7 +201,7 @@ func decodeChunks(d *decode.D, stringData bool) { }) } -func wavDecode(d *decode.D, in any) any { +func wavDecode(d *decode.D, _ any) any { // there are wav files in the wild with id3v2 header id3v1 footer _, _, _ = d.TryFieldFormat("header", headerFormat, nil) diff --git a/format/webp/webp.go b/format/webp/webp.go index 32bb02bc..f469e8e0 100644 --- a/format/webp/webp.go +++ b/format/webp/webp.go @@ -41,7 +41,7 @@ func decodeChunk(d *decode.D, expectedChunkID string, fn func(d *decode.D)) bool return true } -func webpDecode(d *decode.D, in any) any { +func webpDecode(d *decode.D, _ any) any { d.Endian = decode.LittleEndian d.FieldUTF8("riff_id", 4, d.AssertStr("RIFF")) diff --git a/pkg/decode/decode.go b/pkg/decode/decode.go index 80bd02ec..33f873a3 100644 --- a/pkg/decode/decode.go +++ b/pkg/decode/decode.go @@ -122,7 +122,7 @@ func decode(ctx context.Context, br bitio.ReaderAtSeeker, group Group, opts Opti } var minMaxRange ranges.Range - if err := d.Value.WalkRootPreOrder(func(v *Value, rootV *Value, depth int, rootDepth int) error { + if err := d.Value.WalkRootPreOrder(func(v *Value, _ *Value, _ int, _ int) error { minMaxRange = ranges.MinMax(minMaxRange, v.Range) v.Range.Start += decodeRange.Start v.RootReader = br @@ -281,7 +281,7 @@ func (d *D) SharedReadBuf(n int) []byte { func (d *D) FillGaps(r ranges.Range, namePrefix string) { makeWalkFn := func(fn func(iv *Value)) func(iv *Value, rootV *Value, depth int, rootDepth int) error { - return func(iv *Value, rootV *Value, depth int, rootDepth int) error { + return func(iv *Value, _ *Value, _ int, _ int) error { switch iv.V.(type) { case *Compound: default: @@ -294,7 +294,7 @@ func (d *D) FillGaps(r ranges.Range, namePrefix string) { // TODO: redo this, tries to get rid of slice grow // TODO: pre-sorted somehow? n := 0 - _ = d.Value.WalkRootPreOrder(makeWalkFn(func(iv *Value) { n++ })) + _ = d.Value.WalkRootPreOrder(makeWalkFn(func(_ *Value) { n++ })) valueRanges := make([]ranges.Range, n) i := 0 _ = d.Value.WalkRootPreOrder(makeWalkFn(func(iv *Value) { diff --git a/pkg/decode/format.go b/pkg/decode/format.go index 534b4c24..ca0cfada 100644 --- a/pkg/decode/format.go +++ b/pkg/decode/format.go @@ -14,7 +14,7 @@ type Format struct { ProbeOrder int // probe order is from low to hi value then by name Description string Groups []string - DecodeFn func(d *D, in any) any + DecodeFn func(d *D, _ any) any DecodeInArg any DecodeOutType any RootArray bool @@ -46,7 +46,7 @@ type FormatHelp struct { References []HelpReference } -func FormatFn(d func(d *D, in any) any) Group { +func FormatFn(d func(d *D, _ any) any) Group { return Group{{ DecodeFn: d, }} diff --git a/pkg/interp/interp.go b/pkg/interp/interp.go index 6181c451..73052497 100644 --- a/pkg/interp/interp.go +++ b/pkg/interp/interp.go @@ -68,7 +68,7 @@ func init() { RegisterFunc0("_exttype", (*Interp)._extType) RegisterFunc0("_global_state", func(i *Interp, c any) any { return *i.state }) - RegisterFunc1("_global_state", func(i *Interp, c any, v any) any { *i.state = v; return v }) + RegisterFunc1("_global_state", func(i *Interp, _ any, v any) any { *i.state = v; return v }) RegisterFunc0("history", (*Interp).history) RegisterIter1("_display", (*Interp)._display)