From 0203dd6bc427249af263624d1f58e0c164784d85 Mon Sep 17 00:00:00 2001 From: David Howden Date: Sun, 3 May 2015 09:58:08 +1000 Subject: [PATCH] Tidy up unsynchroniser.Read some more --- id3v2.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/id3v2.go b/id3v2.go index 539efe7..cd63f33 100644 --- a/id3v2.go +++ b/id3v2.go @@ -244,11 +244,11 @@ type unsynchroniser struct { } // filter io.Reader which skip the Unsynchronisation bytes -func (r *unsynchroniser) Read(p []byte) (i int, err error) { +func (r *unsynchroniser) Read(p []byte) (int, error) { b := make([]byte, 1) + i := 0 for i < len(p) { - x, err := r.Reader.Read(b) - if err != nil || x == 0 { + if n, err := r.Reader.Read(b); err != nil || n == 0 { return i, err } if r.ff && b[0] == 0x00 { @@ -259,7 +259,7 @@ func (r *unsynchroniser) Read(p []byte) (i int, err error) { i++ r.ff = (b[0] == 0xFF) } - return + return i, nil } // ReadID3v2Tags parses ID3v2.{2,3,4} tags from the io.ReadSeeker into a Metadata, returning