Skip to content

cmd/compile/internal/gc: handle errors from *bio.Writer #71621

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

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/cmd/compile/internal/gc/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,7 @@ func dumpasmhdr() {
}
}

b.Close()
if err := b.Close(); err != nil {
base.Fatalf("%v", err)
}
}
8 changes: 7 additions & 1 deletion src/cmd/compile/internal/gc/obj.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func dumpobj1(outfile string, mode int) {
fmt.Printf("can't create %s: %v\n", outfile, err)
base.ErrorExit()
}
defer bout.Close()

bout.WriteString("!<arch>\n")

if mode&modeCompilerObj != 0 {
Expand All @@ -70,6 +70,12 @@ func dumpobj1(outfile string, mode int) {
dumpLinkerObj(bout)
finishArchiveEntry(bout, start, "_go_.o")
}

if err := bout.Close(); err != nil {
base.FlushErrors()
fmt.Printf("error while writing to file %s: %v\n", outfile, err)
base.ErrorExit()
}
}

func printObjHeader(bout *bio.Writer) {
Expand Down