Skip to content

Commit c8664ce

Browse files
mateusz834gopherbot
authored andcommitted
cmd/compile/internal/gc: handle errors from *bio.Writer
The error is stored internally in *bio.Writer, more specifically in *bufio.Writer and the current code does not handle it, ignoring errors silently. Change-Id: Iefa9bf7ddabb3c4fc03377e676a8098dcad9be6d GitHub-Last-Rev: a5d3622 GitHub-Pull-Request: #71621 Reviewed-on: https://go-review.googlesource.com/c/go/+/647915 Reviewed-by: Keith Randall <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Keith Randall <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Auto-Submit: Keith Randall <[email protected]>
1 parent 3105e3d commit c8664ce

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/cmd/compile/internal/gc/export.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,7 @@ func dumpasmhdr() {
4747
}
4848
}
4949

50-
b.Close()
50+
if err := b.Close(); err != nil {
51+
base.Fatalf("%v", err)
52+
}
5153
}

src/cmd/compile/internal/gc/obj.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func dumpobj1(outfile string, mode int) {
5757
fmt.Printf("can't create %s: %v\n", outfile, err)
5858
base.ErrorExit()
5959
}
60-
defer bout.Close()
60+
6161
bout.WriteString("!<arch>\n")
6262

6363
if mode&modeCompilerObj != 0 {
@@ -70,6 +70,12 @@ func dumpobj1(outfile string, mode int) {
7070
dumpLinkerObj(bout)
7171
finishArchiveEntry(bout, start, "_go_.o")
7272
}
73+
74+
if err := bout.Close(); err != nil {
75+
base.FlushErrors()
76+
fmt.Printf("error while writing to file %s: %v\n", outfile, err)
77+
base.ErrorExit()
78+
}
7379
}
7480

7581
func printObjHeader(bout *bio.Writer) {

0 commit comments

Comments
 (0)