bug-m4
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Frozen state generation fails with returncode 0


From: Eric Blake
Subject: Re: Frozen state generation fails with returncode 0
Date: Thu, 22 May 2008 22:35:07 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]