From: Ayan George Date: Fri, 8 May 2020 04:13:44 +0000 (-0400) Subject: image/png: remove too early declaration of "n" X-Git-Tag: go1.15beta1~168 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=c844fec7f6097289abb657d9a334cce97786c48c;p=gostls13.git image/png: remove too early declaration of "n" Before this commit, the code declares and assigns "n" with the result of io.ReadFull() -- but the value is not used. The variable is then reused later in the function. This commit removes the first declaration of "n" and declares it closer to where it is used. Change-Id: I7ffe19a10f2a563c306bb6fe6562493435b9dc5a Reviewed-on: https://go-review.googlesource.com/c/go/+/232917 Reviewed-by: Rob Pike --- diff --git a/src/image/png/reader.go b/src/image/png/reader.go index 5521b39bb0..910520bd4b 100644 --- a/src/image/png/reader.go +++ b/src/image/png/reader.go @@ -862,8 +862,7 @@ func (d *decoder) parseIEND(length uint32) error { func (d *decoder) parseChunk() error { // Read the length and chunk type. - n, err := io.ReadFull(d.r, d.tmp[:8]) - if err != nil { + if _, err := io.ReadFull(d.r, d.tmp[:8]); err != nil { return err } length := binary.BigEndian.Uint32(d.tmp[:4]) @@ -920,7 +919,7 @@ func (d *decoder) parseChunk() error { // Ignore this chunk (of a known length). var ignored [4096]byte for length > 0 { - n, err = io.ReadFull(d.r, ignored[:min(len(ignored), int(length))]) + n, err := io.ReadFull(d.r, ignored[:min(len(ignored), int(length))]) if err != nil { return err }