diff options
author | H. Peter Anvin <hpa@zytor.com> | 2009-07-12 12:11:52 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2009-07-12 12:15:35 -0700 |
commit | d0fbb7f0ab355fd4e73d1aab215a2aa387b615c3 (patch) | |
tree | 636f3b611b9fc5d630c547c9cbd65028f7ae360b /output | |
parent | 323fcff32bd5d48a690e14a72c980892924c05ab (diff) | |
download | nasm-d0fbb7f0ab355fd4e73d1aab215a2aa387b615c3.tar.gz nasm-d0fbb7f0ab355fd4e73d1aab215a2aa387b615c3.tar.bz2 nasm-d0fbb7f0ab355fd4e73d1aab215a2aa387b615c3.zip |
Don't fclose() the output in the backend
We fopen() the output file in common code but fclose() it in the
backend. This is bad for a variety of reasons:
1. it is generally an awkward interface to change ownership.
2. we should use ferror() to test for write errors, and that is
better done in common code.
3. it requires more code.
4. we still need to fclose() in common code during error handing.
Thus, move the fclose() of the output out of the backends, and add
fflush() so we can test ferror() on output.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'output')
-rw-r--r-- | output/outaout.c | 1 | ||||
-rw-r--r-- | output/outas86.c | 1 | ||||
-rw-r--r-- | output/outbin.c | 1 | ||||
-rw-r--r-- | output/outcoff.c | 1 | ||||
-rw-r--r-- | output/outdbg.c | 1 | ||||
-rw-r--r-- | output/outelf32.c | 1 | ||||
-rw-r--r-- | output/outelf64.c | 1 | ||||
-rw-r--r-- | output/outieee.c | 1 | ||||
-rw-r--r-- | output/outmacho32.c | 3 | ||||
-rw-r--r-- | output/outmacho64.c | 3 | ||||
-rw-r--r-- | output/outrdf.c | 1 | ||||
-rw-r--r-- | output/outrdf2.c | 2 |
12 files changed, 0 insertions, 17 deletions
diff --git a/output/outaout.c b/output/outaout.c index 4d38cdf..8d8966b 100644 --- a/output/outaout.c +++ b/output/outaout.c @@ -235,7 +235,6 @@ static void aout_cleanup(int debuginfo) aout_fixup_relocs(&stext); aout_fixup_relocs(&sdata); aout_write(); - fclose(aoutfp); saa_free(stext.data); while (stext.head) { r = stext.head; diff --git a/output/outas86.c b/output/outas86.c index 2fa4efc..f21bd2e 100644 --- a/output/outas86.c +++ b/output/outas86.c @@ -152,7 +152,6 @@ static void as86_cleanup(int debuginfo) (void)debuginfo; as86_write(); - fclose(as86fp); saa_free(stext.data); while (stext.head) { p = stext.head; diff --git a/output/outbin.c b/output/outbin.c index 8942acf..5dc8e97 100644 --- a/output/outbin.c +++ b/output/outbin.c @@ -593,7 +593,6 @@ static void bin_cleanup(int debuginfo) /* Step 6: Write the section data to the output file. */ do_output(); - fclose(fp); /* Done with the output file */ /* Step 7: Generate the map file. */ diff --git a/output/outcoff.c b/output/outcoff.c index 5a03bec..4c1213d 100644 --- a/output/outcoff.c +++ b/output/outcoff.c @@ -236,7 +236,6 @@ static void coff_cleanup(int debuginfo) (void)debuginfo; coff_write(); - fclose(coffp); for (i = 0; i < nsects; i++) { if (sects[i]->data) saa_free(sects[i]->data); diff --git a/output/outdbg.c b/output/outdbg.c index 1ee16ea..497a48e 100644 --- a/output/outdbg.c +++ b/output/outdbg.c @@ -81,7 +81,6 @@ static void dbg_cleanup(int debuginfo) nasm_free(tmp->name); nasm_free(tmp); } - fclose(dbgf); } static int32_t dbg_section_names(char *name, int pass, int *bits) diff --git a/output/outelf32.c b/output/outelf32.c index 7159a1f..99e53ef 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -296,7 +296,6 @@ static void elf_cleanup(int debuginfo) (void)debuginfo; elf_write(); - fclose(elffp); for (i = 0; i < nsects; i++) { if (sects[i]->type != SHT_NOBITS) saa_free(sects[i]->data); diff --git a/output/outelf64.c b/output/outelf64.c index d049894..b797eb8 100644 --- a/output/outelf64.c +++ b/output/outelf64.c @@ -300,7 +300,6 @@ static void elf_cleanup(int debuginfo) (void)debuginfo; elf_write(); - fclose(elffp); for (i = 0; i < nsects; i++) { if (sects[i]->type != SHT_NOBITS) saa_free(sects[i]->data); diff --git a/output/outieee.c b/output/outieee.c index d587d4c..003e4d0 100644 --- a/output/outieee.c +++ b/output/outieee.c @@ -243,7 +243,6 @@ static void ieee_cleanup(int debuginfo) { ieee_write_file(debuginfo); of_ieee.current_dfmt->cleanup(); - fclose(ofp); while (seghead) { struct ieeeSection *segtmp = seghead; seghead = seghead->next; diff --git a/output/outmacho32.c b/output/outmacho32.c index c9e4365..0203f0d 100644 --- a/output/outmacho32.c +++ b/output/outmacho32.c @@ -1280,9 +1280,6 @@ static void macho_cleanup(int debuginfo) macho_calculate_sizes(); macho_write(); - /* done - yay! */ - fclose(machofp); - /* free up everything */ while (sects->next) { s = sects; diff --git a/output/outmacho64.c b/output/outmacho64.c index cad399d..659cbc4 100644 --- a/output/outmacho64.c +++ b/output/outmacho64.c @@ -1449,9 +1449,6 @@ static void macho_cleanup(int debuginfo) macho_calculate_sizes(); macho_write(); - /* done - yay! */ - fclose(machofp); - /* free up everything */ while (sects->next) { s = sects; diff --git a/output/outrdf.c b/output/outrdf.c index fef18fb..6649c16 100644 --- a/output/outrdf.c +++ b/output/outrdf.c @@ -509,7 +509,6 @@ static void rdf_cleanup(int debuginfo) freemembuf(header); freemembuf(seg[0]); freemembuf(seg[1]); - fclose(ofile); } static int32_t rdf_segbase(int32_t segment) diff --git a/output/outrdf2.c b/output/outrdf2.c index 578c923..84a565d 100644 --- a/output/outrdf2.c +++ b/output/outrdf2.c @@ -723,8 +723,6 @@ static void rdf2_cleanup(int debuginfo) fwriteint32_t(0, ofile); fwriteint32_t(0, ofile); fwriteint16_t(0, ofile); - - fclose(ofile); } static int32_t rdf2_segbase(int32_t segment) |