Skip to content

Commit a5d3622

Browse files
committed
cmd/compile/internal/gc: handle errors from *bio.Writer
Change-Id: I425b5d16149a7a40d888a1ab723b3642eb08224f
1 parent 215de81 commit a5d3622

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)