aboutsummaryrefslogtreecommitdiff
path: root/src/image
diff options
context:
space:
mode:
authorAyan George <ayan@ayan.net>2020-05-08 00:13:44 -0400
committerRob Pike <r@golang.org>2020-05-08 22:01:08 +0000
commitc844fec7f6097289abb657d9a334cce97786c48c (patch)
tree2feda3715f7f60caf4232736d7cb3ed7d40bb178 /src/image
parent7cfa7d69259590319524c3715df4a39b39924bc3 (diff)
downloadgo-c844fec7f6097289abb657d9a334cce97786c48c.tar.gz
go-c844fec7f6097289abb657d9a334cce97786c48c.zip
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 <r@golang.org>
Diffstat (limited to 'src/image')
-rw-r--r--src/image/png/reader.go5
1 files changed, 2 insertions, 3 deletions
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
}