*/
difffile = fopen(difffilename, "a");
- if (difffile)
- {
- startpos = ftell(difffile);
-
- /* Write diff header */
- fprintf(difffile,
- "diff %s %s %s\n",
- pretty_diff_opts, best_expect_file, resultsfile);
- fclose(difffile);
+ if (!difffile)
+ bail("could not open file \"%s\" for writing: %m", difffilename);
+ startpos = ftell(difffile);
- /* Run diff */
- snprintf(cmd, sizeof(cmd),
- "diff %s \"%s\" \"%s\" >> \"%s\"",
- pretty_diff_opts, best_expect_file, resultsfile, difffilename);
- run_diff(cmd, difffilename);
+ /* Write diff header */
+ fprintf(difffile,
+ "diff %s %s %s\n",
+ pretty_diff_opts, best_expect_file, resultsfile);
+ fclose(difffile);
- /*
- * Reopen the file for reading to emit the diff as TAP diagnostics. We
- * can't keep the file open while diff appends to it, because on
- * Windows the file lock prevents diff from writing.
- */
- difffile = fopen(difffilename, "r");
- }
+ /* Run diff */
+ snprintf(cmd, sizeof(cmd),
+ "diff %s \"%s\" \"%s\" >> \"%s\"",
+ pretty_diff_opts, best_expect_file, resultsfile, difffilename);
+ run_diff(cmd, difffilename);
- if (difffile)
+ /*
+ * Emit the diff output as TAP diagnostics
+ *
+ * Reopen the file for reading. We can't keep the file open while diff
+ * appends to it, because on Windows the file lock prevents diff from
+ * writing.
+ */
+ difffile = fopen(difffilename, "r");
+ if (!difffile)
+ bail("could not open file \"%s\" for reading: %m", difffilename);
+ else
{
/*
* In case of a crash the diff can be huge and all of the subsequent