Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

io/ioutil: don't check for short write in WriteFile #33064

Closed
jsign opened this issue Jul 11, 2019 · 2 comments
Closed

io/ioutil: don't check for short write in WriteFile #33064

jsign opened this issue Jul 11, 2019 · 2 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@jsign
Copy link
Contributor

jsign commented Jul 11, 2019

What version of Go are you using (go version)?

$ go version
go version go1.12.6 linux/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ignacio/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/ignacio/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build249863972=/tmp/go-build -gno-record-gcc-switches"

Issue description

The function WriteFile() checks if the returned bytes are different from the expected bytes if err=nil. This case will never happen since the Write() function already satisfies that case.
I think this may be related to another previous fix regarding this case.

Propose solution

Delete this if case, since err should be already correctly returned in the previous line.

If this seems correct, I'd like to propose the PR.

@ianlancetaylor ianlancetaylor changed the title ioutil: no need in WriteFile to explicitly check ErrShortWrite io/ioutil: no need in WriteFile to explicitly check ErrShortWrite Jul 11, 2019
@ianlancetaylor
Copy link
Contributor

I think that's fine for the 1.14 release. Thanks.

The check dates back to ff9e657, before the open source release. I think that back then we were less clear on exactly how Write should behave.

@ianlancetaylor ianlancetaylor added the NeedsFix The path to resolution is known, but the work has not been done. label Jul 11, 2019
@ianlancetaylor ianlancetaylor added this to the Go1.14 milestone Jul 11, 2019
@gopherbot
Copy link

Change https://golang.org/cl/185857 mentions this issue: ioutil: no need in WriteFile to explicitly check ErrShortWrite

@jsign jsign changed the title io/ioutil: no need in WriteFile to explicitly check ErrShortWrite io/ioutil: don't check for short write in WriteFile Jul 11, 2019
t4n6a1ka pushed a commit to t4n6a1ka/go that referenced this issue Sep 5, 2019
*os.File already does it.

Fixes golang#33064

Change-Id: I3edf0a31bf6d6e5023f47f01ebc92ed057357278
GitHub-Last-Rev: e6a5ba4
GitHub-Pull-Request: golang#33065
Reviewed-on: https://go-review.googlesource.com/c/go/+/185857
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
@golang golang locked and limited conversation to collaborators Aug 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants