update linter settings (#225)

This commit is contained in:
Alessandro Ros
2025-07-26 16:27:23 +02:00
committed by GitHub
parent ac84aa7ad9
commit 8a1ed14e94
16 changed files with 51 additions and 40 deletions

View File

@@ -67,6 +67,9 @@ linters:
disable:
- fieldalignment
- reflectvaluecompare
settings:
shadow:
strict: true
formatters:
enable:

View File

@@ -175,7 +175,8 @@ func (c *SequenceHeader_ColorConfig) unmarshal(seqProfile uint8, buf []byte, pos
}
if c.SubsamplingX && c.SubsamplingY {
tmp, err := bits.ReadBits(buf, pos, 2)
var tmp uint64
tmp, err = bits.ReadBits(buf, pos, 2)
if err != nil {
return err
}

View File

@@ -357,7 +357,7 @@ func (v *SPS_VUI) unmarshal(buf []byte, pos *int) error {
if bitstreamRestrictionFlag {
v.BitstreamRestriction = &SPS_BitstreamRestriction{}
err := v.BitstreamRestriction.unmarshal(buf, pos)
err = v.BitstreamRestriction.unmarshal(buf, pos)
if err != nil {
return err
}
@@ -706,7 +706,7 @@ func (s *SPS) Unmarshal(buf []byte) error {
if vuiParametersPresentFlag {
s.VUI = &SPS_VUI{}
err := s.VUI.unmarshal(buf, &pos)
err = s.VUI.unmarshal(buf, &pos)
if err != nil {
return err
}

View File

@@ -98,7 +98,8 @@ func getPTSDTSDiff(buf []byte, sps *SPS, pps *PPS) (uint32, error) {
}
b := int(math.Ceil(math.Log2(float64(len(sps.ShortTermRefPicSets)))))
tmp, err := bits.ReadBits(buf, &pos, b)
var tmp uint64
tmp, err = bits.ReadBits(buf, &pos, b)
if err != nil {
return 0, err
}

View File

@@ -298,7 +298,7 @@ func (v *SPS_VUI) unmarshal(buf []byte, pos *int) error {
if timingInfoPresentFlag {
v.TimingInfo = &SPS_TimingInfo{}
err := v.TimingInfo.unmarshal(buf, pos)
err = v.TimingInfo.unmarshal(buf, pos)
if err != nil {
return err
}
@@ -382,7 +382,7 @@ func (p *SPS_ProfileTierLevel) unmarshal(buf []byte, pos *int, maxSubLayersMinus
p.SubLayerProfilePresentFlag = make([]bool, maxSubLayersMinus1)
p.SubLayerLevelPresentFlag = make([]bool, maxSubLayersMinus1)
err := bits.HasSpace(buf, *pos, int(2*maxSubLayersMinus1))
err = bits.HasSpace(buf, *pos, int(2*maxSubLayersMinus1))
if err != nil {
return err
}
@@ -394,7 +394,7 @@ func (p *SPS_ProfileTierLevel) unmarshal(buf []byte, pos *int, maxSubLayersMinus
}
if maxSubLayersMinus1 > 0 {
err := bits.HasSpace(buf, *pos, int(8-maxSubLayersMinus1)*2)
err = bits.HasSpace(buf, *pos, int(8-maxSubLayersMinus1)*2)
if err != nil {
return err
}
@@ -568,7 +568,8 @@ func (r *SPS_ShortTermRefPicSet) unmarshal(buf []byte, pos *int, stRpsIdx uint32
r.UsedByCurrPicS0Flag = make([]bool, r.NumNegativePics)
for i := uint32(0); i < r.NumNegativePics; i++ {
deltaPocS0Minus1, err := bits.ReadGolombUnsigned(buf, pos)
var deltaPocS0Minus1 uint32
deltaPocS0Minus1, err = bits.ReadGolombUnsigned(buf, pos)
if err != nil {
return err
}
@@ -595,7 +596,8 @@ func (r *SPS_ShortTermRefPicSet) unmarshal(buf []byte, pos *int, stRpsIdx uint32
r.UsedByCurrPicS1Flag = make([]bool, r.NumPositivePics)
for i := uint32(0); i < r.NumPositivePics; i++ {
deltaPocS1Minus1, err := bits.ReadGolombUnsigned(buf, pos)
var deltaPocS1Minus1 uint32
deltaPocS1Minus1, err = bits.ReadGolombUnsigned(buf, pos)
if err != nil {
return err
}
@@ -934,7 +936,7 @@ func (s *SPS) Unmarshal(buf []byte) error {
if vuiParametersPresentFlag {
s.VUI = &SPS_VUI{}
err := s.VUI.unmarshal(buf, &pos)
err = s.VUI.unmarshal(buf, &pos)
if err != nil {
return err
}

View File

@@ -177,7 +177,7 @@ func (c AudioSpecificConfig) marshalSizeBits() int {
}
if c.ExtensionType == ObjectTypeSBR || c.ExtensionType == ObjectTypePS {
_, ok := reverseSampleRates[c.ExtensionSampleRate]
_, ok = reverseSampleRates[c.ExtensionSampleRate]
if !ok {
n += 28
} else {
@@ -246,7 +246,7 @@ func (c AudioSpecificConfig) marshalToBits(buf []byte, pos *int) error {
bits.WriteBitsUnsafe(buf, pos, uint64(channelConfig), 4)
if c.ExtensionType == ObjectTypeSBR || c.ExtensionType == ObjectTypePS {
sampleRateIndex, ok := reverseSampleRates[c.ExtensionSampleRate]
sampleRateIndex, ok = reverseSampleRates[c.ExtensionSampleRate]
if !ok {
bits.WriteBitsUnsafe(buf, pos, uint64(0x0F), 4)
bits.WriteBitsUnsafe(buf, pos, uint64(c.ExtensionSampleRate), 24)

View File

@@ -29,7 +29,8 @@ func (m *payloadMux) unmarshalBits(buf []byte, pos *int, li *payloadLengthInfo)
payload := make([]byte, payloadLength)
for i := range payloadLength {
byt, err := bits.ReadBits(buf, pos, 8)
var byt uint64
byt, err = bits.ReadBits(buf, pos, 8)
if err != nil {
return err
}

View File

@@ -181,7 +181,8 @@ func (c *StreamMuxConfig) unmarshalBits(buf []byte, pos *int) error {
}
if c.CRCCheckPresent {
tmp, err := bits.ReadBits(buf, pos, 8)
var tmp uint64
tmp, err = bits.ReadBits(buf, pos, 8)
if err != nil {
return err
}

View File

@@ -40,14 +40,13 @@ func (c *Header_ColorConfig) unmarshal(profile uint8, buf []byte, pos *int) erro
c.ColorSpace = uint8(tmp)
if c.ColorSpace != 7 {
var err error
c.ColorRange, err = bits.ReadFlag(buf, pos)
if err != nil {
return err
}
if profile == 1 || profile == 3 {
err := bits.HasSpace(buf, *pos, 3)
err = bits.HasSpace(buf, *pos, 3)
if err != nil {
return err
}
@@ -66,7 +65,7 @@ func (c *Header_ColorConfig) unmarshal(profile uint8, buf []byte, pos *int) erro
c.SubsamplingX = false
c.SubsamplingY = false
err := bits.HasSpace(buf, *pos, 1)
err = bits.HasSpace(buf, *pos, 1)
if err != nil {
return err
}
@@ -158,7 +157,7 @@ func (h *Header) Unmarshal(buf []byte) error {
h.ErrorResilientMode = bits.ReadFlagUnsafe(buf, &pos)
if !h.NonKeyFrame {
err := bits.HasSpace(buf, pos, 24)
err = bits.HasSpace(buf, pos, 24)
if err != nil {
return err
}

View File

@@ -23,7 +23,7 @@ func av1FindSequenceHeader(buf []byte) ([]byte, error) {
for _, obu := range tu {
var h av1.OBUHeader
err := h.Unmarshal(obu)
err = h.Unmarshal(obu)
if err != nil {
return nil, err
}
@@ -472,7 +472,7 @@ func (i *Init) Unmarshal(r io.ReadSeeker) error {
}
var c mpeg4audio.AudioSpecificConfig
err := c.Unmarshal(spec)
err = c.Unmarshal(spec)
if err != nil {
return nil, fmt.Errorf("invalid MPEG-4 Audio configuration: %w", err)
}

View File

@@ -73,7 +73,7 @@ func (h *opusControlHeader) unmarshal(buf []byte) (int, error) {
}
if h.StartTrimFlag {
err := bits.HasSpace(buf, pos, 16)
err = bits.HasSpace(buf, pos, 16)
if err != nil {
return 0, err
}
@@ -83,7 +83,7 @@ func (h *opusControlHeader) unmarshal(buf []byte) (int, error) {
}
if h.EndTrimFlag {
err := bits.HasSpace(buf, pos, 16)
err = bits.HasSpace(buf, pos, 16)
if err != nil {
return 0, err
}
@@ -93,7 +93,8 @@ func (h *opusControlHeader) unmarshal(buf []byte) (int, error) {
}
if h.ControlExtensionFlag {
tmp, err := bits.ReadBits(buf, &pos, 8)
var tmp uint64
tmp, err = bits.ReadBits(buf, &pos, 8)
if err != nil {
return 0, err
}

View File

@@ -87,8 +87,8 @@ func readMetadataAUWrapper(in []byte) ([]byte, error) {
out := au.AUCellData
for {
var au metadataAUCell
n2, err := au.unmarshal(in[n:])
var n2 int
n2, err = au.unmarshal(in[n:])
if err != nil {
return nil, err
}
@@ -197,7 +197,7 @@ func (r *Reader) Initialize() error {
for i, es := range pmt.ElementaryStreams {
var track Track
err := track.unmarshal(dem, es)
err = track.unmarshal(dem, es)
if err != nil {
return err
}

View File

@@ -1087,7 +1087,7 @@ func TestReader(t *testing.T) {
}
for {
err := r.Read()
err = r.Read()
if errors.Is(err, io.EOF) {
break
}
@@ -1214,7 +1214,7 @@ func TestReaderKLVAsync(t *testing.T) {
})
for {
err := r.Read()
err = r.Read()
if errors.Is(err, io.EOF) {
break
}
@@ -1525,7 +1525,7 @@ func TestReaderDecodeErrors(t *testing.T) {
})
for {
err := r.Read()
err = r.Read()
if err != nil {
require.ErrorIs(t, io.EOF, err)
break
@@ -1684,7 +1684,7 @@ func TestReaderSkipGarbage(t *testing.T) {
})
for {
err := r.Read()
err = r.Read()
if err != nil {
require.ErrorIs(t, io.EOF, err)
break

View File

@@ -40,7 +40,7 @@ func TestTimeDecoderOverflow(t *testing.T) {
// overflow
i += 90000 * stride
secs += stride
ts := d.Decode(i)
ts = d.Decode(i)
require.Equal(t, secs*90000, ts)
// reach 2^32 slowly

View File

@@ -116,7 +116,8 @@ func TestWriterKLVAsync(t *testing.T) {
var pkts []*astits.Packet
for {
pkt, err := dem.NextPacket()
var pkt *astits.Packet
pkt, err = dem.NextPacket()
if errors.Is(err, astits.ErrNoMorePackets) {
break
}
@@ -240,7 +241,7 @@ func TestWriterReaderLongKLVSync(t *testing.T) {
})
for {
err := r.Read()
err = r.Read()
if errors.Is(err, io.EOF) {
break
}

View File

@@ -32,7 +32,7 @@ func av1FindSequenceHeader(buf []byte) ([]byte, error) {
for _, obu := range tu {
var h av1.OBUHeader
err := h.Unmarshal(obu)
err = h.Unmarshal(obu)
if err != nil {
return nil, err
}
@@ -524,7 +524,7 @@ func (p *Presentation) Unmarshal(r io.ReadSeeker) error {
}
var c mpeg4audio.AudioSpecificConfig
err := c.Unmarshal(spec)
err = c.Unmarshal(spec)
if err != nil {
return nil, fmt.Errorf("invalid MPEG-4 Audio configuration: %w", err)
}
@@ -808,14 +808,14 @@ func (p *Presentation) Unmarshal(r io.ReadSeeker) error {
curTrack.Samples[i].PayloadSize = sampleSize
curTrack.Samples[i].GetPayload = func() ([]byte, error) {
_, err = r.Seek(int64(sampleOffset), io.SeekStart)
_, err2 := r.Seek(int64(sampleOffset), io.SeekStart)
if err != nil {
return nil, err
return nil, err2
}
buf := make([]byte, sampleSize)
_, err = io.ReadFull(r, buf)
return buf, err
_, err2 = io.ReadFull(r, buf)
return buf, err2
}
off += sampleSize
@@ -1021,7 +1021,8 @@ func (p *Presentation) marshalMdat(w io.Writer, dataSize uint32, sortedSamples [
}
for _, sa := range sortedSamples {
pl, err := sa.GetPayload()
var pl []byte
pl, err = sa.GetPayload()
if err != nil {
return err
}