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

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

Comments

Projects
None yet
3 participants
@jsign
Copy link

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

This comment has been minimized.

Copy link
Contributor

commented Jul 11, 2019

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 this to the Go1.14 milestone Jul 11, 2019

@jsign jsign referenced a pull request that will close this issue Jul 11, 2019

Open

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

@gopherbot

This comment has been minimized.

Copy link

commented Jul 11, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.