Staticcheck (#464)

Using `go get -u honnef.co/go/tools/cmd/staticcheck`
Uneaarthed a couple of real bugs
This commit is contained in:
Raja Subramanian
2022-02-25 12:04:08 +05:30
committed by GitHub
parent 5a4181b581
commit 0170cc1cb6
19 changed files with 32 additions and 41 deletions
-1
View File
@@ -147,7 +147,6 @@ func TestNack(t *testing.T) {
func TestNewBuffer(t *testing.T) {
type args struct {
options Options
ssrc uint32
}
tests := []struct {
name string
+1 -1
View File
@@ -136,7 +136,7 @@ func (n *nack) getNack(now time.Time, rtt uint32) (shouldSend bool, shouldRemove
var requiredInterval time.Duration
if n.tries > 0 {
// exponentially backoff retries, but cap maximum spacing between retries
requiredInterval := maxInterval
requiredInterval = maxInterval
backoffInterval := time.Duration(float64(rtt)*math.Pow(backoffFactor, float64(n.tries-1))) * time.Millisecond
if backoffInterval < requiredInterval {
requiredInterval = backoffInterval
+1 -1
View File
@@ -120,7 +120,7 @@ func (cs *ConnectionStats) updateScore() float32 {
maxRTT := uint32(0)
maxJitter := uint32(0)
for _, qw := range cs.qualityWindows {
expectedPacketsInInterval += qw.endSeqNum - qw.endSeqNum + 1
expectedPacketsInInterval += qw.endSeqNum - qw.startSeqNum + 1
lostPacketsInInterval += qw.endPacketsLost - qw.startPacketsLost
if qw.maxRTT > maxRTT {
maxRTT = qw.maxRTT
+9 -9
View File
@@ -984,7 +984,7 @@ func TestForwarderGetTranslationParamsAudio(t *testing.T) {
SSRC: 0x12345678,
PayloadSize: 20,
}
extPkt, err := testutils.GetTestExtPacket(params)
extPkt, _ := testutils.GetTestExtPacket(params)
// should lock onto the first packet
expectedTP := TranslationParams{
@@ -1015,7 +1015,7 @@ func TestForwarderGetTranslationParamsAudio(t *testing.T) {
SSRC: 0x12345678,
PayloadSize: 20,
}
extPkt, err = testutils.GetTestExtPacket(params)
extPkt, _ = testutils.GetTestExtPacket(params)
expectedTP = TranslationParams{
shouldDrop: true,
@@ -1032,7 +1032,7 @@ func TestForwarderGetTranslationParamsAudio(t *testing.T) {
Timestamp: 0xabcdef,
SSRC: 0x12345678,
}
extPkt, err = testutils.GetTestExtPacket(params)
extPkt, _ = testutils.GetTestExtPacket(params)
expectedTP = TranslationParams{
shouldDrop: true,
@@ -1049,7 +1049,7 @@ func TestForwarderGetTranslationParamsAudio(t *testing.T) {
SSRC: 0x12345678,
PayloadSize: 20,
}
extPkt, err = testutils.GetTestExtPacket(params)
extPkt, _ = testutils.GetTestExtPacket(params)
expectedTP = TranslationParams{
rtp: &TranslationParamsRTP{
@@ -1069,7 +1069,7 @@ func TestForwarderGetTranslationParamsAudio(t *testing.T) {
Timestamp: 0xabcdef,
SSRC: 0x12345678,
}
extPkt, err = testutils.GetTestExtPacket(params)
extPkt, _ = testutils.GetTestExtPacket(params)
expectedTP = TranslationParams{
rtp: &TranslationParamsRTP{
@@ -1090,7 +1090,7 @@ func TestForwarderGetTranslationParamsAudio(t *testing.T) {
SSRC: 0x12345678,
PayloadSize: 20,
}
extPkt, err = testutils.GetTestExtPacket(params)
extPkt, _ = testutils.GetTestExtPacket(params)
expectedTP = TranslationParams{
rtp: &TranslationParamsRTP{
@@ -1111,7 +1111,7 @@ func TestForwarderGetTranslationParamsAudio(t *testing.T) {
SSRC: 0x87654321,
PayloadSize: 20,
}
extPkt, err = testutils.GetTestExtPacket(params)
extPkt, _ = testutils.GetTestExtPacket(params)
expectedTP = TranslationParams{
rtp: &TranslationParamsRTP{
@@ -1387,7 +1387,7 @@ func TestForwarderGetTranslationParamsVideo(t *testing.T) {
Timestamp: 0xabcdef,
SSRC: 0x12345678,
}
extPkt, err = testutils.GetTestExtPacket(params)
extPkt, _ = testutils.GetTestExtPacket(params)
expectedTP = TranslationParams{
rtp: &TranslationParamsRTP{
@@ -1407,7 +1407,7 @@ func TestForwarderGetTranslationParamsVideo(t *testing.T) {
Timestamp: 0xabcdef,
SSRC: 0x12345678,
}
extPkt, err = testutils.GetTestExtPacket(params)
extPkt, _ = testutils.GetTestExtPacket(params)
expectedTP = TranslationParams{
rtp: &TranslationParamsRTP{
+8 -9
View File
@@ -32,15 +32,14 @@ type rtpExtInfo struct {
type Responder struct {
sync.Mutex
extInfo []rtpExtInfo
lastReport int64
cycles uint32
lastExtSN uint32
pktCtn uint8
lastSn uint16
lastExtInfo uint16
mSSRC uint32
sSSRC uint32
extInfo []rtpExtInfo
lastReport int64
cycles uint32
lastExtSN uint32
pktCtn uint8
lastSn uint16
mSSRC uint32
sSSRC uint32
len uint16
deltaLen uint16