Skip to content

Commit

Permalink
Lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
samitAtsyna committed Jun 29, 2024
1 parent c65d740 commit d61b730
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
5 changes: 1 addition & 4 deletions application_packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (a ApplicationDefined) Marshal() ([]byte, error) {
}

rawPacket := make([]byte, packetSize)
copy(rawPacket[:], headerBytes)
copy(rawPacket, headerBytes)
binary.BigEndian.PutUint32(rawPacket[4:8], a.SSRC)
copy(rawPacket[8:12], a.Name[:])
copy(rawPacket[12:], a.Data)
Expand All @@ -62,7 +62,6 @@ func (a ApplicationDefined) Marshal() ([]byte, error) {

// Unmarshal parses the given raw packet into an AppPacket, handling padding.
func (a *ApplicationDefined) Unmarshal(rawPacket []byte) error {

/*
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
Expand Down Expand Up @@ -114,7 +113,5 @@ func (a *ApplicationDefined) MarshalSize() int {
if paddingSize == 4 {
paddingSize = 0
}

return 12 + dataLength + paddingSize

}
15 changes: 9 additions & 6 deletions application_packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ func TestTApplicationPacketUnmarshal(t *testing.T) {
Name: [4]byte{0x53, 0x55, 0x49, 0x54},
Data: []byte{0x41, 0x42, 0x43, 0x44},
},
}, {
},
{
Name: "validWithPadding",
Data: []byte{
// Application Packet Type + Length(0x0002) (0xA0 has padding bit set)
Expand All @@ -52,7 +53,8 @@ func TestTApplicationPacketUnmarshal(t *testing.T) {
Name: [4]byte{0x53, 0x55, 0x49, 0x54},
Data: []byte{0x41, 0x42, 0x43, 0x44, 0x45},
},
}, {
},
{
Name: "invalidAppPacketLengthField",
Data: []byte{
// Application Packet Type + invalid Length(0x00FF)
Expand All @@ -65,7 +67,8 @@ func TestTApplicationPacketUnmarshal(t *testing.T) {
0x41, 0x42, 0x43, 0x44,
},
WantError: errAppDefinedInvalidLength,
}, {
},
{
Name: "invalidPacketLengthTooShort",
Data: []byte{
// Application Packet Type + Length(0x0002). Total packet length is less than 12 bytes
Expand Down Expand Up @@ -119,9 +122,9 @@ func TestTApplicationPacketUnmarshal(t *testing.T) {
if apk.SSRC != 0x4baae1ab {
t.Fatalf("SSRC %q result: got packet SSRC %x instead of %x", test.Name, apk.SSRC, 0x4baae1ab)
}

}
}

func TestTApplicationPacketMarshal(t *testing.T) {
for _, test := range []struct {
Name string
Expand Down Expand Up @@ -185,12 +188,12 @@ func TestTApplicationPacketMarshal(t *testing.T) {
continue
}

// Check for expected succesful result
// Check for expected successful result
if got, want := rawPacket, test.Want; !reflect.DeepEqual(got, want) {
t.Fatalf("Unmarshal %q result: got %v, want %v", test.Name, got, want)
}

// Check if MarshalSize() is matching the marshalled bytes
// Check if MarshalSize() is matching the marshaled bytes
marshalSize := test.Packet.MarshalSize()
if marshalSize != len(rawPacket) {
t.Fatalf("MarshalSize %q result: got %d bytes instead of %d", test.Name, len(rawPacket), marshalSize)
Expand Down
1 change: 0 additions & 1 deletion errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,4 @@ var (
errBadReadParameter = errors.New("rtcp: cannot read into non-pointer")
errAppDefinedInvalidLength = errors.New("rtcp: application defined packet type invalid length")
errAppDefinedDataTooLarge = errors.New("rtcp: application defined packet data is too large")

)

0 comments on commit d61b730

Please sign in to comment.