nolint:cyclop
(r util.Reader)
| 261 | |
| 262 | //nolint:cyclop |
| 263 | func readCoder(r util.Reader) (*coder, error) { |
| 264 | c := new(coder) |
| 265 | |
| 266 | v, err := r.ReadByte() |
| 267 | if err != nil { |
| 268 | return nil, fmt.Errorf("readCoder: ReadByte error: %w", err) |
| 269 | } |
| 270 | |
| 271 | c.id = make([]byte, v&0xf) |
| 272 | if n, err := r.Read(c.id); err != nil || n != int(v&0xf) { |
| 273 | if err != nil { |
| 274 | return nil, fmt.Errorf("readCoder: Read error: %w", err) |
| 275 | } |
| 276 | |
| 277 | return nil, errIncompleteRead |
| 278 | } |
| 279 | |
| 280 | if v&0x10 != 0 { |
| 281 | c.in, err = readUint64Bounded(r, true) |
| 282 | if err != nil { |
| 283 | return nil, err |
| 284 | } |
| 285 | |
| 286 | c.out, err = readUint64Bounded(r, true) |
| 287 | if err != nil { |
| 288 | return nil, err |
| 289 | } |
| 290 | } else { |
| 291 | c.in, c.out = 1, 1 |
| 292 | } |
| 293 | |
| 294 | if v&0x20 != 0 { |
| 295 | size, err := readUint64Bounded(r, true) |
| 296 | if err != nil { |
| 297 | return nil, err |
| 298 | } |
| 299 | |
| 300 | c.properties = make([]byte, size) |
| 301 | if n, err := r.Read(c.properties); err != nil || uint64(n) != size { //nolint:gosec |
| 302 | if err != nil { |
| 303 | return nil, fmt.Errorf("readCoder: Read error: %w", err) |
| 304 | } |
| 305 | |
| 306 | return nil, errIncompleteRead |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | return c, nil |
| 311 | } |
| 312 | |
| 313 | //nolint:cyclop,funlen |
| 314 | func readFolder(r util.Reader) (*folder, error) { |
no test coverage detected
searching dependent graphs…