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

Change-Id: I425b5d16149a7a40d888a1ab723b3642eb08224f
This commit is contained in:
Mateusz Poliwczak 2025-02-08 14:25:43 +01:00
parent 215de81513
commit a5d3622331
2 changed files with 10 additions and 2 deletions

View file

@ -47,5 +47,7 @@ func dumpasmhdr() {
}
}
b.Close()
if err := b.Close(); err != nil {
base.Fatalf("%v", err)
}
}

View file

@ -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 {
@ -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) {