Skip to content

Commit e1aa7f0

Browse files
committed
fix: use typeSize instead of hard coded '4'
1 parent 2c1723a commit e1aa7f0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

agent/protocol/decoder.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func ExtractBEInt[TIntType int8 | int16 | int32 | uint32 | uint8 | int64](d *Bin
116116

117117
func ExtractLEInt[TIntType int32 | uint32 | uint8](d *BinaryDecoder) (TIntType, error) {
118118
typeSize := int(reflect.TypeOf(TIntType(0)).Size())
119-
if len(d.str) < 4 {
119+
if len(d.str) < typeSize {
120120
return 0, ResourceNotAvailble
121121
}
122122
var x TIntType = 0
@@ -142,7 +142,7 @@ func BEndianBytesToInt[TIntType int32 | uint32 | uint8](d *BinaryDecoder) TIntTy
142142

143143
func LEndianBytesToInt[TIntType int32 | uint32 | uint8](d *BinaryDecoder) TIntType {
144144
typeSize := int(reflect.TypeOf(TIntType(0)).Size())
145-
if len(d.str) < 4 {
145+
if len(d.str) < typeSize {
146146
return 0
147147
}
148148
var x TIntType = 0

0 commit comments

Comments
 (0)