github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/pkg/convert/pprof/streaming/vt_function.go (about) 1 package streaming 2 3 import ( 4 "fmt" 5 "io" 6 "math" 7 ) 8 9 // revive:disable-next-line:cognitive-complexity,cyclomatic necessary complexity 10 func (m *function) UnmarshalVT(dAtA []byte) error { 11 m.id = 0 12 m.name = 0 13 m.filename = 0 14 l := len(dAtA) 15 iNdEx := 0 16 for iNdEx < l { 17 //preIndex := iNdEx 18 var wire uint64 19 for shift := uint(0); ; shift += 7 { 20 if shift >= 64 { 21 return ErrIntOverflow 22 } 23 if iNdEx >= l { 24 return io.ErrUnexpectedEOF 25 } 26 b := dAtA[iNdEx] 27 iNdEx++ 28 wire |= uint64(b&0x7F) << shift 29 if b < 0x80 { 30 break 31 } 32 } 33 fieldNum := int32(wire >> 3) 34 wireType := int(wire & 0x7) 35 if wireType == 4 { 36 return fmt.Errorf("proto: Function: wiretype end group for non-group") 37 } 38 if fieldNum <= 0 { 39 return fmt.Errorf("proto: Function: illegal tag %d (wire type %d)", fieldNum, wire) 40 } 41 switch fieldNum { 42 case 1: 43 if wireType != 0 { 44 return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) 45 } 46 m.id = 0 47 for shift := uint(0); ; shift += 7 { 48 if shift >= 64 { 49 return ErrIntOverflow 50 } 51 if iNdEx >= l { 52 return io.ErrUnexpectedEOF 53 } 54 b := dAtA[iNdEx] 55 iNdEx++ 56 m.id |= uint64(b&0x7F) << shift 57 if b < 0x80 { 58 break 59 } 60 } 61 case 2: 62 if wireType != 0 { 63 return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) 64 } 65 name := int64(0) 66 for shift := uint(0); ; shift += 7 { 67 if shift >= 64 { 68 return ErrIntOverflow 69 } 70 if iNdEx >= l { 71 return io.ErrUnexpectedEOF 72 } 73 b := dAtA[iNdEx] 74 iNdEx++ 75 name |= int64(b&0x7F) << shift 76 if b < 0x80 { 77 break 78 } 79 } 80 if name < 0 || name > math.MaxInt32 { 81 return fmt.Errorf("wromg mamae %d", name) 82 } 83 m.name = int32(name) 84 case 3: 85 if wireType != 0 { 86 return fmt.Errorf("proto: wrong wireType = %d for field SystemName", wireType) 87 } 88 //m.SystemName = 0 89 for shift := uint(0); ; shift += 7 { 90 if shift >= 64 { 91 return ErrIntOverflow 92 } 93 if iNdEx >= l { 94 return io.ErrUnexpectedEOF 95 } 96 b := dAtA[iNdEx] 97 iNdEx++ 98 //m.SystemName |= int64(b&0x7F) << shift 99 if b < 0x80 { 100 break 101 } 102 } 103 case 4: 104 if wireType != 0 { 105 return fmt.Errorf("proto: wrong wireType = %d for field Filename", wireType) 106 } 107 filename := int64(0) 108 for shift := uint(0); ; shift += 7 { 109 if shift >= 64 { 110 return ErrIntOverflow 111 } 112 if iNdEx >= l { 113 return io.ErrUnexpectedEOF 114 } 115 b := dAtA[iNdEx] 116 iNdEx++ 117 filename |= int64(b&0x7F) << shift 118 if b < 0x80 { 119 break 120 } 121 } 122 if filename < 0 || filename > math.MaxInt32 { 123 return fmt.Errorf("wromg filename %d", filename) 124 } 125 m.filename = int32(filename) 126 case 5: 127 if wireType != 0 { 128 return fmt.Errorf("proto: wrong wireType = %d for field StartLine", wireType) 129 } 130 //m.StartLine = 0 131 for shift := uint(0); ; shift += 7 { 132 if shift >= 64 { 133 return ErrIntOverflow 134 } 135 if iNdEx >= l { 136 return io.ErrUnexpectedEOF 137 } 138 b := dAtA[iNdEx] 139 iNdEx++ 140 //m.StartLine |= int64(b&0x7F) << shift 141 if b < 0x80 { 142 break 143 } 144 } 145 default: 146 return ErrUnknownField 147 //iNdEx = preIndex 148 //skippy, err := skip(dAtA[iNdEx:]) 149 //if err != nil { 150 // return err 151 //} 152 //if (skippy < 0) || (iNdEx+skippy) < 0 { 153 // return ErrInvalidLength 154 //} 155 //if (iNdEx + skippy) > l { 156 // return io.ErrUnexpectedEOF 157 //} 158 //m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) 159 //iNdEx += skippy 160 } 161 } 162 163 if iNdEx > l { 164 return io.ErrUnexpectedEOF 165 } 166 return nil 167 }