From 71afd7b11a52d74dfc85634cc7cbd74bbdc8989f Mon Sep 17 00:00:00 2001 From: Jille Timmermans Date: Fri, 17 Mar 2023 11:12:02 +0100 Subject: [PATCH] cleanup: Use io.ReadAll to fully read the buffer Also don't ignore errors other than io.EOF, but return false for them too --- video.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/video.go b/video.go index 5eb0101..5ec7de4 100644 --- a/video.go +++ b/video.go @@ -232,16 +232,10 @@ func (video *Video) Read() bool { } } - total := 0 - for total < video.width*video.height*video.depth { - n, err := video.pipe.Read(video.framebuffer[total:]) - if err == io.EOF { - video.Close() - return false - } - total += n + if _, err := io.ReadFull(video.pipe, video.framebuffer); err != nil { + video.Close() + return false } - return true }