From bf289221deb159f4537c5fa900b0a81041178a63 Mon Sep 17 00:00:00 2001 From: Saxon Date: Wed, 22 Jan 2020 13:08:02 +1030 Subject: [PATCH] codec/h264/lex.go: simplified return logic --- codec/h264/lex.go | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/codec/h264/lex.go b/codec/h264/lex.go index 3d9fb8a4..633d3f53 100644 --- a/codec/h264/lex.go +++ b/codec/h264/lex.go @@ -67,16 +67,12 @@ func Lex(dst io.Writer, src io.Reader, delay time.Duration) error { copy(buf, h264Prefix[:]) writeOut := false -outer: for { var b byte var err error buf, b, err = c.ScanUntil(buf, 0x00) if err != nil { - if err != io.EOF { - return err - } - break + return err } for n := 1; b == 0x0 && n < 4; n++ { @@ -85,7 +81,7 @@ outer: if err != io.EOF { return err } - break outer + return io.ErrUnexpectedEOF } buf = append(buf, b) @@ -110,7 +106,7 @@ outer: if err != io.EOF { return err } - break outer + return io.ErrUnexpectedEOF } buf = append(buf, b) @@ -128,8 +124,4 @@ outer: } } } - if len(buf) == len(h264Prefix) { - return io.EOF - } - return io.ErrUnexpectedEOF }