cleanup: Use io.ReadAll to fully read the buffer

Also don't ignore errors other than io.EOF, but return false for them
too
This commit is contained in:
Jille Timmermans 2023-03-17 11:12:02 +01:00
parent 2e92f00374
commit 71afd7b11a

View file

@ -232,16 +232,10 @@ func (video *Video) Read() bool {
} }
} }
total := 0 if _, err := io.ReadFull(video.pipe, video.framebuffer); err != nil {
for total < video.width*video.height*video.depth {
n, err := video.pipe.Read(video.framebuffer[total:])
if err == io.EOF {
video.Close() video.Close()
return false return false
} }
total += n
}
return true return true
} }