ASN.1 compiler: check write errors

This commit is contained in:
Nicolas Williams
2019-01-15 12:04:31 -06:00
committed by Nico Williams
parent a3a8c1e4a4
commit 18226819cd
2 changed files with 13 additions and 10 deletions

View File

@@ -141,7 +141,8 @@ doit(const char *fn)
}
printf("line: eof offset: %lu\n", (unsigned long)offset);
fclose(fout);
if (fclose(fout) == EOF)
err(1, "writes to file %s failed", fnout);
fclose(f);
return 0;
}

View File

@@ -288,15 +288,16 @@ close_generate (void)
{
fprintf (headerfile, "#endif /* __%s_h__ */\n", headerbase);
if (headerfile)
fclose (headerfile);
if (privheaderfile)
fclose (privheaderfile);
if (templatefile)
fclose (templatefile);
if (headerfile && fclose(headerfile) == EOF)
err(1, "writes to public header file failed");
if (privheaderfile && fclose(privheaderfile) == EOF)
err(1, "writes to private header file failed");
if (templatefile && fclose(templatefile) == EOF)
err(1, "writes to template file failed");
if (logfile) {
fprintf (logfile, "\n");
fclose (logfile);
fprintf(logfile, "\n");
if (fclose(logfile) == EOF)
err(1, "writes to log file failed");
}
}
@@ -399,7 +400,8 @@ close_codefile(void)
if (codefile == NULL)
abort();
fclose(codefile);
if (fclose(codefile) == EOF)
err(1, "writes to source code file failed");
codefile = NULL;
}