Jean-Charles Longuet <jclonguet <at> free.fr> writes: > > As you stated, this was against release 1.4.11. > > I had a look in the git repository, and the open() case seem to handle > errors. However, there are no checks on flose() return value in > produce_frozen_state(). Not sure if you already worked on it.
You're right - a patch I hadn't ported to the master branch yet (this is the patch on branch-1.4/branch-1.6: http://git.savannah.gnu.org/gitweb/?p=m4.git;a=commitdiff;h=34c30#patch8). On the other hand, I'm inconsistent on branch-1.6 (-F uses close_stream(), but -R uses a manual ferror()/fclose() call). > If not, > this short patch may help. I was wondering if fputs() calls required > their return code to be also checked, but I didn't add that in this > one... No need: the use of close_stream() checks ferror on your behalf, and fputs is required to set ferror on failure. Yes, it can lose errno details when compared to checking every fputc/fputs/fprintf, but streams are generally imprecise to begin with, and knowing why a stream failed is less important than knowing that it failed. The code is much more readable/maintainable if you don't have to check every single output routine for failure. > > fputs ("# End of frozen state file\n", file); > - fclose (file); > + if (!fclose(file)) > + m4_error (context, 0, errno, NULL, _("cannot close `%s'"), name); I'd rather use close_stream() here, to match the branch. But thanks for pointing this out. -- Eric Blake