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: Jean-Charles Longuet
Subject: Re: Frozen state generation fails with returncode 0
Date: Thu, 22 May 2008 21:34:45 +0200
User-agent: Thunderbird 2.0.0.14 (Windows/20080421)

Eric Blake wrote :

According to Jean-Charles Longuet on 5/21/2008 2:10 PM:
|
| When m4 fails to open() the frozen state file, it complains
| but the process exit code is still 0. However, the same function
| may trigger failures leading to a non-zero process exit code,
| for example when the close() of the frozen state file fails.

Thanks for the report.  Which version of m4 was this against?  I'm
guessing this was against a release tarball, rather than the current git
repository, since this area of code has changed in the meantime?

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. 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...


diff --git a/src/freeze.c b/src/freeze.c
index d32fc9e..3bb5db9 100644
--- a/src/freeze.c
+++ b/src/freeze.c
@@ -326,7 +326,8 @@ produce_frozen_state (m4 *context, const char *name)
   /* All done.  */

   fputs ("# End of frozen state file\n", file);
-  fclose (file);
+  if (!fclose(file))
+      m4_error (context, 0, errno, NULL, _("cannot close `%s'"), name);
 }

 /* Issue a message saying that some character is an EXPECTED character. */








reply via email to

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